babylon.module.d.ts 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516159517159518159519159520159521159522159523159524159525159526159527159528159529159530159531159532159533159534159535159536159537159538159539159540159541159542159543159544159545159546159547159548159549159550159551159552159553159554159555159556159557159558159559159560159561159562159563159564159565159566159567159568159569159570159571159572159573159574159575159576159577159578159579159580159581159582159583159584159585159586159587159588159589159590159591159592159593159594159595159596159597159598159599159600159601159602159603159604159605159606159607159608159609159610159611159612159613159614159615159616159617159618159619159620159621159622159623159624159625159626159627159628159629159630159631159632159633159634159635159636159637159638159639159640159641159642159643159644159645159646159647159648159649159650159651159652159653159654159655159656159657159658159659159660159661159662159663159664159665159666159667159668159669159670159671159672159673159674159675159676159677159678159679159680159681159682159683159684159685159686159687159688159689159690159691159692159693159694159695159696159697159698159699159700159701159702159703159704159705159706159707159708159709159710159711159712159713159714159715159716159717159718159719159720159721159722159723159724159725159726159727159728159729159730159731159732159733159734159735159736159737159738159739159740159741159742159743159744159745159746159747159748159749159750159751159752159753159754159755159756159757159758159759159760159761159762159763159764159765159766159767159768159769159770159771159772159773159774159775159776159777159778159779159780159781159782159783159784159785159786159787159788159789159790159791159792159793159794159795159796159797159798159799159800159801159802159803159804159805159806159807159808159809159810159811159812159813159814159815159816159817159818159819159820159821159822159823159824159825159826159827159828159829159830159831159832159833159834159835159836159837
  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 (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2427. * Note that for this function to work as expected you should make sure that:
  2428. * - direction and the plane normal are normalized
  2429. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2430. * @param direction the direction to check if the plane is facing
  2431. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2432. * @returns True if the plane is facing the given direction
  2433. */
  2434. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2435. /**
  2436. * Calculates the distance to a point
  2437. * @param point point to calculate distance to
  2438. * @returns the signed distance (float) from the given point to the Plane.
  2439. */
  2440. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2441. /**
  2442. * Creates a plane from an array
  2443. * @param array the array to create a plane from
  2444. * @returns a new Plane from the given array.
  2445. */
  2446. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2447. /**
  2448. * Creates a plane from three points
  2449. * @param point1 point used to create the plane
  2450. * @param point2 point used to create the plane
  2451. * @param point3 point used to create the plane
  2452. * @returns a new Plane defined by the three given points.
  2453. */
  2454. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2455. /**
  2456. * Creates a plane from an origin point and a normal
  2457. * @param origin origin of the plane to be constructed
  2458. * @param normal normal of the plane to be constructed
  2459. * @returns a new Plane the normal vector to this plane at the given origin point.
  2460. * Note : the vector "normal" is updated because normalized.
  2461. */
  2462. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2463. /**
  2464. * Calculates the distance from a plane and a point
  2465. * @param origin origin of the plane to be constructed
  2466. * @param normal normal of the plane to be constructed
  2467. * @param point point to calculate distance to
  2468. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2469. */
  2470. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2471. }
  2472. }
  2473. declare module "babylonjs/Engines/performanceConfigurator" {
  2474. /** @hidden */
  2475. export class PerformanceConfigurator {
  2476. /** @hidden */
  2477. static MatrixUse64Bits: boolean;
  2478. /** @hidden */
  2479. static MatrixTrackPrecisionChange: boolean;
  2480. /** @hidden */
  2481. static MatrixCurrentType: any;
  2482. /** @hidden */
  2483. static MatrixTrackedMatrices: Array<any> | null;
  2484. /** @hidden */
  2485. static SetMatrixPrecision(use64bits: boolean): void;
  2486. }
  2487. }
  2488. declare module "babylonjs/Maths/math.vector" {
  2489. import { Viewport } from "babylonjs/Maths/math.viewport";
  2490. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2491. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2492. import { Plane } from "babylonjs/Maths/math.plane";
  2493. /**
  2494. * Class representing a vector containing 2 coordinates
  2495. */
  2496. export class Vector2 {
  2497. /** defines the first coordinate */
  2498. x: number;
  2499. /** defines the second coordinate */
  2500. y: number;
  2501. /**
  2502. * Creates a new Vector2 from the given x and y coordinates
  2503. * @param x defines the first coordinate
  2504. * @param y defines the second coordinate
  2505. */
  2506. constructor(
  2507. /** defines the first coordinate */
  2508. x?: number,
  2509. /** defines the second coordinate */
  2510. y?: number);
  2511. /**
  2512. * Gets a string with the Vector2 coordinates
  2513. * @returns a string with the Vector2 coordinates
  2514. */
  2515. toString(): string;
  2516. /**
  2517. * Gets class name
  2518. * @returns the string "Vector2"
  2519. */
  2520. getClassName(): string;
  2521. /**
  2522. * Gets current vector hash code
  2523. * @returns the Vector2 hash code as a number
  2524. */
  2525. getHashCode(): number;
  2526. /**
  2527. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2528. * @param array defines the source array
  2529. * @param index defines the offset in source array
  2530. * @returns the current Vector2
  2531. */
  2532. toArray(array: FloatArray, index?: number): Vector2;
  2533. /**
  2534. * Update the current vector from an array
  2535. * @param array defines the destination array
  2536. * @param index defines the offset in the destination array
  2537. * @returns the current Vector3
  2538. */
  2539. fromArray(array: FloatArray, index?: number): Vector2;
  2540. /**
  2541. * Copy the current vector to an array
  2542. * @returns a new array with 2 elements: the Vector2 coordinates.
  2543. */
  2544. asArray(): number[];
  2545. /**
  2546. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2547. * @param source defines the source Vector2
  2548. * @returns the current updated Vector2
  2549. */
  2550. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2551. /**
  2552. * Sets the Vector2 coordinates with the given floats
  2553. * @param x defines the first coordinate
  2554. * @param y defines the second coordinate
  2555. * @returns the current updated Vector2
  2556. */
  2557. copyFromFloats(x: number, y: number): Vector2;
  2558. /**
  2559. * Sets the Vector2 coordinates with the given floats
  2560. * @param x defines the first coordinate
  2561. * @param y defines the second coordinate
  2562. * @returns the current updated Vector2
  2563. */
  2564. set(x: number, y: number): Vector2;
  2565. /**
  2566. * Add another vector with the current one
  2567. * @param otherVector defines the other vector
  2568. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2569. */
  2570. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2571. /**
  2572. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2573. * @param otherVector defines the other vector
  2574. * @param result defines the target vector
  2575. * @returns the unmodified current Vector2
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2578. /**
  2579. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2580. * @param otherVector defines the other vector
  2581. * @returns the current updated Vector2
  2582. */
  2583. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2584. /**
  2585. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2586. * @param otherVector defines the other vector
  2587. * @returns a new Vector2
  2588. */
  2589. addVector3(otherVector: Vector3): Vector2;
  2590. /**
  2591. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2592. * @param otherVector defines the other vector
  2593. * @returns a new Vector2
  2594. */
  2595. subtract(otherVector: Vector2): Vector2;
  2596. /**
  2597. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2598. * @param otherVector defines the other vector
  2599. * @param result defines the target vector
  2600. * @returns the unmodified current Vector2
  2601. */
  2602. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2603. /**
  2604. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2605. * @param otherVector defines the other vector
  2606. * @returns the current updated Vector2
  2607. */
  2608. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2609. /**
  2610. * Multiplies in place the current Vector2 coordinates by the given ones
  2611. * @param otherVector defines the other vector
  2612. * @returns the current updated Vector2
  2613. */
  2614. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2615. /**
  2616. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2617. * @param otherVector defines the other vector
  2618. * @returns a new Vector2
  2619. */
  2620. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2621. /**
  2622. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2623. * @param otherVector defines the other vector
  2624. * @param result defines the target vector
  2625. * @returns the unmodified current Vector2
  2626. */
  2627. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2628. /**
  2629. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2630. * @param x defines the first coordinate
  2631. * @param y defines the second coordinate
  2632. * @returns a new Vector2
  2633. */
  2634. multiplyByFloats(x: number, y: number): Vector2;
  2635. /**
  2636. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2637. * @param otherVector defines the other vector
  2638. * @returns a new Vector2
  2639. */
  2640. divide(otherVector: Vector2): Vector2;
  2641. /**
  2642. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2643. * @param otherVector defines the other vector
  2644. * @param result defines the target vector
  2645. * @returns the unmodified current Vector2
  2646. */
  2647. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2648. /**
  2649. * Divides the current Vector2 coordinates by the given ones
  2650. * @param otherVector defines the other vector
  2651. * @returns the current updated Vector2
  2652. */
  2653. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2654. /**
  2655. * Gets a new Vector2 with current Vector2 negated coordinates
  2656. * @returns a new Vector2
  2657. */
  2658. negate(): Vector2;
  2659. /**
  2660. * Negate this vector in place
  2661. * @returns this
  2662. */
  2663. negateInPlace(): Vector2;
  2664. /**
  2665. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2666. * @param result defines the Vector3 object where to store the result
  2667. * @returns the current Vector2
  2668. */
  2669. negateToRef(result: Vector2): Vector2;
  2670. /**
  2671. * Multiply the Vector2 coordinates by scale
  2672. * @param scale defines the scaling factor
  2673. * @returns the current updated Vector2
  2674. */
  2675. scaleInPlace(scale: number): Vector2;
  2676. /**
  2677. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2678. * @param scale defines the scaling factor
  2679. * @returns a new Vector2
  2680. */
  2681. scale(scale: number): Vector2;
  2682. /**
  2683. * Scale the current Vector2 values by a factor to a given Vector2
  2684. * @param scale defines the scale factor
  2685. * @param result defines the Vector2 object where to store the result
  2686. * @returns the unmodified current Vector2
  2687. */
  2688. scaleToRef(scale: number, result: Vector2): Vector2;
  2689. /**
  2690. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2691. * @param scale defines the scale factor
  2692. * @param result defines the Vector2 object where to store the result
  2693. * @returns the unmodified current Vector2
  2694. */
  2695. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2696. /**
  2697. * Gets a boolean if two vectors are equals
  2698. * @param otherVector defines the other vector
  2699. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2700. */
  2701. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2702. /**
  2703. * Gets a boolean if two vectors are equals (using an epsilon value)
  2704. * @param otherVector defines the other vector
  2705. * @param epsilon defines the minimal distance to consider equality
  2706. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2707. */
  2708. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2709. /**
  2710. * Gets a new Vector2 from current Vector2 floored values
  2711. * @returns a new Vector2
  2712. */
  2713. floor(): Vector2;
  2714. /**
  2715. * Gets a new Vector2 from current Vector2 floored values
  2716. * @returns a new Vector2
  2717. */
  2718. fract(): Vector2;
  2719. /**
  2720. * Gets the length of the vector
  2721. * @returns the vector length (float)
  2722. */
  2723. length(): number;
  2724. /**
  2725. * Gets the vector squared length
  2726. * @returns the vector squared length (float)
  2727. */
  2728. lengthSquared(): number;
  2729. /**
  2730. * Normalize the vector
  2731. * @returns the current updated Vector2
  2732. */
  2733. normalize(): Vector2;
  2734. /**
  2735. * Gets a new Vector2 copied from the Vector2
  2736. * @returns a new Vector2
  2737. */
  2738. clone(): Vector2;
  2739. /**
  2740. * Gets a new Vector2(0, 0)
  2741. * @returns a new Vector2
  2742. */
  2743. static Zero(): Vector2;
  2744. /**
  2745. * Gets a new Vector2(1, 1)
  2746. * @returns a new Vector2
  2747. */
  2748. static One(): Vector2;
  2749. /**
  2750. * Gets a new Vector2 set from the given index element of the given array
  2751. * @param array defines the data source
  2752. * @param offset defines the offset in the data source
  2753. * @returns a new Vector2
  2754. */
  2755. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2756. /**
  2757. * Sets "result" from the given index element of the given array
  2758. * @param array defines the data source
  2759. * @param offset defines the offset in the data source
  2760. * @param result defines the target vector
  2761. */
  2762. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2763. /**
  2764. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2765. * @param value1 defines 1st point of control
  2766. * @param value2 defines 2nd point of control
  2767. * @param value3 defines 3rd point of control
  2768. * @param value4 defines 4th point of control
  2769. * @param amount defines the interpolation factor
  2770. * @returns a new Vector2
  2771. */
  2772. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2773. /**
  2774. * 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".
  2775. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2776. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2777. * @param value defines the value to clamp
  2778. * @param min defines the lower limit
  2779. * @param max defines the upper limit
  2780. * @returns a new Vector2
  2781. */
  2782. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2783. /**
  2784. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2785. * @param value1 defines the 1st control point
  2786. * @param tangent1 defines the outgoing tangent
  2787. * @param value2 defines the 2nd control point
  2788. * @param tangent2 defines the incoming tangent
  2789. * @param amount defines the interpolation factor
  2790. * @returns a new Vector2
  2791. */
  2792. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2793. /**
  2794. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2795. * @param start defines the start vector
  2796. * @param end defines the end vector
  2797. * @param amount defines the interpolation factor
  2798. * @returns a new Vector2
  2799. */
  2800. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2801. /**
  2802. * Gets the dot product of the vector "left" and the vector "right"
  2803. * @param left defines first vector
  2804. * @param right defines second vector
  2805. * @returns the dot product (float)
  2806. */
  2807. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2808. /**
  2809. * Returns a new Vector2 equal to the normalized given vector
  2810. * @param vector defines the vector to normalize
  2811. * @returns a new Vector2
  2812. */
  2813. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2814. /**
  2815. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2816. * @param left defines 1st vector
  2817. * @param right defines 2nd vector
  2818. * @returns a new Vector2
  2819. */
  2820. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2821. /**
  2822. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2823. * @param left defines 1st vector
  2824. * @param right defines 2nd vector
  2825. * @returns a new Vector2
  2826. */
  2827. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2828. /**
  2829. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2830. * @param vector defines the vector to transform
  2831. * @param transformation defines the matrix to apply
  2832. * @returns a new Vector2
  2833. */
  2834. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2835. /**
  2836. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2837. * @param vector defines the vector to transform
  2838. * @param transformation defines the matrix to apply
  2839. * @param result defines the target vector
  2840. */
  2841. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2842. /**
  2843. * Determines if a given vector is included in a triangle
  2844. * @param p defines the vector to test
  2845. * @param p0 defines 1st triangle point
  2846. * @param p1 defines 2nd triangle point
  2847. * @param p2 defines 3rd triangle point
  2848. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2849. */
  2850. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2851. /**
  2852. * Gets the distance between the vectors "value1" and "value2"
  2853. * @param value1 defines first vector
  2854. * @param value2 defines second vector
  2855. * @returns the distance between vectors
  2856. */
  2857. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2858. /**
  2859. * Returns the squared distance between the vectors "value1" and "value2"
  2860. * @param value1 defines first vector
  2861. * @param value2 defines second vector
  2862. * @returns the squared distance between vectors
  2863. */
  2864. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2865. /**
  2866. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2867. * @param value1 defines first vector
  2868. * @param value2 defines second vector
  2869. * @returns a new Vector2
  2870. */
  2871. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2872. /**
  2873. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  2874. * @param value1 defines first vector
  2875. * @param value2 defines second vector
  2876. * @param ref defines third vector
  2877. * @returns ref
  2878. */
  2879. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  2880. /**
  2881. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2882. * @param p defines the middle point
  2883. * @param segA defines one point of the segment
  2884. * @param segB defines the other point of the segment
  2885. * @returns the shortest distance
  2886. */
  2887. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2888. }
  2889. /**
  2890. * Class used to store (x,y,z) vector representation
  2891. * A Vector3 is the main object used in 3D geometry
  2892. * It can represent etiher the coordinates of a point the space, either a direction
  2893. * Reminder: js uses a left handed forward facing system
  2894. */
  2895. export class Vector3 {
  2896. private static _UpReadOnly;
  2897. private static _ZeroReadOnly;
  2898. /** @hidden */
  2899. _x: number;
  2900. /** @hidden */
  2901. _y: number;
  2902. /** @hidden */
  2903. _z: number;
  2904. /** @hidden */
  2905. _isDirty: boolean;
  2906. /** Gets or sets the x coordinate */
  2907. get x(): number;
  2908. set x(value: number);
  2909. /** Gets or sets the y coordinate */
  2910. get y(): number;
  2911. set y(value: number);
  2912. /** Gets or sets the z coordinate */
  2913. get z(): number;
  2914. set z(value: number);
  2915. /**
  2916. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2917. * @param x defines the first coordinates (on X axis)
  2918. * @param y defines the second coordinates (on Y axis)
  2919. * @param z defines the third coordinates (on Z axis)
  2920. */
  2921. constructor(x?: number, y?: number, z?: number);
  2922. /**
  2923. * Creates a string representation of the Vector3
  2924. * @returns a string with the Vector3 coordinates.
  2925. */
  2926. toString(): string;
  2927. /**
  2928. * Gets the class name
  2929. * @returns the string "Vector3"
  2930. */
  2931. getClassName(): string;
  2932. /**
  2933. * Creates the Vector3 hash code
  2934. * @returns a number which tends to be unique between Vector3 instances
  2935. */
  2936. getHashCode(): number;
  2937. /**
  2938. * Creates an array containing three elements : the coordinates of the Vector3
  2939. * @returns a new array of numbers
  2940. */
  2941. asArray(): number[];
  2942. /**
  2943. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2944. * @param array defines the destination array
  2945. * @param index defines the offset in the destination array
  2946. * @returns the current Vector3
  2947. */
  2948. toArray(array: FloatArray, index?: number): Vector3;
  2949. /**
  2950. * Update the current vector from an array
  2951. * @param array defines the destination array
  2952. * @param index defines the offset in the destination array
  2953. * @returns the current Vector3
  2954. */
  2955. fromArray(array: FloatArray, index?: number): Vector3;
  2956. /**
  2957. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2958. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2959. */
  2960. toQuaternion(): Quaternion;
  2961. /**
  2962. * Adds the given vector to the current Vector3
  2963. * @param otherVector defines the second operand
  2964. * @returns the current updated Vector3
  2965. */
  2966. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2967. /**
  2968. * Adds the given coordinates to the current Vector3
  2969. * @param x defines the x coordinate of the operand
  2970. * @param y defines the y coordinate of the operand
  2971. * @param z defines the z coordinate of the operand
  2972. * @returns the current updated Vector3
  2973. */
  2974. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2975. /**
  2976. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2977. * @param otherVector defines the second operand
  2978. * @returns the resulting Vector3
  2979. */
  2980. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2981. /**
  2982. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2983. * @param otherVector defines the second operand
  2984. * @param result defines the Vector3 object where to store the result
  2985. * @returns the current Vector3
  2986. */
  2987. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2988. /**
  2989. * Subtract the given vector from the current Vector3
  2990. * @param otherVector defines the second operand
  2991. * @returns the current updated Vector3
  2992. */
  2993. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2994. /**
  2995. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2996. * @param otherVector defines the second operand
  2997. * @returns the resulting Vector3
  2998. */
  2999. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3000. /**
  3001. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3002. * @param otherVector defines the second operand
  3003. * @param result defines the Vector3 object where to store the result
  3004. * @returns the current Vector3
  3005. */
  3006. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3007. /**
  3008. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3009. * @param x defines the x coordinate of the operand
  3010. * @param y defines the y coordinate of the operand
  3011. * @param z defines the z coordinate of the operand
  3012. * @returns the resulting Vector3
  3013. */
  3014. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3015. /**
  3016. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3017. * @param x defines the x coordinate of the operand
  3018. * @param y defines the y coordinate of the operand
  3019. * @param z defines the z coordinate of the operand
  3020. * @param result defines the Vector3 object where to store the result
  3021. * @returns the current Vector3
  3022. */
  3023. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3024. /**
  3025. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3026. * @returns a new Vector3
  3027. */
  3028. negate(): Vector3;
  3029. /**
  3030. * Negate this vector in place
  3031. * @returns this
  3032. */
  3033. negateInPlace(): Vector3;
  3034. /**
  3035. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3036. * @param result defines the Vector3 object where to store the result
  3037. * @returns the current Vector3
  3038. */
  3039. negateToRef(result: Vector3): Vector3;
  3040. /**
  3041. * Multiplies the Vector3 coordinates by the float "scale"
  3042. * @param scale defines the multiplier factor
  3043. * @returns the current updated Vector3
  3044. */
  3045. scaleInPlace(scale: number): Vector3;
  3046. /**
  3047. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3048. * @param scale defines the multiplier factor
  3049. * @returns a new Vector3
  3050. */
  3051. scale(scale: number): Vector3;
  3052. /**
  3053. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3054. * @param scale defines the multiplier factor
  3055. * @param result defines the Vector3 object where to store the result
  3056. * @returns the current Vector3
  3057. */
  3058. scaleToRef(scale: number, result: Vector3): Vector3;
  3059. /**
  3060. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3061. * @param scale defines the scale factor
  3062. * @param result defines the Vector3 object where to store the result
  3063. * @returns the unmodified current Vector3
  3064. */
  3065. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3066. /**
  3067. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3068. * @param origin defines the origin of the projection ray
  3069. * @param plane defines the plane to project to
  3070. * @returns the projected vector3
  3071. */
  3072. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3073. /**
  3074. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3075. * @param origin defines the origin of the projection ray
  3076. * @param plane defines the plane to project to
  3077. * @param result defines the Vector3 where to store the result
  3078. */
  3079. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3080. /**
  3081. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3082. * @param otherVector defines the second operand
  3083. * @returns true if both vectors are equals
  3084. */
  3085. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3086. /**
  3087. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3088. * @param otherVector defines the second operand
  3089. * @param epsilon defines the minimal distance to define values as equals
  3090. * @returns true if both vectors are distant less than epsilon
  3091. */
  3092. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3093. /**
  3094. * Returns true if the current Vector3 coordinates equals the given floats
  3095. * @param x defines the x coordinate of the operand
  3096. * @param y defines the y coordinate of the operand
  3097. * @param z defines the z coordinate of the operand
  3098. * @returns true if both vectors are equals
  3099. */
  3100. equalsToFloats(x: number, y: number, z: number): boolean;
  3101. /**
  3102. * Multiplies the current Vector3 coordinates by the given ones
  3103. * @param otherVector defines the second operand
  3104. * @returns the current updated Vector3
  3105. */
  3106. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3107. /**
  3108. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3109. * @param otherVector defines the second operand
  3110. * @returns the new Vector3
  3111. */
  3112. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3113. /**
  3114. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3115. * @param otherVector defines the second operand
  3116. * @param result defines the Vector3 object where to store the result
  3117. * @returns the current Vector3
  3118. */
  3119. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3120. /**
  3121. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3122. * @param x defines the x coordinate of the operand
  3123. * @param y defines the y coordinate of the operand
  3124. * @param z defines the z coordinate of the operand
  3125. * @returns the new Vector3
  3126. */
  3127. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3128. /**
  3129. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3130. * @param otherVector defines the second operand
  3131. * @returns the new Vector3
  3132. */
  3133. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3134. /**
  3135. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3136. * @param otherVector defines the second operand
  3137. * @param result defines the Vector3 object where to store the result
  3138. * @returns the current Vector3
  3139. */
  3140. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3141. /**
  3142. * Divides the current Vector3 coordinates by the given ones.
  3143. * @param otherVector defines the second operand
  3144. * @returns the current updated Vector3
  3145. */
  3146. divideInPlace(otherVector: Vector3): Vector3;
  3147. /**
  3148. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3149. * @param other defines the second operand
  3150. * @returns the current updated Vector3
  3151. */
  3152. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3153. /**
  3154. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3155. * @param other defines the second operand
  3156. * @returns the current updated Vector3
  3157. */
  3158. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3159. /**
  3160. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3161. * @param x defines the x coordinate of the operand
  3162. * @param y defines the y coordinate of the operand
  3163. * @param z defines the z coordinate of the operand
  3164. * @returns the current updated Vector3
  3165. */
  3166. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3167. /**
  3168. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3169. * @param x defines the x coordinate of the operand
  3170. * @param y defines the y coordinate of the operand
  3171. * @param z defines the z coordinate of the operand
  3172. * @returns the current updated Vector3
  3173. */
  3174. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3175. /**
  3176. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3177. * Check if is non uniform within a certain amount of decimal places to account for this
  3178. * @param epsilon the amount the values can differ
  3179. * @returns if the the vector is non uniform to a certain number of decimal places
  3180. */
  3181. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3182. /**
  3183. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3184. */
  3185. get isNonUniform(): boolean;
  3186. /**
  3187. * Gets a new Vector3 from current Vector3 floored values
  3188. * @returns a new Vector3
  3189. */
  3190. floor(): Vector3;
  3191. /**
  3192. * Gets a new Vector3 from current Vector3 floored values
  3193. * @returns a new Vector3
  3194. */
  3195. fract(): Vector3;
  3196. /**
  3197. * Gets the length of the Vector3
  3198. * @returns the length of the Vector3
  3199. */
  3200. length(): number;
  3201. /**
  3202. * Gets the squared length of the Vector3
  3203. * @returns squared length of the Vector3
  3204. */
  3205. lengthSquared(): number;
  3206. /**
  3207. * Normalize the current Vector3.
  3208. * Please note that this is an in place operation.
  3209. * @returns the current updated Vector3
  3210. */
  3211. normalize(): Vector3;
  3212. /**
  3213. * Reorders the x y z properties of the vector in place
  3214. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3215. * @returns the current updated vector
  3216. */
  3217. reorderInPlace(order: string): this;
  3218. /**
  3219. * Rotates the vector around 0,0,0 by a quaternion
  3220. * @param quaternion the rotation quaternion
  3221. * @param result vector to store the result
  3222. * @returns the resulting vector
  3223. */
  3224. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3225. /**
  3226. * Rotates a vector around a given point
  3227. * @param quaternion the rotation quaternion
  3228. * @param point the point to rotate around
  3229. * @param result vector to store the result
  3230. * @returns the resulting vector
  3231. */
  3232. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3233. /**
  3234. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3235. * The cross product is then orthogonal to both current and "other"
  3236. * @param other defines the right operand
  3237. * @returns the cross product
  3238. */
  3239. cross(other: Vector3): Vector3;
  3240. /**
  3241. * Normalize the current Vector3 with the given input length.
  3242. * Please note that this is an in place operation.
  3243. * @param len the length of the vector
  3244. * @returns the current updated Vector3
  3245. */
  3246. normalizeFromLength(len: number): Vector3;
  3247. /**
  3248. * Normalize the current Vector3 to a new vector
  3249. * @returns the new Vector3
  3250. */
  3251. normalizeToNew(): Vector3;
  3252. /**
  3253. * Normalize the current Vector3 to the reference
  3254. * @param reference define the Vector3 to update
  3255. * @returns the updated Vector3
  3256. */
  3257. normalizeToRef(reference: Vector3): Vector3;
  3258. /**
  3259. * Creates a new Vector3 copied from the current Vector3
  3260. * @returns the new Vector3
  3261. */
  3262. clone(): Vector3;
  3263. /**
  3264. * Copies the given vector coordinates to the current Vector3 ones
  3265. * @param source defines the source Vector3
  3266. * @returns the current updated Vector3
  3267. */
  3268. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3269. /**
  3270. * Copies the given floats to the current Vector3 coordinates
  3271. * @param x defines the x coordinate of the operand
  3272. * @param y defines the y coordinate of the operand
  3273. * @param z defines the z coordinate of the operand
  3274. * @returns the current updated Vector3
  3275. */
  3276. copyFromFloats(x: number, y: number, z: number): Vector3;
  3277. /**
  3278. * Copies the given floats to the current Vector3 coordinates
  3279. * @param x defines the x coordinate of the operand
  3280. * @param y defines the y coordinate of the operand
  3281. * @param z defines the z coordinate of the operand
  3282. * @returns the current updated Vector3
  3283. */
  3284. set(x: number, y: number, z: number): Vector3;
  3285. /**
  3286. * Copies the given float to the current Vector3 coordinates
  3287. * @param v defines the x, y and z coordinates of the operand
  3288. * @returns the current updated Vector3
  3289. */
  3290. setAll(v: number): Vector3;
  3291. /**
  3292. * Get the clip factor between two vectors
  3293. * @param vector0 defines the first operand
  3294. * @param vector1 defines the second operand
  3295. * @param axis defines the axis to use
  3296. * @param size defines the size along the axis
  3297. * @returns the clip factor
  3298. */
  3299. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3300. /**
  3301. * Get angle between two vectors
  3302. * @param vector0 angle between vector0 and vector1
  3303. * @param vector1 angle between vector0 and vector1
  3304. * @param normal direction of the normal
  3305. * @return the angle between vector0 and vector1
  3306. */
  3307. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3308. /**
  3309. * Returns a new Vector3 set from the index "offset" of the given array
  3310. * @param array defines the source array
  3311. * @param offset defines the offset in the source array
  3312. * @returns the new Vector3
  3313. */
  3314. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3315. /**
  3316. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3317. * @param array defines the source array
  3318. * @param offset defines the offset in the source array
  3319. * @returns the new Vector3
  3320. * @deprecated Please use FromArray instead.
  3321. */
  3322. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3323. /**
  3324. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3325. * @param array defines the source array
  3326. * @param offset defines the offset in the source array
  3327. * @param result defines the Vector3 where to store the result
  3328. */
  3329. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3330. /**
  3331. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3332. * @param array defines the source array
  3333. * @param offset defines the offset in the source array
  3334. * @param result defines the Vector3 where to store the result
  3335. * @deprecated Please use FromArrayToRef instead.
  3336. */
  3337. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3338. /**
  3339. * Sets the given vector "result" with the given floats.
  3340. * @param x defines the x coordinate of the source
  3341. * @param y defines the y coordinate of the source
  3342. * @param z defines the z coordinate of the source
  3343. * @param result defines the Vector3 where to store the result
  3344. */
  3345. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3346. /**
  3347. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3348. * @returns a new empty Vector3
  3349. */
  3350. static Zero(): Vector3;
  3351. /**
  3352. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3353. * @returns a new unit Vector3
  3354. */
  3355. static One(): Vector3;
  3356. /**
  3357. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3358. * @returns a new up Vector3
  3359. */
  3360. static Up(): Vector3;
  3361. /**
  3362. * Gets a up Vector3 that must not be updated
  3363. */
  3364. static get UpReadOnly(): DeepImmutable<Vector3>;
  3365. /**
  3366. * Gets a zero Vector3 that must not be updated
  3367. */
  3368. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3369. /**
  3370. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3371. * @returns a new down Vector3
  3372. */
  3373. static Down(): Vector3;
  3374. /**
  3375. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3376. * @param rightHandedSystem is the scene right-handed (negative z)
  3377. * @returns a new forward Vector3
  3378. */
  3379. static Forward(rightHandedSystem?: boolean): Vector3;
  3380. /**
  3381. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3382. * @param rightHandedSystem is the scene right-handed (negative-z)
  3383. * @returns a new forward Vector3
  3384. */
  3385. static Backward(rightHandedSystem?: boolean): Vector3;
  3386. /**
  3387. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3388. * @returns a new right Vector3
  3389. */
  3390. static Right(): Vector3;
  3391. /**
  3392. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3393. * @returns a new left Vector3
  3394. */
  3395. static Left(): Vector3;
  3396. /**
  3397. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3398. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3399. * @param vector defines the Vector3 to transform
  3400. * @param transformation defines the transformation matrix
  3401. * @returns the transformed Vector3
  3402. */
  3403. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3404. /**
  3405. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3406. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3407. * @param vector defines the Vector3 to transform
  3408. * @param transformation defines the transformation matrix
  3409. * @param result defines the Vector3 where to store the result
  3410. */
  3411. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3412. /**
  3413. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3414. * This method computes tranformed coordinates only, not transformed direction vectors
  3415. * @param x define the x coordinate of the source vector
  3416. * @param y define the y coordinate of the source vector
  3417. * @param z define the z coordinate of the source vector
  3418. * @param transformation defines the transformation matrix
  3419. * @param result defines the Vector3 where to store the result
  3420. */
  3421. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3422. /**
  3423. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3424. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3425. * @param vector defines the Vector3 to transform
  3426. * @param transformation defines the transformation matrix
  3427. * @returns the new Vector3
  3428. */
  3429. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3430. /**
  3431. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3432. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3433. * @param vector defines the Vector3 to transform
  3434. * @param transformation defines the transformation matrix
  3435. * @param result defines the Vector3 where to store the result
  3436. */
  3437. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3438. /**
  3439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3440. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3441. * @param x define the x coordinate of the source vector
  3442. * @param y define the y coordinate of the source vector
  3443. * @param z define the z coordinate of the source vector
  3444. * @param transformation defines the transformation matrix
  3445. * @param result defines the Vector3 where to store the result
  3446. */
  3447. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3448. /**
  3449. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3450. * @param value1 defines the first control point
  3451. * @param value2 defines the second control point
  3452. * @param value3 defines the third control point
  3453. * @param value4 defines the fourth control point
  3454. * @param amount defines the amount on the spline to use
  3455. * @returns the new Vector3
  3456. */
  3457. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3458. /**
  3459. * 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"
  3460. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3461. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3462. * @param value defines the current value
  3463. * @param min defines the lower range value
  3464. * @param max defines the upper range value
  3465. * @returns the new Vector3
  3466. */
  3467. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3468. /**
  3469. * 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"
  3470. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3471. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3472. * @param value defines the current value
  3473. * @param min defines the lower range value
  3474. * @param max defines the upper range value
  3475. * @param result defines the Vector3 where to store the result
  3476. */
  3477. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3478. /**
  3479. * Checks if a given vector is inside a specific range
  3480. * @param v defines the vector to test
  3481. * @param min defines the minimum range
  3482. * @param max defines the maximum range
  3483. */
  3484. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3485. /**
  3486. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3487. * @param value1 defines the first control point
  3488. * @param tangent1 defines the first tangent vector
  3489. * @param value2 defines the second control point
  3490. * @param tangent2 defines the second tangent vector
  3491. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3492. * @returns the new Vector3
  3493. */
  3494. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3495. /**
  3496. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3497. * @param start defines the start value
  3498. * @param end defines the end value
  3499. * @param amount max defines amount between both (between 0 and 1)
  3500. * @returns the new Vector3
  3501. */
  3502. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3503. /**
  3504. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3505. * @param start defines the start value
  3506. * @param end defines the end value
  3507. * @param amount max defines amount between both (between 0 and 1)
  3508. * @param result defines the Vector3 where to store the result
  3509. */
  3510. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3511. /**
  3512. * Returns the dot product (float) between the vectors "left" and "right"
  3513. * @param left defines the left operand
  3514. * @param right defines the right operand
  3515. * @returns the dot product
  3516. */
  3517. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3518. /**
  3519. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3520. * The cross product is then orthogonal to both "left" and "right"
  3521. * @param left defines the left operand
  3522. * @param right defines the right operand
  3523. * @returns the cross product
  3524. */
  3525. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3526. /**
  3527. * Sets the given vector "result" with the cross product of "left" and "right"
  3528. * The cross product is then orthogonal to both "left" and "right"
  3529. * @param left defines the left operand
  3530. * @param right defines the right operand
  3531. * @param result defines the Vector3 where to store the result
  3532. */
  3533. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3534. /**
  3535. * Returns a new Vector3 as the normalization of the given vector
  3536. * @param vector defines the Vector3 to normalize
  3537. * @returns the new Vector3
  3538. */
  3539. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3540. /**
  3541. * Sets the given vector "result" with the normalization of the given first vector
  3542. * @param vector defines the Vector3 to normalize
  3543. * @param result defines the Vector3 where to store the result
  3544. */
  3545. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3546. /**
  3547. * Project a Vector3 onto screen space
  3548. * @param vector defines the Vector3 to project
  3549. * @param world defines the world matrix to use
  3550. * @param transform defines the transform (view x projection) matrix to use
  3551. * @param viewport defines the screen viewport to use
  3552. * @returns the new Vector3
  3553. */
  3554. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3555. /**
  3556. * Project a Vector3 onto screen space to reference
  3557. * @param vector defines the Vector3 to project
  3558. * @param world defines the world matrix to use
  3559. * @param transform defines the transform (view x projection) matrix to use
  3560. * @param viewport defines the screen viewport to use
  3561. * @param result the vector in which the screen space will be stored
  3562. * @returns the new Vector3
  3563. */
  3564. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3565. /** @hidden */
  3566. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3567. /**
  3568. * Unproject from screen space to object space
  3569. * @param source defines the screen space Vector3 to use
  3570. * @param viewportWidth defines the current width of the viewport
  3571. * @param viewportHeight defines the current height of the viewport
  3572. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3573. * @param transform defines the transform (view x projection) matrix to use
  3574. * @returns the new Vector3
  3575. */
  3576. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: 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. * @returns the new Vector3
  3586. */
  3587. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3588. /**
  3589. * Unproject from screen space to object space
  3590. * @param source defines the screen space Vector3 to use
  3591. * @param viewportWidth defines the current width of the viewport
  3592. * @param viewportHeight defines the current height of the viewport
  3593. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3594. * @param view defines the view matrix to use
  3595. * @param projection defines the projection matrix to use
  3596. * @param result defines the Vector3 where to store the result
  3597. */
  3598. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3599. /**
  3600. * Unproject from screen space to object space
  3601. * @param sourceX defines the screen space x coordinate to use
  3602. * @param sourceY defines the screen space y coordinate to use
  3603. * @param sourceZ defines the screen space z coordinate to use
  3604. * @param viewportWidth defines the current width of the viewport
  3605. * @param viewportHeight defines the current height of the viewport
  3606. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3607. * @param view defines the view matrix to use
  3608. * @param projection defines the projection matrix to use
  3609. * @param result defines the Vector3 where to store the result
  3610. */
  3611. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3612. /**
  3613. * Gets the minimal coordinate values between two Vector3
  3614. * @param left defines the first operand
  3615. * @param right defines the second operand
  3616. * @returns the new Vector3
  3617. */
  3618. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3619. /**
  3620. * Gets the maximal coordinate values between two Vector3
  3621. * @param left defines the first operand
  3622. * @param right defines the second operand
  3623. * @returns the new Vector3
  3624. */
  3625. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3626. /**
  3627. * Returns the distance between the vectors "value1" and "value2"
  3628. * @param value1 defines the first operand
  3629. * @param value2 defines the second operand
  3630. * @returns the distance
  3631. */
  3632. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3633. /**
  3634. * Returns the squared distance between the vectors "value1" and "value2"
  3635. * @param value1 defines the first operand
  3636. * @param value2 defines the second operand
  3637. * @returns the squared distance
  3638. */
  3639. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3640. /**
  3641. * Returns a new Vector3 located at the center between "value1" and "value2"
  3642. * @param value1 defines the first operand
  3643. * @param value2 defines the second operand
  3644. * @returns the new Vector3
  3645. */
  3646. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3647. /**
  3648. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3649. * @param value1 defines first vector
  3650. * @param value2 defines second vector
  3651. * @param ref defines third vector
  3652. * @returns ref
  3653. */
  3654. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3655. /**
  3656. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3657. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3658. * to something in order to rotate it from its local system to the given target system
  3659. * Note: axis1, axis2 and axis3 are normalized during this operation
  3660. * @param axis1 defines the first axis
  3661. * @param axis2 defines the second axis
  3662. * @param axis3 defines the third axis
  3663. * @returns a new Vector3
  3664. */
  3665. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3666. /**
  3667. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3668. * @param axis1 defines the first axis
  3669. * @param axis2 defines the second axis
  3670. * @param axis3 defines the third axis
  3671. * @param ref defines the Vector3 where to store the result
  3672. */
  3673. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3674. }
  3675. /**
  3676. * Vector4 class created for EulerAngle class conversion to Quaternion
  3677. */
  3678. export class Vector4 {
  3679. /** x value of the vector */
  3680. x: number;
  3681. /** y value of the vector */
  3682. y: number;
  3683. /** z value of the vector */
  3684. z: number;
  3685. /** w value of the vector */
  3686. w: number;
  3687. /**
  3688. * Creates a Vector4 object from the given floats.
  3689. * @param x x value of the vector
  3690. * @param y y value of the vector
  3691. * @param z z value of the vector
  3692. * @param w w value of the vector
  3693. */
  3694. constructor(
  3695. /** x value of the vector */
  3696. x: number,
  3697. /** y value of the vector */
  3698. y: number,
  3699. /** z value of the vector */
  3700. z: number,
  3701. /** w value of the vector */
  3702. w: number);
  3703. /**
  3704. * Returns the string with the Vector4 coordinates.
  3705. * @returns a string containing all the vector values
  3706. */
  3707. toString(): string;
  3708. /**
  3709. * Returns the string "Vector4".
  3710. * @returns "Vector4"
  3711. */
  3712. getClassName(): string;
  3713. /**
  3714. * Returns the Vector4 hash code.
  3715. * @returns a unique hash code
  3716. */
  3717. getHashCode(): number;
  3718. /**
  3719. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3720. * @returns the resulting array
  3721. */
  3722. asArray(): number[];
  3723. /**
  3724. * Populates the given array from the given index with the Vector4 coordinates.
  3725. * @param array array to populate
  3726. * @param index index of the array to start at (default: 0)
  3727. * @returns the Vector4.
  3728. */
  3729. toArray(array: FloatArray, index?: number): Vector4;
  3730. /**
  3731. * Update the current vector from an array
  3732. * @param array defines the destination array
  3733. * @param index defines the offset in the destination array
  3734. * @returns the current Vector3
  3735. */
  3736. fromArray(array: FloatArray, index?: number): Vector4;
  3737. /**
  3738. * Adds the given vector to the current Vector4.
  3739. * @param otherVector the vector to add
  3740. * @returns the updated Vector4.
  3741. */
  3742. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3743. /**
  3744. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3745. * @param otherVector the vector to add
  3746. * @returns the resulting vector
  3747. */
  3748. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3749. /**
  3750. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3751. * @param otherVector the vector to add
  3752. * @param result the vector to store the result
  3753. * @returns the current Vector4.
  3754. */
  3755. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3756. /**
  3757. * Subtract in place the given vector from the current Vector4.
  3758. * @param otherVector the vector to subtract
  3759. * @returns the updated Vector4.
  3760. */
  3761. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3762. /**
  3763. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3764. * @param otherVector the vector to add
  3765. * @returns the new vector with the result
  3766. */
  3767. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3768. /**
  3769. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3770. * @param otherVector the vector to subtract
  3771. * @param result the vector to store the result
  3772. * @returns the current Vector4.
  3773. */
  3774. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3775. /**
  3776. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3777. */
  3778. /**
  3779. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3780. * @param x value to subtract
  3781. * @param y value to subtract
  3782. * @param z value to subtract
  3783. * @param w value to subtract
  3784. * @returns new vector containing the result
  3785. */
  3786. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3787. /**
  3788. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3789. * @param x value to subtract
  3790. * @param y value to subtract
  3791. * @param z value to subtract
  3792. * @param w value to subtract
  3793. * @param result the vector to store the result in
  3794. * @returns the current Vector4.
  3795. */
  3796. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3797. /**
  3798. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3799. * @returns a new vector with the negated values
  3800. */
  3801. negate(): Vector4;
  3802. /**
  3803. * Negate this vector in place
  3804. * @returns this
  3805. */
  3806. negateInPlace(): Vector4;
  3807. /**
  3808. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3809. * @param result defines the Vector3 object where to store the result
  3810. * @returns the current Vector4
  3811. */
  3812. negateToRef(result: Vector4): Vector4;
  3813. /**
  3814. * Multiplies the current Vector4 coordinates by scale (float).
  3815. * @param scale the number to scale with
  3816. * @returns the updated Vector4.
  3817. */
  3818. scaleInPlace(scale: number): Vector4;
  3819. /**
  3820. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3821. * @param scale the number to scale with
  3822. * @returns a new vector with the result
  3823. */
  3824. scale(scale: number): Vector4;
  3825. /**
  3826. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3827. * @param scale the number to scale with
  3828. * @param result a vector to store the result in
  3829. * @returns the current Vector4.
  3830. */
  3831. scaleToRef(scale: number, result: Vector4): Vector4;
  3832. /**
  3833. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3834. * @param scale defines the scale factor
  3835. * @param result defines the Vector4 object where to store the result
  3836. * @returns the unmodified current Vector4
  3837. */
  3838. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3839. /**
  3840. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3841. * @param otherVector the vector to compare against
  3842. * @returns true if they are equal
  3843. */
  3844. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3845. /**
  3846. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3847. * @param otherVector vector to compare against
  3848. * @param epsilon (Default: very small number)
  3849. * @returns true if they are equal
  3850. */
  3851. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3852. /**
  3853. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3854. * @param x x value to compare against
  3855. * @param y y value to compare against
  3856. * @param z z value to compare against
  3857. * @param w w value to compare against
  3858. * @returns true if equal
  3859. */
  3860. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3861. /**
  3862. * Multiplies in place the current Vector4 by the given one.
  3863. * @param otherVector vector to multiple with
  3864. * @returns the updated Vector4.
  3865. */
  3866. multiplyInPlace(otherVector: Vector4): Vector4;
  3867. /**
  3868. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3869. * @param otherVector vector to multiple with
  3870. * @returns resulting new vector
  3871. */
  3872. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3873. /**
  3874. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3875. * @param otherVector vector to multiple with
  3876. * @param result vector to store the result
  3877. * @returns the current Vector4.
  3878. */
  3879. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3880. /**
  3881. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3882. * @param x x value multiply with
  3883. * @param y y value multiply with
  3884. * @param z z value multiply with
  3885. * @param w w value multiply with
  3886. * @returns resulting new vector
  3887. */
  3888. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3889. /**
  3890. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3891. * @param otherVector vector to devide with
  3892. * @returns resulting new vector
  3893. */
  3894. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3895. /**
  3896. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3897. * @param otherVector vector to devide with
  3898. * @param result vector to store the result
  3899. * @returns the current Vector4.
  3900. */
  3901. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3902. /**
  3903. * Divides the current Vector3 coordinates by the given ones.
  3904. * @param otherVector vector to devide with
  3905. * @returns the updated Vector3.
  3906. */
  3907. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3908. /**
  3909. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3910. * @param other defines the second operand
  3911. * @returns the current updated Vector4
  3912. */
  3913. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3914. /**
  3915. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3916. * @param other defines the second operand
  3917. * @returns the current updated Vector4
  3918. */
  3919. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3920. /**
  3921. * Gets a new Vector4 from current Vector4 floored values
  3922. * @returns a new Vector4
  3923. */
  3924. floor(): Vector4;
  3925. /**
  3926. * Gets a new Vector4 from current Vector3 floored values
  3927. * @returns a new Vector4
  3928. */
  3929. fract(): Vector4;
  3930. /**
  3931. * Returns the Vector4 length (float).
  3932. * @returns the length
  3933. */
  3934. length(): number;
  3935. /**
  3936. * Returns the Vector4 squared length (float).
  3937. * @returns the length squared
  3938. */
  3939. lengthSquared(): number;
  3940. /**
  3941. * Normalizes in place the Vector4.
  3942. * @returns the updated Vector4.
  3943. */
  3944. normalize(): Vector4;
  3945. /**
  3946. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3947. * @returns this converted to a new vector3
  3948. */
  3949. toVector3(): Vector3;
  3950. /**
  3951. * Returns a new Vector4 copied from the current one.
  3952. * @returns the new cloned vector
  3953. */
  3954. clone(): Vector4;
  3955. /**
  3956. * Updates the current Vector4 with the given one coordinates.
  3957. * @param source the source vector to copy from
  3958. * @returns the updated Vector4.
  3959. */
  3960. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3961. /**
  3962. * Updates the current Vector4 coordinates with the given floats.
  3963. * @param x float to copy from
  3964. * @param y float to copy from
  3965. * @param z float to copy from
  3966. * @param w float to copy from
  3967. * @returns the updated Vector4.
  3968. */
  3969. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3970. /**
  3971. * Updates the current Vector4 coordinates with the given floats.
  3972. * @param x float to set from
  3973. * @param y float to set from
  3974. * @param z float to set from
  3975. * @param w float to set from
  3976. * @returns the updated Vector4.
  3977. */
  3978. set(x: number, y: number, z: number, w: number): Vector4;
  3979. /**
  3980. * Copies the given float to the current Vector3 coordinates
  3981. * @param v defines the x, y, z and w coordinates of the operand
  3982. * @returns the current updated Vector3
  3983. */
  3984. setAll(v: number): Vector4;
  3985. /**
  3986. * Returns a new Vector4 set from the starting index of the given array.
  3987. * @param array the array to pull values from
  3988. * @param offset the offset into the array to start at
  3989. * @returns the new vector
  3990. */
  3991. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3992. /**
  3993. * Updates the given vector "result" from the starting index of the given array.
  3994. * @param array the array to pull values from
  3995. * @param offset the offset into the array to start at
  3996. * @param result the vector to store the result in
  3997. */
  3998. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3999. /**
  4000. * Updates the given vector "result" from the starting index of the given Float32Array.
  4001. * @param array the array to pull values from
  4002. * @param offset the offset into the array to start at
  4003. * @param result the vector to store the result in
  4004. */
  4005. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4006. /**
  4007. * Updates the given vector "result" coordinates from the given floats.
  4008. * @param x float to set from
  4009. * @param y float to set from
  4010. * @param z float to set from
  4011. * @param w float to set from
  4012. * @param result the vector to the floats in
  4013. */
  4014. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4015. /**
  4016. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4017. * @returns the new vector
  4018. */
  4019. static Zero(): Vector4;
  4020. /**
  4021. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4022. * @returns the new vector
  4023. */
  4024. static One(): Vector4;
  4025. /**
  4026. * Returns a new normalized Vector4 from the given one.
  4027. * @param vector the vector to normalize
  4028. * @returns the vector
  4029. */
  4030. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4031. /**
  4032. * Updates the given vector "result" from the normalization of the given one.
  4033. * @param vector the vector to normalize
  4034. * @param result the vector to store the result in
  4035. */
  4036. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4037. /**
  4038. * Returns a vector with the minimum values from the left and right vectors
  4039. * @param left left vector to minimize
  4040. * @param right right vector to minimize
  4041. * @returns a new vector with the minimum of the left and right vector values
  4042. */
  4043. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4044. /**
  4045. * Returns a vector with the maximum values from the left and right vectors
  4046. * @param left left vector to maximize
  4047. * @param right right vector to maximize
  4048. * @returns a new vector with the maximum of the left and right vector values
  4049. */
  4050. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4051. /**
  4052. * Returns the distance (float) between the vectors "value1" and "value2".
  4053. * @param value1 value to calulate the distance between
  4054. * @param value2 value to calulate the distance between
  4055. * @return the distance between the two vectors
  4056. */
  4057. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4058. /**
  4059. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4060. * @param value1 value to calulate the distance between
  4061. * @param value2 value to calulate the distance between
  4062. * @return the distance between the two vectors squared
  4063. */
  4064. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4065. /**
  4066. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4067. * @param value1 value to calulate the center between
  4068. * @param value2 value to calulate the center between
  4069. * @return the center between the two vectors
  4070. */
  4071. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4072. /**
  4073. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4074. * @param value1 defines first vector
  4075. * @param value2 defines second vector
  4076. * @param ref defines third vector
  4077. * @returns ref
  4078. */
  4079. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4080. /**
  4081. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4082. * This methods computes transformed normalized direction vectors only.
  4083. * @param vector the vector to transform
  4084. * @param transformation the transformation matrix to apply
  4085. * @returns the new vector
  4086. */
  4087. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4088. /**
  4089. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4090. * This methods computes transformed normalized direction vectors only.
  4091. * @param vector the vector to transform
  4092. * @param transformation the transformation matrix to apply
  4093. * @param result the vector to store the result in
  4094. */
  4095. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4096. /**
  4097. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4098. * This methods computes transformed normalized direction vectors only.
  4099. * @param x value to transform
  4100. * @param y value to transform
  4101. * @param z value to transform
  4102. * @param w value to transform
  4103. * @param transformation the transformation matrix to apply
  4104. * @param result the vector to store the results in
  4105. */
  4106. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4107. /**
  4108. * Creates a new Vector4 from a Vector3
  4109. * @param source defines the source data
  4110. * @param w defines the 4th component (default is 0)
  4111. * @returns a new Vector4
  4112. */
  4113. static FromVector3(source: Vector3, w?: number): Vector4;
  4114. }
  4115. /**
  4116. * Class used to store quaternion data
  4117. * @see https://en.wikipedia.org/wiki/Quaternion
  4118. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4119. */
  4120. export class Quaternion {
  4121. /** @hidden */
  4122. _x: number;
  4123. /** @hidden */
  4124. _y: number;
  4125. /** @hidden */
  4126. _z: number;
  4127. /** @hidden */
  4128. _w: number;
  4129. /** @hidden */
  4130. _isDirty: boolean;
  4131. /** Gets or sets the x coordinate */
  4132. get x(): number;
  4133. set x(value: number);
  4134. /** Gets or sets the y coordinate */
  4135. get y(): number;
  4136. set y(value: number);
  4137. /** Gets or sets the z coordinate */
  4138. get z(): number;
  4139. set z(value: number);
  4140. /** Gets or sets the w coordinate */
  4141. get w(): number;
  4142. set w(value: number);
  4143. /**
  4144. * Creates a new Quaternion from the given floats
  4145. * @param x defines the first component (0 by default)
  4146. * @param y defines the second component (0 by default)
  4147. * @param z defines the third component (0 by default)
  4148. * @param w defines the fourth component (1.0 by default)
  4149. */
  4150. constructor(x?: number, y?: number, z?: number, w?: number);
  4151. /**
  4152. * Gets a string representation for the current quaternion
  4153. * @returns a string with the Quaternion coordinates
  4154. */
  4155. toString(): string;
  4156. /**
  4157. * Gets the class name of the quaternion
  4158. * @returns the string "Quaternion"
  4159. */
  4160. getClassName(): string;
  4161. /**
  4162. * Gets a hash code for this quaternion
  4163. * @returns the quaternion hash code
  4164. */
  4165. getHashCode(): number;
  4166. /**
  4167. * Copy the quaternion to an array
  4168. * @returns a new array populated with 4 elements from the quaternion coordinates
  4169. */
  4170. asArray(): number[];
  4171. /**
  4172. * Check if two quaternions are equals
  4173. * @param otherQuaternion defines the second operand
  4174. * @return true if the current quaternion and the given one coordinates are strictly equals
  4175. */
  4176. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4177. /**
  4178. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4179. * @param otherQuaternion defines the other quaternion
  4180. * @param epsilon defines the minimal distance to consider equality
  4181. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4182. */
  4183. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4184. /**
  4185. * Clone the current quaternion
  4186. * @returns a new quaternion copied from the current one
  4187. */
  4188. clone(): Quaternion;
  4189. /**
  4190. * Copy a quaternion to the current one
  4191. * @param other defines the other quaternion
  4192. * @returns the updated current quaternion
  4193. */
  4194. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4195. /**
  4196. * Updates the current quaternion with the given float coordinates
  4197. * @param x defines the x coordinate
  4198. * @param y defines the y coordinate
  4199. * @param z defines the z coordinate
  4200. * @param w defines the w coordinate
  4201. * @returns the updated current quaternion
  4202. */
  4203. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4204. /**
  4205. * Updates the current quaternion from the given float coordinates
  4206. * @param x defines the x coordinate
  4207. * @param y defines the y coordinate
  4208. * @param z defines the z coordinate
  4209. * @param w defines the w coordinate
  4210. * @returns the updated current quaternion
  4211. */
  4212. set(x: number, y: number, z: number, w: number): Quaternion;
  4213. /**
  4214. * Adds two quaternions
  4215. * @param other defines the second operand
  4216. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4217. */
  4218. add(other: DeepImmutable<Quaternion>): Quaternion;
  4219. /**
  4220. * Add a quaternion to the current one
  4221. * @param other defines the quaternion to add
  4222. * @returns the current quaternion
  4223. */
  4224. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4225. /**
  4226. * Subtract two quaternions
  4227. * @param other defines the second operand
  4228. * @returns a new quaternion as the subtraction result of the given one from the current one
  4229. */
  4230. subtract(other: Quaternion): Quaternion;
  4231. /**
  4232. * Multiplies the current quaternion by a scale factor
  4233. * @param value defines the scale factor
  4234. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4235. */
  4236. scale(value: number): Quaternion;
  4237. /**
  4238. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4239. * @param scale defines the scale factor
  4240. * @param result defines the Quaternion object where to store the result
  4241. * @returns the unmodified current quaternion
  4242. */
  4243. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4244. /**
  4245. * Multiplies in place the current quaternion by a scale factor
  4246. * @param value defines the scale factor
  4247. * @returns the current modified quaternion
  4248. */
  4249. scaleInPlace(value: number): Quaternion;
  4250. /**
  4251. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4252. * @param scale defines the scale factor
  4253. * @param result defines the Quaternion object where to store the result
  4254. * @returns the unmodified current quaternion
  4255. */
  4256. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4257. /**
  4258. * Multiplies two quaternions
  4259. * @param q1 defines the second operand
  4260. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4261. */
  4262. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4263. /**
  4264. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4265. * @param q1 defines the second operand
  4266. * @param result defines the target quaternion
  4267. * @returns the current quaternion
  4268. */
  4269. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4270. /**
  4271. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4272. * @param q1 defines the second operand
  4273. * @returns the currentupdated quaternion
  4274. */
  4275. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4276. /**
  4277. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4278. * @param ref defines the target quaternion
  4279. * @returns the current quaternion
  4280. */
  4281. conjugateToRef(ref: Quaternion): Quaternion;
  4282. /**
  4283. * Conjugates in place (1-q) the current quaternion
  4284. * @returns the current updated quaternion
  4285. */
  4286. conjugateInPlace(): Quaternion;
  4287. /**
  4288. * Conjugates in place (1-q) the current quaternion
  4289. * @returns a new quaternion
  4290. */
  4291. conjugate(): Quaternion;
  4292. /**
  4293. * Gets length of current quaternion
  4294. * @returns the quaternion length (float)
  4295. */
  4296. length(): number;
  4297. /**
  4298. * Normalize in place the current quaternion
  4299. * @returns the current updated quaternion
  4300. */
  4301. normalize(): Quaternion;
  4302. /**
  4303. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4304. * @param order is a reserved parameter and is ignored for now
  4305. * @returns a new Vector3 containing the Euler angles
  4306. */
  4307. toEulerAngles(order?: string): Vector3;
  4308. /**
  4309. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4310. * @param result defines the vector which will be filled with the Euler angles
  4311. * @returns the current unchanged quaternion
  4312. */
  4313. toEulerAnglesToRef(result: Vector3): Quaternion;
  4314. /**
  4315. * Updates the given rotation matrix with the current quaternion values
  4316. * @param result defines the target matrix
  4317. * @returns the current unchanged quaternion
  4318. */
  4319. toRotationMatrix(result: Matrix): Quaternion;
  4320. /**
  4321. * Updates the current quaternion from the given rotation matrix values
  4322. * @param matrix defines the source matrix
  4323. * @returns the current updated quaternion
  4324. */
  4325. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4326. /**
  4327. * Creates a new quaternion from a rotation matrix
  4328. * @param matrix defines the source matrix
  4329. * @returns a new quaternion created from the given rotation matrix values
  4330. */
  4331. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4332. /**
  4333. * Updates the given quaternion with the given rotation matrix values
  4334. * @param matrix defines the source matrix
  4335. * @param result defines the target quaternion
  4336. */
  4337. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4338. /**
  4339. * Returns the dot product (float) between the quaternions "left" and "right"
  4340. * @param left defines the left operand
  4341. * @param right defines the right operand
  4342. * @returns the dot product
  4343. */
  4344. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4345. /**
  4346. * Checks if the two quaternions are close to each other
  4347. * @param quat0 defines the first quaternion to check
  4348. * @param quat1 defines the second quaternion to check
  4349. * @returns true if the two quaternions are close to each other
  4350. */
  4351. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4352. /**
  4353. * Creates an empty quaternion
  4354. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4355. */
  4356. static Zero(): Quaternion;
  4357. /**
  4358. * Inverse a given quaternion
  4359. * @param q defines the source quaternion
  4360. * @returns a new quaternion as the inverted current quaternion
  4361. */
  4362. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4363. /**
  4364. * Inverse a given quaternion
  4365. * @param q defines the source quaternion
  4366. * @param result the quaternion the result will be stored in
  4367. * @returns the result quaternion
  4368. */
  4369. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4370. /**
  4371. * Creates an identity quaternion
  4372. * @returns the identity quaternion
  4373. */
  4374. static Identity(): Quaternion;
  4375. /**
  4376. * Gets a boolean indicating if the given quaternion is identity
  4377. * @param quaternion defines the quaternion to check
  4378. * @returns true if the quaternion is identity
  4379. */
  4380. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4381. /**
  4382. * Creates a quaternion from a rotation around an axis
  4383. * @param axis defines the axis to use
  4384. * @param angle defines the angle to use
  4385. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4386. */
  4387. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4388. /**
  4389. * Creates a rotation around an axis and stores it into the given quaternion
  4390. * @param axis defines the axis to use
  4391. * @param angle defines the angle to use
  4392. * @param result defines the target quaternion
  4393. * @returns the target quaternion
  4394. */
  4395. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4396. /**
  4397. * Creates a new quaternion from data stored into an array
  4398. * @param array defines the data source
  4399. * @param offset defines the offset in the source array where the data starts
  4400. * @returns a new quaternion
  4401. */
  4402. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4403. /**
  4404. * Updates the given quaternion "result" from the starting index of the given array.
  4405. * @param array the array to pull values from
  4406. * @param offset the offset into the array to start at
  4407. * @param result the quaternion to store the result in
  4408. */
  4409. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4410. /**
  4411. * Create a quaternion from Euler rotation angles
  4412. * @param x Pitch
  4413. * @param y Yaw
  4414. * @param z Roll
  4415. * @returns the new Quaternion
  4416. */
  4417. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4418. /**
  4419. * Updates a quaternion from Euler rotation angles
  4420. * @param x Pitch
  4421. * @param y Yaw
  4422. * @param z Roll
  4423. * @param result the quaternion to store the result
  4424. * @returns the updated quaternion
  4425. */
  4426. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4427. /**
  4428. * Create a quaternion from Euler rotation vector
  4429. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4430. * @returns the new Quaternion
  4431. */
  4432. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4433. /**
  4434. * Updates a quaternion from Euler rotation vector
  4435. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4436. * @param result the quaternion to store the result
  4437. * @returns the updated quaternion
  4438. */
  4439. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4440. /**
  4441. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4442. * @param yaw defines the rotation around Y axis
  4443. * @param pitch defines the rotation around X axis
  4444. * @param roll defines the rotation around Z axis
  4445. * @returns the new quaternion
  4446. */
  4447. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4448. /**
  4449. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4450. * @param yaw defines the rotation around Y axis
  4451. * @param pitch defines the rotation around X axis
  4452. * @param roll defines the rotation around Z axis
  4453. * @param result defines the target quaternion
  4454. */
  4455. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4456. /**
  4457. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4458. * @param alpha defines the rotation around first axis
  4459. * @param beta defines the rotation around second axis
  4460. * @param gamma defines the rotation around third axis
  4461. * @returns the new quaternion
  4462. */
  4463. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4464. /**
  4465. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4466. * @param alpha defines the rotation around first axis
  4467. * @param beta defines the rotation around second axis
  4468. * @param gamma defines the rotation around third axis
  4469. * @param result defines the target quaternion
  4470. */
  4471. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4472. /**
  4473. * 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)
  4474. * @param axis1 defines the first axis
  4475. * @param axis2 defines the second axis
  4476. * @param axis3 defines the third axis
  4477. * @returns the new quaternion
  4478. */
  4479. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4480. /**
  4481. * 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
  4482. * @param axis1 defines the first axis
  4483. * @param axis2 defines the second axis
  4484. * @param axis3 defines the third axis
  4485. * @param ref defines the target quaternion
  4486. */
  4487. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4488. /**
  4489. * Interpolates between two quaternions
  4490. * @param left defines first quaternion
  4491. * @param right defines second quaternion
  4492. * @param amount defines the gradient to use
  4493. * @returns the new interpolated quaternion
  4494. */
  4495. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4496. /**
  4497. * Interpolates between two quaternions and stores it into a target quaternion
  4498. * @param left defines first quaternion
  4499. * @param right defines second quaternion
  4500. * @param amount defines the gradient to use
  4501. * @param result defines the target quaternion
  4502. */
  4503. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4504. /**
  4505. * Interpolate between two quaternions using Hermite interpolation
  4506. * @param value1 defines first quaternion
  4507. * @param tangent1 defines the incoming tangent
  4508. * @param value2 defines second quaternion
  4509. * @param tangent2 defines the outgoing tangent
  4510. * @param amount defines the target quaternion
  4511. * @returns the new interpolated quaternion
  4512. */
  4513. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4514. }
  4515. /**
  4516. * Class used to store matrix data (4x4)
  4517. */
  4518. export class Matrix {
  4519. /**
  4520. * Gets the precision of matrix computations
  4521. */
  4522. static get Use64Bits(): boolean;
  4523. private static _updateFlagSeed;
  4524. private static _identityReadOnly;
  4525. private _isIdentity;
  4526. private _isIdentityDirty;
  4527. private _isIdentity3x2;
  4528. private _isIdentity3x2Dirty;
  4529. /**
  4530. * Gets the update flag of the matrix which is an unique number for the matrix.
  4531. * It will be incremented every time the matrix data change.
  4532. * You can use it to speed the comparison between two versions of the same matrix.
  4533. */
  4534. updateFlag: number;
  4535. private readonly _m;
  4536. /**
  4537. * Gets the internal data of the matrix
  4538. */
  4539. get m(): DeepImmutable<Float32Array | Array<number>>;
  4540. /** @hidden */
  4541. _markAsUpdated(): void;
  4542. /** @hidden */
  4543. private _updateIdentityStatus;
  4544. /**
  4545. * Creates an empty matrix (filled with zeros)
  4546. */
  4547. constructor();
  4548. /**
  4549. * Check if the current matrix is identity
  4550. * @returns true is the matrix is the identity matrix
  4551. */
  4552. isIdentity(): boolean;
  4553. /**
  4554. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4555. * @returns true is the matrix is the identity matrix
  4556. */
  4557. isIdentityAs3x2(): boolean;
  4558. /**
  4559. * Gets the determinant of the matrix
  4560. * @returns the matrix determinant
  4561. */
  4562. determinant(): number;
  4563. /**
  4564. * Returns the matrix as a Float32Array or Array<number>
  4565. * @returns the matrix underlying array
  4566. */
  4567. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4568. /**
  4569. * Returns the matrix as a Float32Array or Array<number>
  4570. * @returns the matrix underlying array.
  4571. */
  4572. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4573. /**
  4574. * Inverts the current matrix in place
  4575. * @returns the current inverted matrix
  4576. */
  4577. invert(): Matrix;
  4578. /**
  4579. * Sets all the matrix elements to zero
  4580. * @returns the current matrix
  4581. */
  4582. reset(): Matrix;
  4583. /**
  4584. * Adds the current matrix with a second one
  4585. * @param other defines the matrix to add
  4586. * @returns a new matrix as the addition of the current matrix and the given one
  4587. */
  4588. add(other: DeepImmutable<Matrix>): Matrix;
  4589. /**
  4590. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4591. * @param other defines the matrix to add
  4592. * @param result defines the target matrix
  4593. * @returns the current matrix
  4594. */
  4595. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4596. /**
  4597. * Adds in place the given matrix to the current matrix
  4598. * @param other defines the second operand
  4599. * @returns the current updated matrix
  4600. */
  4601. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4602. /**
  4603. * Sets the given matrix to the current inverted Matrix
  4604. * @param other defines the target matrix
  4605. * @returns the unmodified current matrix
  4606. */
  4607. invertToRef(other: Matrix): Matrix;
  4608. /**
  4609. * add a value at the specified position in the current Matrix
  4610. * @param index the index of the value within the matrix. between 0 and 15.
  4611. * @param value the value to be added
  4612. * @returns the current updated matrix
  4613. */
  4614. addAtIndex(index: number, value: number): Matrix;
  4615. /**
  4616. * mutiply the specified position in the current Matrix by a value
  4617. * @param index the index of the value within the matrix. between 0 and 15.
  4618. * @param value the value to be added
  4619. * @returns the current updated matrix
  4620. */
  4621. multiplyAtIndex(index: number, value: number): Matrix;
  4622. /**
  4623. * Inserts the translation vector (using 3 floats) in the current matrix
  4624. * @param x defines the 1st component of the translation
  4625. * @param y defines the 2nd component of the translation
  4626. * @param z defines the 3rd component of the translation
  4627. * @returns the current updated matrix
  4628. */
  4629. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4630. /**
  4631. * Adds the translation vector (using 3 floats) in the current matrix
  4632. * @param x defines the 1st component of the translation
  4633. * @param y defines the 2nd component of the translation
  4634. * @param z defines the 3rd component of the translation
  4635. * @returns the current updated matrix
  4636. */
  4637. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4638. /**
  4639. * Inserts the translation vector in the current matrix
  4640. * @param vector3 defines the translation to insert
  4641. * @returns the current updated matrix
  4642. */
  4643. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4644. /**
  4645. * Gets the translation value of the current matrix
  4646. * @returns a new Vector3 as the extracted translation from the matrix
  4647. */
  4648. getTranslation(): Vector3;
  4649. /**
  4650. * Fill a Vector3 with the extracted translation from the matrix
  4651. * @param result defines the Vector3 where to store the translation
  4652. * @returns the current matrix
  4653. */
  4654. getTranslationToRef(result: Vector3): Matrix;
  4655. /**
  4656. * Remove rotation and scaling part from the matrix
  4657. * @returns the updated matrix
  4658. */
  4659. removeRotationAndScaling(): Matrix;
  4660. /**
  4661. * Multiply two matrices
  4662. * @param other defines the second operand
  4663. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4664. */
  4665. multiply(other: DeepImmutable<Matrix>): Matrix;
  4666. /**
  4667. * Copy the current matrix from the given one
  4668. * @param other defines the source matrix
  4669. * @returns the current updated matrix
  4670. */
  4671. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4672. /**
  4673. * Populates the given array from the starting index with the current matrix values
  4674. * @param array defines the target array
  4675. * @param offset defines the offset in the target array where to start storing values
  4676. * @returns the current matrix
  4677. */
  4678. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4679. /**
  4680. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4681. * @param other defines the second operand
  4682. * @param result defines the matrix where to store the multiplication
  4683. * @returns the current matrix
  4684. */
  4685. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4686. /**
  4687. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4688. * @param other defines the second operand
  4689. * @param result defines the array where to store the multiplication
  4690. * @param offset defines the offset in the target array where to start storing values
  4691. * @returns the current matrix
  4692. */
  4693. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4694. /**
  4695. * Check equality between this matrix and a second one
  4696. * @param value defines the second matrix to compare
  4697. * @returns true is the current matrix and the given one values are strictly equal
  4698. */
  4699. equals(value: DeepImmutable<Matrix>): boolean;
  4700. /**
  4701. * Clone the current matrix
  4702. * @returns a new matrix from the current matrix
  4703. */
  4704. clone(): Matrix;
  4705. /**
  4706. * Returns the name of the current matrix class
  4707. * @returns the string "Matrix"
  4708. */
  4709. getClassName(): string;
  4710. /**
  4711. * Gets the hash code of the current matrix
  4712. * @returns the hash code
  4713. */
  4714. getHashCode(): number;
  4715. /**
  4716. * Decomposes the current Matrix into a translation, rotation and scaling components
  4717. * @param scale defines the scale vector3 given as a reference to update
  4718. * @param rotation defines the rotation quaternion given as a reference to update
  4719. * @param translation defines the translation vector3 given as a reference to update
  4720. * @returns true if operation was successful
  4721. */
  4722. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4723. /**
  4724. * Gets specific row of the matrix
  4725. * @param index defines the number of the row to get
  4726. * @returns the index-th row of the current matrix as a new Vector4
  4727. */
  4728. getRow(index: number): Nullable<Vector4>;
  4729. /**
  4730. * Sets the index-th row of the current matrix to the vector4 values
  4731. * @param index defines the number of the row to set
  4732. * @param row defines the target vector4
  4733. * @returns the updated current matrix
  4734. */
  4735. setRow(index: number, row: Vector4): Matrix;
  4736. /**
  4737. * Compute the transpose of the matrix
  4738. * @returns the new transposed matrix
  4739. */
  4740. transpose(): Matrix;
  4741. /**
  4742. * Compute the transpose of the matrix and store it in a given matrix
  4743. * @param result defines the target matrix
  4744. * @returns the current matrix
  4745. */
  4746. transposeToRef(result: Matrix): Matrix;
  4747. /**
  4748. * Sets the index-th row of the current matrix with the given 4 x float values
  4749. * @param index defines the row index
  4750. * @param x defines the x component to set
  4751. * @param y defines the y component to set
  4752. * @param z defines the z component to set
  4753. * @param w defines the w component to set
  4754. * @returns the updated current matrix
  4755. */
  4756. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4757. /**
  4758. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4759. * @param scale defines the scale factor
  4760. * @returns a new matrix
  4761. */
  4762. scale(scale: number): Matrix;
  4763. /**
  4764. * Scale the current matrix values by a factor to a given result matrix
  4765. * @param scale defines the scale factor
  4766. * @param result defines the matrix to store the result
  4767. * @returns the current matrix
  4768. */
  4769. scaleToRef(scale: number, result: Matrix): Matrix;
  4770. /**
  4771. * Scale the current matrix values by a factor and add the result to a given matrix
  4772. * @param scale defines the scale factor
  4773. * @param result defines the Matrix to store the result
  4774. * @returns the current matrix
  4775. */
  4776. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4777. /**
  4778. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4779. * @param ref matrix to store the result
  4780. */
  4781. toNormalMatrix(ref: Matrix): void;
  4782. /**
  4783. * Gets only rotation part of the current matrix
  4784. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4785. */
  4786. getRotationMatrix(): Matrix;
  4787. /**
  4788. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4789. * @param result defines the target matrix to store data to
  4790. * @returns the current matrix
  4791. */
  4792. getRotationMatrixToRef(result: Matrix): Matrix;
  4793. /**
  4794. * Toggles model matrix from being right handed to left handed in place and vice versa
  4795. */
  4796. toggleModelMatrixHandInPlace(): void;
  4797. /**
  4798. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4799. */
  4800. toggleProjectionMatrixHandInPlace(): void;
  4801. /**
  4802. * Creates a matrix from an array
  4803. * @param array defines the source array
  4804. * @param offset defines an offset in the source array
  4805. * @returns a new Matrix set from the starting index of the given array
  4806. */
  4807. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4808. /**
  4809. * Copy the content of an array into a given matrix
  4810. * @param array defines the source array
  4811. * @param offset defines an offset in the source array
  4812. * @param result defines the target matrix
  4813. */
  4814. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4815. /**
  4816. * Stores an array into a matrix after having multiplied each component by a given factor
  4817. * @param array defines the source array
  4818. * @param offset defines the offset in the source array
  4819. * @param scale defines the scaling factor
  4820. * @param result defines the target matrix
  4821. */
  4822. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4823. /**
  4824. * Gets an identity matrix that must not be updated
  4825. */
  4826. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4827. /**
  4828. * Stores a list of values (16) inside a given matrix
  4829. * @param initialM11 defines 1st value of 1st row
  4830. * @param initialM12 defines 2nd value of 1st row
  4831. * @param initialM13 defines 3rd value of 1st row
  4832. * @param initialM14 defines 4th value of 1st row
  4833. * @param initialM21 defines 1st value of 2nd row
  4834. * @param initialM22 defines 2nd value of 2nd row
  4835. * @param initialM23 defines 3rd value of 2nd row
  4836. * @param initialM24 defines 4th value of 2nd row
  4837. * @param initialM31 defines 1st value of 3rd row
  4838. * @param initialM32 defines 2nd value of 3rd row
  4839. * @param initialM33 defines 3rd value of 3rd row
  4840. * @param initialM34 defines 4th value of 3rd row
  4841. * @param initialM41 defines 1st value of 4th row
  4842. * @param initialM42 defines 2nd value of 4th row
  4843. * @param initialM43 defines 3rd value of 4th row
  4844. * @param initialM44 defines 4th value of 4th row
  4845. * @param result defines the target matrix
  4846. */
  4847. 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;
  4848. /**
  4849. * Creates new matrix from a list of values (16)
  4850. * @param initialM11 defines 1st value of 1st row
  4851. * @param initialM12 defines 2nd value of 1st row
  4852. * @param initialM13 defines 3rd value of 1st row
  4853. * @param initialM14 defines 4th value of 1st row
  4854. * @param initialM21 defines 1st value of 2nd row
  4855. * @param initialM22 defines 2nd value of 2nd row
  4856. * @param initialM23 defines 3rd value of 2nd row
  4857. * @param initialM24 defines 4th value of 2nd row
  4858. * @param initialM31 defines 1st value of 3rd row
  4859. * @param initialM32 defines 2nd value of 3rd row
  4860. * @param initialM33 defines 3rd value of 3rd row
  4861. * @param initialM34 defines 4th value of 3rd row
  4862. * @param initialM41 defines 1st value of 4th row
  4863. * @param initialM42 defines 2nd value of 4th row
  4864. * @param initialM43 defines 3rd value of 4th row
  4865. * @param initialM44 defines 4th value of 4th row
  4866. * @returns the new matrix
  4867. */
  4868. 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;
  4869. /**
  4870. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4871. * @param scale defines the scale vector3
  4872. * @param rotation defines the rotation quaternion
  4873. * @param translation defines the translation vector3
  4874. * @returns a new matrix
  4875. */
  4876. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4877. /**
  4878. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4879. * @param scale defines the scale vector3
  4880. * @param rotation defines the rotation quaternion
  4881. * @param translation defines the translation vector3
  4882. * @param result defines the target matrix
  4883. */
  4884. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4885. /**
  4886. * Creates a new identity matrix
  4887. * @returns a new identity matrix
  4888. */
  4889. static Identity(): Matrix;
  4890. /**
  4891. * Creates a new identity matrix and stores the result in a given matrix
  4892. * @param result defines the target matrix
  4893. */
  4894. static IdentityToRef(result: Matrix): void;
  4895. /**
  4896. * Creates a new zero matrix
  4897. * @returns a new zero matrix
  4898. */
  4899. static Zero(): Matrix;
  4900. /**
  4901. * Creates a new rotation matrix for "angle" radians around the X axis
  4902. * @param angle defines the angle (in radians) to use
  4903. * @return the new matrix
  4904. */
  4905. static RotationX(angle: number): Matrix;
  4906. /**
  4907. * Creates a new matrix as the invert of a given matrix
  4908. * @param source defines the source matrix
  4909. * @returns the new matrix
  4910. */
  4911. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4912. /**
  4913. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4914. * @param angle defines the angle (in radians) to use
  4915. * @param result defines the target matrix
  4916. */
  4917. static RotationXToRef(angle: number, result: Matrix): void;
  4918. /**
  4919. * Creates a new rotation matrix for "angle" radians around the Y axis
  4920. * @param angle defines the angle (in radians) to use
  4921. * @return the new matrix
  4922. */
  4923. static RotationY(angle: number): Matrix;
  4924. /**
  4925. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4926. * @param angle defines the angle (in radians) to use
  4927. * @param result defines the target matrix
  4928. */
  4929. static RotationYToRef(angle: number, result: Matrix): void;
  4930. /**
  4931. * Creates a new rotation matrix for "angle" radians around the Z axis
  4932. * @param angle defines the angle (in radians) to use
  4933. * @return the new matrix
  4934. */
  4935. static RotationZ(angle: number): Matrix;
  4936. /**
  4937. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4938. * @param angle defines the angle (in radians) to use
  4939. * @param result defines the target matrix
  4940. */
  4941. static RotationZToRef(angle: number, result: Matrix): void;
  4942. /**
  4943. * Creates a new rotation matrix for "angle" radians around the given axis
  4944. * @param axis defines the axis to use
  4945. * @param angle defines the angle (in radians) to use
  4946. * @return the new matrix
  4947. */
  4948. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4949. /**
  4950. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4951. * @param axis defines the axis to use
  4952. * @param angle defines the angle (in radians) to use
  4953. * @param result defines the target matrix
  4954. */
  4955. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4956. /**
  4957. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4958. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4959. * @param from defines the vector to align
  4960. * @param to defines the vector to align to
  4961. * @param result defines the target matrix
  4962. */
  4963. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4964. /**
  4965. * Creates a rotation matrix
  4966. * @param yaw defines the yaw angle in radians (Y axis)
  4967. * @param pitch defines the pitch angle in radians (X axis)
  4968. * @param roll defines the roll angle in radians (Z axis)
  4969. * @returns the new rotation matrix
  4970. */
  4971. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4972. /**
  4973. * Creates a rotation matrix and stores it in a given matrix
  4974. * @param yaw defines the yaw angle in radians (Y axis)
  4975. * @param pitch defines the pitch angle in radians (X axis)
  4976. * @param roll defines the roll angle in radians (Z axis)
  4977. * @param result defines the target matrix
  4978. */
  4979. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4980. /**
  4981. * Creates a scaling matrix
  4982. * @param x defines the scale factor on X axis
  4983. * @param y defines the scale factor on Y axis
  4984. * @param z defines the scale factor on Z axis
  4985. * @returns the new matrix
  4986. */
  4987. static Scaling(x: number, y: number, z: number): Matrix;
  4988. /**
  4989. * Creates a scaling matrix and stores it in a given matrix
  4990. * @param x defines the scale factor on X axis
  4991. * @param y defines the scale factor on Y axis
  4992. * @param z defines the scale factor on Z axis
  4993. * @param result defines the target matrix
  4994. */
  4995. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4996. /**
  4997. * Creates a translation matrix
  4998. * @param x defines the translation on X axis
  4999. * @param y defines the translation on Y axis
  5000. * @param z defines the translationon Z axis
  5001. * @returns the new matrix
  5002. */
  5003. static Translation(x: number, y: number, z: number): Matrix;
  5004. /**
  5005. * Creates a translation matrix and stores it in a given matrix
  5006. * @param x defines the translation on X axis
  5007. * @param y defines the translation on Y axis
  5008. * @param z defines the translationon Z axis
  5009. * @param result defines the target matrix
  5010. */
  5011. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5012. /**
  5013. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5014. * @param startValue defines the start value
  5015. * @param endValue defines the end value
  5016. * @param gradient defines the gradient factor
  5017. * @returns the new matrix
  5018. */
  5019. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5020. /**
  5021. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5022. * @param startValue defines the start value
  5023. * @param endValue defines the end value
  5024. * @param gradient defines the gradient factor
  5025. * @param result defines the Matrix object where to store data
  5026. */
  5027. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5028. /**
  5029. * Builds a new matrix whose values are computed by:
  5030. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5031. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5032. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5033. * @param startValue defines the first matrix
  5034. * @param endValue defines the second matrix
  5035. * @param gradient defines the gradient between the two matrices
  5036. * @returns the new matrix
  5037. */
  5038. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5039. /**
  5040. * Update a matrix to values which are computed by:
  5041. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5042. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5043. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5044. * @param startValue defines the first matrix
  5045. * @param endValue defines the second matrix
  5046. * @param gradient defines the gradient between the two matrices
  5047. * @param result defines the target matrix
  5048. */
  5049. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5050. /**
  5051. * 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"
  5052. * This function works in left 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. * @returns the new matrix
  5057. */
  5058. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5059. /**
  5060. * 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".
  5061. * This function works in left handed mode
  5062. * @param eye defines the final position of the entity
  5063. * @param target defines where the entity should look at
  5064. * @param up defines the up vector for the entity
  5065. * @param result defines the target matrix
  5066. */
  5067. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5068. /**
  5069. * 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"
  5070. * This function works in right handed mode
  5071. * @param eye defines the final position of the entity
  5072. * @param target defines where the entity should look at
  5073. * @param up defines the up vector for the entity
  5074. * @returns the new matrix
  5075. */
  5076. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5077. /**
  5078. * 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".
  5079. * This function works in right handed mode
  5080. * @param eye defines the final position of the entity
  5081. * @param target defines where the entity should look at
  5082. * @param up defines the up vector for the entity
  5083. * @param result defines the target matrix
  5084. */
  5085. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5086. /**
  5087. * Create a left-handed orthographic projection matrix
  5088. * @param width defines the viewport width
  5089. * @param height defines the viewport height
  5090. * @param znear defines the near clip plane
  5091. * @param zfar defines the far clip plane
  5092. * @returns a new matrix as a left-handed orthographic projection matrix
  5093. */
  5094. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5095. /**
  5096. * Store a left-handed orthographic projection to a given matrix
  5097. * @param width defines the viewport width
  5098. * @param height defines the viewport height
  5099. * @param znear defines the near clip plane
  5100. * @param zfar defines the far clip plane
  5101. * @param result defines the target matrix
  5102. */
  5103. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5104. /**
  5105. * Create a left-handed orthographic projection matrix
  5106. * @param left defines the viewport left coordinate
  5107. * @param right defines the viewport right coordinate
  5108. * @param bottom defines the viewport bottom coordinate
  5109. * @param top defines the viewport top coordinate
  5110. * @param znear defines the near clip plane
  5111. * @param zfar defines the far clip plane
  5112. * @returns a new matrix as a left-handed orthographic projection matrix
  5113. */
  5114. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5115. /**
  5116. * Stores a left-handed orthographic projection into a given matrix
  5117. * @param left defines the viewport left coordinate
  5118. * @param right defines the viewport right coordinate
  5119. * @param bottom defines the viewport bottom coordinate
  5120. * @param top defines the viewport top coordinate
  5121. * @param znear defines the near clip plane
  5122. * @param zfar defines the far clip plane
  5123. * @param result defines the target matrix
  5124. */
  5125. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5126. /**
  5127. * Creates a right-handed orthographic projection matrix
  5128. * @param left defines the viewport left coordinate
  5129. * @param right defines the viewport right coordinate
  5130. * @param bottom defines the viewport bottom coordinate
  5131. * @param top defines the viewport top coordinate
  5132. * @param znear defines the near clip plane
  5133. * @param zfar defines the far clip plane
  5134. * @returns a new matrix as a right-handed orthographic projection matrix
  5135. */
  5136. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5137. /**
  5138. * Stores a right-handed orthographic projection into a given matrix
  5139. * @param left defines the viewport left coordinate
  5140. * @param right defines the viewport right coordinate
  5141. * @param bottom defines the viewport bottom coordinate
  5142. * @param top defines the viewport top coordinate
  5143. * @param znear defines the near clip plane
  5144. * @param zfar defines the far clip plane
  5145. * @param result defines the target matrix
  5146. */
  5147. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5148. /**
  5149. * Creates a left-handed perspective projection matrix
  5150. * @param width defines the viewport width
  5151. * @param height defines the viewport height
  5152. * @param znear defines the near clip plane
  5153. * @param zfar defines the far clip plane
  5154. * @returns a new matrix as a left-handed perspective projection matrix
  5155. */
  5156. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5157. /**
  5158. * Creates a left-handed perspective projection matrix
  5159. * @param fov defines the horizontal field of view
  5160. * @param aspect defines the aspect ratio
  5161. * @param znear defines the near clip plane
  5162. * @param zfar defines the far clip plane
  5163. * @returns a new matrix as a left-handed perspective projection matrix
  5164. */
  5165. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5166. /**
  5167. * Stores a left-handed perspective projection into a given matrix
  5168. * @param fov defines the horizontal field of view
  5169. * @param aspect defines the aspect ratio
  5170. * @param znear defines the near clip plane
  5171. * @param zfar defines the far clip plane
  5172. * @param result defines the target matrix
  5173. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5174. */
  5175. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5176. /**
  5177. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5178. * @param fov defines the horizontal field of view
  5179. * @param aspect defines the aspect ratio
  5180. * @param znear defines the near clip plane
  5181. * @param zfar not used as infinity is used as far clip
  5182. * @param result defines the target matrix
  5183. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5184. */
  5185. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5186. /**
  5187. * Creates a right-handed perspective projection matrix
  5188. * @param fov defines the horizontal field of view
  5189. * @param aspect defines the aspect ratio
  5190. * @param znear defines the near clip plane
  5191. * @param zfar defines the far clip plane
  5192. * @returns a new matrix as a right-handed perspective projection matrix
  5193. */
  5194. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5195. /**
  5196. * Stores a right-handed perspective projection into a given matrix
  5197. * @param fov defines the horizontal field of view
  5198. * @param aspect defines the aspect ratio
  5199. * @param znear defines the near clip plane
  5200. * @param zfar defines the far clip plane
  5201. * @param result defines the target matrix
  5202. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5203. */
  5204. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5205. /**
  5206. * Stores a right-handed perspective projection into a given matrix
  5207. * @param fov defines the horizontal field of view
  5208. * @param aspect defines the aspect ratio
  5209. * @param znear defines the near clip plane
  5210. * @param zfar not used as infinity is used as far clip
  5211. * @param result defines the target matrix
  5212. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5213. */
  5214. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5215. /**
  5216. * Stores a perspective projection for WebVR info a given matrix
  5217. * @param fov defines the field of view
  5218. * @param znear defines the near clip plane
  5219. * @param zfar defines the far clip plane
  5220. * @param result defines the target matrix
  5221. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5222. */
  5223. static PerspectiveFovWebVRToRef(fov: {
  5224. upDegrees: number;
  5225. downDegrees: number;
  5226. leftDegrees: number;
  5227. rightDegrees: number;
  5228. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5229. /**
  5230. * Computes a complete transformation matrix
  5231. * @param viewport defines the viewport to use
  5232. * @param world defines the world matrix
  5233. * @param view defines the view matrix
  5234. * @param projection defines the projection matrix
  5235. * @param zmin defines the near clip plane
  5236. * @param zmax defines the far clip plane
  5237. * @returns the transformation matrix
  5238. */
  5239. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5240. /**
  5241. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5242. * @param matrix defines the matrix to use
  5243. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5244. */
  5245. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5246. /**
  5247. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5248. * @param matrix defines the matrix to use
  5249. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5250. */
  5251. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5252. /**
  5253. * Compute the transpose of a given matrix
  5254. * @param matrix defines the matrix to transpose
  5255. * @returns the new matrix
  5256. */
  5257. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5258. /**
  5259. * Compute the transpose of a matrix and store it in a target matrix
  5260. * @param matrix defines the matrix to transpose
  5261. * @param result defines the target matrix
  5262. */
  5263. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5264. /**
  5265. * Computes a reflection matrix from a plane
  5266. * @param plane defines the reflection plane
  5267. * @returns a new matrix
  5268. */
  5269. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5270. /**
  5271. * Computes a reflection matrix from a plane
  5272. * @param plane defines the reflection plane
  5273. * @param result defines the target matrix
  5274. */
  5275. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5276. /**
  5277. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5278. * @param xaxis defines the value of the 1st axis
  5279. * @param yaxis defines the value of the 2nd axis
  5280. * @param zaxis defines the value of the 3rd axis
  5281. * @param result defines the target matrix
  5282. */
  5283. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5284. /**
  5285. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5286. * @param quat defines the quaternion to use
  5287. * @param result defines the target matrix
  5288. */
  5289. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5290. }
  5291. /**
  5292. * @hidden
  5293. */
  5294. export class TmpVectors {
  5295. static Vector2: Vector2[];
  5296. static Vector3: Vector3[];
  5297. static Vector4: Vector4[];
  5298. static Quaternion: Quaternion[];
  5299. static Matrix: Matrix[];
  5300. }
  5301. }
  5302. declare module "babylonjs/Maths/math.path" {
  5303. import { DeepImmutable, Nullable } from "babylonjs/types";
  5304. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5305. /**
  5306. * Defines potential orientation for back face culling
  5307. */
  5308. export enum Orientation {
  5309. /**
  5310. * Clockwise
  5311. */
  5312. CW = 0,
  5313. /** Counter clockwise */
  5314. CCW = 1
  5315. }
  5316. /** Class used to represent a Bezier curve */
  5317. export class BezierCurve {
  5318. /**
  5319. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5320. * @param t defines the time
  5321. * @param x1 defines the left coordinate on X axis
  5322. * @param y1 defines the left coordinate on Y axis
  5323. * @param x2 defines the right coordinate on X axis
  5324. * @param y2 defines the right coordinate on Y axis
  5325. * @returns the interpolated value
  5326. */
  5327. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5328. }
  5329. /**
  5330. * Defines angle representation
  5331. */
  5332. export class Angle {
  5333. private _radians;
  5334. /**
  5335. * Creates an Angle object of "radians" radians (float).
  5336. * @param radians the angle in radians
  5337. */
  5338. constructor(radians: number);
  5339. /**
  5340. * Get value in degrees
  5341. * @returns the Angle value in degrees (float)
  5342. */
  5343. degrees(): number;
  5344. /**
  5345. * Get value in radians
  5346. * @returns the Angle value in radians (float)
  5347. */
  5348. radians(): number;
  5349. /**
  5350. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5351. * @param a defines first point as the origin
  5352. * @param b defines point
  5353. * @returns a new Angle
  5354. */
  5355. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5356. /**
  5357. * Gets a new Angle object from the given float in radians
  5358. * @param radians defines the angle value in radians
  5359. * @returns a new Angle
  5360. */
  5361. static FromRadians(radians: number): Angle;
  5362. /**
  5363. * Gets a new Angle object from the given float in degrees
  5364. * @param degrees defines the angle value in degrees
  5365. * @returns a new Angle
  5366. */
  5367. static FromDegrees(degrees: number): Angle;
  5368. }
  5369. /**
  5370. * This represents an arc in a 2d space.
  5371. */
  5372. export class Arc2 {
  5373. /** Defines the start point of the arc */
  5374. startPoint: Vector2;
  5375. /** Defines the mid point of the arc */
  5376. midPoint: Vector2;
  5377. /** Defines the end point of the arc */
  5378. endPoint: Vector2;
  5379. /**
  5380. * Defines the center point of the arc.
  5381. */
  5382. centerPoint: Vector2;
  5383. /**
  5384. * Defines the radius of the arc.
  5385. */
  5386. radius: number;
  5387. /**
  5388. * Defines the angle of the arc (from mid point to end point).
  5389. */
  5390. angle: Angle;
  5391. /**
  5392. * Defines the start angle of the arc (from start point to middle point).
  5393. */
  5394. startAngle: Angle;
  5395. /**
  5396. * Defines the orientation of the arc (clock wise/counter clock wise).
  5397. */
  5398. orientation: Orientation;
  5399. /**
  5400. * Creates an Arc object from the three given points : start, middle and end.
  5401. * @param startPoint Defines the start point of the arc
  5402. * @param midPoint Defines the midlle point of the arc
  5403. * @param endPoint Defines the end point of the arc
  5404. */
  5405. constructor(
  5406. /** Defines the start point of the arc */
  5407. startPoint: Vector2,
  5408. /** Defines the mid point of the arc */
  5409. midPoint: Vector2,
  5410. /** Defines the end point of the arc */
  5411. endPoint: Vector2);
  5412. }
  5413. /**
  5414. * Represents a 2D path made up of multiple 2D points
  5415. */
  5416. export class Path2 {
  5417. private _points;
  5418. private _length;
  5419. /**
  5420. * If the path start and end point are the same
  5421. */
  5422. closed: boolean;
  5423. /**
  5424. * Creates a Path2 object from the starting 2D coordinates x and y.
  5425. * @param x the starting points x value
  5426. * @param y the starting points y value
  5427. */
  5428. constructor(x: number, y: number);
  5429. /**
  5430. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5431. * @param x the added points x value
  5432. * @param y the added points y value
  5433. * @returns the updated Path2.
  5434. */
  5435. addLineTo(x: number, y: number): Path2;
  5436. /**
  5437. * 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.
  5438. * @param midX middle point x value
  5439. * @param midY middle point y value
  5440. * @param endX end point x value
  5441. * @param endY end point y value
  5442. * @param numberOfSegments (default: 36)
  5443. * @returns the updated Path2.
  5444. */
  5445. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5446. /**
  5447. * Closes the Path2.
  5448. * @returns the Path2.
  5449. */
  5450. close(): Path2;
  5451. /**
  5452. * Gets the sum of the distance between each sequential point in the path
  5453. * @returns the Path2 total length (float).
  5454. */
  5455. length(): number;
  5456. /**
  5457. * Gets the points which construct the path
  5458. * @returns the Path2 internal array of points.
  5459. */
  5460. getPoints(): Vector2[];
  5461. /**
  5462. * Retreives the point at the distance aways from the starting point
  5463. * @param normalizedLengthPosition the length along the path to retreive the point from
  5464. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5465. */
  5466. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5467. /**
  5468. * Creates a new path starting from an x and y position
  5469. * @param x starting x value
  5470. * @param y starting y value
  5471. * @returns a new Path2 starting at the coordinates (x, y).
  5472. */
  5473. static StartingAt(x: number, y: number): Path2;
  5474. }
  5475. /**
  5476. * Represents a 3D path made up of multiple 3D points
  5477. */
  5478. export class Path3D {
  5479. /**
  5480. * an array of Vector3, the curve axis of the Path3D
  5481. */
  5482. path: Vector3[];
  5483. private _curve;
  5484. private _distances;
  5485. private _tangents;
  5486. private _normals;
  5487. private _binormals;
  5488. private _raw;
  5489. private _alignTangentsWithPath;
  5490. private readonly _pointAtData;
  5491. /**
  5492. * new Path3D(path, normal, raw)
  5493. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5494. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5495. * @param path an array of Vector3, the curve axis of the Path3D
  5496. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5497. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5498. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5499. */
  5500. constructor(
  5501. /**
  5502. * an array of Vector3, the curve axis of the Path3D
  5503. */
  5504. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5505. /**
  5506. * Returns the Path3D array of successive Vector3 designing its curve.
  5507. * @returns the Path3D array of successive Vector3 designing its curve.
  5508. */
  5509. getCurve(): Vector3[];
  5510. /**
  5511. * Returns the Path3D array of successive Vector3 designing its curve.
  5512. * @returns the Path3D array of successive Vector3 designing its curve.
  5513. */
  5514. getPoints(): Vector3[];
  5515. /**
  5516. * @returns the computed length (float) of the path.
  5517. */
  5518. length(): number;
  5519. /**
  5520. * Returns an array populated with tangent vectors on each Path3D curve point.
  5521. * @returns an array populated with tangent vectors on each Path3D curve point.
  5522. */
  5523. getTangents(): Vector3[];
  5524. /**
  5525. * Returns an array populated with normal vectors on each Path3D curve point.
  5526. * @returns an array populated with normal vectors on each Path3D curve point.
  5527. */
  5528. getNormals(): Vector3[];
  5529. /**
  5530. * Returns an array populated with binormal vectors on each Path3D curve point.
  5531. * @returns an array populated with binormal vectors on each Path3D curve point.
  5532. */
  5533. getBinormals(): Vector3[];
  5534. /**
  5535. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5536. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5537. */
  5538. getDistances(): number[];
  5539. /**
  5540. * Returns an interpolated point along this path
  5541. * @param position the position of the point along this path, from 0.0 to 1.0
  5542. * @returns a new Vector3 as the point
  5543. */
  5544. getPointAt(position: number): Vector3;
  5545. /**
  5546. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5547. * @param position the position of the point along this path, from 0.0 to 1.0
  5548. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5549. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5550. */
  5551. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5552. /**
  5553. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5554. * @param position the position of the point along this path, from 0.0 to 1.0
  5555. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5556. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5557. */
  5558. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5559. /**
  5560. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5561. * @param position the position of the point along this path, from 0.0 to 1.0
  5562. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5563. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5564. */
  5565. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5566. /**
  5567. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5568. * @param position the position of the point along this path, from 0.0 to 1.0
  5569. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5570. */
  5571. getDistanceAt(position: number): number;
  5572. /**
  5573. * Returns the array index of the previous point of an interpolated point along this path
  5574. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5575. * @returns the array index
  5576. */
  5577. getPreviousPointIndexAt(position: number): number;
  5578. /**
  5579. * 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)
  5580. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5581. * @returns the sub position
  5582. */
  5583. getSubPositionAt(position: number): number;
  5584. /**
  5585. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5586. * @param target the vector of which to get the closest position to
  5587. * @returns the position of the closest virtual point on this path to the target vector
  5588. */
  5589. getClosestPositionTo(target: Vector3): number;
  5590. /**
  5591. * Returns a sub path (slice) of this path
  5592. * @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
  5593. * @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
  5594. * @returns a sub path (slice) of this path
  5595. */
  5596. slice(start?: number, end?: number): Path3D;
  5597. /**
  5598. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5599. * @param path path which all values are copied into the curves points
  5600. * @param firstNormal which should be projected onto the curve
  5601. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5602. * @returns the same object updated.
  5603. */
  5604. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5605. private _compute;
  5606. private _getFirstNonNullVector;
  5607. private _getLastNonNullVector;
  5608. private _normalVector;
  5609. /**
  5610. * Updates the point at data for an interpolated point along this curve
  5611. * @param position the position of the point along this curve, from 0.0 to 1.0
  5612. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5613. * @returns the (updated) point at data
  5614. */
  5615. private _updatePointAtData;
  5616. /**
  5617. * Updates the point at data from the specified parameters
  5618. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5619. * @param point the interpolated point
  5620. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5621. */
  5622. private _setPointAtData;
  5623. /**
  5624. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5625. */
  5626. private _updateInterpolationMatrix;
  5627. }
  5628. /**
  5629. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5630. * A Curve3 is designed from a series of successive Vector3.
  5631. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5632. */
  5633. export class Curve3 {
  5634. private _points;
  5635. private _length;
  5636. /**
  5637. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5638. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5639. * @param v1 (Vector3) the control point
  5640. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5641. * @param nbPoints (integer) the wanted number of points in the curve
  5642. * @returns the created Curve3
  5643. */
  5644. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5645. /**
  5646. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5647. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5648. * @param v1 (Vector3) the first control point
  5649. * @param v2 (Vector3) the second control point
  5650. * @param v3 (Vector3) the end point of the Cubic Bezier
  5651. * @param nbPoints (integer) the wanted number of points in the curve
  5652. * @returns the created Curve3
  5653. */
  5654. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5655. /**
  5656. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5657. * @param p1 (Vector3) the origin point of the Hermite Spline
  5658. * @param t1 (Vector3) the tangent vector at the origin point
  5659. * @param p2 (Vector3) the end point of the Hermite Spline
  5660. * @param t2 (Vector3) the tangent vector at the end point
  5661. * @param nbPoints (integer) the wanted number of points in the curve
  5662. * @returns the created Curve3
  5663. */
  5664. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5665. /**
  5666. * Returns a Curve3 object along a CatmullRom Spline curve :
  5667. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5668. * @param nbPoints (integer) the wanted number of points between each curve control points
  5669. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5670. * @returns the created Curve3
  5671. */
  5672. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5673. /**
  5674. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5675. * A Curve3 is designed from a series of successive Vector3.
  5676. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5677. * @param points points which make up the curve
  5678. */
  5679. constructor(points: Vector3[]);
  5680. /**
  5681. * @returns the Curve3 stored array of successive Vector3
  5682. */
  5683. getPoints(): Vector3[];
  5684. /**
  5685. * @returns the computed length (float) of the curve.
  5686. */
  5687. length(): number;
  5688. /**
  5689. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5690. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5691. * curveA and curveB keep unchanged.
  5692. * @param curve the curve to continue from this curve
  5693. * @returns the newly constructed curve
  5694. */
  5695. continue(curve: DeepImmutable<Curve3>): Curve3;
  5696. private _computeLength;
  5697. }
  5698. }
  5699. declare module "babylonjs/Animations/easing" {
  5700. /**
  5701. * This represents the main contract an easing function should follow.
  5702. * Easing functions are used throughout the animation system.
  5703. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5704. */
  5705. export interface IEasingFunction {
  5706. /**
  5707. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5708. * of the easing function.
  5709. * The link below provides some of the most common examples of easing functions.
  5710. * @see https://easings.net/
  5711. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5712. * @returns the corresponding value on the curve defined by the easing function
  5713. */
  5714. ease(gradient: number): number;
  5715. }
  5716. /**
  5717. * Base class used for every default easing function.
  5718. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5719. */
  5720. export class EasingFunction implements IEasingFunction {
  5721. /**
  5722. * Interpolation follows the mathematical formula associated with the easing function.
  5723. */
  5724. static readonly EASINGMODE_EASEIN: number;
  5725. /**
  5726. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5727. */
  5728. static readonly EASINGMODE_EASEOUT: number;
  5729. /**
  5730. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5731. */
  5732. static readonly EASINGMODE_EASEINOUT: number;
  5733. private _easingMode;
  5734. /**
  5735. * Sets the easing mode of the current function.
  5736. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5737. */
  5738. setEasingMode(easingMode: number): void;
  5739. /**
  5740. * Gets the current easing mode.
  5741. * @returns the easing mode
  5742. */
  5743. getEasingMode(): number;
  5744. /**
  5745. * @hidden
  5746. */
  5747. easeInCore(gradient: number): number;
  5748. /**
  5749. * Given an input gradient between 0 and 1, this returns the corresponding value
  5750. * of the easing function.
  5751. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5752. * @returns the corresponding value on the curve defined by the easing function
  5753. */
  5754. ease(gradient: number): number;
  5755. }
  5756. /**
  5757. * Easing function with a circle shape (see link below).
  5758. * @see https://easings.net/#easeInCirc
  5759. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5760. */
  5761. export class CircleEase extends EasingFunction implements IEasingFunction {
  5762. /** @hidden */
  5763. easeInCore(gradient: number): number;
  5764. }
  5765. /**
  5766. * Easing function with a ease back shape (see link below).
  5767. * @see https://easings.net/#easeInBack
  5768. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5769. */
  5770. export class BackEase extends EasingFunction implements IEasingFunction {
  5771. /** Defines the amplitude of the function */
  5772. amplitude: number;
  5773. /**
  5774. * Instantiates a back ease easing
  5775. * @see https://easings.net/#easeInBack
  5776. * @param amplitude Defines the amplitude of the function
  5777. */
  5778. constructor(
  5779. /** Defines the amplitude of the function */
  5780. amplitude?: number);
  5781. /** @hidden */
  5782. easeInCore(gradient: number): number;
  5783. }
  5784. /**
  5785. * Easing function with a bouncing shape (see link below).
  5786. * @see https://easings.net/#easeInBounce
  5787. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5788. */
  5789. export class BounceEase extends EasingFunction implements IEasingFunction {
  5790. /** Defines the number of bounces */
  5791. bounces: number;
  5792. /** Defines the amplitude of the bounce */
  5793. bounciness: number;
  5794. /**
  5795. * Instantiates a bounce easing
  5796. * @see https://easings.net/#easeInBounce
  5797. * @param bounces Defines the number of bounces
  5798. * @param bounciness Defines the amplitude of the bounce
  5799. */
  5800. constructor(
  5801. /** Defines the number of bounces */
  5802. bounces?: number,
  5803. /** Defines the amplitude of the bounce */
  5804. bounciness?: number);
  5805. /** @hidden */
  5806. easeInCore(gradient: number): number;
  5807. }
  5808. /**
  5809. * Easing function with a power of 3 shape (see link below).
  5810. * @see https://easings.net/#easeInCubic
  5811. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5812. */
  5813. export class CubicEase extends EasingFunction implements IEasingFunction {
  5814. /** @hidden */
  5815. easeInCore(gradient: number): number;
  5816. }
  5817. /**
  5818. * Easing function with an elastic shape (see link below).
  5819. * @see https://easings.net/#easeInElastic
  5820. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5821. */
  5822. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5823. /** Defines the number of oscillations*/
  5824. oscillations: number;
  5825. /** Defines the amplitude of the oscillations*/
  5826. springiness: number;
  5827. /**
  5828. * Instantiates an elastic easing function
  5829. * @see https://easings.net/#easeInElastic
  5830. * @param oscillations Defines the number of oscillations
  5831. * @param springiness Defines the amplitude of the oscillations
  5832. */
  5833. constructor(
  5834. /** Defines the number of oscillations*/
  5835. oscillations?: number,
  5836. /** Defines the amplitude of the oscillations*/
  5837. springiness?: number);
  5838. /** @hidden */
  5839. easeInCore(gradient: number): number;
  5840. }
  5841. /**
  5842. * Easing function with an exponential shape (see link below).
  5843. * @see https://easings.net/#easeInExpo
  5844. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5845. */
  5846. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5847. /** Defines the exponent of the function */
  5848. exponent: number;
  5849. /**
  5850. * Instantiates an exponential easing function
  5851. * @see https://easings.net/#easeInExpo
  5852. * @param exponent Defines the exponent of the function
  5853. */
  5854. constructor(
  5855. /** Defines the exponent of the function */
  5856. exponent?: number);
  5857. /** @hidden */
  5858. easeInCore(gradient: number): number;
  5859. }
  5860. /**
  5861. * Easing function with a power shape (see link below).
  5862. * @see https://easings.net/#easeInQuad
  5863. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5864. */
  5865. export class PowerEase extends EasingFunction implements IEasingFunction {
  5866. /** Defines the power of the function */
  5867. power: number;
  5868. /**
  5869. * Instantiates an power base easing function
  5870. * @see https://easings.net/#easeInQuad
  5871. * @param power Defines the power of the function
  5872. */
  5873. constructor(
  5874. /** Defines the power of the function */
  5875. power?: number);
  5876. /** @hidden */
  5877. easeInCore(gradient: number): number;
  5878. }
  5879. /**
  5880. * Easing function with a power of 2 shape (see link below).
  5881. * @see https://easings.net/#easeInQuad
  5882. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5883. */
  5884. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5885. /** @hidden */
  5886. easeInCore(gradient: number): number;
  5887. }
  5888. /**
  5889. * Easing function with a power of 4 shape (see link below).
  5890. * @see https://easings.net/#easeInQuart
  5891. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5892. */
  5893. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5894. /** @hidden */
  5895. easeInCore(gradient: number): number;
  5896. }
  5897. /**
  5898. * Easing function with a power of 5 shape (see link below).
  5899. * @see https://easings.net/#easeInQuint
  5900. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5901. */
  5902. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5903. /** @hidden */
  5904. easeInCore(gradient: number): number;
  5905. }
  5906. /**
  5907. * Easing function with a sin shape (see link below).
  5908. * @see https://easings.net/#easeInSine
  5909. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5910. */
  5911. export class SineEase extends EasingFunction implements IEasingFunction {
  5912. /** @hidden */
  5913. easeInCore(gradient: number): number;
  5914. }
  5915. /**
  5916. * Easing function with a bezier shape (see link below).
  5917. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5918. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5919. */
  5920. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5921. /** Defines the x component of the start tangent in the bezier curve */
  5922. x1: number;
  5923. /** Defines the y component of the start tangent in the bezier curve */
  5924. y1: number;
  5925. /** Defines the x component of the end tangent in the bezier curve */
  5926. x2: number;
  5927. /** Defines the y component of the end tangent in the bezier curve */
  5928. y2: number;
  5929. /**
  5930. * Instantiates a bezier function
  5931. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5932. * @param x1 Defines the x component of the start tangent in the bezier curve
  5933. * @param y1 Defines the y component of the start tangent in the bezier curve
  5934. * @param x2 Defines the x component of the end tangent in the bezier curve
  5935. * @param y2 Defines the y component of the end tangent in the bezier curve
  5936. */
  5937. constructor(
  5938. /** Defines the x component of the start tangent in the bezier curve */
  5939. x1?: number,
  5940. /** Defines the y component of the start tangent in the bezier curve */
  5941. y1?: number,
  5942. /** Defines the x component of the end tangent in the bezier curve */
  5943. x2?: number,
  5944. /** Defines the y component of the end tangent in the bezier curve */
  5945. y2?: number);
  5946. /** @hidden */
  5947. easeInCore(gradient: number): number;
  5948. }
  5949. }
  5950. declare module "babylonjs/Maths/math.color" {
  5951. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5952. /**
  5953. * Class used to hold a RBG color
  5954. */
  5955. export class Color3 {
  5956. /**
  5957. * Defines the red component (between 0 and 1, default is 0)
  5958. */
  5959. r: number;
  5960. /**
  5961. * Defines the green component (between 0 and 1, default is 0)
  5962. */
  5963. g: number;
  5964. /**
  5965. * Defines the blue component (between 0 and 1, default is 0)
  5966. */
  5967. b: number;
  5968. /**
  5969. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5970. * @param r defines the red component (between 0 and 1, default is 0)
  5971. * @param g defines the green component (between 0 and 1, default is 0)
  5972. * @param b defines the blue component (between 0 and 1, default is 0)
  5973. */
  5974. constructor(
  5975. /**
  5976. * Defines the red component (between 0 and 1, default is 0)
  5977. */
  5978. r?: number,
  5979. /**
  5980. * Defines the green component (between 0 and 1, default is 0)
  5981. */
  5982. g?: number,
  5983. /**
  5984. * Defines the blue component (between 0 and 1, default is 0)
  5985. */
  5986. b?: number);
  5987. /**
  5988. * Creates a string with the Color3 current values
  5989. * @returns the string representation of the Color3 object
  5990. */
  5991. toString(): string;
  5992. /**
  5993. * Returns the string "Color3"
  5994. * @returns "Color3"
  5995. */
  5996. getClassName(): string;
  5997. /**
  5998. * Compute the Color3 hash code
  5999. * @returns an unique number that can be used to hash Color3 objects
  6000. */
  6001. getHashCode(): number;
  6002. /**
  6003. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6004. * @param array defines the array where to store the r,g,b components
  6005. * @param index defines an optional index in the target array to define where to start storing values
  6006. * @returns the current Color3 object
  6007. */
  6008. toArray(array: FloatArray, index?: number): Color3;
  6009. /**
  6010. * Update the current color with values stored in an array from the starting index of the given array
  6011. * @param array defines the source array
  6012. * @param offset defines an offset in the source array
  6013. * @returns the current Color3 object
  6014. */
  6015. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6016. /**
  6017. * Returns a new Color4 object from the current Color3 and the given alpha
  6018. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6019. * @returns a new Color4 object
  6020. */
  6021. toColor4(alpha?: number): Color4;
  6022. /**
  6023. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6024. * @returns the new array
  6025. */
  6026. asArray(): number[];
  6027. /**
  6028. * Returns the luminance value
  6029. * @returns a float value
  6030. */
  6031. toLuminance(): number;
  6032. /**
  6033. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6034. * @param otherColor defines the second operand
  6035. * @returns the new Color3 object
  6036. */
  6037. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6038. /**
  6039. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6040. * @param otherColor defines the second operand
  6041. * @param result defines the Color3 object where to store the result
  6042. * @returns the current Color3
  6043. */
  6044. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6045. /**
  6046. * Determines equality between Color3 objects
  6047. * @param otherColor defines the second operand
  6048. * @returns true if the rgb values are equal to the given ones
  6049. */
  6050. equals(otherColor: DeepImmutable<Color3>): boolean;
  6051. /**
  6052. * Determines equality between the current Color3 object and a set of r,b,g values
  6053. * @param r defines the red component to check
  6054. * @param g defines the green component to check
  6055. * @param b defines the blue component to check
  6056. * @returns true if the rgb values are equal to the given ones
  6057. */
  6058. equalsFloats(r: number, g: number, b: number): boolean;
  6059. /**
  6060. * Multiplies in place each rgb value by scale
  6061. * @param scale defines the scaling factor
  6062. * @returns the updated Color3
  6063. */
  6064. scale(scale: number): Color3;
  6065. /**
  6066. * Multiplies the rgb values by scale and stores the result into "result"
  6067. * @param scale defines the scaling factor
  6068. * @param result defines the Color3 object where to store the result
  6069. * @returns the unmodified current Color3
  6070. */
  6071. scaleToRef(scale: number, result: Color3): Color3;
  6072. /**
  6073. * Scale the current Color3 values by a factor and add the result to a given Color3
  6074. * @param scale defines the scale factor
  6075. * @param result defines color to store the result into
  6076. * @returns the unmodified current Color3
  6077. */
  6078. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6079. /**
  6080. * Clamps the rgb values by the min and max values and stores the result into "result"
  6081. * @param min defines minimum clamping value (default is 0)
  6082. * @param max defines maximum clamping value (default is 1)
  6083. * @param result defines color to store the result into
  6084. * @returns the original Color3
  6085. */
  6086. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6087. /**
  6088. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6089. * @param otherColor defines the second operand
  6090. * @returns the new Color3
  6091. */
  6092. add(otherColor: DeepImmutable<Color3>): Color3;
  6093. /**
  6094. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6095. * @param otherColor defines the second operand
  6096. * @param result defines Color3 object to store the result into
  6097. * @returns the unmodified current Color3
  6098. */
  6099. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6100. /**
  6101. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6102. * @param otherColor defines the second operand
  6103. * @returns the new Color3
  6104. */
  6105. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6106. /**
  6107. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6108. * @param otherColor defines the second operand
  6109. * @param result defines Color3 object to store the result into
  6110. * @returns the unmodified current Color3
  6111. */
  6112. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6113. /**
  6114. * Copy the current object
  6115. * @returns a new Color3 copied the current one
  6116. */
  6117. clone(): Color3;
  6118. /**
  6119. * Copies the rgb values from the source in the current Color3
  6120. * @param source defines the source Color3 object
  6121. * @returns the updated Color3 object
  6122. */
  6123. copyFrom(source: DeepImmutable<Color3>): Color3;
  6124. /**
  6125. * Updates the Color3 rgb values from the given floats
  6126. * @param r defines the red component to read from
  6127. * @param g defines the green component to read from
  6128. * @param b defines the blue component to read from
  6129. * @returns the current Color3 object
  6130. */
  6131. copyFromFloats(r: number, g: number, b: number): Color3;
  6132. /**
  6133. * Updates the Color3 rgb values from the given floats
  6134. * @param r defines the red component to read from
  6135. * @param g defines the green component to read from
  6136. * @param b defines the blue component to read from
  6137. * @returns the current Color3 object
  6138. */
  6139. set(r: number, g: number, b: number): Color3;
  6140. /**
  6141. * Compute the Color3 hexadecimal code as a string
  6142. * @returns a string containing the hexadecimal representation of the Color3 object
  6143. */
  6144. toHexString(): string;
  6145. /**
  6146. * Computes a new Color3 converted from the current one to linear space
  6147. * @returns a new Color3 object
  6148. */
  6149. toLinearSpace(): Color3;
  6150. /**
  6151. * Converts current color in rgb space to HSV values
  6152. * @returns a new color3 representing the HSV values
  6153. */
  6154. toHSV(): Color3;
  6155. /**
  6156. * Converts current color in rgb space to HSV values
  6157. * @param result defines the Color3 where to store the HSV values
  6158. */
  6159. toHSVToRef(result: Color3): void;
  6160. /**
  6161. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6162. * @param convertedColor defines the Color3 object where to store the linear space version
  6163. * @returns the unmodified Color3
  6164. */
  6165. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6166. /**
  6167. * Computes a new Color3 converted from the current one to gamma space
  6168. * @returns a new Color3 object
  6169. */
  6170. toGammaSpace(): Color3;
  6171. /**
  6172. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6173. * @param convertedColor defines the Color3 object where to store the gamma space version
  6174. * @returns the unmodified Color3
  6175. */
  6176. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6177. private static _BlackReadOnly;
  6178. /**
  6179. * Convert Hue, saturation and value to a Color3 (RGB)
  6180. * @param hue defines the hue
  6181. * @param saturation defines the saturation
  6182. * @param value defines the value
  6183. * @param result defines the Color3 where to store the RGB values
  6184. */
  6185. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6186. /**
  6187. * Creates a new Color3 from the string containing valid hexadecimal values
  6188. * @param hex defines a string containing valid hexadecimal values
  6189. * @returns a new Color3 object
  6190. */
  6191. static FromHexString(hex: string): Color3;
  6192. /**
  6193. * Creates a new Color3 from the starting index of the given array
  6194. * @param array defines the source array
  6195. * @param offset defines an offset in the source array
  6196. * @returns a new Color3 object
  6197. */
  6198. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6199. /**
  6200. * Creates a new Color3 from the starting index element of the given array
  6201. * @param array defines the source array to read from
  6202. * @param offset defines the offset in the source array
  6203. * @param result defines the target Color3 object
  6204. */
  6205. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6206. /**
  6207. * Creates a new Color3 from integer values (< 256)
  6208. * @param r defines the red component to read from (value between 0 and 255)
  6209. * @param g defines the green component to read from (value between 0 and 255)
  6210. * @param b defines the blue component to read from (value between 0 and 255)
  6211. * @returns a new Color3 object
  6212. */
  6213. static FromInts(r: number, g: number, b: number): Color3;
  6214. /**
  6215. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6216. * @param start defines the start Color3 value
  6217. * @param end defines the end Color3 value
  6218. * @param amount defines the gradient value between start and end
  6219. * @returns a new Color3 object
  6220. */
  6221. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6222. /**
  6223. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6224. * @param left defines the start value
  6225. * @param right defines the end value
  6226. * @param amount defines the gradient factor
  6227. * @param result defines the Color3 object where to store the result
  6228. */
  6229. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6230. /**
  6231. * Returns a Color3 value containing a red color
  6232. * @returns a new Color3 object
  6233. */
  6234. static Red(): Color3;
  6235. /**
  6236. * Returns a Color3 value containing a green color
  6237. * @returns a new Color3 object
  6238. */
  6239. static Green(): Color3;
  6240. /**
  6241. * Returns a Color3 value containing a blue color
  6242. * @returns a new Color3 object
  6243. */
  6244. static Blue(): Color3;
  6245. /**
  6246. * Returns a Color3 value containing a black color
  6247. * @returns a new Color3 object
  6248. */
  6249. static Black(): Color3;
  6250. /**
  6251. * Gets a Color3 value containing a black color that must not be updated
  6252. */
  6253. static get BlackReadOnly(): DeepImmutable<Color3>;
  6254. /**
  6255. * Returns a Color3 value containing a white color
  6256. * @returns a new Color3 object
  6257. */
  6258. static White(): Color3;
  6259. /**
  6260. * Returns a Color3 value containing a purple color
  6261. * @returns a new Color3 object
  6262. */
  6263. static Purple(): Color3;
  6264. /**
  6265. * Returns a Color3 value containing a magenta color
  6266. * @returns a new Color3 object
  6267. */
  6268. static Magenta(): Color3;
  6269. /**
  6270. * Returns a Color3 value containing a yellow color
  6271. * @returns a new Color3 object
  6272. */
  6273. static Yellow(): Color3;
  6274. /**
  6275. * Returns a Color3 value containing a gray color
  6276. * @returns a new Color3 object
  6277. */
  6278. static Gray(): Color3;
  6279. /**
  6280. * Returns a Color3 value containing a teal color
  6281. * @returns a new Color3 object
  6282. */
  6283. static Teal(): Color3;
  6284. /**
  6285. * Returns a Color3 value containing a random color
  6286. * @returns a new Color3 object
  6287. */
  6288. static Random(): Color3;
  6289. }
  6290. /**
  6291. * Class used to hold a RBGA color
  6292. */
  6293. export class Color4 {
  6294. /**
  6295. * Defines the red component (between 0 and 1, default is 0)
  6296. */
  6297. r: number;
  6298. /**
  6299. * Defines the green component (between 0 and 1, default is 0)
  6300. */
  6301. g: number;
  6302. /**
  6303. * Defines the blue component (between 0 and 1, default is 0)
  6304. */
  6305. b: number;
  6306. /**
  6307. * Defines the alpha component (between 0 and 1, default is 1)
  6308. */
  6309. a: number;
  6310. /**
  6311. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6312. * @param r defines the red component (between 0 and 1, default is 0)
  6313. * @param g defines the green component (between 0 and 1, default is 0)
  6314. * @param b defines the blue component (between 0 and 1, default is 0)
  6315. * @param a defines the alpha component (between 0 and 1, default is 1)
  6316. */
  6317. constructor(
  6318. /**
  6319. * Defines the red component (between 0 and 1, default is 0)
  6320. */
  6321. r?: number,
  6322. /**
  6323. * Defines the green component (between 0 and 1, default is 0)
  6324. */
  6325. g?: number,
  6326. /**
  6327. * Defines the blue component (between 0 and 1, default is 0)
  6328. */
  6329. b?: number,
  6330. /**
  6331. * Defines the alpha component (between 0 and 1, default is 1)
  6332. */
  6333. a?: number);
  6334. /**
  6335. * Adds in place the given Color4 values to the current Color4 object
  6336. * @param right defines the second operand
  6337. * @returns the current updated Color4 object
  6338. */
  6339. addInPlace(right: DeepImmutable<Color4>): Color4;
  6340. /**
  6341. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6342. * @returns the new array
  6343. */
  6344. asArray(): number[];
  6345. /**
  6346. * Stores from the starting index in the given array the Color4 successive values
  6347. * @param array defines the array where to store the r,g,b components
  6348. * @param index defines an optional index in the target array to define where to start storing values
  6349. * @returns the current Color4 object
  6350. */
  6351. toArray(array: number[], index?: number): Color4;
  6352. /**
  6353. * Update the current color with values stored in an array from the starting index of the given array
  6354. * @param array defines the source array
  6355. * @param offset defines an offset in the source array
  6356. * @returns the current Color4 object
  6357. */
  6358. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6359. /**
  6360. * Determines equality between Color4 objects
  6361. * @param otherColor defines the second operand
  6362. * @returns true if the rgba values are equal to the given ones
  6363. */
  6364. equals(otherColor: DeepImmutable<Color4>): boolean;
  6365. /**
  6366. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6367. * @param right defines the second operand
  6368. * @returns a new Color4 object
  6369. */
  6370. add(right: DeepImmutable<Color4>): Color4;
  6371. /**
  6372. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6373. * @param right defines the second operand
  6374. * @returns a new Color4 object
  6375. */
  6376. subtract(right: DeepImmutable<Color4>): Color4;
  6377. /**
  6378. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6379. * @param right defines the second operand
  6380. * @param result defines the Color4 object where to store the result
  6381. * @returns the current Color4 object
  6382. */
  6383. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6384. /**
  6385. * Creates a new Color4 with the current Color4 values multiplied by scale
  6386. * @param scale defines the scaling factor to apply
  6387. * @returns a new Color4 object
  6388. */
  6389. scale(scale: number): Color4;
  6390. /**
  6391. * Multiplies the current Color4 values by scale and stores the result in "result"
  6392. * @param scale defines the scaling factor to apply
  6393. * @param result defines the Color4 object where to store the result
  6394. * @returns the current unmodified Color4
  6395. */
  6396. scaleToRef(scale: number, result: Color4): Color4;
  6397. /**
  6398. * Scale the current Color4 values by a factor and add the result to a given Color4
  6399. * @param scale defines the scale factor
  6400. * @param result defines the Color4 object where to store the result
  6401. * @returns the unmodified current Color4
  6402. */
  6403. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6404. /**
  6405. * Clamps the rgb values by the min and max values and stores the result into "result"
  6406. * @param min defines minimum clamping value (default is 0)
  6407. * @param max defines maximum clamping value (default is 1)
  6408. * @param result defines color to store the result into.
  6409. * @returns the cuurent Color4
  6410. */
  6411. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6412. /**
  6413. * Multipy an Color4 value by another and return a new Color4 object
  6414. * @param color defines the Color4 value to multiply by
  6415. * @returns a new Color4 object
  6416. */
  6417. multiply(color: Color4): Color4;
  6418. /**
  6419. * Multipy a Color4 value by another and push the result in a reference value
  6420. * @param color defines the Color4 value to multiply by
  6421. * @param result defines the Color4 to fill the result in
  6422. * @returns the result Color4
  6423. */
  6424. multiplyToRef(color: Color4, result: Color4): Color4;
  6425. /**
  6426. * Creates a string with the Color4 current values
  6427. * @returns the string representation of the Color4 object
  6428. */
  6429. toString(): string;
  6430. /**
  6431. * Returns the string "Color4"
  6432. * @returns "Color4"
  6433. */
  6434. getClassName(): string;
  6435. /**
  6436. * Compute the Color4 hash code
  6437. * @returns an unique number that can be used to hash Color4 objects
  6438. */
  6439. getHashCode(): number;
  6440. /**
  6441. * Creates a new Color4 copied from the current one
  6442. * @returns a new Color4 object
  6443. */
  6444. clone(): Color4;
  6445. /**
  6446. * Copies the given Color4 values into the current one
  6447. * @param source defines the source Color4 object
  6448. * @returns the current updated Color4 object
  6449. */
  6450. copyFrom(source: Color4): Color4;
  6451. /**
  6452. * Copies the given float values into the current one
  6453. * @param r defines the red component to read from
  6454. * @param g defines the green component to read from
  6455. * @param b defines the blue component to read from
  6456. * @param a defines the alpha component to read from
  6457. * @returns the current updated Color4 object
  6458. */
  6459. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6460. /**
  6461. * Copies the given float values into the current one
  6462. * @param r defines the red component to read from
  6463. * @param g defines the green component to read from
  6464. * @param b defines the blue component to read from
  6465. * @param a defines the alpha component to read from
  6466. * @returns the current updated Color4 object
  6467. */
  6468. set(r: number, g: number, b: number, a: number): Color4;
  6469. /**
  6470. * Compute the Color4 hexadecimal code as a string
  6471. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6472. * @returns a string containing the hexadecimal representation of the Color4 object
  6473. */
  6474. toHexString(returnAsColor3?: boolean): string;
  6475. /**
  6476. * Computes a new Color4 converted from the current one to linear space
  6477. * @returns a new Color4 object
  6478. */
  6479. toLinearSpace(): Color4;
  6480. /**
  6481. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6482. * @param convertedColor defines the Color4 object where to store the linear space version
  6483. * @returns the unmodified Color4
  6484. */
  6485. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6486. /**
  6487. * Computes a new Color4 converted from the current one to gamma space
  6488. * @returns a new Color4 object
  6489. */
  6490. toGammaSpace(): Color4;
  6491. /**
  6492. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6493. * @param convertedColor defines the Color4 object where to store the gamma space version
  6494. * @returns the unmodified Color4
  6495. */
  6496. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6497. /**
  6498. * Creates a new Color4 from the string containing valid hexadecimal values
  6499. * @param hex defines a string containing valid hexadecimal values
  6500. * @returns a new Color4 object
  6501. */
  6502. static FromHexString(hex: string): Color4;
  6503. /**
  6504. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6505. * @param left defines the start value
  6506. * @param right defines the end value
  6507. * @param amount defines the gradient factor
  6508. * @returns a new Color4 object
  6509. */
  6510. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6511. /**
  6512. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6513. * @param left defines the start value
  6514. * @param right defines the end value
  6515. * @param amount defines the gradient factor
  6516. * @param result defines the Color4 object where to store data
  6517. */
  6518. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6519. /**
  6520. * Creates a new Color4 from a Color3 and an alpha value
  6521. * @param color3 defines the source Color3 to read from
  6522. * @param alpha defines the alpha component (1.0 by default)
  6523. * @returns a new Color4 object
  6524. */
  6525. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6526. /**
  6527. * Creates a new Color4 from the starting index element of the given array
  6528. * @param array defines the source array to read from
  6529. * @param offset defines the offset in the source array
  6530. * @returns a new Color4 object
  6531. */
  6532. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6533. /**
  6534. * Creates a new Color4 from the starting index element of the given array
  6535. * @param array defines the source array to read from
  6536. * @param offset defines the offset in the source array
  6537. * @param result defines the target Color4 object
  6538. */
  6539. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6540. /**
  6541. * Creates a new Color3 from integer values (< 256)
  6542. * @param r defines the red component to read from (value between 0 and 255)
  6543. * @param g defines the green component to read from (value between 0 and 255)
  6544. * @param b defines the blue component to read from (value between 0 and 255)
  6545. * @param a defines the alpha component to read from (value between 0 and 255)
  6546. * @returns a new Color3 object
  6547. */
  6548. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6549. /**
  6550. * Check the content of a given array and convert it to an array containing RGBA data
  6551. * If the original array was already containing count * 4 values then it is returned directly
  6552. * @param colors defines the array to check
  6553. * @param count defines the number of RGBA data to expect
  6554. * @returns an array containing count * 4 values (RGBA)
  6555. */
  6556. static CheckColors4(colors: number[], count: number): number[];
  6557. }
  6558. /**
  6559. * @hidden
  6560. */
  6561. export class TmpColors {
  6562. static Color3: Color3[];
  6563. static Color4: Color4[];
  6564. }
  6565. }
  6566. declare module "babylonjs/Animations/animationKey" {
  6567. /**
  6568. * Defines an interface which represents an animation key frame
  6569. */
  6570. export interface IAnimationKey {
  6571. /**
  6572. * Frame of the key frame
  6573. */
  6574. frame: number;
  6575. /**
  6576. * Value at the specifies key frame
  6577. */
  6578. value: any;
  6579. /**
  6580. * The input tangent for the cubic hermite spline
  6581. */
  6582. inTangent?: any;
  6583. /**
  6584. * The output tangent for the cubic hermite spline
  6585. */
  6586. outTangent?: any;
  6587. /**
  6588. * The animation interpolation type
  6589. */
  6590. interpolation?: AnimationKeyInterpolation;
  6591. }
  6592. /**
  6593. * Enum for the animation key frame interpolation type
  6594. */
  6595. export enum AnimationKeyInterpolation {
  6596. /**
  6597. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6598. */
  6599. STEP = 1
  6600. }
  6601. }
  6602. declare module "babylonjs/Animations/animationRange" {
  6603. /**
  6604. * Represents the range of an animation
  6605. */
  6606. export class AnimationRange {
  6607. /**The name of the animation range**/
  6608. name: string;
  6609. /**The starting frame of the animation */
  6610. from: number;
  6611. /**The ending frame of the animation*/
  6612. to: number;
  6613. /**
  6614. * Initializes the range of an animation
  6615. * @param name The name of the animation range
  6616. * @param from The starting frame of the animation
  6617. * @param to The ending frame of the animation
  6618. */
  6619. constructor(
  6620. /**The name of the animation range**/
  6621. name: string,
  6622. /**The starting frame of the animation */
  6623. from: number,
  6624. /**The ending frame of the animation*/
  6625. to: number);
  6626. /**
  6627. * Makes a copy of the animation range
  6628. * @returns A copy of the animation range
  6629. */
  6630. clone(): AnimationRange;
  6631. }
  6632. }
  6633. declare module "babylonjs/Animations/animationEvent" {
  6634. /**
  6635. * Composed of a frame, and an action function
  6636. */
  6637. export class AnimationEvent {
  6638. /** The frame for which the event is triggered **/
  6639. frame: number;
  6640. /** The event to perform when triggered **/
  6641. action: (currentFrame: number) => void;
  6642. /** Specifies if the event should be triggered only once**/
  6643. onlyOnce?: boolean | undefined;
  6644. /**
  6645. * Specifies if the animation event is done
  6646. */
  6647. isDone: boolean;
  6648. /**
  6649. * Initializes the animation event
  6650. * @param frame The frame for which the event is triggered
  6651. * @param action The event to perform when triggered
  6652. * @param onlyOnce Specifies if the event should be triggered only once
  6653. */
  6654. constructor(
  6655. /** The frame for which the event is triggered **/
  6656. frame: number,
  6657. /** The event to perform when triggered **/
  6658. action: (currentFrame: number) => void,
  6659. /** Specifies if the event should be triggered only once**/
  6660. onlyOnce?: boolean | undefined);
  6661. /** @hidden */
  6662. _clone(): AnimationEvent;
  6663. }
  6664. }
  6665. declare module "babylonjs/Behaviors/behavior" {
  6666. import { Nullable } from "babylonjs/types";
  6667. /**
  6668. * Interface used to define a behavior
  6669. */
  6670. export interface Behavior<T> {
  6671. /** gets or sets behavior's name */
  6672. name: string;
  6673. /**
  6674. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6675. */
  6676. init(): void;
  6677. /**
  6678. * Called when the behavior is attached to a target
  6679. * @param target defines the target where the behavior is attached to
  6680. */
  6681. attach(target: T): void;
  6682. /**
  6683. * Called when the behavior is detached from its target
  6684. */
  6685. detach(): void;
  6686. }
  6687. /**
  6688. * Interface implemented by classes supporting behaviors
  6689. */
  6690. export interface IBehaviorAware<T> {
  6691. /**
  6692. * Attach a behavior
  6693. * @param behavior defines the behavior to attach
  6694. * @returns the current host
  6695. */
  6696. addBehavior(behavior: Behavior<T>): T;
  6697. /**
  6698. * Remove a behavior from the current object
  6699. * @param behavior defines the behavior to detach
  6700. * @returns the current host
  6701. */
  6702. removeBehavior(behavior: Behavior<T>): T;
  6703. /**
  6704. * Gets a behavior using its name to search
  6705. * @param name defines the name to search
  6706. * @returns the behavior or null if not found
  6707. */
  6708. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6709. }
  6710. }
  6711. declare module "babylonjs/Meshes/buffer" {
  6712. import { Nullable, DataArray } from "babylonjs/types";
  6713. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6714. /**
  6715. * Class used to store data that will be store in GPU memory
  6716. */
  6717. export class Buffer {
  6718. private _engine;
  6719. private _buffer;
  6720. /** @hidden */
  6721. _data: Nullable<DataArray>;
  6722. private _updatable;
  6723. private _instanced;
  6724. private _divisor;
  6725. private _isAlreadyOwned;
  6726. /**
  6727. * Gets the byte stride.
  6728. */
  6729. readonly byteStride: number;
  6730. /**
  6731. * Constructor
  6732. * @param engine the engine
  6733. * @param data the data to use for this buffer
  6734. * @param updatable whether the data is updatable
  6735. * @param stride the stride (optional)
  6736. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6737. * @param instanced whether the buffer is instanced (optional)
  6738. * @param useBytes set to true if the stride in in bytes (optional)
  6739. * @param divisor sets an optional divisor for instances (1 by default)
  6740. */
  6741. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6742. /**
  6743. * Create a new VertexBuffer based on the current buffer
  6744. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6745. * @param offset defines offset in the buffer (0 by default)
  6746. * @param size defines the size in floats of attributes (position is 3 for instance)
  6747. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6748. * @param instanced defines if the vertex buffer contains indexed data
  6749. * @param useBytes defines if the offset and stride are in bytes *
  6750. * @param divisor sets an optional divisor for instances (1 by default)
  6751. * @returns the new vertex buffer
  6752. */
  6753. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6754. /**
  6755. * Gets a boolean indicating if the Buffer is updatable?
  6756. * @returns true if the buffer is updatable
  6757. */
  6758. isUpdatable(): boolean;
  6759. /**
  6760. * Gets current buffer's data
  6761. * @returns a DataArray or null
  6762. */
  6763. getData(): Nullable<DataArray>;
  6764. /**
  6765. * Gets underlying native buffer
  6766. * @returns underlying native buffer
  6767. */
  6768. getBuffer(): Nullable<DataBuffer>;
  6769. /**
  6770. * Gets the stride in float32 units (i.e. byte stride / 4).
  6771. * May not be an integer if the byte stride is not divisible by 4.
  6772. * @returns the stride in float32 units
  6773. * @deprecated Please use byteStride instead.
  6774. */
  6775. getStrideSize(): number;
  6776. /**
  6777. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6778. * @param data defines the data to store
  6779. */
  6780. create(data?: Nullable<DataArray>): void;
  6781. /** @hidden */
  6782. _rebuild(): void;
  6783. /**
  6784. * Update current buffer data
  6785. * @param data defines the data to store
  6786. */
  6787. update(data: DataArray): void;
  6788. /**
  6789. * Updates the data directly.
  6790. * @param data the new data
  6791. * @param offset the new offset
  6792. * @param vertexCount the vertex count (optional)
  6793. * @param useBytes set to true if the offset is in bytes
  6794. */
  6795. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6796. /** @hidden */
  6797. _increaseReferences(): void;
  6798. /**
  6799. * Release all resources
  6800. */
  6801. dispose(): void;
  6802. }
  6803. /**
  6804. * Specialized buffer used to store vertex data
  6805. */
  6806. export class VertexBuffer {
  6807. /** @hidden */
  6808. _buffer: Buffer;
  6809. private _kind;
  6810. private _size;
  6811. private _ownsBuffer;
  6812. private _instanced;
  6813. private _instanceDivisor;
  6814. /**
  6815. * The byte type.
  6816. */
  6817. static readonly BYTE: number;
  6818. /**
  6819. * The unsigned byte type.
  6820. */
  6821. static readonly UNSIGNED_BYTE: number;
  6822. /**
  6823. * The short type.
  6824. */
  6825. static readonly SHORT: number;
  6826. /**
  6827. * The unsigned short type.
  6828. */
  6829. static readonly UNSIGNED_SHORT: number;
  6830. /**
  6831. * The integer type.
  6832. */
  6833. static readonly INT: number;
  6834. /**
  6835. * The unsigned integer type.
  6836. */
  6837. static readonly UNSIGNED_INT: number;
  6838. /**
  6839. * The float type.
  6840. */
  6841. static readonly FLOAT: number;
  6842. /**
  6843. * Gets or sets the instance divisor when in instanced mode
  6844. */
  6845. get instanceDivisor(): number;
  6846. set instanceDivisor(value: number);
  6847. /**
  6848. * Gets the byte stride.
  6849. */
  6850. readonly byteStride: number;
  6851. /**
  6852. * Gets the byte offset.
  6853. */
  6854. readonly byteOffset: number;
  6855. /**
  6856. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6857. */
  6858. readonly normalized: boolean;
  6859. /**
  6860. * Gets the data type of each component in the array.
  6861. */
  6862. readonly type: number;
  6863. /**
  6864. * Constructor
  6865. * @param engine the engine
  6866. * @param data the data to use for this vertex buffer
  6867. * @param kind the vertex buffer kind
  6868. * @param updatable whether the data is updatable
  6869. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6870. * @param stride the stride (optional)
  6871. * @param instanced whether the buffer is instanced (optional)
  6872. * @param offset the offset of the data (optional)
  6873. * @param size the number of components (optional)
  6874. * @param type the type of the component (optional)
  6875. * @param normalized whether the data contains normalized data (optional)
  6876. * @param useBytes set to true if stride and offset are in bytes (optional)
  6877. * @param divisor defines the instance divisor to use (1 by default)
  6878. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  6879. */
  6880. 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, takeBufferOwnership?: boolean);
  6881. /** @hidden */
  6882. _rebuild(): void;
  6883. /**
  6884. * Returns the kind of the VertexBuffer (string)
  6885. * @returns a string
  6886. */
  6887. getKind(): string;
  6888. /**
  6889. * Gets a boolean indicating if the VertexBuffer is updatable?
  6890. * @returns true if the buffer is updatable
  6891. */
  6892. isUpdatable(): boolean;
  6893. /**
  6894. * Gets current buffer's data
  6895. * @returns a DataArray or null
  6896. */
  6897. getData(): Nullable<DataArray>;
  6898. /**
  6899. * Gets underlying native buffer
  6900. * @returns underlying native buffer
  6901. */
  6902. getBuffer(): Nullable<DataBuffer>;
  6903. /**
  6904. * Gets the stride in float32 units (i.e. byte stride / 4).
  6905. * May not be an integer if the byte stride is not divisible by 4.
  6906. * @returns the stride in float32 units
  6907. * @deprecated Please use byteStride instead.
  6908. */
  6909. getStrideSize(): number;
  6910. /**
  6911. * Returns the offset as a multiple of the type byte length.
  6912. * @returns the offset in bytes
  6913. * @deprecated Please use byteOffset instead.
  6914. */
  6915. getOffset(): number;
  6916. /**
  6917. * Returns the number of components per vertex attribute (integer)
  6918. * @returns the size in float
  6919. */
  6920. getSize(): number;
  6921. /**
  6922. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6923. * @returns true if this buffer is instanced
  6924. */
  6925. getIsInstanced(): boolean;
  6926. /**
  6927. * Returns the instancing divisor, zero for non-instanced (integer).
  6928. * @returns a number
  6929. */
  6930. getInstanceDivisor(): number;
  6931. /**
  6932. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6933. * @param data defines the data to store
  6934. */
  6935. create(data?: DataArray): void;
  6936. /**
  6937. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6938. * This function will create a new buffer if the current one is not updatable
  6939. * @param data defines the data to store
  6940. */
  6941. update(data: DataArray): void;
  6942. /**
  6943. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6944. * Returns the directly updated WebGLBuffer.
  6945. * @param data the new data
  6946. * @param offset the new offset
  6947. * @param useBytes set to true if the offset is in bytes
  6948. */
  6949. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6950. /**
  6951. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6952. */
  6953. dispose(): void;
  6954. /**
  6955. * Enumerates each value of this vertex buffer as numbers.
  6956. * @param count the number of values to enumerate
  6957. * @param callback the callback function called for each value
  6958. */
  6959. forEach(count: number, callback: (value: number, index: number) => void): void;
  6960. /**
  6961. * Positions
  6962. */
  6963. static readonly PositionKind: string;
  6964. /**
  6965. * Normals
  6966. */
  6967. static readonly NormalKind: string;
  6968. /**
  6969. * Tangents
  6970. */
  6971. static readonly TangentKind: string;
  6972. /**
  6973. * Texture coordinates
  6974. */
  6975. static readonly UVKind: string;
  6976. /**
  6977. * Texture coordinates 2
  6978. */
  6979. static readonly UV2Kind: string;
  6980. /**
  6981. * Texture coordinates 3
  6982. */
  6983. static readonly UV3Kind: string;
  6984. /**
  6985. * Texture coordinates 4
  6986. */
  6987. static readonly UV4Kind: string;
  6988. /**
  6989. * Texture coordinates 5
  6990. */
  6991. static readonly UV5Kind: string;
  6992. /**
  6993. * Texture coordinates 6
  6994. */
  6995. static readonly UV6Kind: string;
  6996. /**
  6997. * Colors
  6998. */
  6999. static readonly ColorKind: string;
  7000. /**
  7001. * Matrix indices (for bones)
  7002. */
  7003. static readonly MatricesIndicesKind: string;
  7004. /**
  7005. * Matrix weights (for bones)
  7006. */
  7007. static readonly MatricesWeightsKind: string;
  7008. /**
  7009. * Additional matrix indices (for bones)
  7010. */
  7011. static readonly MatricesIndicesExtraKind: string;
  7012. /**
  7013. * Additional matrix weights (for bones)
  7014. */
  7015. static readonly MatricesWeightsExtraKind: string;
  7016. /**
  7017. * Deduces the stride given a kind.
  7018. * @param kind The kind string to deduce
  7019. * @returns The deduced stride
  7020. */
  7021. static DeduceStride(kind: string): number;
  7022. /**
  7023. * Gets the byte length of the given type.
  7024. * @param type the type
  7025. * @returns the number of bytes
  7026. */
  7027. static GetTypeByteLength(type: number): number;
  7028. /**
  7029. * Enumerates each value of the given parameters as numbers.
  7030. * @param data the data to enumerate
  7031. * @param byteOffset the byte offset of the data
  7032. * @param byteStride the byte stride of the data
  7033. * @param componentCount the number of components per element
  7034. * @param componentType the type of the component
  7035. * @param count the number of values to enumerate
  7036. * @param normalized whether the data is normalized
  7037. * @param callback the callback function called for each value
  7038. */
  7039. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7040. private static _GetFloatValue;
  7041. }
  7042. }
  7043. declare module "babylonjs/Collisions/intersectionInfo" {
  7044. import { Nullable } from "babylonjs/types";
  7045. /**
  7046. * @hidden
  7047. */
  7048. export class IntersectionInfo {
  7049. bu: Nullable<number>;
  7050. bv: Nullable<number>;
  7051. distance: number;
  7052. faceId: number;
  7053. subMeshId: number;
  7054. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7055. }
  7056. }
  7057. declare module "babylonjs/Culling/boundingSphere" {
  7058. import { DeepImmutable } from "babylonjs/types";
  7059. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7060. import { Plane } from "babylonjs/Maths/math.plane";
  7061. /**
  7062. * Class used to store bounding sphere information
  7063. */
  7064. export class BoundingSphere {
  7065. /**
  7066. * Gets the center of the bounding sphere in local space
  7067. */
  7068. readonly center: Vector3;
  7069. /**
  7070. * Radius of the bounding sphere in local space
  7071. */
  7072. radius: number;
  7073. /**
  7074. * Gets the center of the bounding sphere in world space
  7075. */
  7076. readonly centerWorld: Vector3;
  7077. /**
  7078. * Radius of the bounding sphere in world space
  7079. */
  7080. radiusWorld: number;
  7081. /**
  7082. * Gets the minimum vector in local space
  7083. */
  7084. readonly minimum: Vector3;
  7085. /**
  7086. * Gets the maximum vector in local space
  7087. */
  7088. readonly maximum: Vector3;
  7089. private _worldMatrix;
  7090. private static readonly TmpVector3;
  7091. /**
  7092. * Creates a new bounding sphere
  7093. * @param min defines the minimum vector (in local space)
  7094. * @param max defines the maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7098. /**
  7099. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7100. * @param min defines the new minimum vector (in local space)
  7101. * @param max defines the new maximum vector (in local space)
  7102. * @param worldMatrix defines the new world matrix
  7103. */
  7104. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7105. /**
  7106. * Scale the current bounding sphere by applying a scale factor
  7107. * @param factor defines the scale factor to apply
  7108. * @returns the current bounding box
  7109. */
  7110. scale(factor: number): BoundingSphere;
  7111. /**
  7112. * Gets the world matrix of the bounding box
  7113. * @returns a matrix
  7114. */
  7115. getWorldMatrix(): DeepImmutable<Matrix>;
  7116. /** @hidden */
  7117. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7118. /**
  7119. * Tests if the bounding sphere is intersecting the frustum planes
  7120. * @param frustumPlanes defines the frustum planes to test
  7121. * @returns true if there is an intersection
  7122. */
  7123. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7124. /**
  7125. * Tests if the bounding sphere center is in between the frustum planes.
  7126. * Used for optimistic fast inclusion.
  7127. * @param frustumPlanes defines the frustum planes to test
  7128. * @returns true if the sphere center is in between the frustum planes
  7129. */
  7130. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7131. /**
  7132. * Tests if a point is inside the bounding sphere
  7133. * @param point defines the point to test
  7134. * @returns true if the point is inside the bounding sphere
  7135. */
  7136. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7137. /**
  7138. * Checks if two sphere intersct
  7139. * @param sphere0 sphere 0
  7140. * @param sphere1 sphere 1
  7141. * @returns true if the speres intersect
  7142. */
  7143. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7144. }
  7145. }
  7146. declare module "babylonjs/Culling/boundingBox" {
  7147. import { DeepImmutable } from "babylonjs/types";
  7148. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7149. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7150. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7151. import { Plane } from "babylonjs/Maths/math.plane";
  7152. /**
  7153. * Class used to store bounding box information
  7154. */
  7155. export class BoundingBox implements ICullable {
  7156. /**
  7157. * Gets the 8 vectors representing the bounding box in local space
  7158. */
  7159. readonly vectors: Vector3[];
  7160. /**
  7161. * Gets the center of the bounding box in local space
  7162. */
  7163. readonly center: Vector3;
  7164. /**
  7165. * Gets the center of the bounding box in world space
  7166. */
  7167. readonly centerWorld: Vector3;
  7168. /**
  7169. * Gets the extend size in local space
  7170. */
  7171. readonly extendSize: Vector3;
  7172. /**
  7173. * Gets the extend size in world space
  7174. */
  7175. readonly extendSizeWorld: Vector3;
  7176. /**
  7177. * Gets the OBB (object bounding box) directions
  7178. */
  7179. readonly directions: Vector3[];
  7180. /**
  7181. * Gets the 8 vectors representing the bounding box in world space
  7182. */
  7183. readonly vectorsWorld: Vector3[];
  7184. /**
  7185. * Gets the minimum vector in world space
  7186. */
  7187. readonly minimumWorld: Vector3;
  7188. /**
  7189. * Gets the maximum vector in world space
  7190. */
  7191. readonly maximumWorld: Vector3;
  7192. /**
  7193. * Gets the minimum vector in local space
  7194. */
  7195. readonly minimum: Vector3;
  7196. /**
  7197. * Gets the maximum vector in local space
  7198. */
  7199. readonly maximum: Vector3;
  7200. private _worldMatrix;
  7201. private static readonly TmpVector3;
  7202. /**
  7203. * @hidden
  7204. */
  7205. _tag: number;
  7206. /**
  7207. * Creates a new bounding box
  7208. * @param min defines the minimum vector (in local space)
  7209. * @param max defines the maximum vector (in local space)
  7210. * @param worldMatrix defines the new world matrix
  7211. */
  7212. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7213. /**
  7214. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7215. * @param min defines the new minimum vector (in local space)
  7216. * @param max defines the new maximum vector (in local space)
  7217. * @param worldMatrix defines the new world matrix
  7218. */
  7219. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7220. /**
  7221. * Scale the current bounding box by applying a scale factor
  7222. * @param factor defines the scale factor to apply
  7223. * @returns the current bounding box
  7224. */
  7225. scale(factor: number): BoundingBox;
  7226. /**
  7227. * Gets the world matrix of the bounding box
  7228. * @returns a matrix
  7229. */
  7230. getWorldMatrix(): DeepImmutable<Matrix>;
  7231. /** @hidden */
  7232. _update(world: DeepImmutable<Matrix>): void;
  7233. /**
  7234. * Tests if the bounding box is intersecting the frustum planes
  7235. * @param frustumPlanes defines the frustum planes to test
  7236. * @returns true if there is an intersection
  7237. */
  7238. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7239. /**
  7240. * Tests if the bounding box is entirely inside the frustum planes
  7241. * @param frustumPlanes defines the frustum planes to test
  7242. * @returns true if there is an inclusion
  7243. */
  7244. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7245. /**
  7246. * Tests if a point is inside the bounding box
  7247. * @param point defines the point to test
  7248. * @returns true if the point is inside the bounding box
  7249. */
  7250. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7251. /**
  7252. * Tests if the bounding box intersects with a bounding sphere
  7253. * @param sphere defines the sphere to test
  7254. * @returns true if there is an intersection
  7255. */
  7256. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7257. /**
  7258. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7259. * @param min defines the min vector to use
  7260. * @param max defines the max vector to use
  7261. * @returns true if there is an intersection
  7262. */
  7263. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7264. /**
  7265. * Tests if two bounding boxes are intersections
  7266. * @param box0 defines the first box to test
  7267. * @param box1 defines the second box to test
  7268. * @returns true if there is an intersection
  7269. */
  7270. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7271. /**
  7272. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7273. * @param minPoint defines the minimum vector of the bounding box
  7274. * @param maxPoint defines the maximum vector of the bounding box
  7275. * @param sphereCenter defines the sphere center
  7276. * @param sphereRadius defines the sphere radius
  7277. * @returns true if there is an intersection
  7278. */
  7279. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7280. /**
  7281. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7282. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7283. * @param frustumPlanes defines the frustum planes to test
  7284. * @return true if there is an inclusion
  7285. */
  7286. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7287. /**
  7288. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7289. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7290. * @param frustumPlanes defines the frustum planes to test
  7291. * @return true if there is an intersection
  7292. */
  7293. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7294. }
  7295. }
  7296. declare module "babylonjs/Collisions/collider" {
  7297. import { Nullable, IndicesArray } from "babylonjs/types";
  7298. import { Vector3 } from "babylonjs/Maths/math.vector";
  7299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7300. import { Plane } from "babylonjs/Maths/math.plane";
  7301. /** @hidden */
  7302. export class Collider {
  7303. /** Define if a collision was found */
  7304. collisionFound: boolean;
  7305. /**
  7306. * Define last intersection point in local space
  7307. */
  7308. intersectionPoint: Vector3;
  7309. /**
  7310. * Define last collided mesh
  7311. */
  7312. collidedMesh: Nullable<AbstractMesh>;
  7313. private _collisionPoint;
  7314. private _planeIntersectionPoint;
  7315. private _tempVector;
  7316. private _tempVector2;
  7317. private _tempVector3;
  7318. private _tempVector4;
  7319. private _edge;
  7320. private _baseToVertex;
  7321. private _destinationPoint;
  7322. private _slidePlaneNormal;
  7323. private _displacementVector;
  7324. /** @hidden */
  7325. _radius: Vector3;
  7326. /** @hidden */
  7327. _retry: number;
  7328. private _velocity;
  7329. private _basePoint;
  7330. private _epsilon;
  7331. /** @hidden */
  7332. _velocityWorldLength: number;
  7333. /** @hidden */
  7334. _basePointWorld: Vector3;
  7335. private _velocityWorld;
  7336. private _normalizedVelocity;
  7337. /** @hidden */
  7338. _initialVelocity: Vector3;
  7339. /** @hidden */
  7340. _initialPosition: Vector3;
  7341. private _nearestDistance;
  7342. private _collisionMask;
  7343. get collisionMask(): number;
  7344. set collisionMask(mask: number);
  7345. /**
  7346. * Gets the plane normal used to compute the sliding response (in local space)
  7347. */
  7348. get slidePlaneNormal(): Vector3;
  7349. /** @hidden */
  7350. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7351. /** @hidden */
  7352. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7353. /** @hidden */
  7354. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7355. /** @hidden */
  7356. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7357. /** @hidden */
  7358. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7359. /** @hidden */
  7360. _getResponse(pos: Vector3, vel: Vector3): void;
  7361. }
  7362. }
  7363. declare module "babylonjs/Culling/boundingInfo" {
  7364. import { DeepImmutable } from "babylonjs/types";
  7365. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7366. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7367. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7368. import { Plane } from "babylonjs/Maths/math.plane";
  7369. import { Collider } from "babylonjs/Collisions/collider";
  7370. /**
  7371. * Interface for cullable objects
  7372. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7373. */
  7374. export interface ICullable {
  7375. /**
  7376. * Checks if the object or part of the object is in the frustum
  7377. * @param frustumPlanes Camera near/planes
  7378. * @returns true if the object is in frustum otherwise false
  7379. */
  7380. isInFrustum(frustumPlanes: Plane[]): boolean;
  7381. /**
  7382. * Checks if a cullable object (mesh...) is in the camera frustum
  7383. * Unlike isInFrustum this cheks the full bounding box
  7384. * @param frustumPlanes Camera near/planes
  7385. * @returns true if the object is in frustum otherwise false
  7386. */
  7387. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7388. }
  7389. /**
  7390. * Info for a bounding data of a mesh
  7391. */
  7392. export class BoundingInfo implements ICullable {
  7393. /**
  7394. * Bounding box for the mesh
  7395. */
  7396. readonly boundingBox: BoundingBox;
  7397. /**
  7398. * Bounding sphere for the mesh
  7399. */
  7400. readonly boundingSphere: BoundingSphere;
  7401. private _isLocked;
  7402. private static readonly TmpVector3;
  7403. /**
  7404. * Constructs bounding info
  7405. * @param minimum min vector of the bounding box/sphere
  7406. * @param maximum max vector of the bounding box/sphere
  7407. * @param worldMatrix defines the new world matrix
  7408. */
  7409. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7410. /**
  7411. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7412. * @param min defines the new minimum vector (in local space)
  7413. * @param max defines the new maximum vector (in local space)
  7414. * @param worldMatrix defines the new world matrix
  7415. */
  7416. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7417. /**
  7418. * min vector of the bounding box/sphere
  7419. */
  7420. get minimum(): Vector3;
  7421. /**
  7422. * max vector of the bounding box/sphere
  7423. */
  7424. get maximum(): Vector3;
  7425. /**
  7426. * If the info is locked and won't be updated to avoid perf overhead
  7427. */
  7428. get isLocked(): boolean;
  7429. set isLocked(value: boolean);
  7430. /**
  7431. * Updates the bounding sphere and box
  7432. * @param world world matrix to be used to update
  7433. */
  7434. update(world: DeepImmutable<Matrix>): void;
  7435. /**
  7436. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7437. * @param center New center of the bounding info
  7438. * @param extend New extend of the bounding info
  7439. * @returns the current bounding info
  7440. */
  7441. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7442. /**
  7443. * Scale the current bounding info by applying a scale factor
  7444. * @param factor defines the scale factor to apply
  7445. * @returns the current bounding info
  7446. */
  7447. scale(factor: number): BoundingInfo;
  7448. /**
  7449. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7450. * @param frustumPlanes defines the frustum to test
  7451. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7452. * @returns true if the bounding info is in the frustum planes
  7453. */
  7454. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7455. /**
  7456. * Gets the world distance between the min and max points of the bounding box
  7457. */
  7458. get diagonalLength(): number;
  7459. /**
  7460. * Checks if a cullable object (mesh...) is in the camera frustum
  7461. * Unlike isInFrustum this cheks the full bounding box
  7462. * @param frustumPlanes Camera near/planes
  7463. * @returns true if the object is in frustum otherwise false
  7464. */
  7465. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7466. /** @hidden */
  7467. _checkCollision(collider: Collider): boolean;
  7468. /**
  7469. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7470. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7471. * @param point the point to check intersection with
  7472. * @returns if the point intersects
  7473. */
  7474. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7475. /**
  7476. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7477. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7478. * @param boundingInfo the bounding info to check intersection with
  7479. * @param precise if the intersection should be done using OBB
  7480. * @returns if the bounding info intersects
  7481. */
  7482. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7483. }
  7484. }
  7485. declare module "babylonjs/Maths/math.functions" {
  7486. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7487. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7488. /**
  7489. * Extracts minimum and maximum values from a list of indexed positions
  7490. * @param positions defines the positions to use
  7491. * @param indices defines the indices to the positions
  7492. * @param indexStart defines the start index
  7493. * @param indexCount defines the end index
  7494. * @param bias defines bias value to add to the result
  7495. * @return minimum and maximum values
  7496. */
  7497. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7498. minimum: Vector3;
  7499. maximum: Vector3;
  7500. };
  7501. /**
  7502. * Extracts minimum and maximum values from a list of positions
  7503. * @param positions defines the positions to use
  7504. * @param start defines the start index in the positions array
  7505. * @param count defines the number of positions to handle
  7506. * @param bias defines bias value to add to the result
  7507. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7508. * @return minimum and maximum values
  7509. */
  7510. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7511. minimum: Vector3;
  7512. maximum: Vector3;
  7513. };
  7514. }
  7515. declare module "babylonjs/Misc/guid" {
  7516. /**
  7517. * Class used to manipulate GUIDs
  7518. */
  7519. export class GUID {
  7520. /**
  7521. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7522. * Be aware Math.random() could cause collisions, but:
  7523. * "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"
  7524. * @returns a pseudo random id
  7525. */
  7526. static RandomId(): string;
  7527. }
  7528. }
  7529. declare module "babylonjs/Materials/Textures/baseTexture" {
  7530. import { Observable } from "babylonjs/Misc/observable";
  7531. import { Nullable } from "babylonjs/types";
  7532. import { Scene } from "babylonjs/scene";
  7533. import { Matrix } from "babylonjs/Maths/math.vector";
  7534. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7535. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  7536. import "babylonjs/Misc/fileTools";
  7537. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7538. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  7539. /**
  7540. * Base class of all the textures in babylon.
  7541. * It groups all the common properties the materials, post process, lights... might need
  7542. * in order to make a correct use of the texture.
  7543. */
  7544. export class BaseTexture extends ThinTexture implements IAnimatable {
  7545. /**
  7546. * Default anisotropic filtering level for the application.
  7547. * It is set to 4 as a good tradeoff between perf and quality.
  7548. */
  7549. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7550. /**
  7551. * Gets or sets the unique id of the texture
  7552. */
  7553. uniqueId: number;
  7554. /**
  7555. * Define the name of the texture.
  7556. */
  7557. name: string;
  7558. /**
  7559. * Gets or sets an object used to store user defined information.
  7560. */
  7561. metadata: any;
  7562. /**
  7563. * For internal use only. Please do not use.
  7564. */
  7565. reservedDataStore: any;
  7566. private _hasAlpha;
  7567. /**
  7568. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7569. */
  7570. set hasAlpha(value: boolean);
  7571. get hasAlpha(): boolean;
  7572. /**
  7573. * Defines if the alpha value should be determined via the rgb values.
  7574. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7575. */
  7576. getAlphaFromRGB: boolean;
  7577. /**
  7578. * Intensity or strength of the texture.
  7579. * It is commonly used by materials to fine tune the intensity of the texture
  7580. */
  7581. level: number;
  7582. /**
  7583. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7584. * This is part of the texture as textures usually maps to one uv set.
  7585. */
  7586. coordinatesIndex: number;
  7587. protected _coordinatesMode: number;
  7588. /**
  7589. * How a texture is mapped.
  7590. *
  7591. * | Value | Type | Description |
  7592. * | ----- | ----------------------------------- | ----------- |
  7593. * | 0 | EXPLICIT_MODE | |
  7594. * | 1 | SPHERICAL_MODE | |
  7595. * | 2 | PLANAR_MODE | |
  7596. * | 3 | CUBIC_MODE | |
  7597. * | 4 | PROJECTION_MODE | |
  7598. * | 5 | SKYBOX_MODE | |
  7599. * | 6 | INVCUBIC_MODE | |
  7600. * | 7 | EQUIRECTANGULAR_MODE | |
  7601. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7602. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7603. */
  7604. set coordinatesMode(value: number);
  7605. get coordinatesMode(): number;
  7606. /**
  7607. * | Value | Type | Description |
  7608. * | ----- | ------------------ | ----------- |
  7609. * | 0 | CLAMP_ADDRESSMODE | |
  7610. * | 1 | WRAP_ADDRESSMODE | |
  7611. * | 2 | MIRROR_ADDRESSMODE | |
  7612. */
  7613. get wrapU(): number;
  7614. set wrapU(value: number);
  7615. /**
  7616. * | Value | Type | Description |
  7617. * | ----- | ------------------ | ----------- |
  7618. * | 0 | CLAMP_ADDRESSMODE | |
  7619. * | 1 | WRAP_ADDRESSMODE | |
  7620. * | 2 | MIRROR_ADDRESSMODE | |
  7621. */
  7622. get wrapV(): number;
  7623. set wrapV(value: number);
  7624. /**
  7625. * | Value | Type | Description |
  7626. * | ----- | ------------------ | ----------- |
  7627. * | 0 | CLAMP_ADDRESSMODE | |
  7628. * | 1 | WRAP_ADDRESSMODE | |
  7629. * | 2 | MIRROR_ADDRESSMODE | |
  7630. */
  7631. wrapR: number;
  7632. /**
  7633. * With compliant hardware and browser (supporting anisotropic filtering)
  7634. * this defines the level of anisotropic filtering in the texture.
  7635. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7636. */
  7637. anisotropicFilteringLevel: number;
  7638. private _isCube;
  7639. /**
  7640. * Define if the texture is a cube texture or if false a 2d texture.
  7641. */
  7642. get isCube(): boolean;
  7643. set isCube(value: boolean);
  7644. /**
  7645. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7646. */
  7647. get is3D(): boolean;
  7648. set is3D(value: boolean);
  7649. /**
  7650. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7651. */
  7652. get is2DArray(): boolean;
  7653. set is2DArray(value: boolean);
  7654. private _gammaSpace;
  7655. /**
  7656. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7657. * HDR texture are usually stored in linear space.
  7658. * This only impacts the PBR and Background materials
  7659. */
  7660. get gammaSpace(): boolean;
  7661. set gammaSpace(gamma: boolean);
  7662. /**
  7663. * Gets or sets whether or not the texture contains RGBD data.
  7664. */
  7665. get isRGBD(): boolean;
  7666. set isRGBD(value: boolean);
  7667. /**
  7668. * Is Z inverted in the texture (useful in a cube texture).
  7669. */
  7670. invertZ: boolean;
  7671. /**
  7672. * Are mip maps generated for this texture or not.
  7673. */
  7674. get noMipmap(): boolean;
  7675. /**
  7676. * @hidden
  7677. */
  7678. lodLevelInAlpha: boolean;
  7679. /**
  7680. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7681. */
  7682. get lodGenerationOffset(): number;
  7683. set lodGenerationOffset(value: number);
  7684. /**
  7685. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7686. */
  7687. get lodGenerationScale(): number;
  7688. set lodGenerationScale(value: number);
  7689. /**
  7690. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7691. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7692. * average roughness values.
  7693. */
  7694. get linearSpecularLOD(): boolean;
  7695. set linearSpecularLOD(value: boolean);
  7696. /**
  7697. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7698. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7699. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7700. */
  7701. get irradianceTexture(): Nullable<BaseTexture>;
  7702. set irradianceTexture(value: Nullable<BaseTexture>);
  7703. /**
  7704. * Define if the texture is a render target.
  7705. */
  7706. isRenderTarget: boolean;
  7707. /**
  7708. * Define the unique id of the texture in the scene.
  7709. */
  7710. get uid(): string;
  7711. /** @hidden */
  7712. _prefiltered: boolean;
  7713. /**
  7714. * Return a string representation of the texture.
  7715. * @returns the texture as a string
  7716. */
  7717. toString(): string;
  7718. /**
  7719. * Get the class name of the texture.
  7720. * @returns "BaseTexture"
  7721. */
  7722. getClassName(): string;
  7723. /**
  7724. * Define the list of animation attached to the texture.
  7725. */
  7726. animations: import("babylonjs/Animations/animation").Animation[];
  7727. /**
  7728. * An event triggered when the texture is disposed.
  7729. */
  7730. onDisposeObservable: Observable<BaseTexture>;
  7731. private _onDisposeObserver;
  7732. /**
  7733. * Callback triggered when the texture has been disposed.
  7734. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7735. */
  7736. set onDispose(callback: () => void);
  7737. protected _scene: Nullable<Scene>;
  7738. /** @hidden */
  7739. _texture: Nullable<InternalTexture>;
  7740. private _uid;
  7741. /**
  7742. * Define if the texture is preventinga material to render or not.
  7743. * If not and the texture is not ready, the engine will use a default black texture instead.
  7744. */
  7745. get isBlocking(): boolean;
  7746. /**
  7747. * Instantiates a new BaseTexture.
  7748. * Base class of all the textures in babylon.
  7749. * It groups all the common properties the materials, post process, lights... might need
  7750. * in order to make a correct use of the texture.
  7751. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7752. */
  7753. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7754. /**
  7755. * Get the scene the texture belongs to.
  7756. * @returns the scene or null if undefined
  7757. */
  7758. getScene(): Nullable<Scene>;
  7759. /** @hidden */
  7760. protected _getEngine(): Nullable<ThinEngine>;
  7761. /**
  7762. * Checks if the texture has the same transform matrix than another texture
  7763. * @param texture texture to check against
  7764. * @returns true if the transforms are the same, else false
  7765. */
  7766. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7767. /**
  7768. * Get the texture transform matrix used to offset tile the texture for istance.
  7769. * @returns the transformation matrix
  7770. */
  7771. getTextureMatrix(): Matrix;
  7772. /**
  7773. * Get the texture reflection matrix used to rotate/transform the reflection.
  7774. * @returns the reflection matrix
  7775. */
  7776. getReflectionTextureMatrix(): Matrix;
  7777. /**
  7778. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7779. * @returns true if ready or not blocking
  7780. */
  7781. isReadyOrNotBlocking(): boolean;
  7782. /**
  7783. * Scales the texture if is `canRescale()`
  7784. * @param ratio the resize factor we want to use to rescale
  7785. */
  7786. scale(ratio: number): void;
  7787. /**
  7788. * Get if the texture can rescale.
  7789. */
  7790. get canRescale(): boolean;
  7791. /** @hidden */
  7792. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7793. /** @hidden */
  7794. _rebuild(): void;
  7795. /**
  7796. * Clones the texture.
  7797. * @returns the cloned texture
  7798. */
  7799. clone(): Nullable<BaseTexture>;
  7800. /**
  7801. * Get the texture underlying type (INT, FLOAT...)
  7802. */
  7803. get textureType(): number;
  7804. /**
  7805. * Get the texture underlying format (RGB, RGBA...)
  7806. */
  7807. get textureFormat(): number;
  7808. /**
  7809. * Indicates that textures need to be re-calculated for all materials
  7810. */
  7811. protected _markAllSubMeshesAsTexturesDirty(): void;
  7812. /**
  7813. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7814. * This will returns an RGBA array buffer containing either in values (0-255) or
  7815. * float values (0-1) depending of the underlying buffer type.
  7816. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7817. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7818. * @param buffer defines a user defined buffer to fill with data (can be null)
  7819. * @returns The Array buffer containing the pixels data.
  7820. */
  7821. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7822. /** @hidden */
  7823. get _lodTextureHigh(): Nullable<BaseTexture>;
  7824. /** @hidden */
  7825. get _lodTextureMid(): Nullable<BaseTexture>;
  7826. /** @hidden */
  7827. get _lodTextureLow(): Nullable<BaseTexture>;
  7828. /**
  7829. * Dispose the texture and release its associated resources.
  7830. */
  7831. dispose(): void;
  7832. /**
  7833. * Serialize the texture into a JSON representation that can be parsed later on.
  7834. * @returns the JSON representation of the texture
  7835. */
  7836. serialize(): any;
  7837. /**
  7838. * Helper function to be called back once a list of texture contains only ready textures.
  7839. * @param textures Define the list of textures to wait for
  7840. * @param callback Define the callback triggered once the entire list will be ready
  7841. */
  7842. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7843. private static _isScene;
  7844. }
  7845. }
  7846. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7847. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7848. /** @hidden */
  7849. export class WebGLDataBuffer extends DataBuffer {
  7850. private _buffer;
  7851. constructor(resource: WebGLBuffer);
  7852. get underlyingResource(): any;
  7853. }
  7854. }
  7855. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7856. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7857. import { Nullable } from "babylonjs/types";
  7858. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7859. /** @hidden */
  7860. export class WebGLPipelineContext implements IPipelineContext {
  7861. engine: ThinEngine;
  7862. program: Nullable<WebGLProgram>;
  7863. context?: WebGLRenderingContext;
  7864. vertexShader?: WebGLShader;
  7865. fragmentShader?: WebGLShader;
  7866. isParallelCompiled: boolean;
  7867. onCompiled?: () => void;
  7868. transformFeedback?: WebGLTransformFeedback | null;
  7869. vertexCompilationError: Nullable<string>;
  7870. fragmentCompilationError: Nullable<string>;
  7871. programLinkError: Nullable<string>;
  7872. programValidationError: Nullable<string>;
  7873. get isAsync(): boolean;
  7874. get isReady(): boolean;
  7875. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7876. _getVertexShaderCode(): string | null;
  7877. _getFragmentShaderCode(): string | null;
  7878. }
  7879. }
  7880. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7881. import { FloatArray, Nullable } from "babylonjs/types";
  7882. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7883. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7884. module "babylonjs/Engines/thinEngine" {
  7885. interface ThinEngine {
  7886. /**
  7887. * Create an uniform buffer
  7888. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7889. * @param elements defines the content of the uniform buffer
  7890. * @returns the webGL uniform buffer
  7891. */
  7892. createUniformBuffer(elements: FloatArray): DataBuffer;
  7893. /**
  7894. * Create a dynamic uniform buffer
  7895. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7896. * @param elements defines the content of the uniform buffer
  7897. * @returns the webGL uniform buffer
  7898. */
  7899. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7900. /**
  7901. * Update an existing uniform buffer
  7902. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7903. * @param uniformBuffer defines the target uniform buffer
  7904. * @param elements defines the content to update
  7905. * @param offset defines the offset in the uniform buffer where update should start
  7906. * @param count defines the size of the data to update
  7907. */
  7908. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7909. /**
  7910. * Bind an uniform buffer to the current webGL context
  7911. * @param buffer defines the buffer to bind
  7912. */
  7913. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7914. /**
  7915. * Bind a buffer to the current webGL context at a given location
  7916. * @param buffer defines the buffer to bind
  7917. * @param location defines the index where to bind the buffer
  7918. */
  7919. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7920. /**
  7921. * Bind a specific block at a given index in a specific shader program
  7922. * @param pipelineContext defines the pipeline context to use
  7923. * @param blockName defines the block name
  7924. * @param index defines the index where to bind the block
  7925. */
  7926. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7927. }
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/uniformBuffer" {
  7931. import { Nullable, FloatArray } from "babylonjs/types";
  7932. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7933. import { Engine } from "babylonjs/Engines/engine";
  7934. import { Effect } from "babylonjs/Materials/effect";
  7935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7936. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7937. import { Color3 } from "babylonjs/Maths/math.color";
  7938. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7939. /**
  7940. * Uniform buffer objects.
  7941. *
  7942. * Handles blocks of uniform on the GPU.
  7943. *
  7944. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7945. *
  7946. * For more information, please refer to :
  7947. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7948. */
  7949. export class UniformBuffer {
  7950. private _engine;
  7951. private _buffer;
  7952. private _data;
  7953. private _bufferData;
  7954. private _dynamic?;
  7955. private _uniformLocations;
  7956. private _uniformSizes;
  7957. private _uniformLocationPointer;
  7958. private _needSync;
  7959. private _noUBO;
  7960. private _currentEffect;
  7961. /** @hidden */
  7962. _alreadyBound: boolean;
  7963. private static _MAX_UNIFORM_SIZE;
  7964. private static _tempBuffer;
  7965. /**
  7966. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7967. * This is dynamic to allow compat with webgl 1 and 2.
  7968. * You will need to pass the name of the uniform as well as the value.
  7969. */
  7970. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7971. /**
  7972. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7973. * This is dynamic to allow compat with webgl 1 and 2.
  7974. * You will need to pass the name of the uniform as well as the value.
  7975. */
  7976. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7977. /**
  7978. * Lambda to Update a single float in a uniform buffer.
  7979. * This is dynamic to allow compat with webgl 1 and 2.
  7980. * You will need to pass the name of the uniform as well as the value.
  7981. */
  7982. updateFloat: (name: string, x: number) => void;
  7983. /**
  7984. * Lambda to Update a vec2 of float in a uniform buffer.
  7985. * This is dynamic to allow compat with webgl 1 and 2.
  7986. * You will need to pass the name of the uniform as well as the value.
  7987. */
  7988. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7989. /**
  7990. * Lambda to Update a vec3 of float in a uniform buffer.
  7991. * This is dynamic to allow compat with webgl 1 and 2.
  7992. * You will need to pass the name of the uniform as well as the value.
  7993. */
  7994. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7995. /**
  7996. * Lambda to Update a vec4 of float in a uniform buffer.
  7997. * This is dynamic to allow compat with webgl 1 and 2.
  7998. * You will need to pass the name of the uniform as well as the value.
  7999. */
  8000. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8001. /**
  8002. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8003. * This is dynamic to allow compat with webgl 1 and 2.
  8004. * You will need to pass the name of the uniform as well as the value.
  8005. */
  8006. updateMatrix: (name: string, mat: Matrix) => void;
  8007. /**
  8008. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8009. * This is dynamic to allow compat with webgl 1 and 2.
  8010. * You will need to pass the name of the uniform as well as the value.
  8011. */
  8012. updateVector3: (name: string, vector: Vector3) => void;
  8013. /**
  8014. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8015. * This is dynamic to allow compat with webgl 1 and 2.
  8016. * You will need to pass the name of the uniform as well as the value.
  8017. */
  8018. updateVector4: (name: string, vector: Vector4) => void;
  8019. /**
  8020. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8021. * This is dynamic to allow compat with webgl 1 and 2.
  8022. * You will need to pass the name of the uniform as well as the value.
  8023. */
  8024. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8025. /**
  8026. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8027. * This is dynamic to allow compat with webgl 1 and 2.
  8028. * You will need to pass the name of the uniform as well as the value.
  8029. */
  8030. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8031. /**
  8032. * Instantiates a new Uniform buffer objects.
  8033. *
  8034. * Handles blocks of uniform on the GPU.
  8035. *
  8036. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8037. *
  8038. * For more information, please refer to :
  8039. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8040. * @param engine Define the engine the buffer is associated with
  8041. * @param data Define the data contained in the buffer
  8042. * @param dynamic Define if the buffer is updatable
  8043. */
  8044. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  8045. /**
  8046. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8047. * or just falling back on setUniformXXX calls.
  8048. */
  8049. get useUbo(): boolean;
  8050. /**
  8051. * Indicates if the WebGL underlying uniform buffer is in sync
  8052. * with the javascript cache data.
  8053. */
  8054. get isSync(): boolean;
  8055. /**
  8056. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8057. * Also, a dynamic UniformBuffer will disable cache verification and always
  8058. * update the underlying WebGL uniform buffer to the GPU.
  8059. * @returns if Dynamic, otherwise false
  8060. */
  8061. isDynamic(): boolean;
  8062. /**
  8063. * The data cache on JS side.
  8064. * @returns the underlying data as a float array
  8065. */
  8066. getData(): Float32Array;
  8067. /**
  8068. * The underlying WebGL Uniform buffer.
  8069. * @returns the webgl buffer
  8070. */
  8071. getBuffer(): Nullable<DataBuffer>;
  8072. /**
  8073. * std140 layout specifies how to align data within an UBO structure.
  8074. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8075. * for specs.
  8076. */
  8077. private _fillAlignment;
  8078. /**
  8079. * Adds an uniform in the buffer.
  8080. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8081. * for the layout to be correct !
  8082. * @param name Name of the uniform, as used in the uniform block in the shader.
  8083. * @param size Data size, or data directly.
  8084. */
  8085. addUniform(name: string, size: number | number[]): void;
  8086. /**
  8087. * Adds a Matrix 4x4 to the uniform buffer.
  8088. * @param name Name of the uniform, as used in the uniform block in the shader.
  8089. * @param mat A 4x4 matrix.
  8090. */
  8091. addMatrix(name: string, mat: Matrix): void;
  8092. /**
  8093. * Adds a vec2 to the uniform buffer.
  8094. * @param name Name of the uniform, as used in the uniform block in the shader.
  8095. * @param x Define the x component value of the vec2
  8096. * @param y Define the y component value of the vec2
  8097. */
  8098. addFloat2(name: string, x: number, y: number): void;
  8099. /**
  8100. * Adds a vec3 to the uniform buffer.
  8101. * @param name Name of the uniform, as used in the uniform block in the shader.
  8102. * @param x Define the x component value of the vec3
  8103. * @param y Define the y component value of the vec3
  8104. * @param z Define the z component value of the vec3
  8105. */
  8106. addFloat3(name: string, x: number, y: number, z: number): void;
  8107. /**
  8108. * Adds a vec3 to the uniform buffer.
  8109. * @param name Name of the uniform, as used in the uniform block in the shader.
  8110. * @param color Define the vec3 from a Color
  8111. */
  8112. addColor3(name: string, color: Color3): void;
  8113. /**
  8114. * Adds a vec4 to the uniform buffer.
  8115. * @param name Name of the uniform, as used in the uniform block in the shader.
  8116. * @param color Define the rgb components from a Color
  8117. * @param alpha Define the a component of the vec4
  8118. */
  8119. addColor4(name: string, color: Color3, alpha: number): void;
  8120. /**
  8121. * Adds a vec3 to the uniform buffer.
  8122. * @param name Name of the uniform, as used in the uniform block in the shader.
  8123. * @param vector Define the vec3 components from a Vector
  8124. */
  8125. addVector3(name: string, vector: Vector3): void;
  8126. /**
  8127. * Adds a Matrix 3x3 to the uniform buffer.
  8128. * @param name Name of the uniform, as used in the uniform block in the shader.
  8129. */
  8130. addMatrix3x3(name: string): void;
  8131. /**
  8132. * Adds a Matrix 2x2 to the uniform buffer.
  8133. * @param name Name of the uniform, as used in the uniform block in the shader.
  8134. */
  8135. addMatrix2x2(name: string): void;
  8136. /**
  8137. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8138. */
  8139. create(): void;
  8140. /** @hidden */
  8141. _rebuild(): void;
  8142. /**
  8143. * Updates the WebGL Uniform Buffer on the GPU.
  8144. * If the `dynamic` flag is set to true, no cache comparison is done.
  8145. * Otherwise, the buffer will be updated only if the cache differs.
  8146. */
  8147. update(): void;
  8148. /**
  8149. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8150. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8151. * @param data Define the flattened data
  8152. * @param size Define the size of the data.
  8153. */
  8154. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8155. private _valueCache;
  8156. private _cacheMatrix;
  8157. private _updateMatrix3x3ForUniform;
  8158. private _updateMatrix3x3ForEffect;
  8159. private _updateMatrix2x2ForEffect;
  8160. private _updateMatrix2x2ForUniform;
  8161. private _updateFloatForEffect;
  8162. private _updateFloatForUniform;
  8163. private _updateFloat2ForEffect;
  8164. private _updateFloat2ForUniform;
  8165. private _updateFloat3ForEffect;
  8166. private _updateFloat3ForUniform;
  8167. private _updateFloat4ForEffect;
  8168. private _updateFloat4ForUniform;
  8169. private _updateMatrixForEffect;
  8170. private _updateMatrixForUniform;
  8171. private _updateVector3ForEffect;
  8172. private _updateVector3ForUniform;
  8173. private _updateVector4ForEffect;
  8174. private _updateVector4ForUniform;
  8175. private _updateColor3ForEffect;
  8176. private _updateColor3ForUniform;
  8177. private _updateColor4ForEffect;
  8178. private _updateColor4ForUniform;
  8179. /**
  8180. * Sets a sampler uniform on the effect.
  8181. * @param name Define the name of the sampler.
  8182. * @param texture Define the texture to set in the sampler
  8183. */
  8184. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8185. /**
  8186. * Directly updates the value of the uniform in the cache AND on the GPU.
  8187. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8188. * @param data Define the flattened data
  8189. */
  8190. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8191. /**
  8192. * Binds this uniform buffer to an effect.
  8193. * @param effect Define the effect to bind the buffer to
  8194. * @param name Name of the uniform block in the shader.
  8195. */
  8196. bindToEffect(effect: Effect, name: string): void;
  8197. /**
  8198. * Disposes the uniform buffer.
  8199. */
  8200. dispose(): void;
  8201. }
  8202. }
  8203. declare module "babylonjs/Materials/materialDefines" {
  8204. /**
  8205. * Manages the defines for the Material
  8206. */
  8207. export class MaterialDefines {
  8208. /** @hidden */
  8209. protected _keys: string[];
  8210. private _isDirty;
  8211. /** @hidden */
  8212. _renderId: number;
  8213. /** @hidden */
  8214. _areLightsDirty: boolean;
  8215. /** @hidden */
  8216. _areLightsDisposed: boolean;
  8217. /** @hidden */
  8218. _areAttributesDirty: boolean;
  8219. /** @hidden */
  8220. _areTexturesDirty: boolean;
  8221. /** @hidden */
  8222. _areFresnelDirty: boolean;
  8223. /** @hidden */
  8224. _areMiscDirty: boolean;
  8225. /** @hidden */
  8226. _arePrePassDirty: boolean;
  8227. /** @hidden */
  8228. _areImageProcessingDirty: boolean;
  8229. /** @hidden */
  8230. _normals: boolean;
  8231. /** @hidden */
  8232. _uvs: boolean;
  8233. /** @hidden */
  8234. _needNormals: boolean;
  8235. /** @hidden */
  8236. _needUVs: boolean;
  8237. [id: string]: any;
  8238. /**
  8239. * Specifies if the material needs to be re-calculated
  8240. */
  8241. get isDirty(): boolean;
  8242. /**
  8243. * Marks the material to indicate that it has been re-calculated
  8244. */
  8245. markAsProcessed(): void;
  8246. /**
  8247. * Marks the material to indicate that it needs to be re-calculated
  8248. */
  8249. markAsUnprocessed(): void;
  8250. /**
  8251. * Marks the material to indicate all of its defines need to be re-calculated
  8252. */
  8253. markAllAsDirty(): void;
  8254. /**
  8255. * Marks the material to indicate that image processing needs to be re-calculated
  8256. */
  8257. markAsImageProcessingDirty(): void;
  8258. /**
  8259. * Marks the material to indicate the lights need to be re-calculated
  8260. * @param disposed Defines whether the light is dirty due to dispose or not
  8261. */
  8262. markAsLightDirty(disposed?: boolean): void;
  8263. /**
  8264. * Marks the attribute state as changed
  8265. */
  8266. markAsAttributesDirty(): void;
  8267. /**
  8268. * Marks the texture state as changed
  8269. */
  8270. markAsTexturesDirty(): void;
  8271. /**
  8272. * Marks the fresnel state as changed
  8273. */
  8274. markAsFresnelDirty(): void;
  8275. /**
  8276. * Marks the misc state as changed
  8277. */
  8278. markAsMiscDirty(): void;
  8279. /**
  8280. * Marks the prepass state as changed
  8281. */
  8282. markAsPrePassDirty(): void;
  8283. /**
  8284. * Rebuilds the material defines
  8285. */
  8286. rebuild(): void;
  8287. /**
  8288. * Specifies if two material defines are equal
  8289. * @param other - A material define instance to compare to
  8290. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8291. */
  8292. isEqual(other: MaterialDefines): boolean;
  8293. /**
  8294. * Clones this instance's defines to another instance
  8295. * @param other - material defines to clone values to
  8296. */
  8297. cloneTo(other: MaterialDefines): void;
  8298. /**
  8299. * Resets the material define values
  8300. */
  8301. reset(): void;
  8302. /**
  8303. * Converts the material define values to a string
  8304. * @returns - String of material define information
  8305. */
  8306. toString(): string;
  8307. }
  8308. }
  8309. declare module "babylonjs/Misc/iInspectable" {
  8310. /**
  8311. * Enum that determines the text-wrapping mode to use.
  8312. */
  8313. export enum InspectableType {
  8314. /**
  8315. * Checkbox for booleans
  8316. */
  8317. Checkbox = 0,
  8318. /**
  8319. * Sliders for numbers
  8320. */
  8321. Slider = 1,
  8322. /**
  8323. * Vector3
  8324. */
  8325. Vector3 = 2,
  8326. /**
  8327. * Quaternions
  8328. */
  8329. Quaternion = 3,
  8330. /**
  8331. * Color3
  8332. */
  8333. Color3 = 4,
  8334. /**
  8335. * String
  8336. */
  8337. String = 5
  8338. }
  8339. /**
  8340. * Interface used to define custom inspectable properties.
  8341. * This interface is used by the inspector to display custom property grids
  8342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8343. */
  8344. export interface IInspectable {
  8345. /**
  8346. * Gets the label to display
  8347. */
  8348. label: string;
  8349. /**
  8350. * Gets the name of the property to edit
  8351. */
  8352. propertyName: string;
  8353. /**
  8354. * Gets the type of the editor to use
  8355. */
  8356. type: InspectableType;
  8357. /**
  8358. * Gets the minimum value of the property when using in "slider" mode
  8359. */
  8360. min?: number;
  8361. /**
  8362. * Gets the maximum value of the property when using in "slider" mode
  8363. */
  8364. max?: number;
  8365. /**
  8366. * Gets the setp to use when using in "slider" mode
  8367. */
  8368. step?: number;
  8369. }
  8370. }
  8371. declare module "babylonjs/Lights/light" {
  8372. import { Nullable } from "babylonjs/types";
  8373. import { Scene } from "babylonjs/scene";
  8374. import { Vector3 } from "babylonjs/Maths/math.vector";
  8375. import { Color3 } from "babylonjs/Maths/math.color";
  8376. import { Node } from "babylonjs/node";
  8377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8378. import { Effect } from "babylonjs/Materials/effect";
  8379. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8380. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  8381. /**
  8382. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8383. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8384. * 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.
  8385. */
  8386. export abstract class Light extends Node {
  8387. /**
  8388. * Falloff Default: light is falling off following the material specification:
  8389. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8390. */
  8391. static readonly FALLOFF_DEFAULT: number;
  8392. /**
  8393. * Falloff Physical: light is falling off following the inverse squared distance law.
  8394. */
  8395. static readonly FALLOFF_PHYSICAL: number;
  8396. /**
  8397. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8398. * to enhance interoperability with other engines.
  8399. */
  8400. static readonly FALLOFF_GLTF: number;
  8401. /**
  8402. * Falloff Standard: light is falling off like in the standard material
  8403. * to enhance interoperability with other materials.
  8404. */
  8405. static readonly FALLOFF_STANDARD: number;
  8406. /**
  8407. * If every light affecting the material is in this lightmapMode,
  8408. * material.lightmapTexture adds or multiplies
  8409. * (depends on material.useLightmapAsShadowmap)
  8410. * after every other light calculations.
  8411. */
  8412. static readonly LIGHTMAP_DEFAULT: number;
  8413. /**
  8414. * material.lightmapTexture as only diffuse lighting from this light
  8415. * adds only specular lighting from this light
  8416. * adds dynamic shadows
  8417. */
  8418. static readonly LIGHTMAP_SPECULAR: number;
  8419. /**
  8420. * material.lightmapTexture as only lighting
  8421. * no light calculation from this light
  8422. * only adds dynamic shadows from this light
  8423. */
  8424. static readonly LIGHTMAP_SHADOWSONLY: number;
  8425. /**
  8426. * Each light type uses the default quantity according to its type:
  8427. * point/spot lights use luminous intensity
  8428. * directional lights use illuminance
  8429. */
  8430. static readonly INTENSITYMODE_AUTOMATIC: number;
  8431. /**
  8432. * lumen (lm)
  8433. */
  8434. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8435. /**
  8436. * candela (lm/sr)
  8437. */
  8438. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8439. /**
  8440. * lux (lm/m^2)
  8441. */
  8442. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8443. /**
  8444. * nit (cd/m^2)
  8445. */
  8446. static readonly INTENSITYMODE_LUMINANCE: number;
  8447. /**
  8448. * Light type const id of the point light.
  8449. */
  8450. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8451. /**
  8452. * Light type const id of the directional light.
  8453. */
  8454. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8455. /**
  8456. * Light type const id of the spot light.
  8457. */
  8458. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8459. /**
  8460. * Light type const id of the hemispheric light.
  8461. */
  8462. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8463. /**
  8464. * Diffuse gives the basic color to an object.
  8465. */
  8466. diffuse: Color3;
  8467. /**
  8468. * Specular produces a highlight color on an object.
  8469. * Note: This is note affecting PBR materials.
  8470. */
  8471. specular: Color3;
  8472. /**
  8473. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8474. * falling off base on range or angle.
  8475. * This can be set to any values in Light.FALLOFF_x.
  8476. *
  8477. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8478. * other types of materials.
  8479. */
  8480. falloffType: number;
  8481. /**
  8482. * Strength of the light.
  8483. * Note: By default it is define in the framework own unit.
  8484. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8485. */
  8486. intensity: number;
  8487. private _range;
  8488. protected _inverseSquaredRange: number;
  8489. /**
  8490. * Defines how far from the source the light is impacting in scene units.
  8491. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8492. */
  8493. get range(): number;
  8494. /**
  8495. * Defines how far from the source the light is impacting in scene units.
  8496. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8497. */
  8498. set range(value: number);
  8499. /**
  8500. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8501. * of light.
  8502. */
  8503. private _photometricScale;
  8504. private _intensityMode;
  8505. /**
  8506. * Gets the photometric scale used to interpret the intensity.
  8507. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8508. */
  8509. get intensityMode(): number;
  8510. /**
  8511. * Sets the photometric scale used to interpret the intensity.
  8512. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8513. */
  8514. set intensityMode(value: number);
  8515. private _radius;
  8516. /**
  8517. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8518. */
  8519. get radius(): number;
  8520. /**
  8521. * sets the light radius used by PBR Materials to simulate soft area lights.
  8522. */
  8523. set radius(value: number);
  8524. private _renderPriority;
  8525. /**
  8526. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8527. * exceeding the number allowed of the materials.
  8528. */
  8529. renderPriority: number;
  8530. private _shadowEnabled;
  8531. /**
  8532. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8533. * the current shadow generator.
  8534. */
  8535. get shadowEnabled(): boolean;
  8536. /**
  8537. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8538. * the current shadow generator.
  8539. */
  8540. set shadowEnabled(value: boolean);
  8541. private _includedOnlyMeshes;
  8542. /**
  8543. * Gets the only meshes impacted by this light.
  8544. */
  8545. get includedOnlyMeshes(): AbstractMesh[];
  8546. /**
  8547. * Sets the only meshes impacted by this light.
  8548. */
  8549. set includedOnlyMeshes(value: AbstractMesh[]);
  8550. private _excludedMeshes;
  8551. /**
  8552. * Gets the meshes not impacted by this light.
  8553. */
  8554. get excludedMeshes(): AbstractMesh[];
  8555. /**
  8556. * Sets the meshes not impacted by this light.
  8557. */
  8558. set excludedMeshes(value: AbstractMesh[]);
  8559. private _excludeWithLayerMask;
  8560. /**
  8561. * Gets the layer id use to find what meshes are not impacted by the light.
  8562. * Inactive if 0
  8563. */
  8564. get excludeWithLayerMask(): number;
  8565. /**
  8566. * Sets the layer id use to find what meshes are not impacted by the light.
  8567. * Inactive if 0
  8568. */
  8569. set excludeWithLayerMask(value: number);
  8570. private _includeOnlyWithLayerMask;
  8571. /**
  8572. * Gets the layer id use to find what meshes are impacted by the light.
  8573. * Inactive if 0
  8574. */
  8575. get includeOnlyWithLayerMask(): number;
  8576. /**
  8577. * Sets the layer id use to find what meshes are impacted by the light.
  8578. * Inactive if 0
  8579. */
  8580. set includeOnlyWithLayerMask(value: number);
  8581. private _lightmapMode;
  8582. /**
  8583. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8584. */
  8585. get lightmapMode(): number;
  8586. /**
  8587. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8588. */
  8589. set lightmapMode(value: number);
  8590. /**
  8591. * Shadow generator associted to the light.
  8592. * @hidden Internal use only.
  8593. */
  8594. _shadowGenerator: Nullable<IShadowGenerator>;
  8595. /**
  8596. * @hidden Internal use only.
  8597. */
  8598. _excludedMeshesIds: string[];
  8599. /**
  8600. * @hidden Internal use only.
  8601. */
  8602. _includedOnlyMeshesIds: string[];
  8603. /**
  8604. * The current light unifom buffer.
  8605. * @hidden Internal use only.
  8606. */
  8607. _uniformBuffer: UniformBuffer;
  8608. /** @hidden */
  8609. _renderId: number;
  8610. /**
  8611. * Creates a Light object in the scene.
  8612. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8613. * @param name The firendly name of the light
  8614. * @param scene The scene the light belongs too
  8615. */
  8616. constructor(name: string, scene: Scene);
  8617. protected abstract _buildUniformLayout(): void;
  8618. /**
  8619. * Sets the passed Effect "effect" with the Light information.
  8620. * @param effect The effect to update
  8621. * @param lightIndex The index of the light in the effect to update
  8622. * @returns The light
  8623. */
  8624. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8625. /**
  8626. * Sets the passed Effect "effect" with the Light textures.
  8627. * @param effect The effect to update
  8628. * @param lightIndex The index of the light in the effect to update
  8629. * @returns The light
  8630. */
  8631. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8632. /**
  8633. * Binds the lights information from the scene to the effect for the given mesh.
  8634. * @param lightIndex Light index
  8635. * @param scene The scene where the light belongs to
  8636. * @param effect The effect we are binding the data to
  8637. * @param useSpecular Defines if specular is supported
  8638. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8639. */
  8640. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8641. /**
  8642. * Sets the passed Effect "effect" with the Light information.
  8643. * @param effect The effect to update
  8644. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8645. * @returns The light
  8646. */
  8647. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8648. /**
  8649. * Returns the string "Light".
  8650. * @returns the class name
  8651. */
  8652. getClassName(): string;
  8653. /** @hidden */
  8654. readonly _isLight: boolean;
  8655. /**
  8656. * Converts the light information to a readable string for debug purpose.
  8657. * @param fullDetails Supports for multiple levels of logging within scene loading
  8658. * @returns the human readable light info
  8659. */
  8660. toString(fullDetails?: boolean): string;
  8661. /** @hidden */
  8662. protected _syncParentEnabledState(): void;
  8663. /**
  8664. * Set the enabled state of this node.
  8665. * @param value - the new enabled state
  8666. */
  8667. setEnabled(value: boolean): void;
  8668. /**
  8669. * Returns the Light associated shadow generator if any.
  8670. * @return the associated shadow generator.
  8671. */
  8672. getShadowGenerator(): Nullable<IShadowGenerator>;
  8673. /**
  8674. * Returns a Vector3, the absolute light position in the World.
  8675. * @returns the world space position of the light
  8676. */
  8677. getAbsolutePosition(): Vector3;
  8678. /**
  8679. * Specifies if the light will affect the passed mesh.
  8680. * @param mesh The mesh to test against the light
  8681. * @return true the mesh is affected otherwise, false.
  8682. */
  8683. canAffectMesh(mesh: AbstractMesh): boolean;
  8684. /**
  8685. * Sort function to order lights for rendering.
  8686. * @param a First Light object to compare to second.
  8687. * @param b Second Light object to compare first.
  8688. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8689. */
  8690. static CompareLightsPriority(a: Light, b: Light): number;
  8691. /**
  8692. * Releases resources associated with this node.
  8693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8695. */
  8696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8697. /**
  8698. * Returns the light type ID (integer).
  8699. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8700. */
  8701. getTypeID(): number;
  8702. /**
  8703. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8704. * @returns the scaled intensity in intensity mode unit
  8705. */
  8706. getScaledIntensity(): number;
  8707. /**
  8708. * Returns a new Light object, named "name", from the current one.
  8709. * @param name The name of the cloned light
  8710. * @param newParent The parent of this light, if it has one
  8711. * @returns the new created light
  8712. */
  8713. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8714. /**
  8715. * Serializes the current light into a Serialization object.
  8716. * @returns the serialized object.
  8717. */
  8718. serialize(): any;
  8719. /**
  8720. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8721. * This new light is named "name" and added to the passed scene.
  8722. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8723. * @param name The friendly name of the light
  8724. * @param scene The scene the new light will belong to
  8725. * @returns the constructor function
  8726. */
  8727. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8728. /**
  8729. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8730. * @param parsedLight The JSON representation of the light
  8731. * @param scene The scene to create the parsed light in
  8732. * @returns the created light after parsing
  8733. */
  8734. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8735. private _hookArrayForExcluded;
  8736. private _hookArrayForIncludedOnly;
  8737. private _resyncMeshes;
  8738. /**
  8739. * Forces the meshes to update their light related information in their rendering used effects
  8740. * @hidden Internal Use Only
  8741. */
  8742. _markMeshesAsLightDirty(): void;
  8743. /**
  8744. * Recomputes the cached photometric scale if needed.
  8745. */
  8746. private _computePhotometricScale;
  8747. /**
  8748. * Returns the Photometric Scale according to the light type and intensity mode.
  8749. */
  8750. private _getPhotometricScale;
  8751. /**
  8752. * Reorder the light in the scene according to their defined priority.
  8753. * @hidden Internal Use Only
  8754. */
  8755. _reorderLightsInScene(): void;
  8756. /**
  8757. * Prepares the list of defines specific to the light type.
  8758. * @param defines the list of defines
  8759. * @param lightIndex defines the index of the light for the effect
  8760. */
  8761. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8762. }
  8763. }
  8764. declare module "babylonjs/Maths/math.axis" {
  8765. import { Vector3 } from "babylonjs/Maths/math.vector";
  8766. /** Defines supported spaces */
  8767. export enum Space {
  8768. /** Local (object) space */
  8769. LOCAL = 0,
  8770. /** World space */
  8771. WORLD = 1,
  8772. /** Bone space */
  8773. BONE = 2
  8774. }
  8775. /** Defines the 3 main axes */
  8776. export class Axis {
  8777. /** X axis */
  8778. static X: Vector3;
  8779. /** Y axis */
  8780. static Y: Vector3;
  8781. /** Z axis */
  8782. static Z: Vector3;
  8783. }
  8784. /**
  8785. * Defines cartesian components.
  8786. */
  8787. export enum Coordinate {
  8788. /** X axis */
  8789. X = 0,
  8790. /** Y axis */
  8791. Y = 1,
  8792. /** Z axis */
  8793. Z = 2
  8794. }
  8795. }
  8796. declare module "babylonjs/Lights/shadowLight" {
  8797. import { Camera } from "babylonjs/Cameras/camera";
  8798. import { Scene } from "babylonjs/scene";
  8799. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8801. import { Light } from "babylonjs/Lights/light";
  8802. /**
  8803. * Interface describing all the common properties and methods a shadow light needs to implement.
  8804. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8805. * as well as binding the different shadow properties to the effects.
  8806. */
  8807. export interface IShadowLight extends Light {
  8808. /**
  8809. * The light id in the scene (used in scene.findLighById for instance)
  8810. */
  8811. id: string;
  8812. /**
  8813. * The position the shdow will be casted from.
  8814. */
  8815. position: Vector3;
  8816. /**
  8817. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8818. */
  8819. direction: Vector3;
  8820. /**
  8821. * The transformed position. Position of the light in world space taking parenting in account.
  8822. */
  8823. transformedPosition: Vector3;
  8824. /**
  8825. * The transformed direction. Direction of the light in world space taking parenting in account.
  8826. */
  8827. transformedDirection: Vector3;
  8828. /**
  8829. * The friendly name of the light in the scene.
  8830. */
  8831. name: string;
  8832. /**
  8833. * Defines the shadow projection clipping minimum z value.
  8834. */
  8835. shadowMinZ: number;
  8836. /**
  8837. * Defines the shadow projection clipping maximum z value.
  8838. */
  8839. shadowMaxZ: number;
  8840. /**
  8841. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8842. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8843. */
  8844. computeTransformedInformation(): boolean;
  8845. /**
  8846. * Gets the scene the light belongs to.
  8847. * @returns The scene
  8848. */
  8849. getScene(): Scene;
  8850. /**
  8851. * Callback defining a custom Projection Matrix Builder.
  8852. * This can be used to override the default projection matrix computation.
  8853. */
  8854. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8855. /**
  8856. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8857. * @param matrix The materix to updated with the projection information
  8858. * @param viewMatrix The transform matrix of the light
  8859. * @param renderList The list of mesh to render in the map
  8860. * @returns The current light
  8861. */
  8862. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8863. /**
  8864. * Gets the current depth scale used in ESM.
  8865. * @returns The scale
  8866. */
  8867. getDepthScale(): number;
  8868. /**
  8869. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8870. * @returns true if a cube texture needs to be use
  8871. */
  8872. needCube(): boolean;
  8873. /**
  8874. * Detects if the projection matrix requires to be recomputed this frame.
  8875. * @returns true if it requires to be recomputed otherwise, false.
  8876. */
  8877. needProjectionMatrixCompute(): boolean;
  8878. /**
  8879. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8880. */
  8881. forceProjectionMatrixCompute(): void;
  8882. /**
  8883. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8884. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8885. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8886. */
  8887. getShadowDirection(faceIndex?: number): Vector3;
  8888. /**
  8889. * Gets the minZ used for shadow according to both the scene and the light.
  8890. * @param activeCamera The camera we are returning the min for
  8891. * @returns the depth min z
  8892. */
  8893. getDepthMinZ(activeCamera: Camera): number;
  8894. /**
  8895. * Gets the maxZ used for shadow according to both the scene and the light.
  8896. * @param activeCamera The camera we are returning the max for
  8897. * @returns the depth max z
  8898. */
  8899. getDepthMaxZ(activeCamera: Camera): number;
  8900. }
  8901. /**
  8902. * Base implementation IShadowLight
  8903. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8904. */
  8905. export abstract class ShadowLight extends Light implements IShadowLight {
  8906. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8907. protected _position: Vector3;
  8908. protected _setPosition(value: Vector3): void;
  8909. /**
  8910. * Sets the position the shadow will be casted from. Also use as the light position for both
  8911. * point and spot lights.
  8912. */
  8913. get position(): Vector3;
  8914. /**
  8915. * Sets the position the shadow will be casted from. Also use as the light position for both
  8916. * point and spot lights.
  8917. */
  8918. set position(value: Vector3);
  8919. protected _direction: Vector3;
  8920. protected _setDirection(value: Vector3): void;
  8921. /**
  8922. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8923. * Also use as the light direction on spot and directional lights.
  8924. */
  8925. get direction(): Vector3;
  8926. /**
  8927. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8928. * Also use as the light direction on spot and directional lights.
  8929. */
  8930. set direction(value: Vector3);
  8931. protected _shadowMinZ: number;
  8932. /**
  8933. * Gets the shadow projection clipping minimum z value.
  8934. */
  8935. get shadowMinZ(): number;
  8936. /**
  8937. * Sets the shadow projection clipping minimum z value.
  8938. */
  8939. set shadowMinZ(value: number);
  8940. protected _shadowMaxZ: number;
  8941. /**
  8942. * Sets the shadow projection clipping maximum z value.
  8943. */
  8944. get shadowMaxZ(): number;
  8945. /**
  8946. * Gets the shadow projection clipping maximum z value.
  8947. */
  8948. set shadowMaxZ(value: number);
  8949. /**
  8950. * Callback defining a custom Projection Matrix Builder.
  8951. * This can be used to override the default projection matrix computation.
  8952. */
  8953. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8954. /**
  8955. * The transformed position. Position of the light in world space taking parenting in account.
  8956. */
  8957. transformedPosition: Vector3;
  8958. /**
  8959. * The transformed direction. Direction of the light in world space taking parenting in account.
  8960. */
  8961. transformedDirection: Vector3;
  8962. private _needProjectionMatrixCompute;
  8963. /**
  8964. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8965. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8966. */
  8967. computeTransformedInformation(): boolean;
  8968. /**
  8969. * Return the depth scale used for the shadow map.
  8970. * @returns the depth scale.
  8971. */
  8972. getDepthScale(): number;
  8973. /**
  8974. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8975. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8976. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8977. */
  8978. getShadowDirection(faceIndex?: number): Vector3;
  8979. /**
  8980. * Returns the ShadowLight absolute position in the World.
  8981. * @returns the position vector in world space
  8982. */
  8983. getAbsolutePosition(): Vector3;
  8984. /**
  8985. * Sets the ShadowLight direction toward the passed target.
  8986. * @param target The point to target in local space
  8987. * @returns the updated ShadowLight direction
  8988. */
  8989. setDirectionToTarget(target: Vector3): Vector3;
  8990. /**
  8991. * Returns the light rotation in euler definition.
  8992. * @returns the x y z rotation in local space.
  8993. */
  8994. getRotation(): Vector3;
  8995. /**
  8996. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8997. * @returns true if a cube texture needs to be use
  8998. */
  8999. needCube(): boolean;
  9000. /**
  9001. * Detects if the projection matrix requires to be recomputed this frame.
  9002. * @returns true if it requires to be recomputed otherwise, false.
  9003. */
  9004. needProjectionMatrixCompute(): boolean;
  9005. /**
  9006. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9007. */
  9008. forceProjectionMatrixCompute(): void;
  9009. /** @hidden */
  9010. _initCache(): void;
  9011. /** @hidden */
  9012. _isSynchronized(): boolean;
  9013. /**
  9014. * Computes the world matrix of the node
  9015. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9016. * @returns the world matrix
  9017. */
  9018. computeWorldMatrix(force?: boolean): Matrix;
  9019. /**
  9020. * Gets the minZ used for shadow according to both the scene and the light.
  9021. * @param activeCamera The camera we are returning the min for
  9022. * @returns the depth min z
  9023. */
  9024. getDepthMinZ(activeCamera: Camera): number;
  9025. /**
  9026. * Gets the maxZ used for shadow according to both the scene and the light.
  9027. * @param activeCamera The camera we are returning the max for
  9028. * @returns the depth max z
  9029. */
  9030. getDepthMaxZ(activeCamera: Camera): number;
  9031. /**
  9032. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9033. * @param matrix The materix to updated with the projection information
  9034. * @param viewMatrix The transform matrix of the light
  9035. * @param renderList The list of mesh to render in the map
  9036. * @returns The current light
  9037. */
  9038. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9039. }
  9040. }
  9041. declare module "babylonjs/Materials/prePassConfiguration" {
  9042. import { Matrix } from "babylonjs/Maths/math.vector";
  9043. import { Mesh } from "babylonjs/Meshes/mesh";
  9044. import { Scene } from "babylonjs/scene";
  9045. import { Effect } from "babylonjs/Materials/effect";
  9046. /**
  9047. * Configuration needed for prepass-capable materials
  9048. */
  9049. export class PrePassConfiguration {
  9050. /**
  9051. * Previous world matrices of meshes carrying this material
  9052. * Used for computing velocity
  9053. */
  9054. previousWorldMatrices: {
  9055. [index: number]: Matrix;
  9056. };
  9057. /**
  9058. * Previous view project matrix
  9059. * Used for computing velocity
  9060. */
  9061. previousViewProjection: Matrix;
  9062. /**
  9063. * Previous bones of meshes carrying this material
  9064. * Used for computing velocity
  9065. */
  9066. previousBones: {
  9067. [index: number]: Float32Array;
  9068. };
  9069. /**
  9070. * Add the required uniforms to the current list.
  9071. * @param uniforms defines the current uniform list.
  9072. */
  9073. static AddUniforms(uniforms: string[]): void;
  9074. /**
  9075. * Add the required samplers to the current list.
  9076. * @param samplers defines the current sampler list.
  9077. */
  9078. static AddSamplers(samplers: string[]): void;
  9079. /**
  9080. * Binds the material data.
  9081. * @param effect defines the effect to update
  9082. * @param scene defines the scene the material belongs to.
  9083. * @param mesh The mesh
  9084. * @param world World matrix of this mesh
  9085. * @param isFrozen Is the material frozen
  9086. */
  9087. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9088. }
  9089. }
  9090. declare module "babylonjs/Cameras/targetCamera" {
  9091. import { Nullable } from "babylonjs/types";
  9092. import { Camera } from "babylonjs/Cameras/camera";
  9093. import { Scene } from "babylonjs/scene";
  9094. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9095. /**
  9096. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9097. * This is the base of the follow, arc rotate cameras and Free camera
  9098. * @see https://doc.babylonjs.com/features/cameras
  9099. */
  9100. export class TargetCamera extends Camera {
  9101. private static _RigCamTransformMatrix;
  9102. private static _TargetTransformMatrix;
  9103. private static _TargetFocalPoint;
  9104. private _tmpUpVector;
  9105. private _tmpTargetVector;
  9106. /**
  9107. * Define the current direction the camera is moving to
  9108. */
  9109. cameraDirection: Vector3;
  9110. /**
  9111. * Define the current rotation the camera is rotating to
  9112. */
  9113. cameraRotation: Vector2;
  9114. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9115. ignoreParentScaling: boolean;
  9116. /**
  9117. * When set, the up vector of the camera will be updated by the rotation of the camera
  9118. */
  9119. updateUpVectorFromRotation: boolean;
  9120. private _tmpQuaternion;
  9121. /**
  9122. * Define the current rotation of the camera
  9123. */
  9124. rotation: Vector3;
  9125. /**
  9126. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9127. */
  9128. rotationQuaternion: Quaternion;
  9129. /**
  9130. * Define the current speed of the camera
  9131. */
  9132. speed: number;
  9133. /**
  9134. * Add constraint to the camera to prevent it to move freely in all directions and
  9135. * around all axis.
  9136. */
  9137. noRotationConstraint: boolean;
  9138. /**
  9139. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9140. * panning
  9141. */
  9142. invertRotation: boolean;
  9143. /**
  9144. * Speed multiplier for inverse camera panning
  9145. */
  9146. inverseRotationSpeed: number;
  9147. /**
  9148. * Define the current target of the camera as an object or a position.
  9149. */
  9150. lockedTarget: any;
  9151. /** @hidden */
  9152. _currentTarget: Vector3;
  9153. /** @hidden */
  9154. _initialFocalDistance: number;
  9155. /** @hidden */
  9156. _viewMatrix: Matrix;
  9157. /** @hidden */
  9158. _camMatrix: Matrix;
  9159. /** @hidden */
  9160. _cameraTransformMatrix: Matrix;
  9161. /** @hidden */
  9162. _cameraRotationMatrix: Matrix;
  9163. /** @hidden */
  9164. _referencePoint: Vector3;
  9165. /** @hidden */
  9166. _transformedReferencePoint: Vector3;
  9167. /** @hidden */
  9168. _reset: () => void;
  9169. private _defaultUp;
  9170. /**
  9171. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9172. * This is the base of the follow, arc rotate cameras and Free camera
  9173. * @see https://doc.babylonjs.com/features/cameras
  9174. * @param name Defines the name of the camera in the scene
  9175. * @param position Defines the start position of the camera in the scene
  9176. * @param scene Defines the scene the camera belongs to
  9177. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9178. */
  9179. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9180. /**
  9181. * Gets the position in front of the camera at a given distance.
  9182. * @param distance The distance from the camera we want the position to be
  9183. * @returns the position
  9184. */
  9185. getFrontPosition(distance: number): Vector3;
  9186. /** @hidden */
  9187. _getLockedTargetPosition(): Nullable<Vector3>;
  9188. private _storedPosition;
  9189. private _storedRotation;
  9190. private _storedRotationQuaternion;
  9191. /**
  9192. * Store current camera state of the camera (fov, position, rotation, etc..)
  9193. * @returns the camera
  9194. */
  9195. storeState(): Camera;
  9196. /**
  9197. * Restored camera state. You must call storeState() first
  9198. * @returns whether it was successful or not
  9199. * @hidden
  9200. */
  9201. _restoreStateValues(): boolean;
  9202. /** @hidden */
  9203. _initCache(): void;
  9204. /** @hidden */
  9205. _updateCache(ignoreParentClass?: boolean): void;
  9206. /** @hidden */
  9207. _isSynchronizedViewMatrix(): boolean;
  9208. /** @hidden */
  9209. _computeLocalCameraSpeed(): number;
  9210. /**
  9211. * Defines the target the camera should look at.
  9212. * @param target Defines the new target as a Vector or a mesh
  9213. */
  9214. setTarget(target: Vector3): void;
  9215. /**
  9216. * Defines the target point of the camera.
  9217. * The camera looks towards it form the radius distance.
  9218. */
  9219. get target(): Vector3;
  9220. set target(value: Vector3);
  9221. /**
  9222. * Return the current target position of the camera. This value is expressed in local space.
  9223. * @returns the target position
  9224. */
  9225. getTarget(): Vector3;
  9226. /** @hidden */
  9227. _decideIfNeedsToMove(): boolean;
  9228. /** @hidden */
  9229. _updatePosition(): void;
  9230. /** @hidden */
  9231. _checkInputs(): void;
  9232. protected _updateCameraRotationMatrix(): void;
  9233. /**
  9234. * 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)
  9235. * @returns the current camera
  9236. */
  9237. private _rotateUpVectorWithCameraRotationMatrix;
  9238. private _cachedRotationZ;
  9239. private _cachedQuaternionRotationZ;
  9240. /** @hidden */
  9241. _getViewMatrix(): Matrix;
  9242. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9243. /**
  9244. * @hidden
  9245. */
  9246. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9247. /**
  9248. * @hidden
  9249. */
  9250. _updateRigCameras(): void;
  9251. private _getRigCamPositionAndTarget;
  9252. /**
  9253. * Gets the current object class name.
  9254. * @return the class name
  9255. */
  9256. getClassName(): string;
  9257. }
  9258. }
  9259. declare module "babylonjs/Cameras/cameraInputsManager" {
  9260. import { Nullable } from "babylonjs/types";
  9261. import { Camera } from "babylonjs/Cameras/camera";
  9262. /**
  9263. * @ignore
  9264. * This is a list of all the different input types that are available in the application.
  9265. * Fo instance: ArcRotateCameraGamepadInput...
  9266. */
  9267. export var CameraInputTypes: {};
  9268. /**
  9269. * This is the contract to implement in order to create a new input class.
  9270. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9271. */
  9272. export interface ICameraInput<TCamera extends Camera> {
  9273. /**
  9274. * Defines the camera the input is attached to.
  9275. */
  9276. camera: Nullable<TCamera>;
  9277. /**
  9278. * Gets the class name of the current intput.
  9279. * @returns the class name
  9280. */
  9281. getClassName(): string;
  9282. /**
  9283. * Get the friendly name associated with the input class.
  9284. * @returns the input friendly name
  9285. */
  9286. getSimpleName(): string;
  9287. /**
  9288. * Attach the input controls to a specific dom element to get the input from.
  9289. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9290. */
  9291. attachControl(noPreventDefault?: boolean): void;
  9292. /**
  9293. * Detach the current controls from the specified dom element.
  9294. */
  9295. detachControl(): void;
  9296. /**
  9297. * Update the current camera state depending on the inputs that have been used this frame.
  9298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9299. */
  9300. checkInputs?: () => void;
  9301. }
  9302. /**
  9303. * Represents a map of input types to input instance or input index to input instance.
  9304. */
  9305. export interface CameraInputsMap<TCamera extends Camera> {
  9306. /**
  9307. * Accessor to the input by input type.
  9308. */
  9309. [name: string]: ICameraInput<TCamera>;
  9310. /**
  9311. * Accessor to the input by input index.
  9312. */
  9313. [idx: number]: ICameraInput<TCamera>;
  9314. }
  9315. /**
  9316. * This represents the input manager used within a camera.
  9317. * It helps dealing with all the different kind of input attached to a camera.
  9318. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9319. */
  9320. export class CameraInputsManager<TCamera extends Camera> {
  9321. /**
  9322. * Defines the list of inputs attahed to the camera.
  9323. */
  9324. attached: CameraInputsMap<TCamera>;
  9325. /**
  9326. * Defines the dom element the camera is collecting inputs from.
  9327. * This is null if the controls have not been attached.
  9328. */
  9329. attachedToElement: boolean;
  9330. /**
  9331. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9332. */
  9333. noPreventDefault: boolean;
  9334. /**
  9335. * Defined the camera the input manager belongs to.
  9336. */
  9337. camera: TCamera;
  9338. /**
  9339. * Update the current camera state depending on the inputs that have been used this frame.
  9340. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9341. */
  9342. checkInputs: () => void;
  9343. /**
  9344. * Instantiate a new Camera Input Manager.
  9345. * @param camera Defines the camera the input manager blongs to
  9346. */
  9347. constructor(camera: TCamera);
  9348. /**
  9349. * Add an input method to a camera
  9350. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9351. * @param input camera input method
  9352. */
  9353. add(input: ICameraInput<TCamera>): void;
  9354. /**
  9355. * Remove a specific input method from a camera
  9356. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9357. * @param inputToRemove camera input method
  9358. */
  9359. remove(inputToRemove: ICameraInput<TCamera>): void;
  9360. /**
  9361. * Remove a specific input type from a camera
  9362. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9363. * @param inputType the type of the input to remove
  9364. */
  9365. removeByType(inputType: string): void;
  9366. private _addCheckInputs;
  9367. /**
  9368. * Attach the input controls to the currently attached dom element to listen the events from.
  9369. * @param input Defines the input to attach
  9370. */
  9371. attachInput(input: ICameraInput<TCamera>): void;
  9372. /**
  9373. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9374. * @param element Defines the dom element to collect the events from
  9375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9376. */
  9377. attachElement(noPreventDefault?: boolean): void;
  9378. /**
  9379. * Detach the current manager inputs controls from a specific dom element.
  9380. * @param element Defines the dom element to collect the events from
  9381. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9382. */
  9383. detachElement(disconnect?: boolean): void;
  9384. /**
  9385. * Rebuild the dynamic inputCheck function from the current list of
  9386. * defined inputs in the manager.
  9387. */
  9388. rebuildInputCheck(): void;
  9389. /**
  9390. * Remove all attached input methods from a camera
  9391. */
  9392. clear(): void;
  9393. /**
  9394. * Serialize the current input manager attached to a camera.
  9395. * This ensures than once parsed,
  9396. * the input associated to the camera will be identical to the current ones
  9397. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9398. */
  9399. serialize(serializedCamera: any): void;
  9400. /**
  9401. * Parses an input manager serialized JSON to restore the previous list of inputs
  9402. * and states associated to a camera.
  9403. * @param parsedCamera Defines the JSON to parse
  9404. */
  9405. parse(parsedCamera: any): void;
  9406. }
  9407. }
  9408. declare module "babylonjs/Events/keyboardEvents" {
  9409. /**
  9410. * Gather the list of keyboard event types as constants.
  9411. */
  9412. export class KeyboardEventTypes {
  9413. /**
  9414. * The keydown event is fired when a key becomes active (pressed).
  9415. */
  9416. static readonly KEYDOWN: number;
  9417. /**
  9418. * The keyup event is fired when a key has been released.
  9419. */
  9420. static readonly KEYUP: number;
  9421. }
  9422. /**
  9423. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9424. */
  9425. export class KeyboardInfo {
  9426. /**
  9427. * Defines the type of event (KeyboardEventTypes)
  9428. */
  9429. type: number;
  9430. /**
  9431. * Defines the related dom event
  9432. */
  9433. event: KeyboardEvent;
  9434. /**
  9435. * Instantiates a new keyboard info.
  9436. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9437. * @param type Defines the type of event (KeyboardEventTypes)
  9438. * @param event Defines the related dom event
  9439. */
  9440. constructor(
  9441. /**
  9442. * Defines the type of event (KeyboardEventTypes)
  9443. */
  9444. type: number,
  9445. /**
  9446. * Defines the related dom event
  9447. */
  9448. event: KeyboardEvent);
  9449. }
  9450. /**
  9451. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9452. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9453. */
  9454. export class KeyboardInfoPre extends KeyboardInfo {
  9455. /**
  9456. * Defines the type of event (KeyboardEventTypes)
  9457. */
  9458. type: number;
  9459. /**
  9460. * Defines the related dom event
  9461. */
  9462. event: KeyboardEvent;
  9463. /**
  9464. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9465. */
  9466. skipOnPointerObservable: boolean;
  9467. /**
  9468. * Instantiates a new keyboard pre info.
  9469. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9470. * @param type Defines the type of event (KeyboardEventTypes)
  9471. * @param event Defines the related dom event
  9472. */
  9473. constructor(
  9474. /**
  9475. * Defines the type of event (KeyboardEventTypes)
  9476. */
  9477. type: number,
  9478. /**
  9479. * Defines the related dom event
  9480. */
  9481. event: KeyboardEvent);
  9482. }
  9483. }
  9484. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9485. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9486. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9487. /**
  9488. * Manage the keyboard inputs to control the movement of a free camera.
  9489. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9490. */
  9491. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9492. /**
  9493. * Defines the camera the input is attached to.
  9494. */
  9495. camera: FreeCamera;
  9496. /**
  9497. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9498. */
  9499. keysUp: number[];
  9500. /**
  9501. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9502. */
  9503. keysUpward: number[];
  9504. /**
  9505. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9506. */
  9507. keysDown: number[];
  9508. /**
  9509. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9510. */
  9511. keysDownward: number[];
  9512. /**
  9513. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9514. */
  9515. keysLeft: number[];
  9516. /**
  9517. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9518. */
  9519. keysRight: number[];
  9520. private _keys;
  9521. private _onCanvasBlurObserver;
  9522. private _onKeyboardObserver;
  9523. private _engine;
  9524. private _scene;
  9525. /**
  9526. * Attach the input controls to a specific dom element to get the input from.
  9527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9528. */
  9529. attachControl(noPreventDefault?: boolean): void;
  9530. /**
  9531. * Detach the current controls from the specified dom element.
  9532. */
  9533. detachControl(): void;
  9534. /**
  9535. * Update the current camera state depending on the inputs that have been used this frame.
  9536. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9537. */
  9538. checkInputs(): void;
  9539. /**
  9540. * Gets the class name of the current intput.
  9541. * @returns the class name
  9542. */
  9543. getClassName(): string;
  9544. /** @hidden */
  9545. _onLostFocus(): void;
  9546. /**
  9547. * Get the friendly name associated with the input class.
  9548. * @returns the input friendly name
  9549. */
  9550. getSimpleName(): string;
  9551. }
  9552. }
  9553. declare module "babylonjs/Actions/action" {
  9554. import { Observable } from "babylonjs/Misc/observable";
  9555. import { Condition } from "babylonjs/Actions/condition";
  9556. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9557. import { Nullable } from "babylonjs/types";
  9558. import { Scene } from "babylonjs/scene";
  9559. import { ActionManager } from "babylonjs/Actions/actionManager";
  9560. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9561. import { Node } from "babylonjs/node";
  9562. /**
  9563. * Interface used to define Action
  9564. */
  9565. export interface IAction {
  9566. /**
  9567. * Trigger for the action
  9568. */
  9569. trigger: number;
  9570. /** Options of the trigger */
  9571. triggerOptions: any;
  9572. /**
  9573. * Gets the trigger parameters
  9574. * @returns the trigger parameters
  9575. */
  9576. getTriggerParameter(): any;
  9577. /**
  9578. * Internal only - executes current action event
  9579. * @hidden
  9580. */
  9581. _executeCurrent(evt?: ActionEvent): void;
  9582. /**
  9583. * Serialize placeholder for child classes
  9584. * @param parent of child
  9585. * @returns the serialized object
  9586. */
  9587. serialize(parent: any): any;
  9588. /**
  9589. * Internal only
  9590. * @hidden
  9591. */
  9592. _prepare(): void;
  9593. /**
  9594. * Internal only - manager for action
  9595. * @hidden
  9596. */
  9597. _actionManager: Nullable<AbstractActionManager>;
  9598. /**
  9599. * Adds action to chain of actions, may be a DoNothingAction
  9600. * @param action defines the next action to execute
  9601. * @returns The action passed in
  9602. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9603. */
  9604. then(action: IAction): IAction;
  9605. }
  9606. /**
  9607. * The action to be carried out following a trigger
  9608. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9609. */
  9610. export class Action implements IAction {
  9611. /** the trigger, with or without parameters, for the action */
  9612. triggerOptions: any;
  9613. /**
  9614. * Trigger for the action
  9615. */
  9616. trigger: number;
  9617. /**
  9618. * Internal only - manager for action
  9619. * @hidden
  9620. */
  9621. _actionManager: ActionManager;
  9622. private _nextActiveAction;
  9623. private _child;
  9624. private _condition?;
  9625. private _triggerParameter;
  9626. /**
  9627. * An event triggered prior to action being executed.
  9628. */
  9629. onBeforeExecuteObservable: Observable<Action>;
  9630. /**
  9631. * Creates a new Action
  9632. * @param triggerOptions the trigger, with or without parameters, for the action
  9633. * @param condition an optional determinant of action
  9634. */
  9635. constructor(
  9636. /** the trigger, with or without parameters, for the action */
  9637. triggerOptions: any, condition?: Condition);
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. _prepare(): void;
  9643. /**
  9644. * Gets the trigger parameters
  9645. * @returns the trigger parameters
  9646. */
  9647. getTriggerParameter(): any;
  9648. /**
  9649. * Internal only - executes current action event
  9650. * @hidden
  9651. */
  9652. _executeCurrent(evt?: ActionEvent): void;
  9653. /**
  9654. * Execute placeholder for child classes
  9655. * @param evt optional action event
  9656. */
  9657. execute(evt?: ActionEvent): void;
  9658. /**
  9659. * Skips to next active action
  9660. */
  9661. skipToNextActiveAction(): void;
  9662. /**
  9663. * Adds action to chain of actions, may be a DoNothingAction
  9664. * @param action defines the next action to execute
  9665. * @returns The action passed in
  9666. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9667. */
  9668. then(action: Action): Action;
  9669. /**
  9670. * Internal only
  9671. * @hidden
  9672. */
  9673. _getProperty(propertyPath: string): string;
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. _getEffectiveTarget(target: any, propertyPath: string): any;
  9679. /**
  9680. * Serialize placeholder for child classes
  9681. * @param parent of child
  9682. * @returns the serialized object
  9683. */
  9684. serialize(parent: any): any;
  9685. /**
  9686. * Internal only called by serialize
  9687. * @hidden
  9688. */
  9689. protected _serialize(serializedAction: any, parent?: any): any;
  9690. /**
  9691. * Internal only
  9692. * @hidden
  9693. */
  9694. static _SerializeValueAsString: (value: any) => string;
  9695. /**
  9696. * Internal only
  9697. * @hidden
  9698. */
  9699. static _GetTargetProperty: (target: Scene | Node) => {
  9700. name: string;
  9701. targetType: string;
  9702. value: string;
  9703. };
  9704. }
  9705. }
  9706. declare module "babylonjs/Actions/condition" {
  9707. import { ActionManager } from "babylonjs/Actions/actionManager";
  9708. /**
  9709. * A Condition applied to an Action
  9710. */
  9711. export class Condition {
  9712. /**
  9713. * Internal only - manager for action
  9714. * @hidden
  9715. */
  9716. _actionManager: ActionManager;
  9717. /**
  9718. * Internal only
  9719. * @hidden
  9720. */
  9721. _evaluationId: number;
  9722. /**
  9723. * Internal only
  9724. * @hidden
  9725. */
  9726. _currentResult: boolean;
  9727. /**
  9728. * Creates a new Condition
  9729. * @param actionManager the manager of the action the condition is applied to
  9730. */
  9731. constructor(actionManager: ActionManager);
  9732. /**
  9733. * Check if the current condition is valid
  9734. * @returns a boolean
  9735. */
  9736. isValid(): boolean;
  9737. /**
  9738. * Internal only
  9739. * @hidden
  9740. */
  9741. _getProperty(propertyPath: string): string;
  9742. /**
  9743. * Internal only
  9744. * @hidden
  9745. */
  9746. _getEffectiveTarget(target: any, propertyPath: string): any;
  9747. /**
  9748. * Serialize placeholder for child classes
  9749. * @returns the serialized object
  9750. */
  9751. serialize(): any;
  9752. /**
  9753. * Internal only
  9754. * @hidden
  9755. */
  9756. protected _serialize(serializedCondition: any): any;
  9757. }
  9758. /**
  9759. * Defines specific conditional operators as extensions of Condition
  9760. */
  9761. export class ValueCondition extends Condition {
  9762. /** path to specify the property of the target the conditional operator uses */
  9763. propertyPath: string;
  9764. /** the value compared by the conditional operator against the current value of the property */
  9765. value: any;
  9766. /** the conditional operator, default ValueCondition.IsEqual */
  9767. operator: number;
  9768. /**
  9769. * Internal only
  9770. * @hidden
  9771. */
  9772. private static _IsEqual;
  9773. /**
  9774. * Internal only
  9775. * @hidden
  9776. */
  9777. private static _IsDifferent;
  9778. /**
  9779. * Internal only
  9780. * @hidden
  9781. */
  9782. private static _IsGreater;
  9783. /**
  9784. * Internal only
  9785. * @hidden
  9786. */
  9787. private static _IsLesser;
  9788. /**
  9789. * returns the number for IsEqual
  9790. */
  9791. static get IsEqual(): number;
  9792. /**
  9793. * Returns the number for IsDifferent
  9794. */
  9795. static get IsDifferent(): number;
  9796. /**
  9797. * Returns the number for IsGreater
  9798. */
  9799. static get IsGreater(): number;
  9800. /**
  9801. * Returns the number for IsLesser
  9802. */
  9803. static get IsLesser(): number;
  9804. /**
  9805. * Internal only The action manager for the condition
  9806. * @hidden
  9807. */
  9808. _actionManager: ActionManager;
  9809. /**
  9810. * Internal only
  9811. * @hidden
  9812. */
  9813. private _target;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. private _effectiveTarget;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private _property;
  9824. /**
  9825. * Creates a new ValueCondition
  9826. * @param actionManager manager for the action the condition applies to
  9827. * @param target for the action
  9828. * @param propertyPath path to specify the property of the target the conditional operator uses
  9829. * @param value the value compared by the conditional operator against the current value of the property
  9830. * @param operator the conditional operator, default ValueCondition.IsEqual
  9831. */
  9832. constructor(actionManager: ActionManager, target: any,
  9833. /** path to specify the property of the target the conditional operator uses */
  9834. propertyPath: string,
  9835. /** the value compared by the conditional operator against the current value of the property */
  9836. value: any,
  9837. /** the conditional operator, default ValueCondition.IsEqual */
  9838. operator?: number);
  9839. /**
  9840. * Compares the given value with the property value for the specified conditional operator
  9841. * @returns the result of the comparison
  9842. */
  9843. isValid(): boolean;
  9844. /**
  9845. * Serialize the ValueCondition into a JSON compatible object
  9846. * @returns serialization object
  9847. */
  9848. serialize(): any;
  9849. /**
  9850. * Gets the name of the conditional operator for the ValueCondition
  9851. * @param operator the conditional operator
  9852. * @returns the name
  9853. */
  9854. static GetOperatorName(operator: number): string;
  9855. }
  9856. /**
  9857. * Defines a predicate condition as an extension of Condition
  9858. */
  9859. export class PredicateCondition extends Condition {
  9860. /** defines the predicate function used to validate the condition */
  9861. predicate: () => boolean;
  9862. /**
  9863. * Internal only - manager for action
  9864. * @hidden
  9865. */
  9866. _actionManager: ActionManager;
  9867. /**
  9868. * Creates a new PredicateCondition
  9869. * @param actionManager manager for the action the condition applies to
  9870. * @param predicate defines the predicate function used to validate the condition
  9871. */
  9872. constructor(actionManager: ActionManager,
  9873. /** defines the predicate function used to validate the condition */
  9874. predicate: () => boolean);
  9875. /**
  9876. * @returns the validity of the predicate condition
  9877. */
  9878. isValid(): boolean;
  9879. }
  9880. /**
  9881. * Defines a state condition as an extension of Condition
  9882. */
  9883. export class StateCondition extends Condition {
  9884. /** Value to compare with target state */
  9885. value: string;
  9886. /**
  9887. * Internal only - manager for action
  9888. * @hidden
  9889. */
  9890. _actionManager: ActionManager;
  9891. /**
  9892. * Internal only
  9893. * @hidden
  9894. */
  9895. private _target;
  9896. /**
  9897. * Creates a new StateCondition
  9898. * @param actionManager manager for the action the condition applies to
  9899. * @param target of the condition
  9900. * @param value to compare with target state
  9901. */
  9902. constructor(actionManager: ActionManager, target: any,
  9903. /** Value to compare with target state */
  9904. value: string);
  9905. /**
  9906. * Gets a boolean indicating if the current condition is met
  9907. * @returns the validity of the state
  9908. */
  9909. isValid(): boolean;
  9910. /**
  9911. * Serialize the StateCondition into a JSON compatible object
  9912. * @returns serialization object
  9913. */
  9914. serialize(): any;
  9915. }
  9916. }
  9917. declare module "babylonjs/Actions/directActions" {
  9918. import { Action } from "babylonjs/Actions/action";
  9919. import { Condition } from "babylonjs/Actions/condition";
  9920. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9921. /**
  9922. * This defines an action responsible to toggle a boolean once triggered.
  9923. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9924. */
  9925. export class SwitchBooleanAction extends Action {
  9926. /**
  9927. * The path to the boolean property in the target object
  9928. */
  9929. propertyPath: string;
  9930. private _target;
  9931. private _effectiveTarget;
  9932. private _property;
  9933. /**
  9934. * Instantiate the action
  9935. * @param triggerOptions defines the trigger options
  9936. * @param target defines the object containing the boolean
  9937. * @param propertyPath defines the path to the boolean property in the target object
  9938. * @param condition defines the trigger related conditions
  9939. */
  9940. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9941. /** @hidden */
  9942. _prepare(): void;
  9943. /**
  9944. * Execute the action toggle the boolean value.
  9945. */
  9946. execute(): void;
  9947. /**
  9948. * Serializes the actions and its related information.
  9949. * @param parent defines the object to serialize in
  9950. * @returns the serialized object
  9951. */
  9952. serialize(parent: any): any;
  9953. }
  9954. /**
  9955. * This defines an action responsible to set a the state field of the target
  9956. * to a desired value once triggered.
  9957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9958. */
  9959. export class SetStateAction extends Action {
  9960. /**
  9961. * The value to store in the state field.
  9962. */
  9963. value: string;
  9964. private _target;
  9965. /**
  9966. * Instantiate the action
  9967. * @param triggerOptions defines the trigger options
  9968. * @param target defines the object containing the state property
  9969. * @param value defines the value to store in the state field
  9970. * @param condition defines the trigger related conditions
  9971. */
  9972. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9973. /**
  9974. * Execute the action and store the value on the target state property.
  9975. */
  9976. execute(): void;
  9977. /**
  9978. * Serializes the actions and its related information.
  9979. * @param parent defines the object to serialize in
  9980. * @returns the serialized object
  9981. */
  9982. serialize(parent: any): any;
  9983. }
  9984. /**
  9985. * This defines an action responsible to set a property of the target
  9986. * to a desired value once triggered.
  9987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9988. */
  9989. export class SetValueAction extends Action {
  9990. /**
  9991. * The path of the property to set in the target.
  9992. */
  9993. propertyPath: string;
  9994. /**
  9995. * The value to set in the property
  9996. */
  9997. value: any;
  9998. private _target;
  9999. private _effectiveTarget;
  10000. private _property;
  10001. /**
  10002. * Instantiate the action
  10003. * @param triggerOptions defines the trigger options
  10004. * @param target defines the object containing the property
  10005. * @param propertyPath defines the path of the property to set in the target
  10006. * @param value defines the value to set in the property
  10007. * @param condition defines the trigger related conditions
  10008. */
  10009. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10010. /** @hidden */
  10011. _prepare(): void;
  10012. /**
  10013. * Execute the action and set the targetted property to the desired value.
  10014. */
  10015. execute(): void;
  10016. /**
  10017. * Serializes the actions and its related information.
  10018. * @param parent defines the object to serialize in
  10019. * @returns the serialized object
  10020. */
  10021. serialize(parent: any): any;
  10022. }
  10023. /**
  10024. * This defines an action responsible to increment the target value
  10025. * to a desired value once triggered.
  10026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10027. */
  10028. export class IncrementValueAction extends Action {
  10029. /**
  10030. * The path of the property to increment in the target.
  10031. */
  10032. propertyPath: string;
  10033. /**
  10034. * The value we should increment the property by.
  10035. */
  10036. value: any;
  10037. private _target;
  10038. private _effectiveTarget;
  10039. private _property;
  10040. /**
  10041. * Instantiate the action
  10042. * @param triggerOptions defines the trigger options
  10043. * @param target defines the object containing the property
  10044. * @param propertyPath defines the path of the property to increment in the target
  10045. * @param value defines the value value we should increment the property by
  10046. * @param condition defines the trigger related conditions
  10047. */
  10048. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10049. /** @hidden */
  10050. _prepare(): void;
  10051. /**
  10052. * Execute the action and increment the target of the value amount.
  10053. */
  10054. execute(): void;
  10055. /**
  10056. * Serializes the actions and its related information.
  10057. * @param parent defines the object to serialize in
  10058. * @returns the serialized object
  10059. */
  10060. serialize(parent: any): any;
  10061. }
  10062. /**
  10063. * This defines an action responsible to start an animation once triggered.
  10064. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10065. */
  10066. export class PlayAnimationAction extends Action {
  10067. /**
  10068. * Where the animation should start (animation frame)
  10069. */
  10070. from: number;
  10071. /**
  10072. * Where the animation should stop (animation frame)
  10073. */
  10074. to: number;
  10075. /**
  10076. * Define if the animation should loop or stop after the first play.
  10077. */
  10078. loop?: boolean;
  10079. private _target;
  10080. /**
  10081. * Instantiate the action
  10082. * @param triggerOptions defines the trigger options
  10083. * @param target defines the target animation or animation name
  10084. * @param from defines from where the animation should start (animation frame)
  10085. * @param end defines where the animation should stop (animation frame)
  10086. * @param loop defines if the animation should loop or stop after the first play
  10087. * @param condition defines the trigger related conditions
  10088. */
  10089. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10090. /** @hidden */
  10091. _prepare(): void;
  10092. /**
  10093. * Execute the action and play the animation.
  10094. */
  10095. execute(): void;
  10096. /**
  10097. * Serializes the actions and its related information.
  10098. * @param parent defines the object to serialize in
  10099. * @returns the serialized object
  10100. */
  10101. serialize(parent: any): any;
  10102. }
  10103. /**
  10104. * This defines an action responsible to stop an animation once triggered.
  10105. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10106. */
  10107. export class StopAnimationAction extends Action {
  10108. private _target;
  10109. /**
  10110. * Instantiate the action
  10111. * @param triggerOptions defines the trigger options
  10112. * @param target defines the target animation or animation name
  10113. * @param condition defines the trigger related conditions
  10114. */
  10115. constructor(triggerOptions: any, target: any, condition?: Condition);
  10116. /** @hidden */
  10117. _prepare(): void;
  10118. /**
  10119. * Execute the action and stop the animation.
  10120. */
  10121. execute(): void;
  10122. /**
  10123. * Serializes the actions and its related information.
  10124. * @param parent defines the object to serialize in
  10125. * @returns the serialized object
  10126. */
  10127. serialize(parent: any): any;
  10128. }
  10129. /**
  10130. * This defines an action responsible that does nothing once triggered.
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10132. */
  10133. export class DoNothingAction extends Action {
  10134. /**
  10135. * Instantiate the action
  10136. * @param triggerOptions defines the trigger options
  10137. * @param condition defines the trigger related conditions
  10138. */
  10139. constructor(triggerOptions?: any, condition?: Condition);
  10140. /**
  10141. * Execute the action and do nothing.
  10142. */
  10143. execute(): void;
  10144. /**
  10145. * Serializes the actions and its related information.
  10146. * @param parent defines the object to serialize in
  10147. * @returns the serialized object
  10148. */
  10149. serialize(parent: any): any;
  10150. }
  10151. /**
  10152. * This defines an action responsible to trigger several actions once triggered.
  10153. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10154. */
  10155. export class CombineAction extends Action {
  10156. /**
  10157. * The list of aggregated animations to run.
  10158. */
  10159. children: Action[];
  10160. /**
  10161. * Instantiate the action
  10162. * @param triggerOptions defines the trigger options
  10163. * @param children defines the list of aggregated animations to run
  10164. * @param condition defines the trigger related conditions
  10165. */
  10166. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10167. /** @hidden */
  10168. _prepare(): void;
  10169. /**
  10170. * Execute the action and executes all the aggregated actions.
  10171. */
  10172. execute(evt: ActionEvent): void;
  10173. /**
  10174. * Serializes the actions and its related information.
  10175. * @param parent defines the object to serialize in
  10176. * @returns the serialized object
  10177. */
  10178. serialize(parent: any): any;
  10179. }
  10180. /**
  10181. * This defines an action responsible to run code (external event) once triggered.
  10182. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10183. */
  10184. export class ExecuteCodeAction extends Action {
  10185. /**
  10186. * The callback function to run.
  10187. */
  10188. func: (evt: ActionEvent) => void;
  10189. /**
  10190. * Instantiate the action
  10191. * @param triggerOptions defines the trigger options
  10192. * @param func defines the callback function to run
  10193. * @param condition defines the trigger related conditions
  10194. */
  10195. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10196. /**
  10197. * Execute the action and run the attached code.
  10198. */
  10199. execute(evt: ActionEvent): void;
  10200. }
  10201. /**
  10202. * This defines an action responsible to set the parent property of the target once triggered.
  10203. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10204. */
  10205. export class SetParentAction extends Action {
  10206. private _parent;
  10207. private _target;
  10208. /**
  10209. * Instantiate the action
  10210. * @param triggerOptions defines the trigger options
  10211. * @param target defines the target containing the parent property
  10212. * @param parent defines from where the animation should start (animation frame)
  10213. * @param condition defines the trigger related conditions
  10214. */
  10215. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10216. /** @hidden */
  10217. _prepare(): void;
  10218. /**
  10219. * Execute the action and set the parent property.
  10220. */
  10221. execute(): void;
  10222. /**
  10223. * Serializes the actions and its related information.
  10224. * @param parent defines the object to serialize in
  10225. * @returns the serialized object
  10226. */
  10227. serialize(parent: any): any;
  10228. }
  10229. }
  10230. declare module "babylonjs/Actions/actionManager" {
  10231. import { Nullable } from "babylonjs/types";
  10232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10233. import { Scene } from "babylonjs/scene";
  10234. import { IAction } from "babylonjs/Actions/action";
  10235. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10236. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10237. /**
  10238. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10239. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10241. */
  10242. export class ActionManager extends AbstractActionManager {
  10243. /**
  10244. * Nothing
  10245. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10246. */
  10247. static readonly NothingTrigger: number;
  10248. /**
  10249. * On pick
  10250. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10251. */
  10252. static readonly OnPickTrigger: number;
  10253. /**
  10254. * On left pick
  10255. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10256. */
  10257. static readonly OnLeftPickTrigger: number;
  10258. /**
  10259. * On right pick
  10260. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10261. */
  10262. static readonly OnRightPickTrigger: number;
  10263. /**
  10264. * On center pick
  10265. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10266. */
  10267. static readonly OnCenterPickTrigger: number;
  10268. /**
  10269. * On pick down
  10270. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10271. */
  10272. static readonly OnPickDownTrigger: number;
  10273. /**
  10274. * On double pick
  10275. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10276. */
  10277. static readonly OnDoublePickTrigger: number;
  10278. /**
  10279. * On pick up
  10280. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10281. */
  10282. static readonly OnPickUpTrigger: number;
  10283. /**
  10284. * On pick out.
  10285. * This trigger will only be raised if you also declared a OnPickDown
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10287. */
  10288. static readonly OnPickOutTrigger: number;
  10289. /**
  10290. * On long press
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly OnLongPressTrigger: number;
  10294. /**
  10295. * On pointer over
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnPointerOverTrigger: number;
  10299. /**
  10300. * On pointer out
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnPointerOutTrigger: number;
  10304. /**
  10305. * On every frame
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnEveryFrameTrigger: number;
  10309. /**
  10310. * On intersection enter
  10311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10312. */
  10313. static readonly OnIntersectionEnterTrigger: number;
  10314. /**
  10315. * On intersection exit
  10316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10317. */
  10318. static readonly OnIntersectionExitTrigger: number;
  10319. /**
  10320. * On key down
  10321. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10322. */
  10323. static readonly OnKeyDownTrigger: number;
  10324. /**
  10325. * On key up
  10326. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10327. */
  10328. static readonly OnKeyUpTrigger: number;
  10329. private _scene;
  10330. /**
  10331. * Creates a new action manager
  10332. * @param scene defines the hosting scene
  10333. */
  10334. constructor(scene: Scene);
  10335. /**
  10336. * Releases all associated resources
  10337. */
  10338. dispose(): void;
  10339. /**
  10340. * Gets hosting scene
  10341. * @returns the hosting scene
  10342. */
  10343. getScene(): Scene;
  10344. /**
  10345. * Does this action manager handles actions of any of the given triggers
  10346. * @param triggers defines the triggers to be tested
  10347. * @return a boolean indicating whether one (or more) of the triggers is handled
  10348. */
  10349. hasSpecificTriggers(triggers: number[]): boolean;
  10350. /**
  10351. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10352. * speed.
  10353. * @param triggerA defines the trigger to be tested
  10354. * @param triggerB defines the trigger to be tested
  10355. * @return a boolean indicating whether one (or more) of the triggers is handled
  10356. */
  10357. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10358. /**
  10359. * Does this action manager handles actions of a given trigger
  10360. * @param trigger defines the trigger to be tested
  10361. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10362. * @return whether the trigger is handled
  10363. */
  10364. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10365. /**
  10366. * Does this action manager has pointer triggers
  10367. */
  10368. get hasPointerTriggers(): boolean;
  10369. /**
  10370. * Does this action manager has pick triggers
  10371. */
  10372. get hasPickTriggers(): boolean;
  10373. /**
  10374. * Registers an action to this action manager
  10375. * @param action defines the action to be registered
  10376. * @return the action amended (prepared) after registration
  10377. */
  10378. registerAction(action: IAction): Nullable<IAction>;
  10379. /**
  10380. * Unregisters an action to this action manager
  10381. * @param action defines the action to be unregistered
  10382. * @return a boolean indicating whether the action has been unregistered
  10383. */
  10384. unregisterAction(action: IAction): Boolean;
  10385. /**
  10386. * Process a specific trigger
  10387. * @param trigger defines the trigger to process
  10388. * @param evt defines the event details to be processed
  10389. */
  10390. processTrigger(trigger: number, evt?: IActionEvent): void;
  10391. /** @hidden */
  10392. _getEffectiveTarget(target: any, propertyPath: string): any;
  10393. /** @hidden */
  10394. _getProperty(propertyPath: string): string;
  10395. /**
  10396. * Serialize this manager to a JSON object
  10397. * @param name defines the property name to store this manager
  10398. * @returns a JSON representation of this manager
  10399. */
  10400. serialize(name: string): any;
  10401. /**
  10402. * Creates a new ActionManager from a JSON data
  10403. * @param parsedActions defines the JSON data to read from
  10404. * @param object defines the hosting mesh
  10405. * @param scene defines the hosting scene
  10406. */
  10407. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10408. /**
  10409. * Get a trigger name by index
  10410. * @param trigger defines the trigger index
  10411. * @returns a trigger name
  10412. */
  10413. static GetTriggerName(trigger: number): string;
  10414. }
  10415. }
  10416. declare module "babylonjs/Culling/ray" {
  10417. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10418. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10420. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10421. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10422. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10423. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10424. import { Plane } from "babylonjs/Maths/math.plane";
  10425. /**
  10426. * Class representing a ray with position and direction
  10427. */
  10428. export class Ray {
  10429. /** origin point */
  10430. origin: Vector3;
  10431. /** direction */
  10432. direction: Vector3;
  10433. /** length of the ray */
  10434. length: number;
  10435. private static readonly _TmpVector3;
  10436. private _tmpRay;
  10437. /**
  10438. * Creates a new ray
  10439. * @param origin origin point
  10440. * @param direction direction
  10441. * @param length length of the ray
  10442. */
  10443. constructor(
  10444. /** origin point */
  10445. origin: Vector3,
  10446. /** direction */
  10447. direction: Vector3,
  10448. /** length of the ray */
  10449. length?: number);
  10450. /**
  10451. * Checks if the ray intersects a box
  10452. * This does not account for the ray lenght by design to improve perfs.
  10453. * @param minimum bound of the box
  10454. * @param maximum bound of the box
  10455. * @param intersectionTreshold extra extend to be added to the box in all direction
  10456. * @returns if the box was hit
  10457. */
  10458. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10459. /**
  10460. * Checks if the ray intersects a box
  10461. * This does not account for the ray lenght by design to improve perfs.
  10462. * @param box the bounding box to check
  10463. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10464. * @returns if the box was hit
  10465. */
  10466. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10467. /**
  10468. * If the ray hits a sphere
  10469. * @param sphere the bounding sphere to check
  10470. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10471. * @returns true if it hits the sphere
  10472. */
  10473. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10474. /**
  10475. * If the ray hits a triange
  10476. * @param vertex0 triangle vertex
  10477. * @param vertex1 triangle vertex
  10478. * @param vertex2 triangle vertex
  10479. * @returns intersection information if hit
  10480. */
  10481. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10482. /**
  10483. * Checks if ray intersects a plane
  10484. * @param plane the plane to check
  10485. * @returns the distance away it was hit
  10486. */
  10487. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10488. /**
  10489. * Calculate the intercept of a ray on a given axis
  10490. * @param axis to check 'x' | 'y' | 'z'
  10491. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10492. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10493. */
  10494. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10495. /**
  10496. * Checks if ray intersects a mesh
  10497. * @param mesh the mesh to check
  10498. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10499. * @returns picking info of the intersecton
  10500. */
  10501. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10502. /**
  10503. * Checks if ray intersects a mesh
  10504. * @param meshes the meshes to check
  10505. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10506. * @param results array to store result in
  10507. * @returns Array of picking infos
  10508. */
  10509. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10510. private _comparePickingInfo;
  10511. private static smallnum;
  10512. private static rayl;
  10513. /**
  10514. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10515. * @param sega the first point of the segment to test the intersection against
  10516. * @param segb the second point of the segment to test the intersection against
  10517. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10518. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10519. */
  10520. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10521. /**
  10522. * Update the ray from viewport position
  10523. * @param x position
  10524. * @param y y position
  10525. * @param viewportWidth viewport width
  10526. * @param viewportHeight viewport height
  10527. * @param world world matrix
  10528. * @param view view matrix
  10529. * @param projection projection matrix
  10530. * @returns this ray updated
  10531. */
  10532. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10533. /**
  10534. * Creates a ray with origin and direction of 0,0,0
  10535. * @returns the new ray
  10536. */
  10537. static Zero(): Ray;
  10538. /**
  10539. * Creates a new ray from screen space and viewport
  10540. * @param x position
  10541. * @param y y position
  10542. * @param viewportWidth viewport width
  10543. * @param viewportHeight viewport height
  10544. * @param world world matrix
  10545. * @param view view matrix
  10546. * @param projection projection matrix
  10547. * @returns new ray
  10548. */
  10549. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10550. /**
  10551. * 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
  10552. * transformed to the given world matrix.
  10553. * @param origin The origin point
  10554. * @param end The end point
  10555. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10556. * @returns the new ray
  10557. */
  10558. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10559. /**
  10560. * Transforms a ray by a matrix
  10561. * @param ray ray to transform
  10562. * @param matrix matrix to apply
  10563. * @returns the resulting new ray
  10564. */
  10565. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10566. /**
  10567. * Transforms a ray by a matrix
  10568. * @param ray ray to transform
  10569. * @param matrix matrix to apply
  10570. * @param result ray to store result in
  10571. */
  10572. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10573. /**
  10574. * Unproject a ray from screen space to object space
  10575. * @param sourceX defines the screen space x coordinate to use
  10576. * @param sourceY defines the screen space y coordinate to use
  10577. * @param viewportWidth defines the current width of the viewport
  10578. * @param viewportHeight defines the current height of the viewport
  10579. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10580. * @param view defines the view matrix to use
  10581. * @param projection defines the projection matrix to use
  10582. */
  10583. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10584. }
  10585. /**
  10586. * Type used to define predicate used to select faces when a mesh intersection is detected
  10587. */
  10588. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10589. module "babylonjs/scene" {
  10590. interface Scene {
  10591. /** @hidden */
  10592. _tempPickingRay: Nullable<Ray>;
  10593. /** @hidden */
  10594. _cachedRayForTransform: Ray;
  10595. /** @hidden */
  10596. _pickWithRayInverseMatrix: Matrix;
  10597. /** @hidden */
  10598. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10599. /** @hidden */
  10600. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10601. /** @hidden */
  10602. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10603. }
  10604. }
  10605. }
  10606. declare module "babylonjs/sceneComponent" {
  10607. import { Scene } from "babylonjs/scene";
  10608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10609. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10610. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10611. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10612. import { Nullable } from "babylonjs/types";
  10613. import { Camera } from "babylonjs/Cameras/camera";
  10614. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10615. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10616. import { AbstractScene } from "babylonjs/abstractScene";
  10617. import { Mesh } from "babylonjs/Meshes/mesh";
  10618. import { Effect } from "babylonjs/Materials/effect";
  10619. /**
  10620. * Groups all the scene component constants in one place to ease maintenance.
  10621. * @hidden
  10622. */
  10623. export class SceneComponentConstants {
  10624. static readonly NAME_EFFECTLAYER: string;
  10625. static readonly NAME_LAYER: string;
  10626. static readonly NAME_LENSFLARESYSTEM: string;
  10627. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10628. static readonly NAME_PARTICLESYSTEM: string;
  10629. static readonly NAME_GAMEPAD: string;
  10630. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10631. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10632. static readonly NAME_PREPASSRENDERER: string;
  10633. static readonly NAME_DEPTHRENDERER: string;
  10634. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10635. static readonly NAME_SPRITE: string;
  10636. static readonly NAME_SUBSURFACE: string;
  10637. static readonly NAME_OUTLINERENDERER: string;
  10638. static readonly NAME_PROCEDURALTEXTURE: string;
  10639. static readonly NAME_SHADOWGENERATOR: string;
  10640. static readonly NAME_OCTREE: string;
  10641. static readonly NAME_PHYSICSENGINE: string;
  10642. static readonly NAME_AUDIO: string;
  10643. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10644. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10645. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10646. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10647. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10648. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10649. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10650. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10651. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10652. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  10653. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10654. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  10655. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10656. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10657. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10658. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10659. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10660. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10661. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10662. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10663. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10664. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10665. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10666. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10667. static readonly STEP_AFTERRENDER_AUDIO: number;
  10668. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10669. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10670. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10671. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10672. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10673. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10674. static readonly STEP_POINTERMOVE_SPRITE: number;
  10675. static readonly STEP_POINTERDOWN_SPRITE: number;
  10676. static readonly STEP_POINTERUP_SPRITE: number;
  10677. }
  10678. /**
  10679. * This represents a scene component.
  10680. *
  10681. * This is used to decouple the dependency the scene is having on the different workloads like
  10682. * layers, post processes...
  10683. */
  10684. export interface ISceneComponent {
  10685. /**
  10686. * The name of the component. Each component must have a unique name.
  10687. */
  10688. name: string;
  10689. /**
  10690. * The scene the component belongs to.
  10691. */
  10692. scene: Scene;
  10693. /**
  10694. * Register the component to one instance of a scene.
  10695. */
  10696. register(): void;
  10697. /**
  10698. * Rebuilds the elements related to this component in case of
  10699. * context lost for instance.
  10700. */
  10701. rebuild(): void;
  10702. /**
  10703. * Disposes the component and the associated ressources.
  10704. */
  10705. dispose(): void;
  10706. }
  10707. /**
  10708. * This represents a SERIALIZABLE scene component.
  10709. *
  10710. * This extends Scene Component to add Serialization methods on top.
  10711. */
  10712. export interface ISceneSerializableComponent extends ISceneComponent {
  10713. /**
  10714. * Adds all the elements from the container to the scene
  10715. * @param container the container holding the elements
  10716. */
  10717. addFromContainer(container: AbstractScene): void;
  10718. /**
  10719. * Removes all the elements in the container from the scene
  10720. * @param container contains the elements to remove
  10721. * @param dispose if the removed element should be disposed (default: false)
  10722. */
  10723. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10724. /**
  10725. * Serializes the component data to the specified json object
  10726. * @param serializationObject The object to serialize to
  10727. */
  10728. serialize(serializationObject: any): void;
  10729. }
  10730. /**
  10731. * Strong typing of a Mesh related stage step action
  10732. */
  10733. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10734. /**
  10735. * Strong typing of a Evaluate Sub Mesh related stage step action
  10736. */
  10737. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10738. /**
  10739. * Strong typing of a pre active Mesh related stage step action
  10740. */
  10741. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10742. /**
  10743. * Strong typing of a Camera related stage step action
  10744. */
  10745. export type CameraStageAction = (camera: Camera) => void;
  10746. /**
  10747. * Strong typing of a Camera Frame buffer related stage step action
  10748. */
  10749. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10750. /**
  10751. * Strong typing of a Render Target related stage step action
  10752. */
  10753. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10754. /**
  10755. * Strong typing of a RenderingGroup related stage step action
  10756. */
  10757. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10758. /**
  10759. * Strong typing of a Mesh Render related stage step action
  10760. */
  10761. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  10762. /**
  10763. * Strong typing of a simple stage step action
  10764. */
  10765. export type SimpleStageAction = () => void;
  10766. /**
  10767. * Strong typing of a render target action.
  10768. */
  10769. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10770. /**
  10771. * Strong typing of a pointer move action.
  10772. */
  10773. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10774. /**
  10775. * Strong typing of a pointer up/down action.
  10776. */
  10777. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10778. /**
  10779. * Representation of a stage in the scene (Basically a list of ordered steps)
  10780. * @hidden
  10781. */
  10782. export class Stage<T extends Function> extends Array<{
  10783. index: number;
  10784. component: ISceneComponent;
  10785. action: T;
  10786. }> {
  10787. /**
  10788. * Hide ctor from the rest of the world.
  10789. * @param items The items to add.
  10790. */
  10791. private constructor();
  10792. /**
  10793. * Creates a new Stage.
  10794. * @returns A new instance of a Stage
  10795. */
  10796. static Create<T extends Function>(): Stage<T>;
  10797. /**
  10798. * Registers a step in an ordered way in the targeted stage.
  10799. * @param index Defines the position to register the step in
  10800. * @param component Defines the component attached to the step
  10801. * @param action Defines the action to launch during the step
  10802. */
  10803. registerStep(index: number, component: ISceneComponent, action: T): void;
  10804. /**
  10805. * Clears all the steps from the stage.
  10806. */
  10807. clear(): void;
  10808. }
  10809. }
  10810. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10811. import { Nullable } from "babylonjs/types";
  10812. import { Observable } from "babylonjs/Misc/observable";
  10813. import { Scene } from "babylonjs/scene";
  10814. import { Sprite } from "babylonjs/Sprites/sprite";
  10815. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10816. import { Ray } from "babylonjs/Culling/ray";
  10817. import { Camera } from "babylonjs/Cameras/camera";
  10818. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10819. import { ISceneComponent } from "babylonjs/sceneComponent";
  10820. module "babylonjs/scene" {
  10821. interface Scene {
  10822. /** @hidden */
  10823. _pointerOverSprite: Nullable<Sprite>;
  10824. /** @hidden */
  10825. _pickedDownSprite: Nullable<Sprite>;
  10826. /** @hidden */
  10827. _tempSpritePickingRay: Nullable<Ray>;
  10828. /**
  10829. * All of the sprite managers added to this scene
  10830. * @see https://doc.babylonjs.com/babylon101/sprites
  10831. */
  10832. spriteManagers: Array<ISpriteManager>;
  10833. /**
  10834. * An event triggered when sprites rendering is about to start
  10835. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10836. */
  10837. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10838. /**
  10839. * An event triggered when sprites rendering is done
  10840. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10841. */
  10842. onAfterSpritesRenderingObservable: Observable<Scene>;
  10843. /** @hidden */
  10844. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10845. /** Launch a ray to try to pick a sprite in the scene
  10846. * @param x position on screen
  10847. * @param y position on screen
  10848. * @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
  10849. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10850. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10851. * @returns a PickingInfo
  10852. */
  10853. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10854. /** Use the given ray to pick a sprite in the scene
  10855. * @param ray The ray (in world space) to use to pick meshes
  10856. * @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
  10857. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10858. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10859. * @returns a PickingInfo
  10860. */
  10861. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10862. /** @hidden */
  10863. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10864. /** Launch a ray to try to pick sprites in the scene
  10865. * @param x position on screen
  10866. * @param y position on screen
  10867. * @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
  10868. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10869. * @returns a PickingInfo array
  10870. */
  10871. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10872. /** Use the given ray to pick sprites in the scene
  10873. * @param ray The ray (in world space) to use to pick meshes
  10874. * @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
  10875. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10876. * @returns a PickingInfo array
  10877. */
  10878. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10879. /**
  10880. * Force the sprite under the pointer
  10881. * @param sprite defines the sprite to use
  10882. */
  10883. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10884. /**
  10885. * Gets the sprite under the pointer
  10886. * @returns a Sprite or null if no sprite is under the pointer
  10887. */
  10888. getPointerOverSprite(): Nullable<Sprite>;
  10889. }
  10890. }
  10891. /**
  10892. * Defines the sprite scene component responsible to manage sprites
  10893. * in a given scene.
  10894. */
  10895. export class SpriteSceneComponent implements ISceneComponent {
  10896. /**
  10897. * The component name helpfull to identify the component in the list of scene components.
  10898. */
  10899. readonly name: string;
  10900. /**
  10901. * The scene the component belongs to.
  10902. */
  10903. scene: Scene;
  10904. /** @hidden */
  10905. private _spritePredicate;
  10906. /**
  10907. * Creates a new instance of the component for the given scene
  10908. * @param scene Defines the scene to register the component in
  10909. */
  10910. constructor(scene: Scene);
  10911. /**
  10912. * Registers the component in a given scene
  10913. */
  10914. register(): void;
  10915. /**
  10916. * Rebuilds the elements related to this component in case of
  10917. * context lost for instance.
  10918. */
  10919. rebuild(): void;
  10920. /**
  10921. * Disposes the component and the associated ressources.
  10922. */
  10923. dispose(): void;
  10924. private _pickSpriteButKeepRay;
  10925. private _pointerMove;
  10926. private _pointerDown;
  10927. private _pointerUp;
  10928. }
  10929. }
  10930. declare module "babylonjs/Misc/timingTools" {
  10931. /**
  10932. * Class used to provide helper for timing
  10933. */
  10934. export class TimingTools {
  10935. /**
  10936. * Polyfill for setImmediate
  10937. * @param action defines the action to execute after the current execution block
  10938. */
  10939. static SetImmediate(action: () => void): void;
  10940. }
  10941. }
  10942. declare module "babylonjs/Misc/instantiationTools" {
  10943. /**
  10944. * Class used to enable instatition of objects by class name
  10945. */
  10946. export class InstantiationTools {
  10947. /**
  10948. * Use this object to register external classes like custom textures or material
  10949. * to allow the laoders to instantiate them
  10950. */
  10951. static RegisteredExternalClasses: {
  10952. [key: string]: Object;
  10953. };
  10954. /**
  10955. * Tries to instantiate a new object from a given class name
  10956. * @param className defines the class name to instantiate
  10957. * @returns the new object or null if the system was not able to do the instantiation
  10958. */
  10959. static Instantiate(className: string): any;
  10960. }
  10961. }
  10962. declare module "babylonjs/Misc/copyTools" {
  10963. import { Nullable } from "babylonjs/types";
  10964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10965. /**
  10966. * Class used to host copy specific utilities
  10967. */
  10968. export class CopyTools {
  10969. /**
  10970. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10971. * @param texture defines the texture to read pixels from
  10972. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10973. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10974. * @returns The base64 encoded string or null
  10975. */
  10976. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10977. }
  10978. }
  10979. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  10980. /**
  10981. * Define options used to create a depth texture
  10982. */
  10983. export class DepthTextureCreationOptions {
  10984. /** Specifies whether or not a stencil should be allocated in the texture */
  10985. generateStencil?: boolean;
  10986. /** Specifies whether or not bilinear filtering is enable on the texture */
  10987. bilinearFiltering?: boolean;
  10988. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10989. comparisonFunction?: number;
  10990. /** Specifies if the created texture is a cube texture */
  10991. isCube?: boolean;
  10992. }
  10993. }
  10994. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  10995. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10996. import { Nullable } from "babylonjs/types";
  10997. import { Scene } from "babylonjs/scene";
  10998. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  10999. module "babylonjs/Engines/thinEngine" {
  11000. interface ThinEngine {
  11001. /**
  11002. * Creates a depth stencil cube texture.
  11003. * This is only available in WebGL 2.
  11004. * @param size The size of face edge in the cube texture.
  11005. * @param options The options defining the cube texture.
  11006. * @returns The cube texture
  11007. */
  11008. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11009. /**
  11010. * Creates a cube texture
  11011. * @param rootUrl defines the url where the files to load is located
  11012. * @param scene defines the current scene
  11013. * @param files defines the list of files to load (1 per face)
  11014. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11015. * @param onLoad defines an optional callback raised when the texture is loaded
  11016. * @param onError defines an optional callback raised if there is an issue to load the texture
  11017. * @param format defines the format of the data
  11018. * @param forcedExtension defines the extension to use to pick the right loader
  11019. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11020. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11021. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11022. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11023. * @param loaderOptions options to be passed to the loader
  11024. * @returns the cube texture as an InternalTexture
  11025. */
  11026. 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;
  11027. /**
  11028. * Creates a cube texture
  11029. * @param rootUrl defines the url where the files to load is located
  11030. * @param scene defines the current scene
  11031. * @param files defines the list of files to load (1 per face)
  11032. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11033. * @param onLoad defines an optional callback raised when the texture is loaded
  11034. * @param onError defines an optional callback raised if there is an issue to load the texture
  11035. * @param format defines the format of the data
  11036. * @param forcedExtension defines the extension to use to pick the right loader
  11037. * @returns the cube texture as an InternalTexture
  11038. */
  11039. 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;
  11040. /**
  11041. * Creates a cube texture
  11042. * @param rootUrl defines the url where the files to load is located
  11043. * @param scene defines the current scene
  11044. * @param files defines the list of files to load (1 per face)
  11045. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11046. * @param onLoad defines an optional callback raised when the texture is loaded
  11047. * @param onError defines an optional callback raised if there is an issue to load the texture
  11048. * @param format defines the format of the data
  11049. * @param forcedExtension defines the extension to use to pick the right loader
  11050. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11051. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11052. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11053. * @returns the cube texture as an InternalTexture
  11054. */
  11055. 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;
  11056. /** @hidden */
  11057. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11058. /** @hidden */
  11059. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11060. /** @hidden */
  11061. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11062. /** @hidden */
  11063. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11064. /**
  11065. * @hidden
  11066. */
  11067. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11068. }
  11069. }
  11070. }
  11071. declare module "babylonjs/Materials/Textures/cubeTexture" {
  11072. import { Nullable } from "babylonjs/types";
  11073. import { Scene } from "babylonjs/scene";
  11074. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11076. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11077. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  11078. import { Observable } from "babylonjs/Misc/observable";
  11079. /**
  11080. * Class for creating a cube texture
  11081. */
  11082. export class CubeTexture extends BaseTexture {
  11083. private _delayedOnLoad;
  11084. /**
  11085. * Observable triggered once the texture has been loaded.
  11086. */
  11087. onLoadObservable: Observable<CubeTexture>;
  11088. /**
  11089. * The url of the texture
  11090. */
  11091. url: string;
  11092. /**
  11093. * Gets or sets the center of the bounding box associated with the cube texture.
  11094. * It must define where the camera used to render the texture was set
  11095. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11096. */
  11097. boundingBoxPosition: Vector3;
  11098. private _boundingBoxSize;
  11099. /**
  11100. * Gets or sets the size of the bounding box associated with the cube texture
  11101. * When defined, the cubemap will switch to local mode
  11102. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11103. * @example https://www.babylonjs-playground.com/#RNASML
  11104. */
  11105. set boundingBoxSize(value: Vector3);
  11106. /**
  11107. * Returns the bounding box size
  11108. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11109. */
  11110. get boundingBoxSize(): Vector3;
  11111. protected _rotationY: number;
  11112. /**
  11113. * Sets texture matrix rotation angle around Y axis in radians.
  11114. */
  11115. set rotationY(value: number);
  11116. /**
  11117. * Gets texture matrix rotation angle around Y axis radians.
  11118. */
  11119. get rotationY(): number;
  11120. /**
  11121. * Are mip maps generated for this texture or not.
  11122. */
  11123. get noMipmap(): boolean;
  11124. private _noMipmap;
  11125. private _files;
  11126. protected _forcedExtension: Nullable<string>;
  11127. private _extensions;
  11128. private _textureMatrix;
  11129. private _format;
  11130. private _createPolynomials;
  11131. private _loaderOptions;
  11132. /**
  11133. * Creates a cube texture from an array of image urls
  11134. * @param files defines an array of image urls
  11135. * @param scene defines the hosting scene
  11136. * @param noMipmap specifies if mip maps are not used
  11137. * @returns a cube texture
  11138. */
  11139. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11140. /**
  11141. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11142. * @param url defines the url of the prefiltered texture
  11143. * @param scene defines the scene the texture is attached to
  11144. * @param forcedExtension defines the extension of the file if different from the url
  11145. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11146. * @return the prefiltered texture
  11147. */
  11148. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11149. /**
  11150. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11151. * as prefiltered data.
  11152. * @param rootUrl defines the url of the texture or the root name of the six images
  11153. * @param null defines the scene or engine the texture is attached to
  11154. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11155. * @param noMipmap defines if mipmaps should be created or not
  11156. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11157. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11158. * @param onError defines a callback triggered in case of error during load
  11159. * @param format defines the internal format to use for the texture once loaded
  11160. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11161. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11162. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11163. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11164. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11165. * @param loaderOptions options to be passed to the loader
  11166. * @return the cube texture
  11167. */
  11168. 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);
  11169. /**
  11170. * Get the current class name of the texture useful for serialization or dynamic coding.
  11171. * @returns "CubeTexture"
  11172. */
  11173. getClassName(): string;
  11174. /**
  11175. * Update the url (and optional buffer) of this texture if url was null during construction.
  11176. * @param url the url of the texture
  11177. * @param forcedExtension defines the extension to use
  11178. * @param onLoad callback called when the texture is loaded (defaults to null)
  11179. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11180. */
  11181. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11182. /**
  11183. * Delays loading of the cube texture
  11184. * @param forcedExtension defines the extension to use
  11185. */
  11186. delayLoad(forcedExtension?: string): void;
  11187. /**
  11188. * Returns the reflection texture matrix
  11189. * @returns the reflection texture matrix
  11190. */
  11191. getReflectionTextureMatrix(): Matrix;
  11192. /**
  11193. * Sets the reflection texture matrix
  11194. * @param value Reflection texture matrix
  11195. */
  11196. setReflectionTextureMatrix(value: Matrix): void;
  11197. /**
  11198. * Parses text to create a cube texture
  11199. * @param parsedTexture define the serialized text to read from
  11200. * @param scene defines the hosting scene
  11201. * @param rootUrl defines the root url of the cube texture
  11202. * @returns a cube texture
  11203. */
  11204. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11205. /**
  11206. * Makes a clone, or deep copy, of the cube texture
  11207. * @returns a new cube texture
  11208. */
  11209. clone(): CubeTexture;
  11210. }
  11211. }
  11212. declare module "babylonjs/Materials/colorCurves" {
  11213. import { Effect } from "babylonjs/Materials/effect";
  11214. /**
  11215. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11216. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11217. * 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;
  11218. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11219. */
  11220. export class ColorCurves {
  11221. private _dirty;
  11222. private _tempColor;
  11223. private _globalCurve;
  11224. private _highlightsCurve;
  11225. private _midtonesCurve;
  11226. private _shadowsCurve;
  11227. private _positiveCurve;
  11228. private _negativeCurve;
  11229. private _globalHue;
  11230. private _globalDensity;
  11231. private _globalSaturation;
  11232. private _globalExposure;
  11233. /**
  11234. * Gets the global Hue value.
  11235. * 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).
  11236. */
  11237. get globalHue(): number;
  11238. /**
  11239. * Sets the global Hue value.
  11240. * 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).
  11241. */
  11242. set globalHue(value: number);
  11243. /**
  11244. * Gets the global Density value.
  11245. * 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.
  11246. * Values less than zero provide a filter of opposite hue.
  11247. */
  11248. get globalDensity(): number;
  11249. /**
  11250. * Sets the global Density value.
  11251. * 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.
  11252. * Values less than zero provide a filter of opposite hue.
  11253. */
  11254. set globalDensity(value: number);
  11255. /**
  11256. * Gets the global Saturation value.
  11257. * 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.
  11258. */
  11259. get globalSaturation(): number;
  11260. /**
  11261. * Sets the global Saturation value.
  11262. * 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.
  11263. */
  11264. set globalSaturation(value: number);
  11265. /**
  11266. * Gets the global Exposure value.
  11267. * 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.
  11268. */
  11269. get globalExposure(): number;
  11270. /**
  11271. * Sets the global Exposure value.
  11272. * 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.
  11273. */
  11274. set globalExposure(value: number);
  11275. private _highlightsHue;
  11276. private _highlightsDensity;
  11277. private _highlightsSaturation;
  11278. private _highlightsExposure;
  11279. /**
  11280. * Gets the highlights Hue value.
  11281. * 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).
  11282. */
  11283. get highlightsHue(): number;
  11284. /**
  11285. * Sets the highlights Hue value.
  11286. * 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).
  11287. */
  11288. set highlightsHue(value: number);
  11289. /**
  11290. * Gets the highlights Density value.
  11291. * 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.
  11292. * Values less than zero provide a filter of opposite hue.
  11293. */
  11294. get highlightsDensity(): number;
  11295. /**
  11296. * Sets the highlights Density value.
  11297. * 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.
  11298. * Values less than zero provide a filter of opposite hue.
  11299. */
  11300. set highlightsDensity(value: number);
  11301. /**
  11302. * Gets the highlights Saturation value.
  11303. * 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.
  11304. */
  11305. get highlightsSaturation(): number;
  11306. /**
  11307. * Sets the highlights Saturation value.
  11308. * 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.
  11309. */
  11310. set highlightsSaturation(value: number);
  11311. /**
  11312. * Gets the highlights Exposure value.
  11313. * 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.
  11314. */
  11315. get highlightsExposure(): number;
  11316. /**
  11317. * Sets the highlights Exposure value.
  11318. * 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.
  11319. */
  11320. set highlightsExposure(value: number);
  11321. private _midtonesHue;
  11322. private _midtonesDensity;
  11323. private _midtonesSaturation;
  11324. private _midtonesExposure;
  11325. /**
  11326. * Gets the midtones Hue value.
  11327. * 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).
  11328. */
  11329. get midtonesHue(): number;
  11330. /**
  11331. * Sets the midtones Hue value.
  11332. * 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).
  11333. */
  11334. set midtonesHue(value: number);
  11335. /**
  11336. * Gets the midtones Density value.
  11337. * 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.
  11338. * Values less than zero provide a filter of opposite hue.
  11339. */
  11340. get midtonesDensity(): number;
  11341. /**
  11342. * Sets the midtones Density value.
  11343. * 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.
  11344. * Values less than zero provide a filter of opposite hue.
  11345. */
  11346. set midtonesDensity(value: number);
  11347. /**
  11348. * Gets the midtones Saturation value.
  11349. * 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.
  11350. */
  11351. get midtonesSaturation(): number;
  11352. /**
  11353. * Sets the midtones Saturation value.
  11354. * 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.
  11355. */
  11356. set midtonesSaturation(value: number);
  11357. /**
  11358. * Gets the midtones Exposure value.
  11359. * 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.
  11360. */
  11361. get midtonesExposure(): number;
  11362. /**
  11363. * Sets the midtones Exposure value.
  11364. * 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.
  11365. */
  11366. set midtonesExposure(value: number);
  11367. private _shadowsHue;
  11368. private _shadowsDensity;
  11369. private _shadowsSaturation;
  11370. private _shadowsExposure;
  11371. /**
  11372. * Gets the shadows Hue value.
  11373. * 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).
  11374. */
  11375. get shadowsHue(): number;
  11376. /**
  11377. * Sets the shadows Hue value.
  11378. * 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).
  11379. */
  11380. set shadowsHue(value: number);
  11381. /**
  11382. * Gets the shadows Density value.
  11383. * 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.
  11384. * Values less than zero provide a filter of opposite hue.
  11385. */
  11386. get shadowsDensity(): number;
  11387. /**
  11388. * Sets the shadows Density value.
  11389. * 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.
  11390. * Values less than zero provide a filter of opposite hue.
  11391. */
  11392. set shadowsDensity(value: number);
  11393. /**
  11394. * Gets the shadows Saturation value.
  11395. * 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.
  11396. */
  11397. get shadowsSaturation(): number;
  11398. /**
  11399. * Sets the shadows Saturation value.
  11400. * 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.
  11401. */
  11402. set shadowsSaturation(value: number);
  11403. /**
  11404. * Gets the shadows Exposure value.
  11405. * 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.
  11406. */
  11407. get shadowsExposure(): number;
  11408. /**
  11409. * Sets the shadows Exposure value.
  11410. * 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.
  11411. */
  11412. set shadowsExposure(value: number);
  11413. /**
  11414. * Returns the class name
  11415. * @returns The class name
  11416. */
  11417. getClassName(): string;
  11418. /**
  11419. * Binds the color curves to the shader.
  11420. * @param colorCurves The color curve to bind
  11421. * @param effect The effect to bind to
  11422. * @param positiveUniform The positive uniform shader parameter
  11423. * @param neutralUniform The neutral uniform shader parameter
  11424. * @param negativeUniform The negative uniform shader parameter
  11425. */
  11426. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11427. /**
  11428. * Prepare the list of uniforms associated with the ColorCurves effects.
  11429. * @param uniformsList The list of uniforms used in the effect
  11430. */
  11431. static PrepareUniforms(uniformsList: string[]): void;
  11432. /**
  11433. * Returns color grading data based on a hue, density, saturation and exposure value.
  11434. * @param filterHue The hue of the color filter.
  11435. * @param filterDensity The density of the color filter.
  11436. * @param saturation The saturation.
  11437. * @param exposure The exposure.
  11438. * @param result The result data container.
  11439. */
  11440. private getColorGradingDataToRef;
  11441. /**
  11442. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11443. * @param value The input slider value in range [-100,100].
  11444. * @returns Adjusted value.
  11445. */
  11446. private static applyColorGradingSliderNonlinear;
  11447. /**
  11448. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11449. * @param hue The hue (H) input.
  11450. * @param saturation The saturation (S) input.
  11451. * @param brightness The brightness (B) input.
  11452. * @result An RGBA color represented as Vector4.
  11453. */
  11454. private static fromHSBToRef;
  11455. /**
  11456. * Returns a value clamped between min and max
  11457. * @param value The value to clamp
  11458. * @param min The minimum of value
  11459. * @param max The maximum of value
  11460. * @returns The clamped value.
  11461. */
  11462. private static clamp;
  11463. /**
  11464. * Clones the current color curve instance.
  11465. * @return The cloned curves
  11466. */
  11467. clone(): ColorCurves;
  11468. /**
  11469. * Serializes the current color curve instance to a json representation.
  11470. * @return a JSON representation
  11471. */
  11472. serialize(): any;
  11473. /**
  11474. * Parses the color curve from a json representation.
  11475. * @param source the JSON source to parse
  11476. * @return The parsed curves
  11477. */
  11478. static Parse(source: any): ColorCurves;
  11479. }
  11480. }
  11481. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  11482. import { Observable } from "babylonjs/Misc/observable";
  11483. import { Nullable } from "babylonjs/types";
  11484. import { Color4 } from "babylonjs/Maths/math.color";
  11485. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11486. import { Effect } from "babylonjs/Materials/effect";
  11487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11488. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  11489. /**
  11490. * Interface to follow in your material defines to integrate easily the
  11491. * Image proccessing functions.
  11492. * @hidden
  11493. */
  11494. export interface IImageProcessingConfigurationDefines {
  11495. IMAGEPROCESSING: boolean;
  11496. VIGNETTE: boolean;
  11497. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11498. VIGNETTEBLENDMODEOPAQUE: boolean;
  11499. TONEMAPPING: boolean;
  11500. TONEMAPPING_ACES: boolean;
  11501. CONTRAST: boolean;
  11502. EXPOSURE: boolean;
  11503. COLORCURVES: boolean;
  11504. COLORGRADING: boolean;
  11505. COLORGRADING3D: boolean;
  11506. SAMPLER3DGREENDEPTH: boolean;
  11507. SAMPLER3DBGRMAP: boolean;
  11508. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11509. }
  11510. /**
  11511. * @hidden
  11512. */
  11513. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11514. IMAGEPROCESSING: boolean;
  11515. VIGNETTE: boolean;
  11516. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11517. VIGNETTEBLENDMODEOPAQUE: boolean;
  11518. TONEMAPPING: boolean;
  11519. TONEMAPPING_ACES: boolean;
  11520. CONTRAST: boolean;
  11521. COLORCURVES: boolean;
  11522. COLORGRADING: boolean;
  11523. COLORGRADING3D: boolean;
  11524. SAMPLER3DGREENDEPTH: boolean;
  11525. SAMPLER3DBGRMAP: boolean;
  11526. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11527. EXPOSURE: boolean;
  11528. constructor();
  11529. }
  11530. /**
  11531. * This groups together the common properties used for image processing either in direct forward pass
  11532. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11533. * or not.
  11534. */
  11535. export class ImageProcessingConfiguration {
  11536. /**
  11537. * Default tone mapping applied in BabylonJS.
  11538. */
  11539. static readonly TONEMAPPING_STANDARD: number;
  11540. /**
  11541. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11542. * to other engines rendering to increase portability.
  11543. */
  11544. static readonly TONEMAPPING_ACES: number;
  11545. /**
  11546. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11547. */
  11548. colorCurves: Nullable<ColorCurves>;
  11549. private _colorCurvesEnabled;
  11550. /**
  11551. * Gets wether the color curves effect is enabled.
  11552. */
  11553. get colorCurvesEnabled(): boolean;
  11554. /**
  11555. * Sets wether the color curves effect is enabled.
  11556. */
  11557. set colorCurvesEnabled(value: boolean);
  11558. private _colorGradingTexture;
  11559. /**
  11560. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11561. */
  11562. get colorGradingTexture(): Nullable<BaseTexture>;
  11563. /**
  11564. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11565. */
  11566. set colorGradingTexture(value: Nullable<BaseTexture>);
  11567. private _colorGradingEnabled;
  11568. /**
  11569. * Gets wether the color grading effect is enabled.
  11570. */
  11571. get colorGradingEnabled(): boolean;
  11572. /**
  11573. * Sets wether the color grading effect is enabled.
  11574. */
  11575. set colorGradingEnabled(value: boolean);
  11576. private _colorGradingWithGreenDepth;
  11577. /**
  11578. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11579. */
  11580. get colorGradingWithGreenDepth(): boolean;
  11581. /**
  11582. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11583. */
  11584. set colorGradingWithGreenDepth(value: boolean);
  11585. private _colorGradingBGR;
  11586. /**
  11587. * Gets wether the color grading texture contains BGR values.
  11588. */
  11589. get colorGradingBGR(): boolean;
  11590. /**
  11591. * Sets wether the color grading texture contains BGR values.
  11592. */
  11593. set colorGradingBGR(value: boolean);
  11594. /** @hidden */
  11595. _exposure: number;
  11596. /**
  11597. * Gets the Exposure used in the effect.
  11598. */
  11599. get exposure(): number;
  11600. /**
  11601. * Sets the Exposure used in the effect.
  11602. */
  11603. set exposure(value: number);
  11604. private _toneMappingEnabled;
  11605. /**
  11606. * Gets wether the tone mapping effect is enabled.
  11607. */
  11608. get toneMappingEnabled(): boolean;
  11609. /**
  11610. * Sets wether the tone mapping effect is enabled.
  11611. */
  11612. set toneMappingEnabled(value: boolean);
  11613. private _toneMappingType;
  11614. /**
  11615. * Gets the type of tone mapping effect.
  11616. */
  11617. get toneMappingType(): number;
  11618. /**
  11619. * Sets the type of tone mapping effect used in BabylonJS.
  11620. */
  11621. set toneMappingType(value: number);
  11622. protected _contrast: number;
  11623. /**
  11624. * Gets the contrast used in the effect.
  11625. */
  11626. get contrast(): number;
  11627. /**
  11628. * Sets the contrast used in the effect.
  11629. */
  11630. set contrast(value: number);
  11631. /**
  11632. * Vignette stretch size.
  11633. */
  11634. vignetteStretch: number;
  11635. /**
  11636. * Vignette centre X Offset.
  11637. */
  11638. vignetteCentreX: number;
  11639. /**
  11640. * Vignette centre Y Offset.
  11641. */
  11642. vignetteCentreY: number;
  11643. /**
  11644. * Vignette weight or intensity of the vignette effect.
  11645. */
  11646. vignetteWeight: number;
  11647. /**
  11648. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11649. * if vignetteEnabled is set to true.
  11650. */
  11651. vignetteColor: Color4;
  11652. /**
  11653. * Camera field of view used by the Vignette effect.
  11654. */
  11655. vignetteCameraFov: number;
  11656. private _vignetteBlendMode;
  11657. /**
  11658. * Gets the vignette blend mode allowing different kind of effect.
  11659. */
  11660. get vignetteBlendMode(): number;
  11661. /**
  11662. * Sets the vignette blend mode allowing different kind of effect.
  11663. */
  11664. set vignetteBlendMode(value: number);
  11665. private _vignetteEnabled;
  11666. /**
  11667. * Gets wether the vignette effect is enabled.
  11668. */
  11669. get vignetteEnabled(): boolean;
  11670. /**
  11671. * Sets wether the vignette effect is enabled.
  11672. */
  11673. set vignetteEnabled(value: boolean);
  11674. private _applyByPostProcess;
  11675. /**
  11676. * Gets wether the image processing is applied through a post process or not.
  11677. */
  11678. get applyByPostProcess(): boolean;
  11679. /**
  11680. * Sets wether the image processing is applied through a post process or not.
  11681. */
  11682. set applyByPostProcess(value: boolean);
  11683. private _isEnabled;
  11684. /**
  11685. * Gets wether the image processing is enabled or not.
  11686. */
  11687. get isEnabled(): boolean;
  11688. /**
  11689. * Sets wether the image processing is enabled or not.
  11690. */
  11691. set isEnabled(value: boolean);
  11692. /**
  11693. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11694. */
  11695. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11696. /**
  11697. * Method called each time the image processing information changes requires to recompile the effect.
  11698. */
  11699. protected _updateParameters(): void;
  11700. /**
  11701. * Gets the current class name.
  11702. * @return "ImageProcessingConfiguration"
  11703. */
  11704. getClassName(): string;
  11705. /**
  11706. * Prepare the list of uniforms associated with the Image Processing effects.
  11707. * @param uniforms The list of uniforms used in the effect
  11708. * @param defines the list of defines currently in use
  11709. */
  11710. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11711. /**
  11712. * Prepare the list of samplers associated with the Image Processing effects.
  11713. * @param samplersList The list of uniforms used in the effect
  11714. * @param defines the list of defines currently in use
  11715. */
  11716. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11717. /**
  11718. * Prepare the list of defines associated to the shader.
  11719. * @param defines the list of defines to complete
  11720. * @param forPostProcess Define if we are currently in post process mode or not
  11721. */
  11722. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11723. /**
  11724. * Returns true if all the image processing information are ready.
  11725. * @returns True if ready, otherwise, false
  11726. */
  11727. isReady(): boolean;
  11728. /**
  11729. * Binds the image processing to the shader.
  11730. * @param effect The effect to bind to
  11731. * @param overrideAspectRatio Override the aspect ratio of the effect
  11732. */
  11733. bind(effect: Effect, overrideAspectRatio?: number): void;
  11734. /**
  11735. * Clones the current image processing instance.
  11736. * @return The cloned image processing
  11737. */
  11738. clone(): ImageProcessingConfiguration;
  11739. /**
  11740. * Serializes the current image processing instance to a json representation.
  11741. * @return a JSON representation
  11742. */
  11743. serialize(): any;
  11744. /**
  11745. * Parses the image processing from a json representation.
  11746. * @param source the JSON source to parse
  11747. * @return The parsed image processing
  11748. */
  11749. static Parse(source: any): ImageProcessingConfiguration;
  11750. private static _VIGNETTEMODE_MULTIPLY;
  11751. private static _VIGNETTEMODE_OPAQUE;
  11752. /**
  11753. * Used to apply the vignette as a mix with the pixel color.
  11754. */
  11755. static get VIGNETTEMODE_MULTIPLY(): number;
  11756. /**
  11757. * Used to apply the vignette as a replacement of the pixel color.
  11758. */
  11759. static get VIGNETTEMODE_OPAQUE(): number;
  11760. }
  11761. }
  11762. declare module "babylonjs/Shaders/postprocess.vertex" {
  11763. /** @hidden */
  11764. export var postprocessVertexShader: {
  11765. name: string;
  11766. shader: string;
  11767. };
  11768. }
  11769. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  11770. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11771. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11772. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  11773. /**
  11774. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11775. */
  11776. export type RenderTargetTextureSize = number | {
  11777. width: number;
  11778. height: number;
  11779. layers?: number;
  11780. };
  11781. module "babylonjs/Engines/thinEngine" {
  11782. interface ThinEngine {
  11783. /**
  11784. * Creates a new render target texture
  11785. * @param size defines the size of the texture
  11786. * @param options defines the options used to create the texture
  11787. * @returns a new render target texture stored in an InternalTexture
  11788. */
  11789. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11790. /**
  11791. * Creates a depth stencil texture.
  11792. * This is only available in WebGL 2 or with the depth texture extension available.
  11793. * @param size The size of face edge in the texture.
  11794. * @param options The options defining the texture.
  11795. * @returns The texture
  11796. */
  11797. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11798. /** @hidden */
  11799. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11800. }
  11801. }
  11802. }
  11803. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  11804. /**
  11805. * Defines the kind of connection point for node based material
  11806. */
  11807. export enum NodeMaterialBlockConnectionPointTypes {
  11808. /** Float */
  11809. Float = 1,
  11810. /** Int */
  11811. Int = 2,
  11812. /** Vector2 */
  11813. Vector2 = 4,
  11814. /** Vector3 */
  11815. Vector3 = 8,
  11816. /** Vector4 */
  11817. Vector4 = 16,
  11818. /** Color3 */
  11819. Color3 = 32,
  11820. /** Color4 */
  11821. Color4 = 64,
  11822. /** Matrix */
  11823. Matrix = 128,
  11824. /** Custom object */
  11825. Object = 256,
  11826. /** Detect type based on connection */
  11827. AutoDetect = 1024,
  11828. /** Output type that will be defined by input type */
  11829. BasedOnInput = 2048
  11830. }
  11831. }
  11832. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  11833. /**
  11834. * Enum used to define the target of a block
  11835. */
  11836. export enum NodeMaterialBlockTargets {
  11837. /** Vertex shader */
  11838. Vertex = 1,
  11839. /** Fragment shader */
  11840. Fragment = 2,
  11841. /** Neutral */
  11842. Neutral = 4,
  11843. /** Vertex and Fragment */
  11844. VertexAndFragment = 3
  11845. }
  11846. }
  11847. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  11848. /**
  11849. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11850. */
  11851. export enum NodeMaterialBlockConnectionPointMode {
  11852. /** Value is an uniform */
  11853. Uniform = 0,
  11854. /** Value is a mesh attribute */
  11855. Attribute = 1,
  11856. /** Value is a varying between vertex and fragment shaders */
  11857. Varying = 2,
  11858. /** Mode is undefined */
  11859. Undefined = 3
  11860. }
  11861. }
  11862. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  11863. /**
  11864. * Enum used to define system values e.g. values automatically provided by the system
  11865. */
  11866. export enum NodeMaterialSystemValues {
  11867. /** World */
  11868. World = 1,
  11869. /** View */
  11870. View = 2,
  11871. /** Projection */
  11872. Projection = 3,
  11873. /** ViewProjection */
  11874. ViewProjection = 4,
  11875. /** WorldView */
  11876. WorldView = 5,
  11877. /** WorldViewProjection */
  11878. WorldViewProjection = 6,
  11879. /** CameraPosition */
  11880. CameraPosition = 7,
  11881. /** Fog Color */
  11882. FogColor = 8,
  11883. /** Delta time */
  11884. DeltaTime = 9
  11885. }
  11886. }
  11887. declare module "babylonjs/Maths/math.frustum" {
  11888. import { Matrix } from "babylonjs/Maths/math.vector";
  11889. import { DeepImmutable } from "babylonjs/types";
  11890. import { Plane } from "babylonjs/Maths/math.plane";
  11891. /**
  11892. * Represents a camera frustum
  11893. */
  11894. export class Frustum {
  11895. /**
  11896. * Gets the planes representing the frustum
  11897. * @param transform matrix to be applied to the returned planes
  11898. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11899. */
  11900. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11901. /**
  11902. * Gets the near frustum plane transformed by the transform matrix
  11903. * @param transform transformation matrix to be applied to the resulting frustum plane
  11904. * @param frustumPlane the resuling frustum plane
  11905. */
  11906. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11907. /**
  11908. * Gets the far frustum plane transformed by the transform matrix
  11909. * @param transform transformation matrix to be applied to the resulting frustum plane
  11910. * @param frustumPlane the resuling frustum plane
  11911. */
  11912. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11913. /**
  11914. * Gets the left frustum plane transformed by the transform matrix
  11915. * @param transform transformation matrix to be applied to the resulting frustum plane
  11916. * @param frustumPlane the resuling frustum plane
  11917. */
  11918. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11919. /**
  11920. * Gets the right frustum plane transformed by the transform matrix
  11921. * @param transform transformation matrix to be applied to the resulting frustum plane
  11922. * @param frustumPlane the resuling frustum plane
  11923. */
  11924. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11925. /**
  11926. * Gets the top frustum plane transformed by the transform matrix
  11927. * @param transform transformation matrix to be applied to the resulting frustum plane
  11928. * @param frustumPlane the resuling frustum plane
  11929. */
  11930. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11931. /**
  11932. * Gets the bottom frustum plane transformed by the transform matrix
  11933. * @param transform transformation matrix to be applied to the resulting frustum plane
  11934. * @param frustumPlane the resuling frustum plane
  11935. */
  11936. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11937. /**
  11938. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11939. * @param transform transformation matrix to be applied to the resulting frustum planes
  11940. * @param frustumPlanes the resuling frustum planes
  11941. */
  11942. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11943. }
  11944. }
  11945. declare module "babylonjs/Maths/math.vertexFormat" {
  11946. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11947. /**
  11948. * Contains position and normal vectors for a vertex
  11949. */
  11950. export class PositionNormalVertex {
  11951. /** the position of the vertex (defaut: 0,0,0) */
  11952. position: Vector3;
  11953. /** the normal of the vertex (defaut: 0,1,0) */
  11954. normal: Vector3;
  11955. /**
  11956. * Creates a PositionNormalVertex
  11957. * @param position the position of the vertex (defaut: 0,0,0)
  11958. * @param normal the normal of the vertex (defaut: 0,1,0)
  11959. */
  11960. constructor(
  11961. /** the position of the vertex (defaut: 0,0,0) */
  11962. position?: Vector3,
  11963. /** the normal of the vertex (defaut: 0,1,0) */
  11964. normal?: Vector3);
  11965. /**
  11966. * Clones the PositionNormalVertex
  11967. * @returns the cloned PositionNormalVertex
  11968. */
  11969. clone(): PositionNormalVertex;
  11970. }
  11971. /**
  11972. * Contains position, normal and uv vectors for a vertex
  11973. */
  11974. export class PositionNormalTextureVertex {
  11975. /** the position of the vertex (defaut: 0,0,0) */
  11976. position: Vector3;
  11977. /** the normal of the vertex (defaut: 0,1,0) */
  11978. normal: Vector3;
  11979. /** the uv of the vertex (default: 0,0) */
  11980. uv: Vector2;
  11981. /**
  11982. * Creates a PositionNormalTextureVertex
  11983. * @param position the position of the vertex (defaut: 0,0,0)
  11984. * @param normal the normal of the vertex (defaut: 0,1,0)
  11985. * @param uv the uv of the vertex (default: 0,0)
  11986. */
  11987. constructor(
  11988. /** the position of the vertex (defaut: 0,0,0) */
  11989. position?: Vector3,
  11990. /** the normal of the vertex (defaut: 0,1,0) */
  11991. normal?: Vector3,
  11992. /** the uv of the vertex (default: 0,0) */
  11993. uv?: Vector2);
  11994. /**
  11995. * Clones the PositionNormalTextureVertex
  11996. * @returns the cloned PositionNormalTextureVertex
  11997. */
  11998. clone(): PositionNormalTextureVertex;
  11999. }
  12000. }
  12001. declare module "babylonjs/Maths/math" {
  12002. export * from "babylonjs/Maths/math.axis";
  12003. export * from "babylonjs/Maths/math.color";
  12004. export * from "babylonjs/Maths/math.constants";
  12005. export * from "babylonjs/Maths/math.frustum";
  12006. export * from "babylonjs/Maths/math.path";
  12007. export * from "babylonjs/Maths/math.plane";
  12008. export * from "babylonjs/Maths/math.size";
  12009. export * from "babylonjs/Maths/math.vector";
  12010. export * from "babylonjs/Maths/math.vertexFormat";
  12011. export * from "babylonjs/Maths/math.viewport";
  12012. }
  12013. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  12014. /**
  12015. * Enum defining the type of animations supported by InputBlock
  12016. */
  12017. export enum AnimatedInputBlockTypes {
  12018. /** No animation */
  12019. None = 0,
  12020. /** Time based animation. Will only work for floats */
  12021. Time = 1
  12022. }
  12023. }
  12024. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  12025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12026. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12027. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  12028. import { Nullable } from "babylonjs/types";
  12029. import { Effect } from "babylonjs/Materials/effect";
  12030. import { Matrix } from "babylonjs/Maths/math.vector";
  12031. import { Scene } from "babylonjs/scene";
  12032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12033. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12034. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12035. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  12036. import { Observable } from "babylonjs/Misc/observable";
  12037. /**
  12038. * Block used to expose an input value
  12039. */
  12040. export class InputBlock extends NodeMaterialBlock {
  12041. private _mode;
  12042. private _associatedVariableName;
  12043. private _storedValue;
  12044. private _valueCallback;
  12045. private _type;
  12046. private _animationType;
  12047. /** Gets or set a value used to limit the range of float values */
  12048. min: number;
  12049. /** Gets or set a value used to limit the range of float values */
  12050. max: number;
  12051. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12052. isBoolean: boolean;
  12053. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12054. matrixMode: number;
  12055. /** @hidden */
  12056. _systemValue: Nullable<NodeMaterialSystemValues>;
  12057. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12058. isConstant: boolean;
  12059. /** Gets or sets the group to use to display this block in the Inspector */
  12060. groupInInspector: string;
  12061. /** Gets an observable raised when the value is changed */
  12062. onValueChangedObservable: Observable<InputBlock>;
  12063. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12064. convertToGammaSpace: boolean;
  12065. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12066. convertToLinearSpace: boolean;
  12067. /**
  12068. * Gets or sets the connection point type (default is float)
  12069. */
  12070. get type(): NodeMaterialBlockConnectionPointTypes;
  12071. /**
  12072. * Creates a new InputBlock
  12073. * @param name defines the block name
  12074. * @param target defines the target of that block (Vertex by default)
  12075. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12076. */
  12077. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12078. /**
  12079. * Validates if a name is a reserve word.
  12080. * @param newName the new name to be given to the node.
  12081. * @returns false if the name is a reserve word, else true.
  12082. */
  12083. validateBlockName(newName: string): boolean;
  12084. /**
  12085. * Gets the output component
  12086. */
  12087. get output(): NodeMaterialConnectionPoint;
  12088. /**
  12089. * Set the source of this connection point to a vertex attribute
  12090. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12091. * @returns the current connection point
  12092. */
  12093. setAsAttribute(attributeName?: string): InputBlock;
  12094. /**
  12095. * Set the source of this connection point to a system value
  12096. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12097. * @returns the current connection point
  12098. */
  12099. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12100. /**
  12101. * Gets or sets the value of that point.
  12102. * Please note that this value will be ignored if valueCallback is defined
  12103. */
  12104. get value(): any;
  12105. set value(value: any);
  12106. /**
  12107. * Gets or sets a callback used to get the value of that point.
  12108. * Please note that setting this value will force the connection point to ignore the value property
  12109. */
  12110. get valueCallback(): () => any;
  12111. set valueCallback(value: () => any);
  12112. /**
  12113. * Gets or sets the associated variable name in the shader
  12114. */
  12115. get associatedVariableName(): string;
  12116. set associatedVariableName(value: string);
  12117. /** Gets or sets the type of animation applied to the input */
  12118. get animationType(): AnimatedInputBlockTypes;
  12119. set animationType(value: AnimatedInputBlockTypes);
  12120. /**
  12121. * Gets a boolean indicating that this connection point not defined yet
  12122. */
  12123. get isUndefined(): boolean;
  12124. /**
  12125. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12126. * In this case the connection point name must be the name of the uniform to use.
  12127. * Can only be set on inputs
  12128. */
  12129. get isUniform(): boolean;
  12130. set isUniform(value: boolean);
  12131. /**
  12132. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12133. * In this case the connection point name must be the name of the attribute to use
  12134. * Can only be set on inputs
  12135. */
  12136. get isAttribute(): boolean;
  12137. set isAttribute(value: boolean);
  12138. /**
  12139. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12140. * Can only be set on exit points
  12141. */
  12142. get isVarying(): boolean;
  12143. set isVarying(value: boolean);
  12144. /**
  12145. * Gets a boolean indicating that the current connection point is a system value
  12146. */
  12147. get isSystemValue(): boolean;
  12148. /**
  12149. * Gets or sets the current well known value or null if not defined as a system value
  12150. */
  12151. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12152. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12153. /**
  12154. * Gets the current class name
  12155. * @returns the class name
  12156. */
  12157. getClassName(): string;
  12158. /**
  12159. * Animate the input if animationType !== None
  12160. * @param scene defines the rendering scene
  12161. */
  12162. animate(scene: Scene): void;
  12163. private _emitDefine;
  12164. initialize(state: NodeMaterialBuildState): void;
  12165. /**
  12166. * Set the input block to its default value (based on its type)
  12167. */
  12168. setDefaultValue(): void;
  12169. private _emitConstant;
  12170. /** @hidden */
  12171. get _noContextSwitch(): boolean;
  12172. private _emit;
  12173. /** @hidden */
  12174. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12175. /** @hidden */
  12176. _transmit(effect: Effect, scene: Scene): void;
  12177. protected _buildBlock(state: NodeMaterialBuildState): void;
  12178. protected _dumpPropertiesCode(): string;
  12179. dispose(): void;
  12180. serialize(): any;
  12181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12182. }
  12183. }
  12184. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  12185. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12186. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12187. import { Nullable } from "babylonjs/types";
  12188. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12189. import { Observable } from "babylonjs/Misc/observable";
  12190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12191. /**
  12192. * Enum used to define the compatibility state between two connection points
  12193. */
  12194. export enum NodeMaterialConnectionPointCompatibilityStates {
  12195. /** Points are compatibles */
  12196. Compatible = 0,
  12197. /** Points are incompatible because of their types */
  12198. TypeIncompatible = 1,
  12199. /** Points are incompatible because of their targets (vertex vs fragment) */
  12200. TargetIncompatible = 2
  12201. }
  12202. /**
  12203. * Defines the direction of a connection point
  12204. */
  12205. export enum NodeMaterialConnectionPointDirection {
  12206. /** Input */
  12207. Input = 0,
  12208. /** Output */
  12209. Output = 1
  12210. }
  12211. /**
  12212. * Defines a connection point for a block
  12213. */
  12214. export class NodeMaterialConnectionPoint {
  12215. /**
  12216. * Checks if two types are equivalent
  12217. * @param type1 type 1 to check
  12218. * @param type2 type 2 to check
  12219. * @returns true if both types are equivalent, else false
  12220. */
  12221. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12222. /** @hidden */
  12223. _ownerBlock: NodeMaterialBlock;
  12224. /** @hidden */
  12225. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12226. private _endpoints;
  12227. private _associatedVariableName;
  12228. private _direction;
  12229. /** @hidden */
  12230. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12231. /** @hidden */
  12232. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12233. /** @hidden */
  12234. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12235. private _type;
  12236. /** @hidden */
  12237. _enforceAssociatedVariableName: boolean;
  12238. /** Gets the direction of the point */
  12239. get direction(): NodeMaterialConnectionPointDirection;
  12240. /** Indicates that this connection point needs dual validation before being connected to another point */
  12241. needDualDirectionValidation: boolean;
  12242. /**
  12243. * Gets or sets the additional types supported by this connection point
  12244. */
  12245. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12246. /**
  12247. * Gets or sets the additional types excluded by this connection point
  12248. */
  12249. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12250. /**
  12251. * Observable triggered when this point is connected
  12252. */
  12253. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12254. /**
  12255. * Gets or sets the associated variable name in the shader
  12256. */
  12257. get associatedVariableName(): string;
  12258. set associatedVariableName(value: string);
  12259. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12260. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12261. /**
  12262. * Gets or sets the connection point type (default is float)
  12263. */
  12264. get type(): NodeMaterialBlockConnectionPointTypes;
  12265. set type(value: NodeMaterialBlockConnectionPointTypes);
  12266. /**
  12267. * Gets or sets the connection point name
  12268. */
  12269. name: string;
  12270. /**
  12271. * Gets or sets the connection point name
  12272. */
  12273. displayName: string;
  12274. /**
  12275. * Gets or sets a boolean indicating that this connection point can be omitted
  12276. */
  12277. isOptional: boolean;
  12278. /**
  12279. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12280. */
  12281. isExposedOnFrame: boolean;
  12282. /**
  12283. * Gets or sets number indicating the position that the port is exposed to on a frame
  12284. */
  12285. exposedPortPosition: number;
  12286. /**
  12287. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12288. */
  12289. define: string;
  12290. /** @hidden */
  12291. _prioritizeVertex: boolean;
  12292. private _target;
  12293. /** Gets or sets the target of that connection point */
  12294. get target(): NodeMaterialBlockTargets;
  12295. set target(value: NodeMaterialBlockTargets);
  12296. /**
  12297. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12298. */
  12299. get isConnected(): boolean;
  12300. /**
  12301. * Gets a boolean indicating that the current point is connected to an input block
  12302. */
  12303. get isConnectedToInputBlock(): boolean;
  12304. /**
  12305. * Gets a the connected input block (if any)
  12306. */
  12307. get connectInputBlock(): Nullable<InputBlock>;
  12308. /** Get the other side of the connection (if any) */
  12309. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12310. /** Get the block that owns this connection point */
  12311. get ownerBlock(): NodeMaterialBlock;
  12312. /** Get the block connected on the other side of this connection (if any) */
  12313. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12314. /** Get the block connected on the endpoints of this connection (if any) */
  12315. get connectedBlocks(): Array<NodeMaterialBlock>;
  12316. /** Gets the list of connected endpoints */
  12317. get endpoints(): NodeMaterialConnectionPoint[];
  12318. /** Gets a boolean indicating if that output point is connected to at least one input */
  12319. get hasEndpoints(): boolean;
  12320. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12321. get isConnectedInVertexShader(): boolean;
  12322. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12323. get isConnectedInFragmentShader(): boolean;
  12324. /**
  12325. * Creates a block suitable to be used as an input for this input point.
  12326. * If null is returned, a block based on the point type will be created.
  12327. * @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
  12328. */
  12329. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12330. /**
  12331. * Creates a new connection point
  12332. * @param name defines the connection point name
  12333. * @param ownerBlock defines the block hosting this connection point
  12334. * @param direction defines the direction of the connection point
  12335. */
  12336. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12337. /**
  12338. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12339. * @returns the class name
  12340. */
  12341. getClassName(): string;
  12342. /**
  12343. * Gets a boolean indicating if the current point can be connected to another point
  12344. * @param connectionPoint defines the other connection point
  12345. * @returns a boolean
  12346. */
  12347. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12348. /**
  12349. * Gets a number indicating if the current point can be connected to another point
  12350. * @param connectionPoint defines the other connection point
  12351. * @returns a number defining the compatibility state
  12352. */
  12353. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12354. /**
  12355. * Connect this point to another connection point
  12356. * @param connectionPoint defines the other connection point
  12357. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12358. * @returns the current connection point
  12359. */
  12360. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12361. /**
  12362. * Disconnect this point from one of his endpoint
  12363. * @param endpoint defines the other connection point
  12364. * @returns the current connection point
  12365. */
  12366. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12367. /**
  12368. * Serializes this point in a JSON representation
  12369. * @param isInput defines if the connection point is an input (default is true)
  12370. * @returns the serialized point object
  12371. */
  12372. serialize(isInput?: boolean): any;
  12373. /**
  12374. * Release resources
  12375. */
  12376. dispose(): void;
  12377. }
  12378. }
  12379. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  12380. /**
  12381. * Enum used to define the material modes
  12382. */
  12383. export enum NodeMaterialModes {
  12384. /** Regular material */
  12385. Material = 0,
  12386. /** For post process */
  12387. PostProcess = 1,
  12388. /** For particle system */
  12389. Particle = 2,
  12390. /** For procedural texture */
  12391. ProceduralTexture = 3
  12392. }
  12393. }
  12394. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  12395. /** @hidden */
  12396. export var helperFunctions: {
  12397. name: string;
  12398. shader: string;
  12399. };
  12400. }
  12401. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  12402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12404. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12405. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12407. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12408. import { Effect } from "babylonjs/Materials/effect";
  12409. import { Mesh } from "babylonjs/Meshes/mesh";
  12410. import { Nullable } from "babylonjs/types";
  12411. import { Texture } from "babylonjs/Materials/Textures/texture";
  12412. import { Scene } from "babylonjs/scene";
  12413. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12414. /**
  12415. * Block used to read a texture from a sampler
  12416. */
  12417. export class TextureBlock extends NodeMaterialBlock {
  12418. private _defineName;
  12419. private _linearDefineName;
  12420. private _gammaDefineName;
  12421. private _tempTextureRead;
  12422. private _samplerName;
  12423. private _transformedUVName;
  12424. private _textureTransformName;
  12425. private _textureInfoName;
  12426. private _mainUVName;
  12427. private _mainUVDefineName;
  12428. private _fragmentOnly;
  12429. /**
  12430. * Gets or sets the texture associated with the node
  12431. */
  12432. texture: Nullable<Texture>;
  12433. /**
  12434. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12435. */
  12436. convertToGammaSpace: boolean;
  12437. /**
  12438. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12439. */
  12440. convertToLinearSpace: boolean;
  12441. /**
  12442. * Create a new TextureBlock
  12443. * @param name defines the block name
  12444. */
  12445. constructor(name: string, fragmentOnly?: boolean);
  12446. /**
  12447. * Gets the current class name
  12448. * @returns the class name
  12449. */
  12450. getClassName(): string;
  12451. /**
  12452. * Gets the uv input component
  12453. */
  12454. get uv(): NodeMaterialConnectionPoint;
  12455. /**
  12456. * Gets the rgba output component
  12457. */
  12458. get rgba(): NodeMaterialConnectionPoint;
  12459. /**
  12460. * Gets the rgb output component
  12461. */
  12462. get rgb(): NodeMaterialConnectionPoint;
  12463. /**
  12464. * Gets the r output component
  12465. */
  12466. get r(): NodeMaterialConnectionPoint;
  12467. /**
  12468. * Gets the g output component
  12469. */
  12470. get g(): NodeMaterialConnectionPoint;
  12471. /**
  12472. * Gets the b output component
  12473. */
  12474. get b(): NodeMaterialConnectionPoint;
  12475. /**
  12476. * Gets the a output component
  12477. */
  12478. get a(): NodeMaterialConnectionPoint;
  12479. get target(): NodeMaterialBlockTargets;
  12480. autoConfigure(material: NodeMaterial): void;
  12481. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12482. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12483. isReady(): boolean;
  12484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12485. private get _isMixed();
  12486. private _injectVertexCode;
  12487. private _writeTextureRead;
  12488. private _writeOutput;
  12489. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12490. protected _dumpPropertiesCode(): string;
  12491. serialize(): any;
  12492. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12493. }
  12494. }
  12495. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  12496. /** @hidden */
  12497. export var reflectionFunction: {
  12498. name: string;
  12499. shader: string;
  12500. };
  12501. }
  12502. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  12503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12508. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12509. import { Effect } from "babylonjs/Materials/effect";
  12510. import { Mesh } from "babylonjs/Meshes/mesh";
  12511. import { Nullable } from "babylonjs/types";
  12512. import { Scene } from "babylonjs/scene";
  12513. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  12514. /**
  12515. * Base block used to read a reflection texture from a sampler
  12516. */
  12517. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12518. /** @hidden */
  12519. _define3DName: string;
  12520. /** @hidden */
  12521. _defineCubicName: string;
  12522. /** @hidden */
  12523. _defineExplicitName: string;
  12524. /** @hidden */
  12525. _defineProjectionName: string;
  12526. /** @hidden */
  12527. _defineLocalCubicName: string;
  12528. /** @hidden */
  12529. _defineSphericalName: string;
  12530. /** @hidden */
  12531. _definePlanarName: string;
  12532. /** @hidden */
  12533. _defineEquirectangularName: string;
  12534. /** @hidden */
  12535. _defineMirroredEquirectangularFixedName: string;
  12536. /** @hidden */
  12537. _defineEquirectangularFixedName: string;
  12538. /** @hidden */
  12539. _defineSkyboxName: string;
  12540. /** @hidden */
  12541. _defineOppositeZ: string;
  12542. /** @hidden */
  12543. _cubeSamplerName: string;
  12544. /** @hidden */
  12545. _2DSamplerName: string;
  12546. protected _positionUVWName: string;
  12547. protected _directionWName: string;
  12548. protected _reflectionVectorName: string;
  12549. /** @hidden */
  12550. _reflectionCoordsName: string;
  12551. /** @hidden */
  12552. _reflectionMatrixName: string;
  12553. protected _reflectionColorName: string;
  12554. /**
  12555. * Gets or sets the texture associated with the node
  12556. */
  12557. texture: Nullable<BaseTexture>;
  12558. /**
  12559. * Create a new ReflectionTextureBaseBlock
  12560. * @param name defines the block name
  12561. */
  12562. constructor(name: string);
  12563. /**
  12564. * Gets the current class name
  12565. * @returns the class name
  12566. */
  12567. getClassName(): string;
  12568. /**
  12569. * Gets the world position input component
  12570. */
  12571. abstract get position(): NodeMaterialConnectionPoint;
  12572. /**
  12573. * Gets the world position input component
  12574. */
  12575. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12576. /**
  12577. * Gets the world normal input component
  12578. */
  12579. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12580. /**
  12581. * Gets the world input component
  12582. */
  12583. abstract get world(): NodeMaterialConnectionPoint;
  12584. /**
  12585. * Gets the camera (or eye) position component
  12586. */
  12587. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12588. /**
  12589. * Gets the view input component
  12590. */
  12591. abstract get view(): NodeMaterialConnectionPoint;
  12592. protected _getTexture(): Nullable<BaseTexture>;
  12593. autoConfigure(material: NodeMaterial): void;
  12594. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12595. isReady(): boolean;
  12596. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12597. /**
  12598. * Gets the code to inject in the vertex shader
  12599. * @param state current state of the node material building
  12600. * @returns the shader code
  12601. */
  12602. handleVertexSide(state: NodeMaterialBuildState): string;
  12603. /**
  12604. * Handles the inits for the fragment code path
  12605. * @param state node material build state
  12606. */
  12607. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12608. /**
  12609. * Generates the reflection coords code for the fragment code path
  12610. * @param worldNormalVarName name of the world normal variable
  12611. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12612. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12613. * @returns the shader code
  12614. */
  12615. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12616. /**
  12617. * Generates the reflection color code for the fragment code path
  12618. * @param lodVarName name of the lod variable
  12619. * @param swizzleLookupTexture swizzle to use for the final color variable
  12620. * @returns the shader code
  12621. */
  12622. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12623. /**
  12624. * Generates the code corresponding to the connected output points
  12625. * @param state node material build state
  12626. * @param varName name of the variable to output
  12627. * @returns the shader code
  12628. */
  12629. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12630. protected _buildBlock(state: NodeMaterialBuildState): this;
  12631. protected _dumpPropertiesCode(): string;
  12632. serialize(): any;
  12633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12634. }
  12635. }
  12636. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  12637. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12638. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12639. import { Nullable } from "babylonjs/types";
  12640. /**
  12641. * Defines a connection point to be used for points with a custom object type
  12642. */
  12643. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12644. private _blockType;
  12645. private _blockName;
  12646. private _nameForCheking?;
  12647. /**
  12648. * Creates a new connection point
  12649. * @param name defines the connection point name
  12650. * @param ownerBlock defines the block hosting this connection point
  12651. * @param direction defines the direction of the connection point
  12652. */
  12653. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12654. /**
  12655. * Gets a number indicating if the current point can be connected to another point
  12656. * @param connectionPoint defines the other connection point
  12657. * @returns a number defining the compatibility state
  12658. */
  12659. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12660. /**
  12661. * Creates a block suitable to be used as an input for this input point.
  12662. * If null is returned, a block based on the point type will be created.
  12663. * @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
  12664. */
  12665. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12666. }
  12667. }
  12668. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  12669. /**
  12670. * Enum defining the type of properties that can be edited in the property pages in the NME
  12671. */
  12672. export enum PropertyTypeForEdition {
  12673. /** property is a boolean */
  12674. Boolean = 0,
  12675. /** property is a float */
  12676. Float = 1,
  12677. /** property is a Vector2 */
  12678. Vector2 = 2,
  12679. /** property is a list of values */
  12680. List = 3
  12681. }
  12682. /**
  12683. * Interface that defines an option in a variable of type list
  12684. */
  12685. export interface IEditablePropertyListOption {
  12686. /** label of the option */
  12687. "label": string;
  12688. /** value of the option */
  12689. "value": number;
  12690. }
  12691. /**
  12692. * Interface that defines the options available for an editable property
  12693. */
  12694. export interface IEditablePropertyOption {
  12695. /** min value */
  12696. "min"?: number;
  12697. /** max value */
  12698. "max"?: number;
  12699. /** notifiers: indicates which actions to take when the property is changed */
  12700. "notifiers"?: {
  12701. /** the material should be rebuilt */
  12702. "rebuild"?: boolean;
  12703. /** the preview should be updated */
  12704. "update"?: boolean;
  12705. };
  12706. /** list of the options for a variable of type list */
  12707. "options"?: IEditablePropertyListOption[];
  12708. }
  12709. /**
  12710. * Interface that describes an editable property
  12711. */
  12712. export interface IPropertyDescriptionForEdition {
  12713. /** name of the property */
  12714. "propertyName": string;
  12715. /** display name of the property */
  12716. "displayName": string;
  12717. /** type of the property */
  12718. "type": PropertyTypeForEdition;
  12719. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12720. "groupName": string;
  12721. /** options for the property */
  12722. "options": IEditablePropertyOption;
  12723. }
  12724. /**
  12725. * Decorator that flags a property in a node material block as being editable
  12726. */
  12727. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12728. }
  12729. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  12730. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12731. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12732. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12734. import { Nullable } from "babylonjs/types";
  12735. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12736. import { Mesh } from "babylonjs/Meshes/mesh";
  12737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12738. import { Effect } from "babylonjs/Materials/effect";
  12739. import { Scene } from "babylonjs/scene";
  12740. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12741. /**
  12742. * Block used to implement the refraction part of the sub surface module of the PBR material
  12743. */
  12744. export class RefractionBlock extends NodeMaterialBlock {
  12745. /** @hidden */
  12746. _define3DName: string;
  12747. /** @hidden */
  12748. _refractionMatrixName: string;
  12749. /** @hidden */
  12750. _defineLODRefractionAlpha: string;
  12751. /** @hidden */
  12752. _defineLinearSpecularRefraction: string;
  12753. /** @hidden */
  12754. _defineOppositeZ: string;
  12755. /** @hidden */
  12756. _cubeSamplerName: string;
  12757. /** @hidden */
  12758. _2DSamplerName: string;
  12759. /** @hidden */
  12760. _vRefractionMicrosurfaceInfosName: string;
  12761. /** @hidden */
  12762. _vRefractionInfosName: string;
  12763. /** @hidden */
  12764. _vRefractionFilteringInfoName: string;
  12765. private _scene;
  12766. /**
  12767. * The properties below are set by the main PBR block prior to calling methods of this class.
  12768. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12769. * It's less burden on the user side in the editor part.
  12770. */
  12771. /** @hidden */
  12772. viewConnectionPoint: NodeMaterialConnectionPoint;
  12773. /** @hidden */
  12774. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12775. /**
  12776. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12777. * Materials half opaque for instance using refraction could benefit from this control.
  12778. */
  12779. linkRefractionWithTransparency: boolean;
  12780. /**
  12781. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12782. */
  12783. invertRefractionY: boolean;
  12784. /**
  12785. * Gets or sets the texture associated with the node
  12786. */
  12787. texture: Nullable<BaseTexture>;
  12788. /**
  12789. * Create a new RefractionBlock
  12790. * @param name defines the block name
  12791. */
  12792. constructor(name: string);
  12793. /**
  12794. * Gets the current class name
  12795. * @returns the class name
  12796. */
  12797. getClassName(): string;
  12798. /**
  12799. * Gets the intensity input component
  12800. */
  12801. get intensity(): NodeMaterialConnectionPoint;
  12802. /**
  12803. * Gets the tint at distance input component
  12804. */
  12805. get tintAtDistance(): NodeMaterialConnectionPoint;
  12806. /**
  12807. * Gets the view input component
  12808. */
  12809. get view(): NodeMaterialConnectionPoint;
  12810. /**
  12811. * Gets the refraction object output component
  12812. */
  12813. get refraction(): NodeMaterialConnectionPoint;
  12814. /**
  12815. * Returns true if the block has a texture
  12816. */
  12817. get hasTexture(): boolean;
  12818. protected _getTexture(): Nullable<BaseTexture>;
  12819. autoConfigure(material: NodeMaterial): void;
  12820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12821. isReady(): boolean;
  12822. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12823. /**
  12824. * Gets the main code of the block (fragment side)
  12825. * @param state current state of the node material building
  12826. * @returns the shader code
  12827. */
  12828. getCode(state: NodeMaterialBuildState): string;
  12829. protected _buildBlock(state: NodeMaterialBuildState): this;
  12830. protected _dumpPropertiesCode(): string;
  12831. serialize(): any;
  12832. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12833. }
  12834. }
  12835. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  12836. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12837. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12838. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12841. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12843. import { Nullable } from "babylonjs/types";
  12844. import { Scene } from "babylonjs/scene";
  12845. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12846. /**
  12847. * Base block used as input for post process
  12848. */
  12849. export class CurrentScreenBlock extends NodeMaterialBlock {
  12850. private _samplerName;
  12851. private _linearDefineName;
  12852. private _gammaDefineName;
  12853. private _mainUVName;
  12854. private _tempTextureRead;
  12855. /**
  12856. * Gets or sets the texture associated with the node
  12857. */
  12858. texture: Nullable<BaseTexture>;
  12859. /**
  12860. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12861. */
  12862. convertToGammaSpace: boolean;
  12863. /**
  12864. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12865. */
  12866. convertToLinearSpace: boolean;
  12867. /**
  12868. * Create a new CurrentScreenBlock
  12869. * @param name defines the block name
  12870. */
  12871. constructor(name: string);
  12872. /**
  12873. * Gets the current class name
  12874. * @returns the class name
  12875. */
  12876. getClassName(): string;
  12877. /**
  12878. * Gets the uv input component
  12879. */
  12880. get uv(): NodeMaterialConnectionPoint;
  12881. /**
  12882. * Gets the rgba output component
  12883. */
  12884. get rgba(): NodeMaterialConnectionPoint;
  12885. /**
  12886. * Gets the rgb output component
  12887. */
  12888. get rgb(): NodeMaterialConnectionPoint;
  12889. /**
  12890. * Gets the r output component
  12891. */
  12892. get r(): NodeMaterialConnectionPoint;
  12893. /**
  12894. * Gets the g output component
  12895. */
  12896. get g(): NodeMaterialConnectionPoint;
  12897. /**
  12898. * Gets the b output component
  12899. */
  12900. get b(): NodeMaterialConnectionPoint;
  12901. /**
  12902. * Gets the a output component
  12903. */
  12904. get a(): NodeMaterialConnectionPoint;
  12905. /**
  12906. * Initialize the block and prepare the context for build
  12907. * @param state defines the state that will be used for the build
  12908. */
  12909. initialize(state: NodeMaterialBuildState): void;
  12910. get target(): NodeMaterialBlockTargets;
  12911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12912. isReady(): boolean;
  12913. private _injectVertexCode;
  12914. private _writeTextureRead;
  12915. private _writeOutput;
  12916. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12917. serialize(): any;
  12918. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12919. }
  12920. }
  12921. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  12922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12926. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12928. import { Nullable } from "babylonjs/types";
  12929. import { Scene } from "babylonjs/scene";
  12930. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12931. /**
  12932. * Base block used for the particle texture
  12933. */
  12934. export class ParticleTextureBlock extends NodeMaterialBlock {
  12935. private _samplerName;
  12936. private _linearDefineName;
  12937. private _gammaDefineName;
  12938. private _tempTextureRead;
  12939. /**
  12940. * Gets or sets the texture associated with the node
  12941. */
  12942. texture: Nullable<BaseTexture>;
  12943. /**
  12944. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12945. */
  12946. convertToGammaSpace: boolean;
  12947. /**
  12948. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12949. */
  12950. convertToLinearSpace: boolean;
  12951. /**
  12952. * Create a new ParticleTextureBlock
  12953. * @param name defines the block name
  12954. */
  12955. constructor(name: string);
  12956. /**
  12957. * Gets the current class name
  12958. * @returns the class name
  12959. */
  12960. getClassName(): string;
  12961. /**
  12962. * Gets the uv input component
  12963. */
  12964. get uv(): NodeMaterialConnectionPoint;
  12965. /**
  12966. * Gets the rgba output component
  12967. */
  12968. get rgba(): NodeMaterialConnectionPoint;
  12969. /**
  12970. * Gets the rgb output component
  12971. */
  12972. get rgb(): NodeMaterialConnectionPoint;
  12973. /**
  12974. * Gets the r output component
  12975. */
  12976. get r(): NodeMaterialConnectionPoint;
  12977. /**
  12978. * Gets the g output component
  12979. */
  12980. get g(): NodeMaterialConnectionPoint;
  12981. /**
  12982. * Gets the b output component
  12983. */
  12984. get b(): NodeMaterialConnectionPoint;
  12985. /**
  12986. * Gets the a output component
  12987. */
  12988. get a(): NodeMaterialConnectionPoint;
  12989. /**
  12990. * Initialize the block and prepare the context for build
  12991. * @param state defines the state that will be used for the build
  12992. */
  12993. initialize(state: NodeMaterialBuildState): void;
  12994. autoConfigure(material: NodeMaterial): void;
  12995. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12996. isReady(): boolean;
  12997. private _writeOutput;
  12998. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12999. serialize(): any;
  13000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13001. }
  13002. }
  13003. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  13004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13006. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  13007. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  13008. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  13009. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  13010. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  13011. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  13012. import { Scene } from "babylonjs/scene";
  13013. /**
  13014. * Class used to store shared data between 2 NodeMaterialBuildState
  13015. */
  13016. export class NodeMaterialBuildStateSharedData {
  13017. /**
  13018. * Gets the list of emitted varyings
  13019. */
  13020. temps: string[];
  13021. /**
  13022. * Gets the list of emitted varyings
  13023. */
  13024. varyings: string[];
  13025. /**
  13026. * Gets the varying declaration string
  13027. */
  13028. varyingDeclaration: string;
  13029. /**
  13030. * Input blocks
  13031. */
  13032. inputBlocks: InputBlock[];
  13033. /**
  13034. * Input blocks
  13035. */
  13036. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13037. /**
  13038. * Bindable blocks (Blocks that need to set data to the effect)
  13039. */
  13040. bindableBlocks: NodeMaterialBlock[];
  13041. /**
  13042. * List of blocks that can provide a compilation fallback
  13043. */
  13044. blocksWithFallbacks: NodeMaterialBlock[];
  13045. /**
  13046. * List of blocks that can provide a define update
  13047. */
  13048. blocksWithDefines: NodeMaterialBlock[];
  13049. /**
  13050. * List of blocks that can provide a repeatable content
  13051. */
  13052. repeatableContentBlocks: NodeMaterialBlock[];
  13053. /**
  13054. * List of blocks that can provide a dynamic list of uniforms
  13055. */
  13056. dynamicUniformBlocks: NodeMaterialBlock[];
  13057. /**
  13058. * List of blocks that can block the isReady function for the material
  13059. */
  13060. blockingBlocks: NodeMaterialBlock[];
  13061. /**
  13062. * Gets the list of animated inputs
  13063. */
  13064. animatedInputs: InputBlock[];
  13065. /**
  13066. * Build Id used to avoid multiple recompilations
  13067. */
  13068. buildId: number;
  13069. /** List of emitted variables */
  13070. variableNames: {
  13071. [key: string]: number;
  13072. };
  13073. /** List of emitted defines */
  13074. defineNames: {
  13075. [key: string]: number;
  13076. };
  13077. /** Should emit comments? */
  13078. emitComments: boolean;
  13079. /** Emit build activity */
  13080. verbose: boolean;
  13081. /** Gets or sets the hosting scene */
  13082. scene: Scene;
  13083. /**
  13084. * Gets the compilation hints emitted at compilation time
  13085. */
  13086. hints: {
  13087. needWorldViewMatrix: boolean;
  13088. needWorldViewProjectionMatrix: boolean;
  13089. needAlphaBlending: boolean;
  13090. needAlphaTesting: boolean;
  13091. };
  13092. /**
  13093. * List of compilation checks
  13094. */
  13095. checks: {
  13096. emitVertex: boolean;
  13097. emitFragment: boolean;
  13098. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13099. };
  13100. /**
  13101. * Is vertex program allowed to be empty?
  13102. */
  13103. allowEmptyVertexProgram: boolean;
  13104. /** Creates a new shared data */
  13105. constructor();
  13106. /**
  13107. * Emits console errors and exceptions if there is a failing check
  13108. */
  13109. emitErrors(): void;
  13110. }
  13111. }
  13112. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  13113. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13114. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13115. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  13116. /**
  13117. * Class used to store node based material build state
  13118. */
  13119. export class NodeMaterialBuildState {
  13120. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13121. supportUniformBuffers: boolean;
  13122. /**
  13123. * Gets the list of emitted attributes
  13124. */
  13125. attributes: string[];
  13126. /**
  13127. * Gets the list of emitted uniforms
  13128. */
  13129. uniforms: string[];
  13130. /**
  13131. * Gets the list of emitted constants
  13132. */
  13133. constants: string[];
  13134. /**
  13135. * Gets the list of emitted samplers
  13136. */
  13137. samplers: string[];
  13138. /**
  13139. * Gets the list of emitted functions
  13140. */
  13141. functions: {
  13142. [key: string]: string;
  13143. };
  13144. /**
  13145. * Gets the list of emitted extensions
  13146. */
  13147. extensions: {
  13148. [key: string]: string;
  13149. };
  13150. /**
  13151. * Gets the target of the compilation state
  13152. */
  13153. target: NodeMaterialBlockTargets;
  13154. /**
  13155. * Gets the list of emitted counters
  13156. */
  13157. counters: {
  13158. [key: string]: number;
  13159. };
  13160. /**
  13161. * Shared data between multiple NodeMaterialBuildState instances
  13162. */
  13163. sharedData: NodeMaterialBuildStateSharedData;
  13164. /** @hidden */
  13165. _vertexState: NodeMaterialBuildState;
  13166. /** @hidden */
  13167. _attributeDeclaration: string;
  13168. /** @hidden */
  13169. _uniformDeclaration: string;
  13170. /** @hidden */
  13171. _constantDeclaration: string;
  13172. /** @hidden */
  13173. _samplerDeclaration: string;
  13174. /** @hidden */
  13175. _varyingTransfer: string;
  13176. /** @hidden */
  13177. _injectAtEnd: string;
  13178. private _repeatableContentAnchorIndex;
  13179. /** @hidden */
  13180. _builtCompilationString: string;
  13181. /**
  13182. * Gets the emitted compilation strings
  13183. */
  13184. compilationString: string;
  13185. /**
  13186. * Finalize the compilation strings
  13187. * @param state defines the current compilation state
  13188. */
  13189. finalize(state: NodeMaterialBuildState): void;
  13190. /** @hidden */
  13191. get _repeatableContentAnchor(): string;
  13192. /** @hidden */
  13193. _getFreeVariableName(prefix: string): string;
  13194. /** @hidden */
  13195. _getFreeDefineName(prefix: string): string;
  13196. /** @hidden */
  13197. _excludeVariableName(name: string): void;
  13198. /** @hidden */
  13199. _emit2DSampler(name: string): void;
  13200. /** @hidden */
  13201. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13202. /** @hidden */
  13203. _emitExtension(name: string, extension: string, define?: string): void;
  13204. /** @hidden */
  13205. _emitFunction(name: string, code: string, comments: string): void;
  13206. /** @hidden */
  13207. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13208. replaceStrings?: {
  13209. search: RegExp;
  13210. replace: string;
  13211. }[];
  13212. repeatKey?: string;
  13213. }): string;
  13214. /** @hidden */
  13215. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13216. repeatKey?: string;
  13217. removeAttributes?: boolean;
  13218. removeUniforms?: boolean;
  13219. removeVaryings?: boolean;
  13220. removeIfDef?: boolean;
  13221. replaceStrings?: {
  13222. search: RegExp;
  13223. replace: string;
  13224. }[];
  13225. }, storeKey?: string): void;
  13226. /** @hidden */
  13227. _registerTempVariable(name: string): boolean;
  13228. /** @hidden */
  13229. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13230. /** @hidden */
  13231. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13232. /** @hidden */
  13233. _emitFloat(value: number): string;
  13234. }
  13235. }
  13236. declare module "babylonjs/Misc/uniqueIdGenerator" {
  13237. /**
  13238. * Helper class used to generate session unique ID
  13239. */
  13240. export class UniqueIdGenerator {
  13241. private static _UniqueIdCounter;
  13242. /**
  13243. * Gets an unique (relatively to the current scene) Id
  13244. */
  13245. static get UniqueId(): number;
  13246. }
  13247. }
  13248. declare module "babylonjs/Materials/effectFallbacks" {
  13249. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  13250. import { Effect } from "babylonjs/Materials/effect";
  13251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13252. /**
  13253. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13254. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13255. */
  13256. export class EffectFallbacks implements IEffectFallbacks {
  13257. private _defines;
  13258. private _currentRank;
  13259. private _maxRank;
  13260. private _mesh;
  13261. /**
  13262. * Removes the fallback from the bound mesh.
  13263. */
  13264. unBindMesh(): void;
  13265. /**
  13266. * Adds a fallback on the specified property.
  13267. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13268. * @param define The name of the define in the shader
  13269. */
  13270. addFallback(rank: number, define: string): void;
  13271. /**
  13272. * Sets the mesh to use CPU skinning when needing to fallback.
  13273. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13274. * @param mesh The mesh to use the fallbacks.
  13275. */
  13276. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13277. /**
  13278. * Checks to see if more fallbacks are still availible.
  13279. */
  13280. get hasMoreFallbacks(): boolean;
  13281. /**
  13282. * Removes the defines that should be removed when falling back.
  13283. * @param currentDefines defines the current define statements for the shader.
  13284. * @param effect defines the current effect we try to compile
  13285. * @returns The resulting defines with defines of the current rank removed.
  13286. */
  13287. reduce(currentDefines: string, effect: Effect): string;
  13288. }
  13289. }
  13290. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  13291. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13292. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13293. import { Nullable } from "babylonjs/types";
  13294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13295. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13296. import { Effect } from "babylonjs/Materials/effect";
  13297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13298. import { Mesh } from "babylonjs/Meshes/mesh";
  13299. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13300. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13301. import { Scene } from "babylonjs/scene";
  13302. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  13303. /**
  13304. * Defines a block that can be used inside a node based material
  13305. */
  13306. export class NodeMaterialBlock {
  13307. private _buildId;
  13308. private _buildTarget;
  13309. private _target;
  13310. private _isFinalMerger;
  13311. private _isInput;
  13312. private _name;
  13313. protected _isUnique: boolean;
  13314. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13315. inputsAreExclusive: boolean;
  13316. /** @hidden */
  13317. _codeVariableName: string;
  13318. /** @hidden */
  13319. _inputs: NodeMaterialConnectionPoint[];
  13320. /** @hidden */
  13321. _outputs: NodeMaterialConnectionPoint[];
  13322. /** @hidden */
  13323. _preparationId: number;
  13324. /**
  13325. * Gets the name of the block
  13326. */
  13327. get name(): string;
  13328. /**
  13329. * Sets the name of the block. Will check if the name is valid.
  13330. */
  13331. set name(newName: string);
  13332. /**
  13333. * Gets or sets the unique id of the node
  13334. */
  13335. uniqueId: number;
  13336. /**
  13337. * Gets or sets the comments associated with this block
  13338. */
  13339. comments: string;
  13340. /**
  13341. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13342. */
  13343. get isUnique(): boolean;
  13344. /**
  13345. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13346. */
  13347. get isFinalMerger(): boolean;
  13348. /**
  13349. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13350. */
  13351. get isInput(): boolean;
  13352. /**
  13353. * Gets or sets the build Id
  13354. */
  13355. get buildId(): number;
  13356. set buildId(value: number);
  13357. /**
  13358. * Gets or sets the target of the block
  13359. */
  13360. get target(): NodeMaterialBlockTargets;
  13361. set target(value: NodeMaterialBlockTargets);
  13362. /**
  13363. * Gets the list of input points
  13364. */
  13365. get inputs(): NodeMaterialConnectionPoint[];
  13366. /** Gets the list of output points */
  13367. get outputs(): NodeMaterialConnectionPoint[];
  13368. /**
  13369. * Find an input by its name
  13370. * @param name defines the name of the input to look for
  13371. * @returns the input or null if not found
  13372. */
  13373. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13374. /**
  13375. * Find an output by its name
  13376. * @param name defines the name of the outputto look for
  13377. * @returns the output or null if not found
  13378. */
  13379. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13380. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13381. visibleInInspector: boolean;
  13382. /**
  13383. * Creates a new NodeMaterialBlock
  13384. * @param name defines the block name
  13385. * @param target defines the target of that block (Vertex by default)
  13386. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13387. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13388. */
  13389. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13390. /**
  13391. * Initialize the block and prepare the context for build
  13392. * @param state defines the state that will be used for the build
  13393. */
  13394. initialize(state: NodeMaterialBuildState): void;
  13395. /**
  13396. * Bind data to effect. Will only be called for blocks with isBindable === true
  13397. * @param effect defines the effect to bind data to
  13398. * @param nodeMaterial defines the hosting NodeMaterial
  13399. * @param mesh defines the mesh that will be rendered
  13400. * @param subMesh defines the submesh that will be rendered
  13401. */
  13402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13403. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13404. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13405. protected _writeFloat(value: number): string;
  13406. /**
  13407. * Gets the current class name e.g. "NodeMaterialBlock"
  13408. * @returns the class name
  13409. */
  13410. getClassName(): string;
  13411. /**
  13412. * Register a new input. Must be called inside a block constructor
  13413. * @param name defines the connection point name
  13414. * @param type defines the connection point type
  13415. * @param isOptional defines a boolean indicating that this input can be omitted
  13416. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13417. * @param point an already created connection point. If not provided, create a new one
  13418. * @returns the current block
  13419. */
  13420. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13421. /**
  13422. * Register a new output. Must be called inside a block constructor
  13423. * @param name defines the connection point name
  13424. * @param type defines the connection point type
  13425. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13426. * @param point an already created connection point. If not provided, create a new one
  13427. * @returns the current block
  13428. */
  13429. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13430. /**
  13431. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13432. * @param forOutput defines an optional connection point to check compatibility with
  13433. * @returns the first available input or null
  13434. */
  13435. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13436. /**
  13437. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13438. * @param forBlock defines an optional block to check compatibility with
  13439. * @returns the first available input or null
  13440. */
  13441. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13442. /**
  13443. * Gets the sibling of the given output
  13444. * @param current defines the current output
  13445. * @returns the next output in the list or null
  13446. */
  13447. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13448. /**
  13449. * Connect current block with another block
  13450. * @param other defines the block to connect with
  13451. * @param options define the various options to help pick the right connections
  13452. * @returns the current block
  13453. */
  13454. connectTo(other: NodeMaterialBlock, options?: {
  13455. input?: string;
  13456. output?: string;
  13457. outputSwizzle?: string;
  13458. }): this | undefined;
  13459. protected _buildBlock(state: NodeMaterialBuildState): void;
  13460. /**
  13461. * Add uniforms, samplers and uniform buffers at compilation time
  13462. * @param state defines the state to update
  13463. * @param nodeMaterial defines the node material requesting the update
  13464. * @param defines defines the material defines to update
  13465. * @param uniformBuffers defines the list of uniform buffer names
  13466. */
  13467. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13468. /**
  13469. * Add potential fallbacks if shader compilation fails
  13470. * @param mesh defines the mesh to be rendered
  13471. * @param fallbacks defines the current prioritized list of fallbacks
  13472. */
  13473. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13474. /**
  13475. * Initialize defines for shader compilation
  13476. * @param mesh defines the mesh to be rendered
  13477. * @param nodeMaterial defines the node material requesting the update
  13478. * @param defines defines the material defines to update
  13479. * @param useInstances specifies that instances should be used
  13480. */
  13481. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13482. /**
  13483. * Update defines for shader compilation
  13484. * @param mesh defines the mesh to be rendered
  13485. * @param nodeMaterial defines the node material requesting the update
  13486. * @param defines defines the material defines to update
  13487. * @param useInstances specifies that instances should be used
  13488. * @param subMesh defines which submesh to render
  13489. */
  13490. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13491. /**
  13492. * Lets the block try to connect some inputs automatically
  13493. * @param material defines the hosting NodeMaterial
  13494. */
  13495. autoConfigure(material: NodeMaterial): void;
  13496. /**
  13497. * Function called when a block is declared as repeatable content generator
  13498. * @param vertexShaderState defines the current compilation state for the vertex shader
  13499. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13500. * @param mesh defines the mesh to be rendered
  13501. * @param defines defines the material defines to update
  13502. */
  13503. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13504. /**
  13505. * Checks if the block is ready
  13506. * @param mesh defines the mesh to be rendered
  13507. * @param nodeMaterial defines the node material requesting the update
  13508. * @param defines defines the material defines to update
  13509. * @param useInstances specifies that instances should be used
  13510. * @returns true if the block is ready
  13511. */
  13512. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13513. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13514. private _processBuild;
  13515. /**
  13516. * Validates the new name for the block node.
  13517. * @param newName the new name to be given to the node.
  13518. * @returns false if the name is a reserve word, else true.
  13519. */
  13520. validateBlockName(newName: string): boolean;
  13521. /**
  13522. * Compile the current node and generate the shader code
  13523. * @param state defines the current compilation state (uniforms, samplers, current string)
  13524. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13525. * @returns true if already built
  13526. */
  13527. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13528. protected _inputRename(name: string): string;
  13529. protected _outputRename(name: string): string;
  13530. protected _dumpPropertiesCode(): string;
  13531. /** @hidden */
  13532. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13533. /** @hidden */
  13534. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13535. /**
  13536. * Clone the current block to a new identical block
  13537. * @param scene defines the hosting scene
  13538. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13539. * @returns a copy of the current block
  13540. */
  13541. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13542. /**
  13543. * Serializes this block in a JSON representation
  13544. * @returns the serialized block object
  13545. */
  13546. serialize(): any;
  13547. /** @hidden */
  13548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13549. private _deserializePortDisplayNamesAndExposedOnFrame;
  13550. /**
  13551. * Release resources
  13552. */
  13553. dispose(): void;
  13554. }
  13555. }
  13556. declare module "babylonjs/Materials/pushMaterial" {
  13557. import { Nullable } from "babylonjs/types";
  13558. import { Scene } from "babylonjs/scene";
  13559. import { Matrix } from "babylonjs/Maths/math.vector";
  13560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13561. import { Mesh } from "babylonjs/Meshes/mesh";
  13562. import { Material } from "babylonjs/Materials/material";
  13563. import { Effect } from "babylonjs/Materials/effect";
  13564. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13565. /**
  13566. * Base class of materials working in push mode in babylon JS
  13567. * @hidden
  13568. */
  13569. export class PushMaterial extends Material {
  13570. protected _activeEffect: Effect;
  13571. protected _normalMatrix: Matrix;
  13572. constructor(name: string, scene: Scene);
  13573. getEffect(): Effect;
  13574. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13575. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13576. /**
  13577. * Binds the given world matrix to the active effect
  13578. *
  13579. * @param world the matrix to bind
  13580. */
  13581. bindOnlyWorldMatrix(world: Matrix): void;
  13582. /**
  13583. * Binds the given normal matrix to the active effect
  13584. *
  13585. * @param normalMatrix the matrix to bind
  13586. */
  13587. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13588. bind(world: Matrix, mesh?: Mesh): void;
  13589. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13590. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13591. }
  13592. }
  13593. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  13594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13595. /**
  13596. * Root class for all node material optimizers
  13597. */
  13598. export class NodeMaterialOptimizer {
  13599. /**
  13600. * Function used to optimize a NodeMaterial graph
  13601. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13602. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13603. */
  13604. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13605. }
  13606. }
  13607. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  13608. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13609. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13610. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13611. import { Scene } from "babylonjs/scene";
  13612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13613. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13614. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13615. /**
  13616. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13617. */
  13618. export class TransformBlock extends NodeMaterialBlock {
  13619. /**
  13620. * Defines the value to use to complement W value to transform it to a Vector4
  13621. */
  13622. complementW: number;
  13623. /**
  13624. * Defines the value to use to complement z value to transform it to a Vector4
  13625. */
  13626. complementZ: number;
  13627. /**
  13628. * Creates a new TransformBlock
  13629. * @param name defines the block name
  13630. */
  13631. constructor(name: string);
  13632. /**
  13633. * Gets the current class name
  13634. * @returns the class name
  13635. */
  13636. getClassName(): string;
  13637. /**
  13638. * Gets the vector input
  13639. */
  13640. get vector(): NodeMaterialConnectionPoint;
  13641. /**
  13642. * Gets the output component
  13643. */
  13644. get output(): NodeMaterialConnectionPoint;
  13645. /**
  13646. * Gets the xyz output component
  13647. */
  13648. get xyz(): NodeMaterialConnectionPoint;
  13649. /**
  13650. * Gets the matrix transform input
  13651. */
  13652. get transform(): NodeMaterialConnectionPoint;
  13653. protected _buildBlock(state: NodeMaterialBuildState): this;
  13654. /**
  13655. * Update defines for shader compilation
  13656. * @param mesh defines the mesh to be rendered
  13657. * @param nodeMaterial defines the node material requesting the update
  13658. * @param defines defines the material defines to update
  13659. * @param useInstances specifies that instances should be used
  13660. * @param subMesh defines which submesh to render
  13661. */
  13662. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13663. serialize(): any;
  13664. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13665. protected _dumpPropertiesCode(): string;
  13666. }
  13667. }
  13668. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  13669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13672. /**
  13673. * Block used to output the vertex position
  13674. */
  13675. export class VertexOutputBlock extends NodeMaterialBlock {
  13676. /**
  13677. * Creates a new VertexOutputBlock
  13678. * @param name defines the block name
  13679. */
  13680. constructor(name: string);
  13681. /**
  13682. * Gets the current class name
  13683. * @returns the class name
  13684. */
  13685. getClassName(): string;
  13686. /**
  13687. * Gets the vector input component
  13688. */
  13689. get vector(): NodeMaterialConnectionPoint;
  13690. protected _buildBlock(state: NodeMaterialBuildState): this;
  13691. }
  13692. }
  13693. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  13694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13697. /**
  13698. * Block used to output the final color
  13699. */
  13700. export class FragmentOutputBlock extends NodeMaterialBlock {
  13701. /**
  13702. * Create a new FragmentOutputBlock
  13703. * @param name defines the block name
  13704. */
  13705. constructor(name: string);
  13706. /**
  13707. * Gets the current class name
  13708. * @returns the class name
  13709. */
  13710. getClassName(): string;
  13711. /**
  13712. * Gets the rgba input component
  13713. */
  13714. get rgba(): NodeMaterialConnectionPoint;
  13715. /**
  13716. * Gets the rgb input component
  13717. */
  13718. get rgb(): NodeMaterialConnectionPoint;
  13719. /**
  13720. * Gets the a input component
  13721. */
  13722. get a(): NodeMaterialConnectionPoint;
  13723. protected _buildBlock(state: NodeMaterialBuildState): this;
  13724. }
  13725. }
  13726. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  13727. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13728. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13729. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13730. /**
  13731. * Block used for the particle ramp gradient section
  13732. */
  13733. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13734. /**
  13735. * Create a new ParticleRampGradientBlock
  13736. * @param name defines the block name
  13737. */
  13738. constructor(name: string);
  13739. /**
  13740. * Gets the current class name
  13741. * @returns the class name
  13742. */
  13743. getClassName(): string;
  13744. /**
  13745. * Gets the color input component
  13746. */
  13747. get color(): NodeMaterialConnectionPoint;
  13748. /**
  13749. * Gets the rampColor output component
  13750. */
  13751. get rampColor(): NodeMaterialConnectionPoint;
  13752. /**
  13753. * Initialize the block and prepare the context for build
  13754. * @param state defines the state that will be used for the build
  13755. */
  13756. initialize(state: NodeMaterialBuildState): void;
  13757. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13758. }
  13759. }
  13760. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  13761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13764. /**
  13765. * Block used for the particle blend multiply section
  13766. */
  13767. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13768. /**
  13769. * Create a new ParticleBlendMultiplyBlock
  13770. * @param name defines the block name
  13771. */
  13772. constructor(name: string);
  13773. /**
  13774. * Gets the current class name
  13775. * @returns the class name
  13776. */
  13777. getClassName(): string;
  13778. /**
  13779. * Gets the color input component
  13780. */
  13781. get color(): NodeMaterialConnectionPoint;
  13782. /**
  13783. * Gets the alphaTexture input component
  13784. */
  13785. get alphaTexture(): NodeMaterialConnectionPoint;
  13786. /**
  13787. * Gets the alphaColor input component
  13788. */
  13789. get alphaColor(): NodeMaterialConnectionPoint;
  13790. /**
  13791. * Gets the blendColor output component
  13792. */
  13793. get blendColor(): NodeMaterialConnectionPoint;
  13794. /**
  13795. * Initialize the block and prepare the context for build
  13796. * @param state defines the state that will be used for the build
  13797. */
  13798. initialize(state: NodeMaterialBuildState): void;
  13799. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13800. }
  13801. }
  13802. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  13803. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13804. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13805. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13806. /**
  13807. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13808. */
  13809. export class VectorMergerBlock extends NodeMaterialBlock {
  13810. /**
  13811. * Create a new VectorMergerBlock
  13812. * @param name defines the block name
  13813. */
  13814. constructor(name: string);
  13815. /**
  13816. * Gets the current class name
  13817. * @returns the class name
  13818. */
  13819. getClassName(): string;
  13820. /**
  13821. * Gets the xyz component (input)
  13822. */
  13823. get xyzIn(): NodeMaterialConnectionPoint;
  13824. /**
  13825. * Gets the xy component (input)
  13826. */
  13827. get xyIn(): NodeMaterialConnectionPoint;
  13828. /**
  13829. * Gets the x component (input)
  13830. */
  13831. get x(): NodeMaterialConnectionPoint;
  13832. /**
  13833. * Gets the y component (input)
  13834. */
  13835. get y(): NodeMaterialConnectionPoint;
  13836. /**
  13837. * Gets the z component (input)
  13838. */
  13839. get z(): NodeMaterialConnectionPoint;
  13840. /**
  13841. * Gets the w component (input)
  13842. */
  13843. get w(): NodeMaterialConnectionPoint;
  13844. /**
  13845. * Gets the xyzw component (output)
  13846. */
  13847. get xyzw(): NodeMaterialConnectionPoint;
  13848. /**
  13849. * Gets the xyz component (output)
  13850. */
  13851. get xyzOut(): NodeMaterialConnectionPoint;
  13852. /**
  13853. * Gets the xy component (output)
  13854. */
  13855. get xyOut(): NodeMaterialConnectionPoint;
  13856. /**
  13857. * Gets the xy component (output)
  13858. * @deprecated Please use xyOut instead.
  13859. */
  13860. get xy(): NodeMaterialConnectionPoint;
  13861. /**
  13862. * Gets the xyz component (output)
  13863. * @deprecated Please use xyzOut instead.
  13864. */
  13865. get xyz(): NodeMaterialConnectionPoint;
  13866. protected _buildBlock(state: NodeMaterialBuildState): this;
  13867. }
  13868. }
  13869. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  13870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13873. import { Vector2 } from "babylonjs/Maths/math.vector";
  13874. import { Scene } from "babylonjs/scene";
  13875. /**
  13876. * Block used to remap a float from a range to a new one
  13877. */
  13878. export class RemapBlock extends NodeMaterialBlock {
  13879. /**
  13880. * Gets or sets the source range
  13881. */
  13882. sourceRange: Vector2;
  13883. /**
  13884. * Gets or sets the target range
  13885. */
  13886. targetRange: Vector2;
  13887. /**
  13888. * Creates a new RemapBlock
  13889. * @param name defines the block name
  13890. */
  13891. constructor(name: string);
  13892. /**
  13893. * Gets the current class name
  13894. * @returns the class name
  13895. */
  13896. getClassName(): string;
  13897. /**
  13898. * Gets the input component
  13899. */
  13900. get input(): NodeMaterialConnectionPoint;
  13901. /**
  13902. * Gets the source min input component
  13903. */
  13904. get sourceMin(): NodeMaterialConnectionPoint;
  13905. /**
  13906. * Gets the source max input component
  13907. */
  13908. get sourceMax(): NodeMaterialConnectionPoint;
  13909. /**
  13910. * Gets the target min input component
  13911. */
  13912. get targetMin(): NodeMaterialConnectionPoint;
  13913. /**
  13914. * Gets the target max input component
  13915. */
  13916. get targetMax(): NodeMaterialConnectionPoint;
  13917. /**
  13918. * Gets the output component
  13919. */
  13920. get output(): NodeMaterialConnectionPoint;
  13921. protected _buildBlock(state: NodeMaterialBuildState): this;
  13922. protected _dumpPropertiesCode(): string;
  13923. serialize(): any;
  13924. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13925. }
  13926. }
  13927. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  13928. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13929. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13930. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13931. /**
  13932. * Block used to multiply 2 values
  13933. */
  13934. export class MultiplyBlock extends NodeMaterialBlock {
  13935. /**
  13936. * Creates a new MultiplyBlock
  13937. * @param name defines the block name
  13938. */
  13939. constructor(name: string);
  13940. /**
  13941. * Gets the current class name
  13942. * @returns the class name
  13943. */
  13944. getClassName(): string;
  13945. /**
  13946. * Gets the left operand input component
  13947. */
  13948. get left(): NodeMaterialConnectionPoint;
  13949. /**
  13950. * Gets the right operand input component
  13951. */
  13952. get right(): NodeMaterialConnectionPoint;
  13953. /**
  13954. * Gets the output component
  13955. */
  13956. get output(): NodeMaterialConnectionPoint;
  13957. protected _buildBlock(state: NodeMaterialBuildState): this;
  13958. }
  13959. }
  13960. declare module "babylonjs/Misc/gradients" {
  13961. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13962. /** Interface used by value gradients (color, factor, ...) */
  13963. export interface IValueGradient {
  13964. /**
  13965. * Gets or sets the gradient value (between 0 and 1)
  13966. */
  13967. gradient: number;
  13968. }
  13969. /** Class used to store color4 gradient */
  13970. export class ColorGradient implements IValueGradient {
  13971. /**
  13972. * Gets or sets the gradient value (between 0 and 1)
  13973. */
  13974. gradient: number;
  13975. /**
  13976. * Gets or sets first associated color
  13977. */
  13978. color1: Color4;
  13979. /**
  13980. * Gets or sets second associated color
  13981. */
  13982. color2?: Color4 | undefined;
  13983. /**
  13984. * Creates a new color4 gradient
  13985. * @param gradient gets or sets the gradient value (between 0 and 1)
  13986. * @param color1 gets or sets first associated color
  13987. * @param color2 gets or sets first second color
  13988. */
  13989. constructor(
  13990. /**
  13991. * Gets or sets the gradient value (between 0 and 1)
  13992. */
  13993. gradient: number,
  13994. /**
  13995. * Gets or sets first associated color
  13996. */
  13997. color1: Color4,
  13998. /**
  13999. * Gets or sets second associated color
  14000. */
  14001. color2?: Color4 | undefined);
  14002. /**
  14003. * Will get a color picked randomly between color1 and color2.
  14004. * If color2 is undefined then color1 will be used
  14005. * @param result defines the target Color4 to store the result in
  14006. */
  14007. getColorToRef(result: Color4): void;
  14008. }
  14009. /** Class used to store color 3 gradient */
  14010. export class Color3Gradient implements IValueGradient {
  14011. /**
  14012. * Gets or sets the gradient value (between 0 and 1)
  14013. */
  14014. gradient: number;
  14015. /**
  14016. * Gets or sets the associated color
  14017. */
  14018. color: Color3;
  14019. /**
  14020. * Creates a new color3 gradient
  14021. * @param gradient gets or sets the gradient value (between 0 and 1)
  14022. * @param color gets or sets associated color
  14023. */
  14024. constructor(
  14025. /**
  14026. * Gets or sets the gradient value (between 0 and 1)
  14027. */
  14028. gradient: number,
  14029. /**
  14030. * Gets or sets the associated color
  14031. */
  14032. color: Color3);
  14033. }
  14034. /** Class used to store factor gradient */
  14035. export class FactorGradient implements IValueGradient {
  14036. /**
  14037. * Gets or sets the gradient value (between 0 and 1)
  14038. */
  14039. gradient: number;
  14040. /**
  14041. * Gets or sets first associated factor
  14042. */
  14043. factor1: number;
  14044. /**
  14045. * Gets or sets second associated factor
  14046. */
  14047. factor2?: number | undefined;
  14048. /**
  14049. * Creates a new factor gradient
  14050. * @param gradient gets or sets the gradient value (between 0 and 1)
  14051. * @param factor1 gets or sets first associated factor
  14052. * @param factor2 gets or sets second associated factor
  14053. */
  14054. constructor(
  14055. /**
  14056. * Gets or sets the gradient value (between 0 and 1)
  14057. */
  14058. gradient: number,
  14059. /**
  14060. * Gets or sets first associated factor
  14061. */
  14062. factor1: number,
  14063. /**
  14064. * Gets or sets second associated factor
  14065. */
  14066. factor2?: number | undefined);
  14067. /**
  14068. * Will get a number picked randomly between factor1 and factor2.
  14069. * If factor2 is undefined then factor1 will be used
  14070. * @returns the picked number
  14071. */
  14072. getFactor(): number;
  14073. }
  14074. /**
  14075. * Helper used to simplify some generic gradient tasks
  14076. */
  14077. export class GradientHelper {
  14078. /**
  14079. * Gets the current gradient from an array of IValueGradient
  14080. * @param ratio defines the current ratio to get
  14081. * @param gradients defines the array of IValueGradient
  14082. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14083. */
  14084. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14085. }
  14086. }
  14087. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  14088. import { Nullable } from "babylonjs/types";
  14089. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14090. import { Scene } from "babylonjs/scene";
  14091. module "babylonjs/Engines/thinEngine" {
  14092. interface ThinEngine {
  14093. /**
  14094. * Creates a raw texture
  14095. * @param data defines the data to store in the texture
  14096. * @param width defines the width of the texture
  14097. * @param height defines the height of the texture
  14098. * @param format defines the format of the data
  14099. * @param generateMipMaps defines if the engine should generate the mip levels
  14100. * @param invertY defines if data must be stored with Y axis inverted
  14101. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14102. * @param compression defines the compression used (null by default)
  14103. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14104. * @returns the raw texture inside an InternalTexture
  14105. */
  14106. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14107. /**
  14108. * Update a raw texture
  14109. * @param texture defines the texture to update
  14110. * @param data defines the data to store in the texture
  14111. * @param format defines the format of the data
  14112. * @param invertY defines if data must be stored with Y axis inverted
  14113. */
  14114. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14115. /**
  14116. * Update a raw texture
  14117. * @param texture defines the texture to update
  14118. * @param data defines the data to store in the texture
  14119. * @param format defines the format of the data
  14120. * @param invertY defines if data must be stored with Y axis inverted
  14121. * @param compression defines the compression used (null by default)
  14122. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14123. */
  14124. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14125. /**
  14126. * Creates a new raw cube texture
  14127. * @param data defines the array of data to use to create each face
  14128. * @param size defines the size of the textures
  14129. * @param format defines the format of the data
  14130. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14131. * @param generateMipMaps defines if the engine should generate the mip levels
  14132. * @param invertY defines if data must be stored with Y axis inverted
  14133. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14134. * @param compression defines the compression used (null by default)
  14135. * @returns the cube texture as an InternalTexture
  14136. */
  14137. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14138. /**
  14139. * Update a raw cube texture
  14140. * @param texture defines the texture to udpdate
  14141. * @param data defines the data to store
  14142. * @param format defines the data format
  14143. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14144. * @param invertY defines if data must be stored with Y axis inverted
  14145. */
  14146. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14147. /**
  14148. * Update a raw cube texture
  14149. * @param texture defines the texture to udpdate
  14150. * @param data defines the data to store
  14151. * @param format defines the data format
  14152. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14153. * @param invertY defines if data must be stored with Y axis inverted
  14154. * @param compression defines the compression used (null by default)
  14155. */
  14156. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14157. /**
  14158. * Update a raw cube texture
  14159. * @param texture defines the texture to udpdate
  14160. * @param data defines the data to store
  14161. * @param format defines the data format
  14162. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14163. * @param invertY defines if data must be stored with Y axis inverted
  14164. * @param compression defines the compression used (null by default)
  14165. * @param level defines which level of the texture to update
  14166. */
  14167. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14168. /**
  14169. * Creates a new raw cube texture from a specified url
  14170. * @param url defines the url where the data is located
  14171. * @param scene defines the current scene
  14172. * @param size defines the size of the textures
  14173. * @param format defines the format of the data
  14174. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14175. * @param noMipmap defines if the engine should avoid generating the mip levels
  14176. * @param callback defines a callback used to extract texture data from loaded data
  14177. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14178. * @param onLoad defines a callback called when texture is loaded
  14179. * @param onError defines a callback called if there is an error
  14180. * @returns the cube texture as an InternalTexture
  14181. */
  14182. 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;
  14183. /**
  14184. * Creates a new raw cube texture from a specified url
  14185. * @param url defines the url where the data is located
  14186. * @param scene defines the current scene
  14187. * @param size defines the size of the textures
  14188. * @param format defines the format of the data
  14189. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14190. * @param noMipmap defines if the engine should avoid generating the mip levels
  14191. * @param callback defines a callback used to extract texture data from loaded data
  14192. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14193. * @param onLoad defines a callback called when texture is loaded
  14194. * @param onError defines a callback called if there is an error
  14195. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14196. * @param invertY defines if data must be stored with Y axis inverted
  14197. * @returns the cube texture as an InternalTexture
  14198. */
  14199. 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;
  14200. /**
  14201. * Creates a new raw 3D texture
  14202. * @param data defines the data used to create the texture
  14203. * @param width defines the width of the texture
  14204. * @param height defines the height of the texture
  14205. * @param depth defines the depth of the texture
  14206. * @param format defines the format of the texture
  14207. * @param generateMipMaps defines if the engine must generate mip levels
  14208. * @param invertY defines if data must be stored with Y axis inverted
  14209. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14210. * @param compression defines the compressed used (can be null)
  14211. * @param textureType defines the compressed used (can be null)
  14212. * @returns a new raw 3D texture (stored in an InternalTexture)
  14213. */
  14214. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14215. /**
  14216. * Update a raw 3D texture
  14217. * @param texture defines the texture to update
  14218. * @param data defines the data to store
  14219. * @param format defines the data format
  14220. * @param invertY defines if data must be stored with Y axis inverted
  14221. */
  14222. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14223. /**
  14224. * Update a raw 3D texture
  14225. * @param texture defines the texture to update
  14226. * @param data defines the data to store
  14227. * @param format defines the data format
  14228. * @param invertY defines if data must be stored with Y axis inverted
  14229. * @param compression defines the used compression (can be null)
  14230. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14231. */
  14232. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14233. /**
  14234. * Creates a new raw 2D array texture
  14235. * @param data defines the data used to create the texture
  14236. * @param width defines the width of the texture
  14237. * @param height defines the height of the texture
  14238. * @param depth defines the number of layers of the texture
  14239. * @param format defines the format of the texture
  14240. * @param generateMipMaps defines if the engine must generate mip levels
  14241. * @param invertY defines if data must be stored with Y axis inverted
  14242. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14243. * @param compression defines the compressed used (can be null)
  14244. * @param textureType defines the compressed used (can be null)
  14245. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14246. */
  14247. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14248. /**
  14249. * Update a raw 2D array texture
  14250. * @param texture defines the texture to update
  14251. * @param data defines the data to store
  14252. * @param format defines the data format
  14253. * @param invertY defines if data must be stored with Y axis inverted
  14254. */
  14255. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14256. /**
  14257. * Update a raw 2D array texture
  14258. * @param texture defines the texture to update
  14259. * @param data defines the data to store
  14260. * @param format defines the data format
  14261. * @param invertY defines if data must be stored with Y axis inverted
  14262. * @param compression defines the used compression (can be null)
  14263. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14264. */
  14265. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14266. }
  14267. }
  14268. }
  14269. declare module "babylonjs/Materials/Textures/rawTexture" {
  14270. import { Texture } from "babylonjs/Materials/Textures/texture";
  14271. import "babylonjs/Engines/Extensions/engine.rawTexture";
  14272. import { Nullable } from "babylonjs/types";
  14273. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14274. import { Scene } from "babylonjs/scene";
  14275. /**
  14276. * Raw texture can help creating a texture directly from an array of data.
  14277. * This can be super useful if you either get the data from an uncompressed source or
  14278. * if you wish to create your texture pixel by pixel.
  14279. */
  14280. export class RawTexture extends Texture {
  14281. /**
  14282. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14283. */
  14284. format: number;
  14285. /**
  14286. * Instantiates a new RawTexture.
  14287. * Raw texture can help creating a texture directly from an array of data.
  14288. * This can be super useful if you either get the data from an uncompressed source or
  14289. * if you wish to create your texture pixel by pixel.
  14290. * @param data define the array of data to use to create the texture
  14291. * @param width define the width of the texture
  14292. * @param height define the height of the texture
  14293. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14294. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14295. * @param generateMipMaps define whether mip maps should be generated or not
  14296. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14297. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14298. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14299. */
  14300. constructor(data: ArrayBufferView, width: number, height: number,
  14301. /**
  14302. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14303. */
  14304. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14305. /**
  14306. * Updates the texture underlying data.
  14307. * @param data Define the new data of the texture
  14308. */
  14309. update(data: ArrayBufferView): void;
  14310. /**
  14311. * Creates a luminance 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. * @returns the luminance texture
  14320. */
  14321. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14322. /**
  14323. * Creates a luminance alpha texture from some data.
  14324. * @param data Define the texture data
  14325. * @param width Define the width of the texture
  14326. * @param height Define the height of the texture
  14327. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14328. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14329. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14330. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14331. * @returns the luminance alpha texture
  14332. */
  14333. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14334. /**
  14335. * Creates an alpha texture from some data.
  14336. * @param data Define the texture data
  14337. * @param width Define the width of the texture
  14338. * @param height Define the height of the texture
  14339. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14340. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14341. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14342. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14343. * @returns the alpha texture
  14344. */
  14345. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14346. /**
  14347. * Creates a RGB texture from some data.
  14348. * @param data Define the texture data
  14349. * @param width Define the width of the texture
  14350. * @param height Define the height of the texture
  14351. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14352. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14353. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14354. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14355. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14356. * @returns the RGB alpha texture
  14357. */
  14358. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14359. /**
  14360. * Creates a RGBA texture from some data.
  14361. * @param data Define the texture data
  14362. * @param width Define the width of the texture
  14363. * @param height Define the height of the texture
  14364. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14365. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14366. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14367. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14368. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14369. * @returns the RGBA texture
  14370. */
  14371. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14372. /**
  14373. * Creates a R texture from some data.
  14374. * @param data Define the texture data
  14375. * @param width Define the width of the texture
  14376. * @param height Define the height of the texture
  14377. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14378. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14379. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14380. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14381. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14382. * @returns the R texture
  14383. */
  14384. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14385. }
  14386. }
  14387. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  14388. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  14389. import { IndicesArray, DataArray } from "babylonjs/types";
  14390. module "babylonjs/Engines/thinEngine" {
  14391. interface ThinEngine {
  14392. /**
  14393. * Update a dynamic index buffer
  14394. * @param indexBuffer defines the target index buffer
  14395. * @param indices defines the data to update
  14396. * @param offset defines the offset in the target index buffer where update should start
  14397. */
  14398. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14399. /**
  14400. * Updates a dynamic vertex buffer.
  14401. * @param vertexBuffer the vertex buffer to update
  14402. * @param data the data used to update the vertex buffer
  14403. * @param byteOffset the byte offset of the data
  14404. * @param byteLength the byte length of the data
  14405. */
  14406. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14407. }
  14408. }
  14409. }
  14410. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14411. import { Scene } from "babylonjs/scene";
  14412. import { ISceneComponent } from "babylonjs/sceneComponent";
  14413. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14414. module "babylonjs/abstractScene" {
  14415. interface AbstractScene {
  14416. /**
  14417. * The list of procedural textures added to the scene
  14418. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14419. */
  14420. proceduralTextures: Array<ProceduralTexture>;
  14421. }
  14422. }
  14423. /**
  14424. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14425. * in a given scene.
  14426. */
  14427. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14428. /**
  14429. * The component name helpfull to identify the component in the list of scene components.
  14430. */
  14431. readonly name: string;
  14432. /**
  14433. * The scene the component belongs to.
  14434. */
  14435. scene: Scene;
  14436. /**
  14437. * Creates a new instance of the component for the given scene
  14438. * @param scene Defines the scene to register the component in
  14439. */
  14440. constructor(scene: Scene);
  14441. /**
  14442. * Registers the component in a given scene
  14443. */
  14444. register(): void;
  14445. /**
  14446. * Rebuilds the elements related to this component in case of
  14447. * context lost for instance.
  14448. */
  14449. rebuild(): void;
  14450. /**
  14451. * Disposes the component and the associated ressources.
  14452. */
  14453. dispose(): void;
  14454. private _beforeClear;
  14455. }
  14456. }
  14457. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  14458. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14459. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14460. module "babylonjs/Engines/thinEngine" {
  14461. interface ThinEngine {
  14462. /**
  14463. * Creates a new render target cube texture
  14464. * @param size defines the size of the texture
  14465. * @param options defines the options used to create the texture
  14466. * @returns a new render target cube texture stored in an InternalTexture
  14467. */
  14468. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14469. }
  14470. }
  14471. }
  14472. declare module "babylonjs/Shaders/procedural.vertex" {
  14473. /** @hidden */
  14474. export var proceduralVertexShader: {
  14475. name: string;
  14476. shader: string;
  14477. };
  14478. }
  14479. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14480. import { Observable } from "babylonjs/Misc/observable";
  14481. import { Nullable } from "babylonjs/types";
  14482. import { Scene } from "babylonjs/scene";
  14483. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  14484. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  14485. import { Effect } from "babylonjs/Materials/effect";
  14486. import { Texture } from "babylonjs/Materials/Textures/texture";
  14487. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14488. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  14489. import "babylonjs/Shaders/procedural.vertex";
  14490. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  14491. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  14492. /**
  14493. * 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.
  14494. * This is the base class of any Procedural texture and contains most of the shareable code.
  14495. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14496. */
  14497. export class ProceduralTexture extends Texture {
  14498. /**
  14499. * Define if the texture is enabled or not (disabled texture will not render)
  14500. */
  14501. isEnabled: boolean;
  14502. /**
  14503. * Define if the texture must be cleared before rendering (default is true)
  14504. */
  14505. autoClear: boolean;
  14506. /**
  14507. * Callback called when the texture is generated
  14508. */
  14509. onGenerated: () => void;
  14510. /**
  14511. * Event raised when the texture is generated
  14512. */
  14513. onGeneratedObservable: Observable<ProceduralTexture>;
  14514. /**
  14515. * Event raised before the texture is generated
  14516. */
  14517. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14518. /**
  14519. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14520. */
  14521. nodeMaterialSource: Nullable<NodeMaterial>;
  14522. /** @hidden */
  14523. _generateMipMaps: boolean;
  14524. /** @hidden **/
  14525. _effect: Effect;
  14526. /** @hidden */
  14527. _textures: {
  14528. [key: string]: Texture;
  14529. };
  14530. /** @hidden */
  14531. protected _fallbackTexture: Nullable<Texture>;
  14532. private _size;
  14533. private _currentRefreshId;
  14534. private _frameId;
  14535. private _refreshRate;
  14536. private _vertexBuffers;
  14537. private _indexBuffer;
  14538. private _uniforms;
  14539. private _samplers;
  14540. private _fragment;
  14541. private _floats;
  14542. private _ints;
  14543. private _floatsArrays;
  14544. private _colors3;
  14545. private _colors4;
  14546. private _vectors2;
  14547. private _vectors3;
  14548. private _matrices;
  14549. private _fallbackTextureUsed;
  14550. private _fullEngine;
  14551. private _cachedDefines;
  14552. private _contentUpdateId;
  14553. private _contentData;
  14554. /**
  14555. * Instantiates a new procedural texture.
  14556. * 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.
  14557. * This is the base class of any Procedural texture and contains most of the shareable code.
  14558. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14559. * @param name Define the name of the texture
  14560. * @param size Define the size of the texture to create
  14561. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14562. * @param scene Define the scene the texture belongs to
  14563. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14564. * @param generateMipMaps Define if the texture should creates mip maps or not
  14565. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14566. * @param textureType The FBO internal texture type
  14567. */
  14568. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14569. /**
  14570. * The effect that is created when initializing the post process.
  14571. * @returns The created effect corresponding the the postprocess.
  14572. */
  14573. getEffect(): Effect;
  14574. /**
  14575. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14576. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14577. */
  14578. getContent(): Nullable<ArrayBufferView>;
  14579. private _createIndexBuffer;
  14580. /** @hidden */
  14581. _rebuild(): void;
  14582. /**
  14583. * Resets the texture in order to recreate its associated resources.
  14584. * This can be called in case of context loss
  14585. */
  14586. reset(): void;
  14587. protected _getDefines(): string;
  14588. /**
  14589. * Is the texture ready to be used ? (rendered at least once)
  14590. * @returns true if ready, otherwise, false.
  14591. */
  14592. isReady(): boolean;
  14593. /**
  14594. * Resets the refresh counter of the texture and start bak from scratch.
  14595. * Could be useful to regenerate the texture if it is setup to render only once.
  14596. */
  14597. resetRefreshCounter(): void;
  14598. /**
  14599. * Set the fragment shader to use in order to render the texture.
  14600. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14601. */
  14602. setFragment(fragment: any): void;
  14603. /**
  14604. * Define the refresh rate of the texture or the rendering frequency.
  14605. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14606. */
  14607. get refreshRate(): number;
  14608. set refreshRate(value: number);
  14609. /** @hidden */
  14610. _shouldRender(): boolean;
  14611. /**
  14612. * Get the size the texture is rendering at.
  14613. * @returns the size (on cube texture it is always squared)
  14614. */
  14615. getRenderSize(): RenderTargetTextureSize;
  14616. /**
  14617. * Resize the texture to new value.
  14618. * @param size Define the new size the texture should have
  14619. * @param generateMipMaps Define whether the new texture should create mip maps
  14620. */
  14621. resize(size: number, generateMipMaps: boolean): void;
  14622. private _checkUniform;
  14623. /**
  14624. * Set a texture in the shader program used to render.
  14625. * @param name Define the name of the uniform samplers as defined in the shader
  14626. * @param texture Define the texture to bind to this sampler
  14627. * @return the texture itself allowing "fluent" like uniform updates
  14628. */
  14629. setTexture(name: string, texture: Texture): ProceduralTexture;
  14630. /**
  14631. * Set a float in the shader.
  14632. * @param name Define the name of the uniform as defined in the shader
  14633. * @param value Define the value to give to the uniform
  14634. * @return the texture itself allowing "fluent" like uniform updates
  14635. */
  14636. setFloat(name: string, value: number): ProceduralTexture;
  14637. /**
  14638. * Set a int in the shader.
  14639. * @param name Define the name of the uniform as defined in the shader
  14640. * @param value Define the value to give to the uniform
  14641. * @return the texture itself allowing "fluent" like uniform updates
  14642. */
  14643. setInt(name: string, value: number): ProceduralTexture;
  14644. /**
  14645. * Set an array of floats in the shader.
  14646. * @param name Define the name of the uniform as defined in the shader
  14647. * @param value Define the value to give to the uniform
  14648. * @return the texture itself allowing "fluent" like uniform updates
  14649. */
  14650. setFloats(name: string, value: number[]): ProceduralTexture;
  14651. /**
  14652. * Set a vec3 in the shader from a Color3.
  14653. * @param name Define the name of the uniform as defined in the shader
  14654. * @param value Define the value to give to the uniform
  14655. * @return the texture itself allowing "fluent" like uniform updates
  14656. */
  14657. setColor3(name: string, value: Color3): ProceduralTexture;
  14658. /**
  14659. * Set a vec4 in the shader from a Color4.
  14660. * @param name Define the name of the uniform as defined in the shader
  14661. * @param value Define the value to give to the uniform
  14662. * @return the texture itself allowing "fluent" like uniform updates
  14663. */
  14664. setColor4(name: string, value: Color4): ProceduralTexture;
  14665. /**
  14666. * Set a vec2 in the shader from a Vector2.
  14667. * @param name Define the name of the uniform as defined in the shader
  14668. * @param value Define the value to give to the uniform
  14669. * @return the texture itself allowing "fluent" like uniform updates
  14670. */
  14671. setVector2(name: string, value: Vector2): ProceduralTexture;
  14672. /**
  14673. * Set a vec3 in the shader from a Vector3.
  14674. * @param name Define the name of the uniform as defined in the shader
  14675. * @param value Define the value to give to the uniform
  14676. * @return the texture itself allowing "fluent" like uniform updates
  14677. */
  14678. setVector3(name: string, value: Vector3): ProceduralTexture;
  14679. /**
  14680. * Set a mat4 in the shader from a MAtrix.
  14681. * @param name Define the name of the uniform as defined in the shader
  14682. * @param value Define the value to give to the uniform
  14683. * @return the texture itself allowing "fluent" like uniform updates
  14684. */
  14685. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14686. /**
  14687. * Render the texture to its associated render target.
  14688. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14689. */
  14690. render(useCameraPostProcess?: boolean): void;
  14691. /**
  14692. * Clone the texture.
  14693. * @returns the cloned texture
  14694. */
  14695. clone(): ProceduralTexture;
  14696. /**
  14697. * Dispose the texture and release its asoociated resources.
  14698. */
  14699. dispose(): void;
  14700. }
  14701. }
  14702. declare module "babylonjs/Particles/baseParticleSystem" {
  14703. import { Nullable } from "babylonjs/types";
  14704. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14706. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14707. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  14708. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14709. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14710. import { Color4 } from "babylonjs/Maths/math.color";
  14711. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14712. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  14713. import { Animation } from "babylonjs/Animations/animation";
  14714. import { Scene } from "babylonjs/scene";
  14715. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14716. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14717. /**
  14718. * This represents the base class for particle system in Babylon.
  14719. * 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.
  14720. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14721. * @example https://doc.babylonjs.com/babylon101/particles
  14722. */
  14723. export class BaseParticleSystem {
  14724. /**
  14725. * Source color is added to the destination color without alpha affecting the result
  14726. */
  14727. static BLENDMODE_ONEONE: number;
  14728. /**
  14729. * Blend current color and particle color using particle’s alpha
  14730. */
  14731. static BLENDMODE_STANDARD: number;
  14732. /**
  14733. * Add current color and particle color multiplied by particle’s alpha
  14734. */
  14735. static BLENDMODE_ADD: number;
  14736. /**
  14737. * Multiply current color with particle color
  14738. */
  14739. static BLENDMODE_MULTIPLY: number;
  14740. /**
  14741. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14742. */
  14743. static BLENDMODE_MULTIPLYADD: number;
  14744. /**
  14745. * List of animations used by the particle system.
  14746. */
  14747. animations: Animation[];
  14748. /**
  14749. * Gets or sets the unique id of the particle system
  14750. */
  14751. uniqueId: number;
  14752. /**
  14753. * The id of the Particle system.
  14754. */
  14755. id: string;
  14756. /**
  14757. * The friendly name of the Particle system.
  14758. */
  14759. name: string;
  14760. /**
  14761. * Snippet ID if the particle system was created from the snippet server
  14762. */
  14763. snippetId: string;
  14764. /**
  14765. * The rendering group used by the Particle system to chose when to render.
  14766. */
  14767. renderingGroupId: number;
  14768. /**
  14769. * The emitter represents the Mesh or position we are attaching the particle system to.
  14770. */
  14771. emitter: Nullable<AbstractMesh | Vector3>;
  14772. /**
  14773. * The maximum number of particles to emit per frame
  14774. */
  14775. emitRate: number;
  14776. /**
  14777. * If you want to launch only a few particles at once, that can be done, as well.
  14778. */
  14779. manualEmitCount: number;
  14780. /**
  14781. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14782. */
  14783. updateSpeed: number;
  14784. /**
  14785. * The amount of time the particle system is running (depends of the overall update speed).
  14786. */
  14787. targetStopDuration: number;
  14788. /**
  14789. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14790. */
  14791. disposeOnStop: boolean;
  14792. /**
  14793. * Minimum power of emitting particles.
  14794. */
  14795. minEmitPower: number;
  14796. /**
  14797. * Maximum power of emitting particles.
  14798. */
  14799. maxEmitPower: number;
  14800. /**
  14801. * Minimum life time of emitting particles.
  14802. */
  14803. minLifeTime: number;
  14804. /**
  14805. * Maximum life time of emitting particles.
  14806. */
  14807. maxLifeTime: number;
  14808. /**
  14809. * Minimum Size of emitting particles.
  14810. */
  14811. minSize: number;
  14812. /**
  14813. * Maximum Size of emitting particles.
  14814. */
  14815. maxSize: number;
  14816. /**
  14817. * Minimum scale of emitting particles on X axis.
  14818. */
  14819. minScaleX: number;
  14820. /**
  14821. * Maximum scale of emitting particles on X axis.
  14822. */
  14823. maxScaleX: number;
  14824. /**
  14825. * Minimum scale of emitting particles on Y axis.
  14826. */
  14827. minScaleY: number;
  14828. /**
  14829. * Maximum scale of emitting particles on Y axis.
  14830. */
  14831. maxScaleY: number;
  14832. /**
  14833. * Gets or sets the minimal initial rotation in radians.
  14834. */
  14835. minInitialRotation: number;
  14836. /**
  14837. * Gets or sets the maximal initial rotation in radians.
  14838. */
  14839. maxInitialRotation: number;
  14840. /**
  14841. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14842. */
  14843. minAngularSpeed: number;
  14844. /**
  14845. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14846. */
  14847. maxAngularSpeed: number;
  14848. /**
  14849. * The texture used to render each particle. (this can be a spritesheet)
  14850. */
  14851. particleTexture: Nullable<BaseTexture>;
  14852. /**
  14853. * The layer mask we are rendering the particles through.
  14854. */
  14855. layerMask: number;
  14856. /**
  14857. * This can help using your own shader to render the particle system.
  14858. * The according effect will be created
  14859. */
  14860. customShader: any;
  14861. /**
  14862. * By default particle system starts as soon as they are created. This prevents the
  14863. * automatic start to happen and let you decide when to start emitting particles.
  14864. */
  14865. preventAutoStart: boolean;
  14866. private _noiseTexture;
  14867. /**
  14868. * Gets or sets a texture used to add random noise to particle positions
  14869. */
  14870. get noiseTexture(): Nullable<ProceduralTexture>;
  14871. set noiseTexture(value: Nullable<ProceduralTexture>);
  14872. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14873. noiseStrength: Vector3;
  14874. /**
  14875. * Callback triggered when the particle animation is ending.
  14876. */
  14877. onAnimationEnd: Nullable<() => void>;
  14878. /**
  14879. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14880. */
  14881. blendMode: number;
  14882. /**
  14883. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14884. * to override the particles.
  14885. */
  14886. forceDepthWrite: boolean;
  14887. /** 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 */
  14888. preWarmCycles: number;
  14889. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14890. preWarmStepOffset: number;
  14891. /**
  14892. * 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)
  14893. */
  14894. spriteCellChangeSpeed: number;
  14895. /**
  14896. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14897. */
  14898. startSpriteCellID: number;
  14899. /**
  14900. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14901. */
  14902. endSpriteCellID: number;
  14903. /**
  14904. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14905. */
  14906. spriteCellWidth: number;
  14907. /**
  14908. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14909. */
  14910. spriteCellHeight: number;
  14911. /**
  14912. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14913. */
  14914. spriteRandomStartCell: boolean;
  14915. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14916. translationPivot: Vector2;
  14917. /** @hidden */
  14918. protected _isAnimationSheetEnabled: boolean;
  14919. /**
  14920. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14921. */
  14922. beginAnimationOnStart: boolean;
  14923. /**
  14924. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14925. */
  14926. beginAnimationFrom: number;
  14927. /**
  14928. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14929. */
  14930. beginAnimationTo: number;
  14931. /**
  14932. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14933. */
  14934. beginAnimationLoop: boolean;
  14935. /**
  14936. * Gets or sets a world offset applied to all particles
  14937. */
  14938. worldOffset: Vector3;
  14939. /**
  14940. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14941. */
  14942. get isAnimationSheetEnabled(): boolean;
  14943. set isAnimationSheetEnabled(value: boolean);
  14944. /**
  14945. * Get hosting scene
  14946. * @returns the scene
  14947. */
  14948. getScene(): Nullable<Scene>;
  14949. /**
  14950. * You can use gravity if you want to give an orientation to your particles.
  14951. */
  14952. gravity: Vector3;
  14953. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14954. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14955. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14956. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14957. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14958. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14959. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14960. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14961. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14962. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14963. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14964. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14965. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14966. /**
  14967. * Defines the delay in milliseconds before starting the system (0 by default)
  14968. */
  14969. startDelay: number;
  14970. /**
  14971. * Gets the current list of drag gradients.
  14972. * You must use addDragGradient and removeDragGradient to udpate this list
  14973. * @returns the list of drag gradients
  14974. */
  14975. getDragGradients(): Nullable<Array<FactorGradient>>;
  14976. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14977. limitVelocityDamping: number;
  14978. /**
  14979. * Gets the current list of limit velocity gradients.
  14980. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14981. * @returns the list of limit velocity gradients
  14982. */
  14983. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14984. /**
  14985. * Gets the current list of color gradients.
  14986. * You must use addColorGradient and removeColorGradient to udpate this list
  14987. * @returns the list of color gradients
  14988. */
  14989. getColorGradients(): Nullable<Array<ColorGradient>>;
  14990. /**
  14991. * Gets the current list of size gradients.
  14992. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14993. * @returns the list of size gradients
  14994. */
  14995. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14996. /**
  14997. * Gets the current list of color remap gradients.
  14998. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14999. * @returns the list of color remap gradients
  15000. */
  15001. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15002. /**
  15003. * Gets the current list of alpha remap gradients.
  15004. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15005. * @returns the list of alpha remap gradients
  15006. */
  15007. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15008. /**
  15009. * Gets the current list of life time gradients.
  15010. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15011. * @returns the list of life time gradients
  15012. */
  15013. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15014. /**
  15015. * Gets the current list of angular speed gradients.
  15016. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15017. * @returns the list of angular speed gradients
  15018. */
  15019. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15020. /**
  15021. * Gets the current list of velocity gradients.
  15022. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15023. * @returns the list of velocity gradients
  15024. */
  15025. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15026. /**
  15027. * Gets the current list of start size gradients.
  15028. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15029. * @returns the list of start size gradients
  15030. */
  15031. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15032. /**
  15033. * Gets the current list of emit rate gradients.
  15034. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15035. * @returns the list of emit rate gradients
  15036. */
  15037. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15038. /**
  15039. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15040. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15041. */
  15042. get direction1(): Vector3;
  15043. set direction1(value: Vector3);
  15044. /**
  15045. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15046. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15047. */
  15048. get direction2(): Vector3;
  15049. set direction2(value: Vector3);
  15050. /**
  15051. * 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.
  15052. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15053. */
  15054. get minEmitBox(): Vector3;
  15055. set minEmitBox(value: Vector3);
  15056. /**
  15057. * 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.
  15058. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15059. */
  15060. get maxEmitBox(): Vector3;
  15061. set maxEmitBox(value: Vector3);
  15062. /**
  15063. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15064. */
  15065. color1: Color4;
  15066. /**
  15067. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15068. */
  15069. color2: Color4;
  15070. /**
  15071. * Color the particle will have at the end of its lifetime
  15072. */
  15073. colorDead: Color4;
  15074. /**
  15075. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15076. */
  15077. textureMask: Color4;
  15078. /**
  15079. * The particle emitter type defines the emitter used by the particle system.
  15080. * It can be for example box, sphere, or cone...
  15081. */
  15082. particleEmitterType: IParticleEmitterType;
  15083. /** @hidden */
  15084. _isSubEmitter: boolean;
  15085. /**
  15086. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15087. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15088. */
  15089. billboardMode: number;
  15090. protected _isBillboardBased: boolean;
  15091. /**
  15092. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15093. */
  15094. get isBillboardBased(): boolean;
  15095. set isBillboardBased(value: boolean);
  15096. /**
  15097. * The scene the particle system belongs to.
  15098. */
  15099. protected _scene: Nullable<Scene>;
  15100. /**
  15101. * The engine the particle system belongs to.
  15102. */
  15103. protected _engine: ThinEngine;
  15104. /**
  15105. * Local cache of defines for image processing.
  15106. */
  15107. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15108. /**
  15109. * Default configuration related to image processing available in the standard Material.
  15110. */
  15111. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15112. /**
  15113. * Gets the image processing configuration used either in this material.
  15114. */
  15115. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15116. /**
  15117. * Sets the Default image processing configuration used either in the this material.
  15118. *
  15119. * If sets to null, the scene one is in use.
  15120. */
  15121. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15122. /**
  15123. * Attaches a new image processing configuration to the Standard Material.
  15124. * @param configuration
  15125. */
  15126. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15127. /** @hidden */
  15128. protected _reset(): void;
  15129. /** @hidden */
  15130. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15131. /**
  15132. * Instantiates a particle system.
  15133. * 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.
  15134. * @param name The name of the particle system
  15135. */
  15136. constructor(name: string);
  15137. /**
  15138. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15139. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15140. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15141. * @returns the emitter
  15142. */
  15143. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15144. /**
  15145. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15146. * @param radius The radius of the hemisphere to emit from
  15147. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15148. * @returns the emitter
  15149. */
  15150. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15151. /**
  15152. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15153. * @param radius The radius of the sphere to emit from
  15154. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15155. * @returns the emitter
  15156. */
  15157. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15158. /**
  15159. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15160. * @param radius The radius of the sphere to emit from
  15161. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15162. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15163. * @returns the emitter
  15164. */
  15165. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15166. /**
  15167. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15168. * @param radius The radius of the emission cylinder
  15169. * @param height The height of the emission cylinder
  15170. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15171. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15172. * @returns the emitter
  15173. */
  15174. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15175. /**
  15176. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15177. * @param radius The radius of the cylinder to emit from
  15178. * @param height The height of the emission cylinder
  15179. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15180. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15181. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15182. * @returns the emitter
  15183. */
  15184. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15185. /**
  15186. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15187. * @param radius The radius of the cone to emit from
  15188. * @param angle The base angle of the cone
  15189. * @returns the emitter
  15190. */
  15191. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15192. /**
  15193. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15194. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15195. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15196. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15197. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15198. * @returns the emitter
  15199. */
  15200. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15201. }
  15202. }
  15203. declare module "babylonjs/Particles/subEmitter" {
  15204. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15205. import { Scene } from "babylonjs/scene";
  15206. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15207. /**
  15208. * Type of sub emitter
  15209. */
  15210. export enum SubEmitterType {
  15211. /**
  15212. * Attached to the particle over it's lifetime
  15213. */
  15214. ATTACHED = 0,
  15215. /**
  15216. * Created when the particle dies
  15217. */
  15218. END = 1
  15219. }
  15220. /**
  15221. * Sub emitter class used to emit particles from an existing particle
  15222. */
  15223. export class SubEmitter {
  15224. /**
  15225. * the particle system to be used by the sub emitter
  15226. */
  15227. particleSystem: ParticleSystem;
  15228. /**
  15229. * Type of the submitter (Default: END)
  15230. */
  15231. type: SubEmitterType;
  15232. /**
  15233. * 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)
  15234. * Note: This only is supported when using an emitter of type Mesh
  15235. */
  15236. inheritDirection: boolean;
  15237. /**
  15238. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15239. */
  15240. inheritedVelocityAmount: number;
  15241. /**
  15242. * Creates a sub emitter
  15243. * @param particleSystem the particle system to be used by the sub emitter
  15244. */
  15245. constructor(
  15246. /**
  15247. * the particle system to be used by the sub emitter
  15248. */
  15249. particleSystem: ParticleSystem);
  15250. /**
  15251. * Clones the sub emitter
  15252. * @returns the cloned sub emitter
  15253. */
  15254. clone(): SubEmitter;
  15255. /**
  15256. * Serialize current object to a JSON object
  15257. * @returns the serialized object
  15258. */
  15259. serialize(): any;
  15260. /** @hidden */
  15261. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15262. /**
  15263. * Creates a new SubEmitter from a serialized JSON version
  15264. * @param serializationObject defines the JSON object to read from
  15265. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15266. * @param rootUrl defines the rootUrl for data loading
  15267. * @returns a new SubEmitter
  15268. */
  15269. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15270. /** Release associated resources */
  15271. dispose(): void;
  15272. }
  15273. }
  15274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15275. /** @hidden */
  15276. export var clipPlaneFragmentDeclaration: {
  15277. name: string;
  15278. shader: string;
  15279. };
  15280. }
  15281. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15282. /** @hidden */
  15283. export var imageProcessingDeclaration: {
  15284. name: string;
  15285. shader: string;
  15286. };
  15287. }
  15288. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15289. /** @hidden */
  15290. export var imageProcessingFunctions: {
  15291. name: string;
  15292. shader: string;
  15293. };
  15294. }
  15295. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15296. /** @hidden */
  15297. export var clipPlaneFragment: {
  15298. name: string;
  15299. shader: string;
  15300. };
  15301. }
  15302. declare module "babylonjs/Shaders/particles.fragment" {
  15303. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15304. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15305. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15306. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15307. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15308. /** @hidden */
  15309. export var particlesPixelShader: {
  15310. name: string;
  15311. shader: string;
  15312. };
  15313. }
  15314. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15315. /** @hidden */
  15316. export var clipPlaneVertexDeclaration: {
  15317. name: string;
  15318. shader: string;
  15319. };
  15320. }
  15321. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15322. /** @hidden */
  15323. export var clipPlaneVertex: {
  15324. name: string;
  15325. shader: string;
  15326. };
  15327. }
  15328. declare module "babylonjs/Shaders/particles.vertex" {
  15329. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15330. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15331. /** @hidden */
  15332. export var particlesVertexShader: {
  15333. name: string;
  15334. shader: string;
  15335. };
  15336. }
  15337. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  15338. import { Nullable } from "babylonjs/types";
  15339. import { Plane } from "babylonjs/Maths/math";
  15340. /**
  15341. * Interface used to define entities containing multiple clip planes
  15342. */
  15343. export interface IClipPlanesHolder {
  15344. /**
  15345. * Gets or sets the active clipplane 1
  15346. */
  15347. clipPlane: Nullable<Plane>;
  15348. /**
  15349. * Gets or sets the active clipplane 2
  15350. */
  15351. clipPlane2: Nullable<Plane>;
  15352. /**
  15353. * Gets or sets the active clipplane 3
  15354. */
  15355. clipPlane3: Nullable<Plane>;
  15356. /**
  15357. * Gets or sets the active clipplane 4
  15358. */
  15359. clipPlane4: Nullable<Plane>;
  15360. /**
  15361. * Gets or sets the active clipplane 5
  15362. */
  15363. clipPlane5: Nullable<Plane>;
  15364. /**
  15365. * Gets or sets the active clipplane 6
  15366. */
  15367. clipPlane6: Nullable<Plane>;
  15368. }
  15369. }
  15370. declare module "babylonjs/Materials/thinMaterialHelper" {
  15371. import { Effect } from "babylonjs/Materials/effect";
  15372. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  15373. /**
  15374. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15375. *
  15376. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15377. *
  15378. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15379. */
  15380. export class ThinMaterialHelper {
  15381. /**
  15382. * Binds the clip plane information from the holder to the effect.
  15383. * @param effect The effect we are binding the data to
  15384. * @param holder The entity containing the clip plane information
  15385. */
  15386. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15387. }
  15388. }
  15389. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  15390. module "babylonjs/Engines/thinEngine" {
  15391. interface ThinEngine {
  15392. /**
  15393. * Sets alpha constants used by some alpha blending modes
  15394. * @param r defines the red component
  15395. * @param g defines the green component
  15396. * @param b defines the blue component
  15397. * @param a defines the alpha component
  15398. */
  15399. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15400. /**
  15401. * Sets the current alpha mode
  15402. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15403. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15404. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15405. */
  15406. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15407. /**
  15408. * Gets the current alpha mode
  15409. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15410. * @returns the current alpha mode
  15411. */
  15412. getAlphaMode(): number;
  15413. /**
  15414. * Sets the current alpha equation
  15415. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15416. */
  15417. setAlphaEquation(equation: number): void;
  15418. /**
  15419. * Gets the current alpha equation.
  15420. * @returns the current alpha equation
  15421. */
  15422. getAlphaEquation(): number;
  15423. }
  15424. }
  15425. }
  15426. declare module "babylonjs/Particles/particleSystem" {
  15427. import { Nullable } from "babylonjs/types";
  15428. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  15429. import { Observable } from "babylonjs/Misc/observable";
  15430. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15431. import { Effect } from "babylonjs/Materials/effect";
  15432. import { IDisposable } from "babylonjs/scene";
  15433. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15434. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15435. import { Particle } from "babylonjs/Particles/particle";
  15436. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15437. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15438. import "babylonjs/Shaders/particles.fragment";
  15439. import "babylonjs/Shaders/particles.vertex";
  15440. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  15441. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15442. import "babylonjs/Engines/Extensions/engine.alpha";
  15443. import { Scene } from "babylonjs/scene";
  15444. /**
  15445. * This represents a particle system in Babylon.
  15446. * 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.
  15447. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15448. * @example https://doc.babylonjs.com/babylon101/particles
  15449. */
  15450. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15451. /**
  15452. * Billboard mode will only apply to Y axis
  15453. */
  15454. static readonly BILLBOARDMODE_Y: number;
  15455. /**
  15456. * Billboard mode will apply to all axes
  15457. */
  15458. static readonly BILLBOARDMODE_ALL: number;
  15459. /**
  15460. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15461. */
  15462. static readonly BILLBOARDMODE_STRETCHED: number;
  15463. /**
  15464. * This function can be defined to provide custom update for active particles.
  15465. * This function will be called instead of regular update (age, position, color, etc.).
  15466. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15467. */
  15468. updateFunction: (particles: Particle[]) => void;
  15469. private _emitterWorldMatrix;
  15470. /**
  15471. * This function can be defined to specify initial direction for every new particle.
  15472. * It by default use the emitterType defined function
  15473. */
  15474. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15475. /**
  15476. * This function can be defined to specify initial position for every new particle.
  15477. * It by default use the emitterType defined function
  15478. */
  15479. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15480. /**
  15481. * @hidden
  15482. */
  15483. _inheritedVelocityOffset: Vector3;
  15484. /**
  15485. * An event triggered when the system is disposed
  15486. */
  15487. onDisposeObservable: Observable<IParticleSystem>;
  15488. /**
  15489. * An event triggered when the system is stopped
  15490. */
  15491. onStoppedObservable: Observable<IParticleSystem>;
  15492. private _onDisposeObserver;
  15493. /**
  15494. * Sets a callback that will be triggered when the system is disposed
  15495. */
  15496. set onDispose(callback: () => void);
  15497. private _particles;
  15498. private _epsilon;
  15499. private _capacity;
  15500. private _stockParticles;
  15501. private _newPartsExcess;
  15502. private _vertexData;
  15503. private _vertexBuffer;
  15504. private _vertexBuffers;
  15505. private _spriteBuffer;
  15506. private _indexBuffer;
  15507. private _effect;
  15508. private _customEffect;
  15509. private _cachedDefines;
  15510. private _scaledColorStep;
  15511. private _colorDiff;
  15512. private _scaledDirection;
  15513. private _scaledGravity;
  15514. private _currentRenderId;
  15515. private _alive;
  15516. private _useInstancing;
  15517. private _vertexArrayObject;
  15518. private _started;
  15519. private _stopped;
  15520. private _actualFrame;
  15521. private _scaledUpdateSpeed;
  15522. private _vertexBufferSize;
  15523. /** @hidden */
  15524. _currentEmitRateGradient: Nullable<FactorGradient>;
  15525. /** @hidden */
  15526. _currentEmitRate1: number;
  15527. /** @hidden */
  15528. _currentEmitRate2: number;
  15529. /** @hidden */
  15530. _currentStartSizeGradient: Nullable<FactorGradient>;
  15531. /** @hidden */
  15532. _currentStartSize1: number;
  15533. /** @hidden */
  15534. _currentStartSize2: number;
  15535. private readonly _rawTextureWidth;
  15536. private _rampGradientsTexture;
  15537. private _useRampGradients;
  15538. /** Gets or sets a matrix to use to compute projection */
  15539. defaultProjectionMatrix: Matrix;
  15540. /** Gets or sets a matrix to use to compute view */
  15541. defaultViewMatrix: Matrix;
  15542. /** Gets or sets a boolean indicating that ramp gradients must be used
  15543. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15544. */
  15545. get useRampGradients(): boolean;
  15546. set useRampGradients(value: boolean);
  15547. /**
  15548. * 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.
  15549. * 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: [])
  15550. */
  15551. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15552. private _subEmitters;
  15553. /**
  15554. * @hidden
  15555. * If the particle systems emitter should be disposed when the particle system is disposed
  15556. */
  15557. _disposeEmitterOnDispose: boolean;
  15558. /**
  15559. * The current active Sub-systems, this property is used by the root particle system only.
  15560. */
  15561. activeSubSystems: Array<ParticleSystem>;
  15562. /**
  15563. * Specifies if the particles are updated in emitter local space or world space
  15564. */
  15565. isLocal: boolean;
  15566. private _rootParticleSystem;
  15567. /**
  15568. * Gets the current list of active particles
  15569. */
  15570. get particles(): Particle[];
  15571. /**
  15572. * Gets the number of particles active at the same time.
  15573. * @returns The number of active particles.
  15574. */
  15575. getActiveCount(): number;
  15576. /**
  15577. * Returns the string "ParticleSystem"
  15578. * @returns a string containing the class name
  15579. */
  15580. getClassName(): string;
  15581. /**
  15582. * Gets a boolean indicating that the system is stopping
  15583. * @returns true if the system is currently stopping
  15584. */
  15585. isStopping(): boolean;
  15586. /**
  15587. * Gets the custom effect used to render the particles
  15588. * @param blendMode Blend mode for which the effect should be retrieved
  15589. * @returns The effect
  15590. */
  15591. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15592. /**
  15593. * Sets the custom effect used to render the particles
  15594. * @param effect The effect to set
  15595. * @param blendMode Blend mode for which the effect should be set
  15596. */
  15597. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15598. /** @hidden */
  15599. private _onBeforeDrawParticlesObservable;
  15600. /**
  15601. * Observable that will be called just before the particles are drawn
  15602. */
  15603. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15604. /**
  15605. * Gets the name of the particle vertex shader
  15606. */
  15607. get vertexShaderName(): string;
  15608. /**
  15609. * Instantiates a particle system.
  15610. * 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.
  15611. * @param name The name of the particle system
  15612. * @param capacity The max number of particles alive at the same time
  15613. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15614. * @param customEffect a custom effect used to change the way particles are rendered by default
  15615. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15616. * @param epsilon Offset used to render the particles
  15617. */
  15618. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15619. private _addFactorGradient;
  15620. private _removeFactorGradient;
  15621. /**
  15622. * Adds a new life time gradient
  15623. * @param gradient defines the gradient to use (between 0 and 1)
  15624. * @param factor defines the life time factor to affect to the specified gradient
  15625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15626. * @returns the current particle system
  15627. */
  15628. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15629. /**
  15630. * Remove a specific life time gradient
  15631. * @param gradient defines the gradient to remove
  15632. * @returns the current particle system
  15633. */
  15634. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15635. /**
  15636. * Adds a new size gradient
  15637. * @param gradient defines the gradient to use (between 0 and 1)
  15638. * @param factor defines the size factor to affect to the specified gradient
  15639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15640. * @returns the current particle system
  15641. */
  15642. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15643. /**
  15644. * Remove a specific size gradient
  15645. * @param gradient defines the gradient to remove
  15646. * @returns the current particle system
  15647. */
  15648. removeSizeGradient(gradient: number): IParticleSystem;
  15649. /**
  15650. * Adds a new color remap gradient
  15651. * @param gradient defines the gradient to use (between 0 and 1)
  15652. * @param min defines the color remap minimal range
  15653. * @param max defines the color remap maximal range
  15654. * @returns the current particle system
  15655. */
  15656. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15657. /**
  15658. * Remove a specific color remap gradient
  15659. * @param gradient defines the gradient to remove
  15660. * @returns the current particle system
  15661. */
  15662. removeColorRemapGradient(gradient: number): IParticleSystem;
  15663. /**
  15664. * Adds a new alpha remap gradient
  15665. * @param gradient defines the gradient to use (between 0 and 1)
  15666. * @param min defines the alpha remap minimal range
  15667. * @param max defines the alpha remap maximal range
  15668. * @returns the current particle system
  15669. */
  15670. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15671. /**
  15672. * Remove a specific alpha remap gradient
  15673. * @param gradient defines the gradient to remove
  15674. * @returns the current particle system
  15675. */
  15676. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15677. /**
  15678. * Adds a new angular speed gradient
  15679. * @param gradient defines the gradient to use (between 0 and 1)
  15680. * @param factor defines the angular speed to affect to the specified gradient
  15681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15682. * @returns the current particle system
  15683. */
  15684. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15685. /**
  15686. * Remove a specific angular speed gradient
  15687. * @param gradient defines the gradient to remove
  15688. * @returns the current particle system
  15689. */
  15690. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15691. /**
  15692. * Adds a new velocity gradient
  15693. * @param gradient defines the gradient to use (between 0 and 1)
  15694. * @param factor defines the velocity to affect to the specified gradient
  15695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15696. * @returns the current particle system
  15697. */
  15698. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15699. /**
  15700. * Remove a specific velocity gradient
  15701. * @param gradient defines the gradient to remove
  15702. * @returns the current particle system
  15703. */
  15704. removeVelocityGradient(gradient: number): IParticleSystem;
  15705. /**
  15706. * Adds a new limit velocity gradient
  15707. * @param gradient defines the gradient to use (between 0 and 1)
  15708. * @param factor defines the limit velocity value to affect to the specified gradient
  15709. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15710. * @returns the current particle system
  15711. */
  15712. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15713. /**
  15714. * Remove a specific limit velocity gradient
  15715. * @param gradient defines the gradient to remove
  15716. * @returns the current particle system
  15717. */
  15718. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15719. /**
  15720. * Adds a new drag gradient
  15721. * @param gradient defines the gradient to use (between 0 and 1)
  15722. * @param factor defines the drag value to affect to the specified gradient
  15723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15724. * @returns the current particle system
  15725. */
  15726. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15727. /**
  15728. * Remove a specific drag gradient
  15729. * @param gradient defines the gradient to remove
  15730. * @returns the current particle system
  15731. */
  15732. removeDragGradient(gradient: number): IParticleSystem;
  15733. /**
  15734. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15735. * @param gradient defines the gradient to use (between 0 and 1)
  15736. * @param factor defines the emit rate value to affect to the specified gradient
  15737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15738. * @returns the current particle system
  15739. */
  15740. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15741. /**
  15742. * Remove a specific emit rate gradient
  15743. * @param gradient defines the gradient to remove
  15744. * @returns the current particle system
  15745. */
  15746. removeEmitRateGradient(gradient: number): IParticleSystem;
  15747. /**
  15748. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15749. * @param gradient defines the gradient to use (between 0 and 1)
  15750. * @param factor defines the start size value to affect to the specified gradient
  15751. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15752. * @returns the current particle system
  15753. */
  15754. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15755. /**
  15756. * Remove a specific start size gradient
  15757. * @param gradient defines the gradient to remove
  15758. * @returns the current particle system
  15759. */
  15760. removeStartSizeGradient(gradient: number): IParticleSystem;
  15761. private _createRampGradientTexture;
  15762. /**
  15763. * Gets the current list of ramp gradients.
  15764. * You must use addRampGradient and removeRampGradient to udpate this list
  15765. * @returns the list of ramp gradients
  15766. */
  15767. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15768. /** Force the system to rebuild all gradients that need to be resync */
  15769. forceRefreshGradients(): void;
  15770. private _syncRampGradientTexture;
  15771. /**
  15772. * Adds a new ramp gradient used to remap particle colors
  15773. * @param gradient defines the gradient to use (between 0 and 1)
  15774. * @param color defines the color to affect to the specified gradient
  15775. * @returns the current particle system
  15776. */
  15777. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15778. /**
  15779. * Remove a specific ramp gradient
  15780. * @param gradient defines the gradient to remove
  15781. * @returns the current particle system
  15782. */
  15783. removeRampGradient(gradient: number): ParticleSystem;
  15784. /**
  15785. * Adds a new color gradient
  15786. * @param gradient defines the gradient to use (between 0 and 1)
  15787. * @param color1 defines the color to affect to the specified gradient
  15788. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15789. * @returns this particle system
  15790. */
  15791. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15792. /**
  15793. * Remove a specific color gradient
  15794. * @param gradient defines the gradient to remove
  15795. * @returns this particle system
  15796. */
  15797. removeColorGradient(gradient: number): IParticleSystem;
  15798. private _fetchR;
  15799. protected _reset(): void;
  15800. private _resetEffect;
  15801. private _createVertexBuffers;
  15802. private _createIndexBuffer;
  15803. /**
  15804. * Gets the maximum number of particles active at the same time.
  15805. * @returns The max number of active particles.
  15806. */
  15807. getCapacity(): number;
  15808. /**
  15809. * Gets whether there are still active particles in the system.
  15810. * @returns True if it is alive, otherwise false.
  15811. */
  15812. isAlive(): boolean;
  15813. /**
  15814. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15815. * @returns True if it has been started, otherwise false.
  15816. */
  15817. isStarted(): boolean;
  15818. private _prepareSubEmitterInternalArray;
  15819. /**
  15820. * Starts the particle system and begins to emit
  15821. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15822. */
  15823. start(delay?: number): void;
  15824. /**
  15825. * Stops the particle system.
  15826. * @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.
  15827. */
  15828. stop(stopSubEmitters?: boolean): void;
  15829. /**
  15830. * Remove all active particles
  15831. */
  15832. reset(): void;
  15833. /**
  15834. * @hidden (for internal use only)
  15835. */
  15836. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15837. /**
  15838. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15839. * Its lifetime will start back at 0.
  15840. */
  15841. recycleParticle: (particle: Particle) => void;
  15842. private _stopSubEmitters;
  15843. private _createParticle;
  15844. private _removeFromRoot;
  15845. private _emitFromParticle;
  15846. private _update;
  15847. /** @hidden */
  15848. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15849. /** @hidden */
  15850. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15851. /**
  15852. * Fill the defines array according to the current settings of the particle system
  15853. * @param defines Array to be updated
  15854. * @param blendMode blend mode to take into account when updating the array
  15855. */
  15856. fillDefines(defines: Array<string>, blendMode: number): void;
  15857. /**
  15858. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15859. * @param uniforms Uniforms array to fill
  15860. * @param attributes Attributes array to fill
  15861. * @param samplers Samplers array to fill
  15862. */
  15863. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15864. /** @hidden */
  15865. private _getEffect;
  15866. /**
  15867. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15868. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15869. */
  15870. animate(preWarmOnly?: boolean): void;
  15871. private _appendParticleVertices;
  15872. /**
  15873. * Rebuilds the particle system.
  15874. */
  15875. rebuild(): void;
  15876. /**
  15877. * Is this system ready to be used/rendered
  15878. * @return true if the system is ready
  15879. */
  15880. isReady(): boolean;
  15881. private _render;
  15882. /**
  15883. * Renders the particle system in its current state.
  15884. * @returns the current number of particles
  15885. */
  15886. render(): number;
  15887. /**
  15888. * Disposes the particle system and free the associated resources
  15889. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15890. */
  15891. dispose(disposeTexture?: boolean): void;
  15892. /**
  15893. * Clones the particle system.
  15894. * @param name The name of the cloned object
  15895. * @param newEmitter The new emitter to use
  15896. * @returns the cloned particle system
  15897. */
  15898. clone(name: string, newEmitter: any): ParticleSystem;
  15899. /**
  15900. * Serializes the particle system to a JSON object
  15901. * @param serializeTexture defines if the texture must be serialized as well
  15902. * @returns the JSON object
  15903. */
  15904. serialize(serializeTexture?: boolean): any;
  15905. /** @hidden */
  15906. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15907. /** @hidden */
  15908. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15909. /**
  15910. * Parses a JSON object to create a particle system.
  15911. * @param parsedParticleSystem The JSON object to parse
  15912. * @param sceneOrEngine The scene or the engine to create the particle system in
  15913. * @param rootUrl The root url to use to load external dependencies like texture
  15914. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15915. * @returns the Parsed particle system
  15916. */
  15917. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15918. }
  15919. }
  15920. declare module "babylonjs/Particles/particle" {
  15921. import { Nullable } from "babylonjs/types";
  15922. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  15923. import { Color4 } from "babylonjs/Maths/math.color";
  15924. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15925. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15926. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  15927. /**
  15928. * A particle represents one of the element emitted by a particle system.
  15929. * This is mainly define by its coordinates, direction, velocity and age.
  15930. */
  15931. export class Particle {
  15932. /**
  15933. * The particle system the particle belongs to.
  15934. */
  15935. particleSystem: ParticleSystem;
  15936. private static _Count;
  15937. /**
  15938. * Unique ID of the particle
  15939. */
  15940. id: number;
  15941. /**
  15942. * The world position of the particle in the scene.
  15943. */
  15944. position: Vector3;
  15945. /**
  15946. * The world direction of the particle in the scene.
  15947. */
  15948. direction: Vector3;
  15949. /**
  15950. * The color of the particle.
  15951. */
  15952. color: Color4;
  15953. /**
  15954. * The color change of the particle per step.
  15955. */
  15956. colorStep: Color4;
  15957. /**
  15958. * Defines how long will the life of the particle be.
  15959. */
  15960. lifeTime: number;
  15961. /**
  15962. * The current age of the particle.
  15963. */
  15964. age: number;
  15965. /**
  15966. * The current size of the particle.
  15967. */
  15968. size: number;
  15969. /**
  15970. * The current scale of the particle.
  15971. */
  15972. scale: Vector2;
  15973. /**
  15974. * The current angle of the particle.
  15975. */
  15976. angle: number;
  15977. /**
  15978. * Defines how fast is the angle changing.
  15979. */
  15980. angularSpeed: number;
  15981. /**
  15982. * Defines the cell index used by the particle to be rendered from a sprite.
  15983. */
  15984. cellIndex: number;
  15985. /**
  15986. * The information required to support color remapping
  15987. */
  15988. remapData: Vector4;
  15989. /** @hidden */
  15990. _randomCellOffset?: number;
  15991. /** @hidden */
  15992. _initialDirection: Nullable<Vector3>;
  15993. /** @hidden */
  15994. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15995. /** @hidden */
  15996. _initialStartSpriteCellID: number;
  15997. /** @hidden */
  15998. _initialEndSpriteCellID: number;
  15999. /** @hidden */
  16000. _currentColorGradient: Nullable<ColorGradient>;
  16001. /** @hidden */
  16002. _currentColor1: Color4;
  16003. /** @hidden */
  16004. _currentColor2: Color4;
  16005. /** @hidden */
  16006. _currentSizeGradient: Nullable<FactorGradient>;
  16007. /** @hidden */
  16008. _currentSize1: number;
  16009. /** @hidden */
  16010. _currentSize2: number;
  16011. /** @hidden */
  16012. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16013. /** @hidden */
  16014. _currentAngularSpeed1: number;
  16015. /** @hidden */
  16016. _currentAngularSpeed2: number;
  16017. /** @hidden */
  16018. _currentVelocityGradient: Nullable<FactorGradient>;
  16019. /** @hidden */
  16020. _currentVelocity1: number;
  16021. /** @hidden */
  16022. _currentVelocity2: number;
  16023. /** @hidden */
  16024. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16025. /** @hidden */
  16026. _currentLimitVelocity1: number;
  16027. /** @hidden */
  16028. _currentLimitVelocity2: number;
  16029. /** @hidden */
  16030. _currentDragGradient: Nullable<FactorGradient>;
  16031. /** @hidden */
  16032. _currentDrag1: number;
  16033. /** @hidden */
  16034. _currentDrag2: number;
  16035. /** @hidden */
  16036. _randomNoiseCoordinates1: Vector3;
  16037. /** @hidden */
  16038. _randomNoiseCoordinates2: Vector3;
  16039. /** @hidden */
  16040. _localPosition?: Vector3;
  16041. /**
  16042. * Creates a new instance Particle
  16043. * @param particleSystem the particle system the particle belongs to
  16044. */
  16045. constructor(
  16046. /**
  16047. * The particle system the particle belongs to.
  16048. */
  16049. particleSystem: ParticleSystem);
  16050. private updateCellInfoFromSystem;
  16051. /**
  16052. * Defines how the sprite cell index is updated for the particle
  16053. */
  16054. updateCellIndex(): void;
  16055. /** @hidden */
  16056. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16057. /** @hidden */
  16058. _inheritParticleInfoToSubEmitters(): void;
  16059. /** @hidden */
  16060. _reset(): void;
  16061. /**
  16062. * Copy the properties of particle to another one.
  16063. * @param other the particle to copy the information to.
  16064. */
  16065. copyTo(other: Particle): void;
  16066. }
  16067. }
  16068. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  16069. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16070. import { Effect } from "babylonjs/Materials/effect";
  16071. import { Particle } from "babylonjs/Particles/particle";
  16072. import { Nullable } from "babylonjs/types";
  16073. import { Scene } from "babylonjs/scene";
  16074. /**
  16075. * Particle emitter represents a volume emitting particles.
  16076. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16077. */
  16078. export interface IParticleEmitterType {
  16079. /**
  16080. * Called by the particle System when the direction is computed for the created particle.
  16081. * @param worldMatrix is the world matrix of the particle system
  16082. * @param directionToUpdate is the direction vector to update with the result
  16083. * @param particle is the particle we are computed the direction for
  16084. * @param isLocal defines if the direction should be set in local space
  16085. */
  16086. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16087. /**
  16088. * Called by the particle System when the position is computed for the created particle.
  16089. * @param worldMatrix is the world matrix of the particle system
  16090. * @param positionToUpdate is the position vector to update with the result
  16091. * @param particle is the particle we are computed the position for
  16092. * @param isLocal defines if the position should be set in local space
  16093. */
  16094. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16095. /**
  16096. * Clones the current emitter and returns a copy of it
  16097. * @returns the new emitter
  16098. */
  16099. clone(): IParticleEmitterType;
  16100. /**
  16101. * Called by the GPUParticleSystem to setup the update shader
  16102. * @param effect defines the update shader
  16103. */
  16104. applyToShader(effect: Effect): void;
  16105. /**
  16106. * Returns a string to use to update the GPU particles update shader
  16107. * @returns the effect defines string
  16108. */
  16109. getEffectDefines(): string;
  16110. /**
  16111. * Returns a string representing the class name
  16112. * @returns a string containing the class name
  16113. */
  16114. getClassName(): string;
  16115. /**
  16116. * Serializes the particle system to a JSON object.
  16117. * @returns the JSON object
  16118. */
  16119. serialize(): any;
  16120. /**
  16121. * Parse properties from a JSON object
  16122. * @param serializationObject defines the JSON object
  16123. * @param scene defines the hosting scene
  16124. */
  16125. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16126. }
  16127. }
  16128. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16129. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16130. import { Effect } from "babylonjs/Materials/effect";
  16131. import { Particle } from "babylonjs/Particles/particle";
  16132. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16133. /**
  16134. * Particle emitter emitting particles from the inside of a box.
  16135. * It emits the particles randomly between 2 given directions.
  16136. */
  16137. export class BoxParticleEmitter implements IParticleEmitterType {
  16138. /**
  16139. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16140. */
  16141. direction1: Vector3;
  16142. /**
  16143. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16144. */
  16145. direction2: Vector3;
  16146. /**
  16147. * 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.
  16148. */
  16149. minEmitBox: Vector3;
  16150. /**
  16151. * 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.
  16152. */
  16153. maxEmitBox: Vector3;
  16154. /**
  16155. * Creates a new instance BoxParticleEmitter
  16156. */
  16157. constructor();
  16158. /**
  16159. * Called by the particle System when the direction is computed for the created particle.
  16160. * @param worldMatrix is the world matrix of the particle system
  16161. * @param directionToUpdate is the direction vector to update with the result
  16162. * @param particle is the particle we are computed the direction for
  16163. * @param isLocal defines if the direction should be set in local space
  16164. */
  16165. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16166. /**
  16167. * Called by the particle System when the position is computed for the created particle.
  16168. * @param worldMatrix is the world matrix of the particle system
  16169. * @param positionToUpdate is the position vector to update with the result
  16170. * @param particle is the particle we are computed the position for
  16171. * @param isLocal defines if the position should be set in local space
  16172. */
  16173. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16174. /**
  16175. * Clones the current emitter and returns a copy of it
  16176. * @returns the new emitter
  16177. */
  16178. clone(): BoxParticleEmitter;
  16179. /**
  16180. * Called by the GPUParticleSystem to setup the update shader
  16181. * @param effect defines the update shader
  16182. */
  16183. applyToShader(effect: Effect): void;
  16184. /**
  16185. * Returns a string to use to update the GPU particles update shader
  16186. * @returns a string containng the defines string
  16187. */
  16188. getEffectDefines(): string;
  16189. /**
  16190. * Returns the string "BoxParticleEmitter"
  16191. * @returns a string containing the class name
  16192. */
  16193. getClassName(): string;
  16194. /**
  16195. * Serializes the particle system to a JSON object.
  16196. * @returns the JSON object
  16197. */
  16198. serialize(): any;
  16199. /**
  16200. * Parse properties from a JSON object
  16201. * @param serializationObject defines the JSON object
  16202. */
  16203. parse(serializationObject: any): void;
  16204. }
  16205. }
  16206. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16207. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16208. import { Effect } from "babylonjs/Materials/effect";
  16209. import { Particle } from "babylonjs/Particles/particle";
  16210. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16211. /**
  16212. * Particle emitter emitting particles from the inside of a cone.
  16213. * It emits the particles alongside the cone volume from the base to the particle.
  16214. * The emission direction might be randomized.
  16215. */
  16216. export class ConeParticleEmitter implements IParticleEmitterType {
  16217. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16218. directionRandomizer: number;
  16219. private _radius;
  16220. private _angle;
  16221. private _height;
  16222. /**
  16223. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16224. */
  16225. radiusRange: number;
  16226. /**
  16227. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16228. */
  16229. heightRange: number;
  16230. /**
  16231. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16232. */
  16233. emitFromSpawnPointOnly: boolean;
  16234. /**
  16235. * Gets or sets the radius of the emission cone
  16236. */
  16237. get radius(): number;
  16238. set radius(value: number);
  16239. /**
  16240. * Gets or sets the angle of the emission cone
  16241. */
  16242. get angle(): number;
  16243. set angle(value: number);
  16244. private _buildHeight;
  16245. /**
  16246. * Creates a new instance ConeParticleEmitter
  16247. * @param radius the radius of the emission cone (1 by default)
  16248. * @param angle the cone base angle (PI by default)
  16249. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16250. */
  16251. constructor(radius?: number, angle?: number,
  16252. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16253. directionRandomizer?: number);
  16254. /**
  16255. * Called by the particle System when the direction is computed for the created particle.
  16256. * @param worldMatrix is the world matrix of the particle system
  16257. * @param directionToUpdate is the direction vector to update with the result
  16258. * @param particle is the particle we are computed the direction for
  16259. * @param isLocal defines if the direction should be set in local space
  16260. */
  16261. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16262. /**
  16263. * Called by the particle System when the position is computed for the created particle.
  16264. * @param worldMatrix is the world matrix of the particle system
  16265. * @param positionToUpdate is the position vector to update with the result
  16266. * @param particle is the particle we are computed the position for
  16267. * @param isLocal defines if the position should be set in local space
  16268. */
  16269. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16270. /**
  16271. * Clones the current emitter and returns a copy of it
  16272. * @returns the new emitter
  16273. */
  16274. clone(): ConeParticleEmitter;
  16275. /**
  16276. * Called by the GPUParticleSystem to setup the update shader
  16277. * @param effect defines the update shader
  16278. */
  16279. applyToShader(effect: Effect): void;
  16280. /**
  16281. * Returns a string to use to update the GPU particles update shader
  16282. * @returns a string containng the defines string
  16283. */
  16284. getEffectDefines(): string;
  16285. /**
  16286. * Returns the string "ConeParticleEmitter"
  16287. * @returns a string containing the class name
  16288. */
  16289. getClassName(): string;
  16290. /**
  16291. * Serializes the particle system to a JSON object.
  16292. * @returns the JSON object
  16293. */
  16294. serialize(): any;
  16295. /**
  16296. * Parse properties from a JSON object
  16297. * @param serializationObject defines the JSON object
  16298. */
  16299. parse(serializationObject: any): void;
  16300. }
  16301. }
  16302. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16303. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16304. import { Effect } from "babylonjs/Materials/effect";
  16305. import { Particle } from "babylonjs/Particles/particle";
  16306. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16307. /**
  16308. * Particle emitter emitting particles from the inside of a cylinder.
  16309. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16310. */
  16311. export class CylinderParticleEmitter implements IParticleEmitterType {
  16312. /**
  16313. * The radius of the emission cylinder.
  16314. */
  16315. radius: number;
  16316. /**
  16317. * The height of the emission cylinder.
  16318. */
  16319. height: number;
  16320. /**
  16321. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16322. */
  16323. radiusRange: number;
  16324. /**
  16325. * How much to randomize the particle direction [0-1].
  16326. */
  16327. directionRandomizer: number;
  16328. /**
  16329. * Creates a new instance CylinderParticleEmitter
  16330. * @param radius the radius of the emission cylinder (1 by default)
  16331. * @param height the height of the emission cylinder (1 by default)
  16332. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16333. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16334. */
  16335. constructor(
  16336. /**
  16337. * The radius of the emission cylinder.
  16338. */
  16339. radius?: number,
  16340. /**
  16341. * The height of the emission cylinder.
  16342. */
  16343. height?: number,
  16344. /**
  16345. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16346. */
  16347. radiusRange?: number,
  16348. /**
  16349. * How much to randomize the particle direction [0-1].
  16350. */
  16351. directionRandomizer?: number);
  16352. /**
  16353. * Called by the particle System when the direction is computed for the created particle.
  16354. * @param worldMatrix is the world matrix of the particle system
  16355. * @param directionToUpdate is the direction vector to update with the result
  16356. * @param particle is the particle we are computed the direction for
  16357. * @param isLocal defines if the direction should be set in local space
  16358. */
  16359. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16360. /**
  16361. * Called by the particle System when the position is computed for the created particle.
  16362. * @param worldMatrix is the world matrix of the particle system
  16363. * @param positionToUpdate is the position vector to update with the result
  16364. * @param particle is the particle we are computed the position for
  16365. * @param isLocal defines if the position should be set in local space
  16366. */
  16367. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16368. /**
  16369. * Clones the current emitter and returns a copy of it
  16370. * @returns the new emitter
  16371. */
  16372. clone(): CylinderParticleEmitter;
  16373. /**
  16374. * Called by the GPUParticleSystem to setup the update shader
  16375. * @param effect defines the update shader
  16376. */
  16377. applyToShader(effect: Effect): void;
  16378. /**
  16379. * Returns a string to use to update the GPU particles update shader
  16380. * @returns a string containng the defines string
  16381. */
  16382. getEffectDefines(): string;
  16383. /**
  16384. * Returns the string "CylinderParticleEmitter"
  16385. * @returns a string containing the class name
  16386. */
  16387. getClassName(): string;
  16388. /**
  16389. * Serializes the particle system to a JSON object.
  16390. * @returns the JSON object
  16391. */
  16392. serialize(): any;
  16393. /**
  16394. * Parse properties from a JSON object
  16395. * @param serializationObject defines the JSON object
  16396. */
  16397. parse(serializationObject: any): void;
  16398. }
  16399. /**
  16400. * Particle emitter emitting particles from the inside of a cylinder.
  16401. * It emits the particles randomly between two vectors.
  16402. */
  16403. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16404. /**
  16405. * The min limit of the emission direction.
  16406. */
  16407. direction1: Vector3;
  16408. /**
  16409. * The max limit of the emission direction.
  16410. */
  16411. direction2: Vector3;
  16412. /**
  16413. * Creates a new instance CylinderDirectedParticleEmitter
  16414. * @param radius the radius of the emission cylinder (1 by default)
  16415. * @param height the height of the emission cylinder (1 by default)
  16416. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16417. * @param direction1 the min limit of the emission direction (up vector by default)
  16418. * @param direction2 the max limit of the emission direction (up vector by default)
  16419. */
  16420. constructor(radius?: number, height?: number, radiusRange?: number,
  16421. /**
  16422. * The min limit of the emission direction.
  16423. */
  16424. direction1?: Vector3,
  16425. /**
  16426. * The max limit of the emission direction.
  16427. */
  16428. direction2?: Vector3);
  16429. /**
  16430. * Called by the particle System when the direction is computed for the created particle.
  16431. * @param worldMatrix is the world matrix of the particle system
  16432. * @param directionToUpdate is the direction vector to update with the result
  16433. * @param particle is the particle we are computed the direction for
  16434. */
  16435. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16436. /**
  16437. * Clones the current emitter and returns a copy of it
  16438. * @returns the new emitter
  16439. */
  16440. clone(): CylinderDirectedParticleEmitter;
  16441. /**
  16442. * Called by the GPUParticleSystem to setup the update shader
  16443. * @param effect defines the update shader
  16444. */
  16445. applyToShader(effect: Effect): void;
  16446. /**
  16447. * Returns a string to use to update the GPU particles update shader
  16448. * @returns a string containng the defines string
  16449. */
  16450. getEffectDefines(): string;
  16451. /**
  16452. * Returns the string "CylinderDirectedParticleEmitter"
  16453. * @returns a string containing the class name
  16454. */
  16455. getClassName(): string;
  16456. /**
  16457. * Serializes the particle system to a JSON object.
  16458. * @returns the JSON object
  16459. */
  16460. serialize(): any;
  16461. /**
  16462. * Parse properties from a JSON object
  16463. * @param serializationObject defines the JSON object
  16464. */
  16465. parse(serializationObject: any): void;
  16466. }
  16467. }
  16468. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16469. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16470. import { Effect } from "babylonjs/Materials/effect";
  16471. import { Particle } from "babylonjs/Particles/particle";
  16472. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16473. /**
  16474. * Particle emitter emitting particles from the inside of a hemisphere.
  16475. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16476. */
  16477. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16478. /**
  16479. * The radius of the emission hemisphere.
  16480. */
  16481. radius: number;
  16482. /**
  16483. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16484. */
  16485. radiusRange: number;
  16486. /**
  16487. * How much to randomize the particle direction [0-1].
  16488. */
  16489. directionRandomizer: number;
  16490. /**
  16491. * Creates a new instance HemisphericParticleEmitter
  16492. * @param radius the radius of the emission hemisphere (1 by default)
  16493. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16494. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16495. */
  16496. constructor(
  16497. /**
  16498. * The radius of the emission hemisphere.
  16499. */
  16500. radius?: number,
  16501. /**
  16502. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16503. */
  16504. radiusRange?: number,
  16505. /**
  16506. * How much to randomize the particle direction [0-1].
  16507. */
  16508. directionRandomizer?: number);
  16509. /**
  16510. * Called by the particle System when the direction is computed for the created particle.
  16511. * @param worldMatrix is the world matrix of the particle system
  16512. * @param directionToUpdate is the direction vector to update with the result
  16513. * @param particle is the particle we are computed the direction for
  16514. * @param isLocal defines if the direction should be set in local space
  16515. */
  16516. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16517. /**
  16518. * Called by the particle System when the position is computed for the created particle.
  16519. * @param worldMatrix is the world matrix of the particle system
  16520. * @param positionToUpdate is the position vector to update with the result
  16521. * @param particle is the particle we are computed the position for
  16522. * @param isLocal defines if the position should be set in local space
  16523. */
  16524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16525. /**
  16526. * Clones the current emitter and returns a copy of it
  16527. * @returns the new emitter
  16528. */
  16529. clone(): HemisphericParticleEmitter;
  16530. /**
  16531. * Called by the GPUParticleSystem to setup the update shader
  16532. * @param effect defines the update shader
  16533. */
  16534. applyToShader(effect: Effect): void;
  16535. /**
  16536. * Returns a string to use to update the GPU particles update shader
  16537. * @returns a string containng the defines string
  16538. */
  16539. getEffectDefines(): string;
  16540. /**
  16541. * Returns the string "HemisphericParticleEmitter"
  16542. * @returns a string containing the class name
  16543. */
  16544. getClassName(): string;
  16545. /**
  16546. * Serializes the particle system to a JSON object.
  16547. * @returns the JSON object
  16548. */
  16549. serialize(): any;
  16550. /**
  16551. * Parse properties from a JSON object
  16552. * @param serializationObject defines the JSON object
  16553. */
  16554. parse(serializationObject: any): void;
  16555. }
  16556. }
  16557. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16558. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16559. import { Effect } from "babylonjs/Materials/effect";
  16560. import { Particle } from "babylonjs/Particles/particle";
  16561. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16562. /**
  16563. * Particle emitter emitting particles from a point.
  16564. * It emits the particles randomly between 2 given directions.
  16565. */
  16566. export class PointParticleEmitter implements IParticleEmitterType {
  16567. /**
  16568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16569. */
  16570. direction1: Vector3;
  16571. /**
  16572. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16573. */
  16574. direction2: Vector3;
  16575. /**
  16576. * Creates a new instance PointParticleEmitter
  16577. */
  16578. constructor();
  16579. /**
  16580. * Called by the particle System when the direction is computed for the created particle.
  16581. * @param worldMatrix is the world matrix of the particle system
  16582. * @param directionToUpdate is the direction vector to update with the result
  16583. * @param particle is the particle we are computed the direction for
  16584. * @param isLocal defines if the direction should be set in local space
  16585. */
  16586. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16587. /**
  16588. * Called by the particle System when the position is computed for the created particle.
  16589. * @param worldMatrix is the world matrix of the particle system
  16590. * @param positionToUpdate is the position vector to update with the result
  16591. * @param particle is the particle we are computed the position for
  16592. * @param isLocal defines if the position should be set in local space
  16593. */
  16594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16595. /**
  16596. * Clones the current emitter and returns a copy of it
  16597. * @returns the new emitter
  16598. */
  16599. clone(): PointParticleEmitter;
  16600. /**
  16601. * Called by the GPUParticleSystem to setup the update shader
  16602. * @param effect defines the update shader
  16603. */
  16604. applyToShader(effect: Effect): void;
  16605. /**
  16606. * Returns a string to use to update the GPU particles update shader
  16607. * @returns a string containng the defines string
  16608. */
  16609. getEffectDefines(): string;
  16610. /**
  16611. * Returns the string "PointParticleEmitter"
  16612. * @returns a string containing the class name
  16613. */
  16614. getClassName(): string;
  16615. /**
  16616. * Serializes the particle system to a JSON object.
  16617. * @returns the JSON object
  16618. */
  16619. serialize(): any;
  16620. /**
  16621. * Parse properties from a JSON object
  16622. * @param serializationObject defines the JSON object
  16623. */
  16624. parse(serializationObject: any): void;
  16625. }
  16626. }
  16627. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16628. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16629. import { Effect } from "babylonjs/Materials/effect";
  16630. import { Particle } from "babylonjs/Particles/particle";
  16631. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16632. /**
  16633. * Particle emitter emitting particles from the inside of a sphere.
  16634. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16635. */
  16636. export class SphereParticleEmitter implements IParticleEmitterType {
  16637. /**
  16638. * The radius of the emission sphere.
  16639. */
  16640. radius: number;
  16641. /**
  16642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16643. */
  16644. radiusRange: number;
  16645. /**
  16646. * How much to randomize the particle direction [0-1].
  16647. */
  16648. directionRandomizer: number;
  16649. /**
  16650. * Creates a new instance SphereParticleEmitter
  16651. * @param radius the radius of the emission sphere (1 by default)
  16652. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16653. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16654. */
  16655. constructor(
  16656. /**
  16657. * The radius of the emission sphere.
  16658. */
  16659. radius?: number,
  16660. /**
  16661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16662. */
  16663. radiusRange?: number,
  16664. /**
  16665. * How much to randomize the particle direction [0-1].
  16666. */
  16667. directionRandomizer?: number);
  16668. /**
  16669. * Called by the particle System when the direction is computed for the created particle.
  16670. * @param worldMatrix is the world matrix of the particle system
  16671. * @param directionToUpdate is the direction vector to update with the result
  16672. * @param particle is the particle we are computed the direction for
  16673. * @param isLocal defines if the direction should be set in local space
  16674. */
  16675. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16676. /**
  16677. * Called by the particle System when the position is computed for the created particle.
  16678. * @param worldMatrix is the world matrix of the particle system
  16679. * @param positionToUpdate is the position vector to update with the result
  16680. * @param particle is the particle we are computed the position for
  16681. * @param isLocal defines if the position should be set in local space
  16682. */
  16683. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16684. /**
  16685. * Clones the current emitter and returns a copy of it
  16686. * @returns the new emitter
  16687. */
  16688. clone(): SphereParticleEmitter;
  16689. /**
  16690. * Called by the GPUParticleSystem to setup the update shader
  16691. * @param effect defines the update shader
  16692. */
  16693. applyToShader(effect: Effect): void;
  16694. /**
  16695. * Returns a string to use to update the GPU particles update shader
  16696. * @returns a string containng the defines string
  16697. */
  16698. getEffectDefines(): string;
  16699. /**
  16700. * Returns the string "SphereParticleEmitter"
  16701. * @returns a string containing the class name
  16702. */
  16703. getClassName(): string;
  16704. /**
  16705. * Serializes the particle system to a JSON object.
  16706. * @returns the JSON object
  16707. */
  16708. serialize(): any;
  16709. /**
  16710. * Parse properties from a JSON object
  16711. * @param serializationObject defines the JSON object
  16712. */
  16713. parse(serializationObject: any): void;
  16714. }
  16715. /**
  16716. * Particle emitter emitting particles from the inside of a sphere.
  16717. * It emits the particles randomly between two vectors.
  16718. */
  16719. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16720. /**
  16721. * The min limit of the emission direction.
  16722. */
  16723. direction1: Vector3;
  16724. /**
  16725. * The max limit of the emission direction.
  16726. */
  16727. direction2: Vector3;
  16728. /**
  16729. * Creates a new instance SphereDirectedParticleEmitter
  16730. * @param radius the radius of the emission sphere (1 by default)
  16731. * @param direction1 the min limit of the emission direction (up vector by default)
  16732. * @param direction2 the max limit of the emission direction (up vector by default)
  16733. */
  16734. constructor(radius?: number,
  16735. /**
  16736. * The min limit of the emission direction.
  16737. */
  16738. direction1?: Vector3,
  16739. /**
  16740. * The max limit of the emission direction.
  16741. */
  16742. direction2?: Vector3);
  16743. /**
  16744. * Called by the particle System when the direction is computed for the created particle.
  16745. * @param worldMatrix is the world matrix of the particle system
  16746. * @param directionToUpdate is the direction vector to update with the result
  16747. * @param particle is the particle we are computed the direction for
  16748. */
  16749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16750. /**
  16751. * Clones the current emitter and returns a copy of it
  16752. * @returns the new emitter
  16753. */
  16754. clone(): SphereDirectedParticleEmitter;
  16755. /**
  16756. * Called by the GPUParticleSystem to setup the update shader
  16757. * @param effect defines the update shader
  16758. */
  16759. applyToShader(effect: Effect): void;
  16760. /**
  16761. * Returns a string to use to update the GPU particles update shader
  16762. * @returns a string containng the defines string
  16763. */
  16764. getEffectDefines(): string;
  16765. /**
  16766. * Returns the string "SphereDirectedParticleEmitter"
  16767. * @returns a string containing the class name
  16768. */
  16769. getClassName(): string;
  16770. /**
  16771. * Serializes the particle system to a JSON object.
  16772. * @returns the JSON object
  16773. */
  16774. serialize(): any;
  16775. /**
  16776. * Parse properties from a JSON object
  16777. * @param serializationObject defines the JSON object
  16778. */
  16779. parse(serializationObject: any): void;
  16780. }
  16781. }
  16782. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  16783. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16784. import { Effect } from "babylonjs/Materials/effect";
  16785. import { Particle } from "babylonjs/Particles/particle";
  16786. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16787. import { Nullable } from "babylonjs/types";
  16788. /**
  16789. * Particle emitter emitting particles from a custom list of positions.
  16790. */
  16791. export class CustomParticleEmitter implements IParticleEmitterType {
  16792. /**
  16793. * Gets or sets the position generator that will create the inital position of each particle.
  16794. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16795. */
  16796. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16797. /**
  16798. * Gets or sets the destination generator that will create the final destination of each particle.
  16799. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16800. */
  16801. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16802. /**
  16803. * Creates a new instance CustomParticleEmitter
  16804. */
  16805. constructor();
  16806. /**
  16807. * Called by the particle System when the direction is computed for the created particle.
  16808. * @param worldMatrix is the world matrix of the particle system
  16809. * @param directionToUpdate is the direction vector to update with the result
  16810. * @param particle is the particle we are computed the direction for
  16811. * @param isLocal defines if the direction should be set in local space
  16812. */
  16813. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16814. /**
  16815. * Called by the particle System when the position is computed for the created particle.
  16816. * @param worldMatrix is the world matrix of the particle system
  16817. * @param positionToUpdate is the position vector to update with the result
  16818. * @param particle is the particle we are computed the position for
  16819. * @param isLocal defines if the position should be set in local space
  16820. */
  16821. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16822. /**
  16823. * Clones the current emitter and returns a copy of it
  16824. * @returns the new emitter
  16825. */
  16826. clone(): CustomParticleEmitter;
  16827. /**
  16828. * Called by the GPUParticleSystem to setup the update shader
  16829. * @param effect defines the update shader
  16830. */
  16831. applyToShader(effect: Effect): void;
  16832. /**
  16833. * Returns a string to use to update the GPU particles update shader
  16834. * @returns a string containng the defines string
  16835. */
  16836. getEffectDefines(): string;
  16837. /**
  16838. * Returns the string "PointParticleEmitter"
  16839. * @returns a string containing the class name
  16840. */
  16841. getClassName(): string;
  16842. /**
  16843. * Serializes the particle system to a JSON object.
  16844. * @returns the JSON object
  16845. */
  16846. serialize(): any;
  16847. /**
  16848. * Parse properties from a JSON object
  16849. * @param serializationObject defines the JSON object
  16850. */
  16851. parse(serializationObject: any): void;
  16852. }
  16853. }
  16854. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  16855. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16856. import { Effect } from "babylonjs/Materials/effect";
  16857. import { Particle } from "babylonjs/Particles/particle";
  16858. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16859. import { Nullable } from "babylonjs/types";
  16860. import { Scene } from "babylonjs/scene";
  16861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16862. /**
  16863. * Particle emitter emitting particles from the inside of a box.
  16864. * It emits the particles randomly between 2 given directions.
  16865. */
  16866. export class MeshParticleEmitter implements IParticleEmitterType {
  16867. private _indices;
  16868. private _positions;
  16869. private _normals;
  16870. private _storedNormal;
  16871. private _mesh;
  16872. /**
  16873. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16874. */
  16875. direction1: Vector3;
  16876. /**
  16877. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16878. */
  16879. direction2: Vector3;
  16880. /**
  16881. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16882. */
  16883. useMeshNormalsForDirection: boolean;
  16884. /** Defines the mesh to use as source */
  16885. get mesh(): Nullable<AbstractMesh>;
  16886. set mesh(value: Nullable<AbstractMesh>);
  16887. /**
  16888. * Creates a new instance MeshParticleEmitter
  16889. * @param mesh defines the mesh to use as source
  16890. */
  16891. constructor(mesh?: Nullable<AbstractMesh>);
  16892. /**
  16893. * Called by the particle System when the direction is computed for the created particle.
  16894. * @param worldMatrix is the world matrix of the particle system
  16895. * @param directionToUpdate is the direction vector to update with the result
  16896. * @param particle is the particle we are computed the direction for
  16897. * @param isLocal defines if the direction should be set in local space
  16898. */
  16899. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16900. /**
  16901. * Called by the particle System when the position is computed for the created particle.
  16902. * @param worldMatrix is the world matrix of the particle system
  16903. * @param positionToUpdate is the position vector to update with the result
  16904. * @param particle is the particle we are computed the position for
  16905. * @param isLocal defines if the position should be set in local space
  16906. */
  16907. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16908. /**
  16909. * Clones the current emitter and returns a copy of it
  16910. * @returns the new emitter
  16911. */
  16912. clone(): MeshParticleEmitter;
  16913. /**
  16914. * Called by the GPUParticleSystem to setup the update shader
  16915. * @param effect defines the update shader
  16916. */
  16917. applyToShader(effect: Effect): void;
  16918. /**
  16919. * Returns a string to use to update the GPU particles update shader
  16920. * @returns a string containng the defines string
  16921. */
  16922. getEffectDefines(): string;
  16923. /**
  16924. * Returns the string "BoxParticleEmitter"
  16925. * @returns a string containing the class name
  16926. */
  16927. getClassName(): string;
  16928. /**
  16929. * Serializes the particle system to a JSON object.
  16930. * @returns the JSON object
  16931. */
  16932. serialize(): any;
  16933. /**
  16934. * Parse properties from a JSON object
  16935. * @param serializationObject defines the JSON object
  16936. * @param scene defines the hosting scene
  16937. */
  16938. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16939. }
  16940. }
  16941. declare module "babylonjs/Particles/EmitterTypes/index" {
  16942. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16943. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16944. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16945. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16946. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16947. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16948. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16949. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  16950. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  16951. }
  16952. declare module "babylonjs/Particles/IParticleSystem" {
  16953. import { Nullable } from "babylonjs/types";
  16954. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16955. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16956. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16957. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16958. import { Scene } from "babylonjs/scene";
  16959. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  16960. import { Effect } from "babylonjs/Materials/effect";
  16961. import { Observable } from "babylonjs/Misc/observable";
  16962. import { Animation } from "babylonjs/Animations/animation";
  16963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16964. /**
  16965. * Interface representing a particle system in Babylon.js.
  16966. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16967. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16968. */
  16969. export interface IParticleSystem {
  16970. /**
  16971. * List of animations used by the particle system.
  16972. */
  16973. animations: Animation[];
  16974. /**
  16975. * The id of the Particle system.
  16976. */
  16977. id: string;
  16978. /**
  16979. * The name of the Particle system.
  16980. */
  16981. name: string;
  16982. /**
  16983. * The emitter represents the Mesh or position we are attaching the particle system to.
  16984. */
  16985. emitter: Nullable<AbstractMesh | Vector3>;
  16986. /**
  16987. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16988. */
  16989. isBillboardBased: boolean;
  16990. /**
  16991. * The rendering group used by the Particle system to chose when to render.
  16992. */
  16993. renderingGroupId: number;
  16994. /**
  16995. * The layer mask we are rendering the particles through.
  16996. */
  16997. layerMask: number;
  16998. /**
  16999. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17000. */
  17001. updateSpeed: number;
  17002. /**
  17003. * The amount of time the particle system is running (depends of the overall update speed).
  17004. */
  17005. targetStopDuration: number;
  17006. /**
  17007. * The texture used to render each particle. (this can be a spritesheet)
  17008. */
  17009. particleTexture: Nullable<BaseTexture>;
  17010. /**
  17011. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17012. */
  17013. blendMode: number;
  17014. /**
  17015. * Minimum life time of emitting particles.
  17016. */
  17017. minLifeTime: number;
  17018. /**
  17019. * Maximum life time of emitting particles.
  17020. */
  17021. maxLifeTime: number;
  17022. /**
  17023. * Minimum Size of emitting particles.
  17024. */
  17025. minSize: number;
  17026. /**
  17027. * Maximum Size of emitting particles.
  17028. */
  17029. maxSize: number;
  17030. /**
  17031. * Minimum scale of emitting particles on X axis.
  17032. */
  17033. minScaleX: number;
  17034. /**
  17035. * Maximum scale of emitting particles on X axis.
  17036. */
  17037. maxScaleX: number;
  17038. /**
  17039. * Minimum scale of emitting particles on Y axis.
  17040. */
  17041. minScaleY: number;
  17042. /**
  17043. * Maximum scale of emitting particles on Y axis.
  17044. */
  17045. maxScaleY: number;
  17046. /**
  17047. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17048. */
  17049. color1: Color4;
  17050. /**
  17051. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17052. */
  17053. color2: Color4;
  17054. /**
  17055. * Color the particle will have at the end of its lifetime.
  17056. */
  17057. colorDead: Color4;
  17058. /**
  17059. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17060. */
  17061. emitRate: number;
  17062. /**
  17063. * You can use gravity if you want to give an orientation to your particles.
  17064. */
  17065. gravity: Vector3;
  17066. /**
  17067. * Minimum power of emitting particles.
  17068. */
  17069. minEmitPower: number;
  17070. /**
  17071. * Maximum power of emitting particles.
  17072. */
  17073. maxEmitPower: number;
  17074. /**
  17075. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17076. */
  17077. minAngularSpeed: number;
  17078. /**
  17079. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17080. */
  17081. maxAngularSpeed: number;
  17082. /**
  17083. * Gets or sets the minimal initial rotation in radians.
  17084. */
  17085. minInitialRotation: number;
  17086. /**
  17087. * Gets or sets the maximal initial rotation in radians.
  17088. */
  17089. maxInitialRotation: number;
  17090. /**
  17091. * The particle emitter type defines the emitter used by the particle system.
  17092. * It can be for example box, sphere, or cone...
  17093. */
  17094. particleEmitterType: Nullable<IParticleEmitterType>;
  17095. /**
  17096. * Defines the delay in milliseconds before starting the system (0 by default)
  17097. */
  17098. startDelay: number;
  17099. /**
  17100. * 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
  17101. */
  17102. preWarmCycles: number;
  17103. /**
  17104. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17105. */
  17106. preWarmStepOffset: number;
  17107. /**
  17108. * 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)
  17109. */
  17110. spriteCellChangeSpeed: number;
  17111. /**
  17112. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17113. */
  17114. startSpriteCellID: number;
  17115. /**
  17116. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17117. */
  17118. endSpriteCellID: number;
  17119. /**
  17120. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17121. */
  17122. spriteCellWidth: number;
  17123. /**
  17124. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17125. */
  17126. spriteCellHeight: number;
  17127. /**
  17128. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17129. */
  17130. spriteRandomStartCell: boolean;
  17131. /**
  17132. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17133. */
  17134. isAnimationSheetEnabled: boolean;
  17135. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17136. translationPivot: Vector2;
  17137. /**
  17138. * Gets or sets a texture used to add random noise to particle positions
  17139. */
  17140. noiseTexture: Nullable<BaseTexture>;
  17141. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17142. noiseStrength: Vector3;
  17143. /**
  17144. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17145. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17146. */
  17147. billboardMode: number;
  17148. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17149. limitVelocityDamping: number;
  17150. /**
  17151. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17152. */
  17153. beginAnimationOnStart: boolean;
  17154. /**
  17155. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17156. */
  17157. beginAnimationFrom: number;
  17158. /**
  17159. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17160. */
  17161. beginAnimationTo: number;
  17162. /**
  17163. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17164. */
  17165. beginAnimationLoop: boolean;
  17166. /**
  17167. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17168. */
  17169. disposeOnStop: boolean;
  17170. /**
  17171. * Specifies if the particles are updated in emitter local space or world space
  17172. */
  17173. isLocal: boolean;
  17174. /** Snippet ID if the particle system was created from the snippet server */
  17175. snippetId: string;
  17176. /** Gets or sets a matrix to use to compute projection */
  17177. defaultProjectionMatrix: Matrix;
  17178. /**
  17179. * Gets the maximum number of particles active at the same time.
  17180. * @returns The max number of active particles.
  17181. */
  17182. getCapacity(): number;
  17183. /**
  17184. * Gets the number of particles active at the same time.
  17185. * @returns The number of active particles.
  17186. */
  17187. getActiveCount(): number;
  17188. /**
  17189. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17190. * @returns True if it has been started, otherwise false.
  17191. */
  17192. isStarted(): boolean;
  17193. /**
  17194. * Animates the particle system for this frame.
  17195. */
  17196. animate(): void;
  17197. /**
  17198. * Renders the particle system in its current state.
  17199. * @returns the current number of particles
  17200. */
  17201. render(): number;
  17202. /**
  17203. * Dispose the particle system and frees its associated resources.
  17204. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17205. */
  17206. dispose(disposeTexture?: boolean): void;
  17207. /**
  17208. * An event triggered when the system is disposed
  17209. */
  17210. onDisposeObservable: Observable<IParticleSystem>;
  17211. /**
  17212. * An event triggered when the system is stopped
  17213. */
  17214. onStoppedObservable: Observable<IParticleSystem>;
  17215. /**
  17216. * Clones the particle system.
  17217. * @param name The name of the cloned object
  17218. * @param newEmitter The new emitter to use
  17219. * @returns the cloned particle system
  17220. */
  17221. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17222. /**
  17223. * Serializes the particle system to a JSON object
  17224. * @param serializeTexture defines if the texture must be serialized as well
  17225. * @returns the JSON object
  17226. */
  17227. serialize(serializeTexture: boolean): any;
  17228. /**
  17229. * Rebuild the particle system
  17230. */
  17231. rebuild(): void;
  17232. /** Force the system to rebuild all gradients that need to be resync */
  17233. forceRefreshGradients(): void;
  17234. /**
  17235. * Starts the particle system and begins to emit
  17236. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17237. */
  17238. start(delay?: number): void;
  17239. /**
  17240. * Stops the particle system.
  17241. */
  17242. stop(): void;
  17243. /**
  17244. * Remove all active particles
  17245. */
  17246. reset(): void;
  17247. /**
  17248. * Gets a boolean indicating that the system is stopping
  17249. * @returns true if the system is currently stopping
  17250. */
  17251. isStopping(): boolean;
  17252. /**
  17253. * Is this system ready to be used/rendered
  17254. * @return true if the system is ready
  17255. */
  17256. isReady(): boolean;
  17257. /**
  17258. * Returns the string "ParticleSystem"
  17259. * @returns a string containing the class name
  17260. */
  17261. getClassName(): string;
  17262. /**
  17263. * Gets the custom effect used to render the particles
  17264. * @param blendMode Blend mode for which the effect should be retrieved
  17265. * @returns The effect
  17266. */
  17267. getCustomEffect(blendMode: number): Nullable<Effect>;
  17268. /**
  17269. * Sets the custom effect used to render the particles
  17270. * @param effect The effect to set
  17271. * @param blendMode Blend mode for which the effect should be set
  17272. */
  17273. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17274. /**
  17275. * Fill the defines array according to the current settings of the particle system
  17276. * @param defines Array to be updated
  17277. * @param blendMode blend mode to take into account when updating the array
  17278. */
  17279. fillDefines(defines: Array<string>, blendMode: number): void;
  17280. /**
  17281. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17282. * @param uniforms Uniforms array to fill
  17283. * @param attributes Attributes array to fill
  17284. * @param samplers Samplers array to fill
  17285. */
  17286. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17287. /**
  17288. * Observable that will be called just before the particles are drawn
  17289. */
  17290. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17291. /**
  17292. * Gets the name of the particle vertex shader
  17293. */
  17294. vertexShaderName: string;
  17295. /**
  17296. * Adds a new color gradient
  17297. * @param gradient defines the gradient to use (between 0 and 1)
  17298. * @param color1 defines the color to affect to the specified gradient
  17299. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17300. * @returns the current particle system
  17301. */
  17302. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17303. /**
  17304. * Remove a specific color gradient
  17305. * @param gradient defines the gradient to remove
  17306. * @returns the current particle system
  17307. */
  17308. removeColorGradient(gradient: number): IParticleSystem;
  17309. /**
  17310. * Adds a new size gradient
  17311. * @param gradient defines the gradient to use (between 0 and 1)
  17312. * @param factor defines the size factor to affect to the specified gradient
  17313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17314. * @returns the current particle system
  17315. */
  17316. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17317. /**
  17318. * Remove a specific size gradient
  17319. * @param gradient defines the gradient to remove
  17320. * @returns the current particle system
  17321. */
  17322. removeSizeGradient(gradient: number): IParticleSystem;
  17323. /**
  17324. * Gets the current list of color gradients.
  17325. * You must use addColorGradient and removeColorGradient to udpate this list
  17326. * @returns the list of color gradients
  17327. */
  17328. getColorGradients(): Nullable<Array<ColorGradient>>;
  17329. /**
  17330. * Gets the current list of size gradients.
  17331. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17332. * @returns the list of size gradients
  17333. */
  17334. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17335. /**
  17336. * Gets the current list of angular speed gradients.
  17337. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17338. * @returns the list of angular speed gradients
  17339. */
  17340. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17341. /**
  17342. * Adds a new angular speed gradient
  17343. * @param gradient defines the gradient to use (between 0 and 1)
  17344. * @param factor defines the angular speed to affect to the specified gradient
  17345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17346. * @returns the current particle system
  17347. */
  17348. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17349. /**
  17350. * Remove a specific angular speed gradient
  17351. * @param gradient defines the gradient to remove
  17352. * @returns the current particle system
  17353. */
  17354. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17355. /**
  17356. * Gets the current list of velocity gradients.
  17357. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17358. * @returns the list of velocity gradients
  17359. */
  17360. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17361. /**
  17362. * Adds a new velocity gradient
  17363. * @param gradient defines the gradient to use (between 0 and 1)
  17364. * @param factor defines the velocity to affect to the specified gradient
  17365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17366. * @returns the current particle system
  17367. */
  17368. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17369. /**
  17370. * Remove a specific velocity gradient
  17371. * @param gradient defines the gradient to remove
  17372. * @returns the current particle system
  17373. */
  17374. removeVelocityGradient(gradient: number): IParticleSystem;
  17375. /**
  17376. * Gets the current list of limit velocity gradients.
  17377. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17378. * @returns the list of limit velocity gradients
  17379. */
  17380. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17381. /**
  17382. * Adds a new limit velocity gradient
  17383. * @param gradient defines the gradient to use (between 0 and 1)
  17384. * @param factor defines the limit velocity to affect to the specified gradient
  17385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17386. * @returns the current particle system
  17387. */
  17388. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17389. /**
  17390. * Remove a specific limit velocity gradient
  17391. * @param gradient defines the gradient to remove
  17392. * @returns the current particle system
  17393. */
  17394. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17395. /**
  17396. * Adds a new drag gradient
  17397. * @param gradient defines the gradient to use (between 0 and 1)
  17398. * @param factor defines the drag to affect to the specified gradient
  17399. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17400. * @returns the current particle system
  17401. */
  17402. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17403. /**
  17404. * Remove a specific drag gradient
  17405. * @param gradient defines the gradient to remove
  17406. * @returns the current particle system
  17407. */
  17408. removeDragGradient(gradient: number): IParticleSystem;
  17409. /**
  17410. * Gets the current list of drag gradients.
  17411. * You must use addDragGradient and removeDragGradient to udpate this list
  17412. * @returns the list of drag gradients
  17413. */
  17414. getDragGradients(): Nullable<Array<FactorGradient>>;
  17415. /**
  17416. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17417. * @param gradient defines the gradient to use (between 0 and 1)
  17418. * @param factor defines the emit rate to affect to the specified gradient
  17419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17420. * @returns the current particle system
  17421. */
  17422. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17423. /**
  17424. * Remove a specific emit rate gradient
  17425. * @param gradient defines the gradient to remove
  17426. * @returns the current particle system
  17427. */
  17428. removeEmitRateGradient(gradient: number): IParticleSystem;
  17429. /**
  17430. * Gets the current list of emit rate gradients.
  17431. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17432. * @returns the list of emit rate gradients
  17433. */
  17434. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17435. /**
  17436. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17437. * @param gradient defines the gradient to use (between 0 and 1)
  17438. * @param factor defines the start size to affect to the specified gradient
  17439. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17440. * @returns the current particle system
  17441. */
  17442. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17443. /**
  17444. * Remove a specific start size gradient
  17445. * @param gradient defines the gradient to remove
  17446. * @returns the current particle system
  17447. */
  17448. removeStartSizeGradient(gradient: number): IParticleSystem;
  17449. /**
  17450. * Gets the current list of start size gradients.
  17451. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17452. * @returns the list of start size gradients
  17453. */
  17454. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17455. /**
  17456. * Adds a new life time gradient
  17457. * @param gradient defines the gradient to use (between 0 and 1)
  17458. * @param factor defines the life time factor to affect to the specified gradient
  17459. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17460. * @returns the current particle system
  17461. */
  17462. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17463. /**
  17464. * Remove a specific life time gradient
  17465. * @param gradient defines the gradient to remove
  17466. * @returns the current particle system
  17467. */
  17468. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17469. /**
  17470. * Gets the current list of life time gradients.
  17471. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17472. * @returns the list of life time gradients
  17473. */
  17474. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17475. /**
  17476. * Gets the current list of color gradients.
  17477. * You must use addColorGradient and removeColorGradient to udpate this list
  17478. * @returns the list of color gradients
  17479. */
  17480. getColorGradients(): Nullable<Array<ColorGradient>>;
  17481. /**
  17482. * Adds a new ramp gradient used to remap particle colors
  17483. * @param gradient defines the gradient to use (between 0 and 1)
  17484. * @param color defines the color to affect to the specified gradient
  17485. * @returns the current particle system
  17486. */
  17487. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17488. /**
  17489. * Gets the current list of ramp gradients.
  17490. * You must use addRampGradient and removeRampGradient to udpate this list
  17491. * @returns the list of ramp gradients
  17492. */
  17493. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17494. /** Gets or sets a boolean indicating that ramp gradients must be used
  17495. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17496. */
  17497. useRampGradients: boolean;
  17498. /**
  17499. * Adds a new color remap gradient
  17500. * @param gradient defines the gradient to use (between 0 and 1)
  17501. * @param min defines the color remap minimal range
  17502. * @param max defines the color remap maximal range
  17503. * @returns the current particle system
  17504. */
  17505. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17506. /**
  17507. * Gets the current list of color remap gradients.
  17508. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17509. * @returns the list of color remap gradients
  17510. */
  17511. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17512. /**
  17513. * Adds a new alpha remap gradient
  17514. * @param gradient defines the gradient to use (between 0 and 1)
  17515. * @param min defines the alpha remap minimal range
  17516. * @param max defines the alpha remap maximal range
  17517. * @returns the current particle system
  17518. */
  17519. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17520. /**
  17521. * Gets the current list of alpha remap gradients.
  17522. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17523. * @returns the list of alpha remap gradients
  17524. */
  17525. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17526. /**
  17527. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17528. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17529. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17530. * @returns the emitter
  17531. */
  17532. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17533. /**
  17534. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17535. * @param radius The radius of the hemisphere to emit from
  17536. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17537. * @returns the emitter
  17538. */
  17539. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17540. /**
  17541. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17542. * @param radius The radius of the sphere to emit from
  17543. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17544. * @returns the emitter
  17545. */
  17546. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17547. /**
  17548. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17549. * @param radius The radius of the sphere to emit from
  17550. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17551. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17552. * @returns the emitter
  17553. */
  17554. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17555. /**
  17556. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17557. * @param radius The radius of the emission cylinder
  17558. * @param height The height of the emission cylinder
  17559. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17560. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17561. * @returns the emitter
  17562. */
  17563. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17564. /**
  17565. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17566. * @param radius The radius of the cylinder to emit from
  17567. * @param height The height of the emission cylinder
  17568. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17569. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17570. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17571. * @returns the emitter
  17572. */
  17573. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17574. /**
  17575. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17576. * @param radius The radius of the cone to emit from
  17577. * @param angle The base angle of the cone
  17578. * @returns the emitter
  17579. */
  17580. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17581. /**
  17582. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17583. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17584. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17585. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17586. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17587. * @returns the emitter
  17588. */
  17589. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17590. /**
  17591. * Get hosting scene
  17592. * @returns the scene
  17593. */
  17594. getScene(): Nullable<Scene>;
  17595. }
  17596. }
  17597. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  17598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17601. /**
  17602. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17603. */
  17604. export class ColorSplitterBlock extends NodeMaterialBlock {
  17605. /**
  17606. * Create a new ColorSplitterBlock
  17607. * @param name defines the block name
  17608. */
  17609. constructor(name: string);
  17610. /**
  17611. * Gets the current class name
  17612. * @returns the class name
  17613. */
  17614. getClassName(): string;
  17615. /**
  17616. * Gets the rgba component (input)
  17617. */
  17618. get rgba(): NodeMaterialConnectionPoint;
  17619. /**
  17620. * Gets the rgb component (input)
  17621. */
  17622. get rgbIn(): NodeMaterialConnectionPoint;
  17623. /**
  17624. * Gets the rgb component (output)
  17625. */
  17626. get rgbOut(): NodeMaterialConnectionPoint;
  17627. /**
  17628. * Gets the r component (output)
  17629. */
  17630. get r(): NodeMaterialConnectionPoint;
  17631. /**
  17632. * Gets the g component (output)
  17633. */
  17634. get g(): NodeMaterialConnectionPoint;
  17635. /**
  17636. * Gets the b component (output)
  17637. */
  17638. get b(): NodeMaterialConnectionPoint;
  17639. /**
  17640. * Gets the a component (output)
  17641. */
  17642. get a(): NodeMaterialConnectionPoint;
  17643. protected _inputRename(name: string): string;
  17644. protected _outputRename(name: string): string;
  17645. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17646. }
  17647. }
  17648. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  17649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17652. import { Scene } from "babylonjs/scene";
  17653. /**
  17654. * Operations supported by the Trigonometry block
  17655. */
  17656. export enum TrigonometryBlockOperations {
  17657. /** Cos */
  17658. Cos = 0,
  17659. /** Sin */
  17660. Sin = 1,
  17661. /** Abs */
  17662. Abs = 2,
  17663. /** Exp */
  17664. Exp = 3,
  17665. /** Exp2 */
  17666. Exp2 = 4,
  17667. /** Round */
  17668. Round = 5,
  17669. /** Floor */
  17670. Floor = 6,
  17671. /** Ceiling */
  17672. Ceiling = 7,
  17673. /** Square root */
  17674. Sqrt = 8,
  17675. /** Log */
  17676. Log = 9,
  17677. /** Tangent */
  17678. Tan = 10,
  17679. /** Arc tangent */
  17680. ArcTan = 11,
  17681. /** Arc cosinus */
  17682. ArcCos = 12,
  17683. /** Arc sinus */
  17684. ArcSin = 13,
  17685. /** Fraction */
  17686. Fract = 14,
  17687. /** Sign */
  17688. Sign = 15,
  17689. /** To radians (from degrees) */
  17690. Radians = 16,
  17691. /** To degrees (from radians) */
  17692. Degrees = 17
  17693. }
  17694. /**
  17695. * Block used to apply trigonometry operation to floats
  17696. */
  17697. export class TrigonometryBlock extends NodeMaterialBlock {
  17698. /**
  17699. * Gets or sets the operation applied by the block
  17700. */
  17701. operation: TrigonometryBlockOperations;
  17702. /**
  17703. * Creates a new TrigonometryBlock
  17704. * @param name defines the block name
  17705. */
  17706. constructor(name: string);
  17707. /**
  17708. * Gets the current class name
  17709. * @returns the class name
  17710. */
  17711. getClassName(): string;
  17712. /**
  17713. * Gets the input component
  17714. */
  17715. get input(): NodeMaterialConnectionPoint;
  17716. /**
  17717. * Gets the output component
  17718. */
  17719. get output(): NodeMaterialConnectionPoint;
  17720. protected _buildBlock(state: NodeMaterialBuildState): this;
  17721. serialize(): any;
  17722. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17723. protected _dumpPropertiesCode(): string;
  17724. }
  17725. }
  17726. declare module "babylonjs/Materials/Node/nodeMaterial" {
  17727. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17728. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  17729. import { Scene } from "babylonjs/scene";
  17730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17731. import { Matrix } from "babylonjs/Maths/math.vector";
  17732. import { Mesh } from "babylonjs/Meshes/mesh";
  17733. import { Engine } from "babylonjs/Engines/engine";
  17734. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17735. import { Observable } from "babylonjs/Misc/observable";
  17736. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17737. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17738. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  17739. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17740. import { Nullable } from "babylonjs/types";
  17741. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  17742. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  17743. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  17744. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  17745. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  17746. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  17747. import { Effect } from "babylonjs/Materials/effect";
  17748. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  17749. import { Camera } from "babylonjs/Cameras/camera";
  17750. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  17751. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17752. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17753. /**
  17754. * Interface used to configure the node material editor
  17755. */
  17756. export interface INodeMaterialEditorOptions {
  17757. /** Define the URl to load node editor script */
  17758. editorURL?: string;
  17759. }
  17760. /** @hidden */
  17761. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17762. NORMAL: boolean;
  17763. TANGENT: boolean;
  17764. UV1: boolean;
  17765. /** BONES */
  17766. NUM_BONE_INFLUENCERS: number;
  17767. BonesPerMesh: number;
  17768. BONETEXTURE: boolean;
  17769. /** MORPH TARGETS */
  17770. MORPHTARGETS: boolean;
  17771. MORPHTARGETS_NORMAL: boolean;
  17772. MORPHTARGETS_TANGENT: boolean;
  17773. MORPHTARGETS_UV: boolean;
  17774. NUM_MORPH_INFLUENCERS: number;
  17775. /** IMAGE PROCESSING */
  17776. IMAGEPROCESSING: boolean;
  17777. VIGNETTE: boolean;
  17778. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17779. VIGNETTEBLENDMODEOPAQUE: boolean;
  17780. TONEMAPPING: boolean;
  17781. TONEMAPPING_ACES: boolean;
  17782. CONTRAST: boolean;
  17783. EXPOSURE: boolean;
  17784. COLORCURVES: boolean;
  17785. COLORGRADING: boolean;
  17786. COLORGRADING3D: boolean;
  17787. SAMPLER3DGREENDEPTH: boolean;
  17788. SAMPLER3DBGRMAP: boolean;
  17789. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17790. /** MISC. */
  17791. BUMPDIRECTUV: number;
  17792. constructor();
  17793. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17794. }
  17795. /**
  17796. * Class used to configure NodeMaterial
  17797. */
  17798. export interface INodeMaterialOptions {
  17799. /**
  17800. * Defines if blocks should emit comments
  17801. */
  17802. emitComments: boolean;
  17803. }
  17804. /**
  17805. * Class used to create a node based material built by assembling shader blocks
  17806. */
  17807. export class NodeMaterial extends PushMaterial {
  17808. private static _BuildIdGenerator;
  17809. private _options;
  17810. private _vertexCompilationState;
  17811. private _fragmentCompilationState;
  17812. private _sharedData;
  17813. private _buildId;
  17814. private _buildWasSuccessful;
  17815. private _cachedWorldViewMatrix;
  17816. private _cachedWorldViewProjectionMatrix;
  17817. private _optimizers;
  17818. private _animationFrame;
  17819. /** Define the Url to load node editor script */
  17820. static EditorURL: string;
  17821. /** Define the Url to load snippets */
  17822. static SnippetUrl: string;
  17823. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17824. static IgnoreTexturesAtLoadTime: boolean;
  17825. private BJSNODEMATERIALEDITOR;
  17826. /** Get the inspector from bundle or global */
  17827. private _getGlobalNodeMaterialEditor;
  17828. /**
  17829. * Snippet ID if the material was created from the snippet server
  17830. */
  17831. snippetId: string;
  17832. /**
  17833. * Gets or sets data used by visual editor
  17834. * @see https://nme.babylonjs.com
  17835. */
  17836. editorData: any;
  17837. /**
  17838. * 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)
  17839. */
  17840. ignoreAlpha: boolean;
  17841. /**
  17842. * Defines the maximum number of lights that can be used in the material
  17843. */
  17844. maxSimultaneousLights: number;
  17845. /**
  17846. * Observable raised when the material is built
  17847. */
  17848. onBuildObservable: Observable<NodeMaterial>;
  17849. /**
  17850. * Gets or sets the root nodes of the material vertex shader
  17851. */
  17852. _vertexOutputNodes: NodeMaterialBlock[];
  17853. /**
  17854. * Gets or sets the root nodes of the material fragment (pixel) shader
  17855. */
  17856. _fragmentOutputNodes: NodeMaterialBlock[];
  17857. /** Gets or sets options to control the node material overall behavior */
  17858. get options(): INodeMaterialOptions;
  17859. set options(options: INodeMaterialOptions);
  17860. /**
  17861. * Default configuration related to image processing available in the standard Material.
  17862. */
  17863. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17864. /**
  17865. * Gets the image processing configuration used either in this material.
  17866. */
  17867. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17868. /**
  17869. * Sets the Default image processing configuration used either in the this material.
  17870. *
  17871. * If sets to null, the scene one is in use.
  17872. */
  17873. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17874. /**
  17875. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17876. */
  17877. attachedBlocks: NodeMaterialBlock[];
  17878. /**
  17879. * Specifies the mode of the node material
  17880. * @hidden
  17881. */
  17882. _mode: NodeMaterialModes;
  17883. /**
  17884. * Gets the mode property
  17885. */
  17886. get mode(): NodeMaterialModes;
  17887. /**
  17888. * A free comment about the material
  17889. */
  17890. comment: string;
  17891. /**
  17892. * Create a new node based material
  17893. * @param name defines the material name
  17894. * @param scene defines the hosting scene
  17895. * @param options defines creation option
  17896. */
  17897. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17898. /**
  17899. * Gets the current class name of the material e.g. "NodeMaterial"
  17900. * @returns the class name
  17901. */
  17902. getClassName(): string;
  17903. /**
  17904. * Keep track of the image processing observer to allow dispose and replace.
  17905. */
  17906. private _imageProcessingObserver;
  17907. /**
  17908. * Attaches a new image processing configuration to the Standard Material.
  17909. * @param configuration
  17910. */
  17911. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17912. /**
  17913. * Get a block by its name
  17914. * @param name defines the name of the block to retrieve
  17915. * @returns the required block or null if not found
  17916. */
  17917. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17918. /**
  17919. * Get a block by its name
  17920. * @param predicate defines the predicate used to find the good candidate
  17921. * @returns the required block or null if not found
  17922. */
  17923. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17924. /**
  17925. * Get an input block by its name
  17926. * @param predicate defines the predicate used to find the good candidate
  17927. * @returns the required input block or null if not found
  17928. */
  17929. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17930. /**
  17931. * Gets the list of input blocks attached to this material
  17932. * @returns an array of InputBlocks
  17933. */
  17934. getInputBlocks(): InputBlock[];
  17935. /**
  17936. * Adds a new optimizer to the list of optimizers
  17937. * @param optimizer defines the optimizers to add
  17938. * @returns the current material
  17939. */
  17940. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17941. /**
  17942. * Remove an optimizer from the list of optimizers
  17943. * @param optimizer defines the optimizers to remove
  17944. * @returns the current material
  17945. */
  17946. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17947. /**
  17948. * Add a new block to the list of output nodes
  17949. * @param node defines the node to add
  17950. * @returns the current material
  17951. */
  17952. addOutputNode(node: NodeMaterialBlock): this;
  17953. /**
  17954. * Remove a block from the list of root nodes
  17955. * @param node defines the node to remove
  17956. * @returns the current material
  17957. */
  17958. removeOutputNode(node: NodeMaterialBlock): this;
  17959. private _addVertexOutputNode;
  17960. private _removeVertexOutputNode;
  17961. private _addFragmentOutputNode;
  17962. private _removeFragmentOutputNode;
  17963. /**
  17964. * Specifies if the material will require alpha blending
  17965. * @returns a boolean specifying if alpha blending is needed
  17966. */
  17967. needAlphaBlending(): boolean;
  17968. /**
  17969. * Specifies if this material should be rendered in alpha test mode
  17970. * @returns a boolean specifying if an alpha test is needed.
  17971. */
  17972. needAlphaTesting(): boolean;
  17973. private _initializeBlock;
  17974. private _resetDualBlocks;
  17975. /**
  17976. * Remove a block from the current node material
  17977. * @param block defines the block to remove
  17978. */
  17979. removeBlock(block: NodeMaterialBlock): void;
  17980. /**
  17981. * Build the material and generates the inner effect
  17982. * @param verbose defines if the build should log activity
  17983. */
  17984. build(verbose?: boolean): void;
  17985. /**
  17986. * Runs an otpimization phase to try to improve the shader code
  17987. */
  17988. optimize(): void;
  17989. private _prepareDefinesForAttributes;
  17990. /**
  17991. * Create a post process from the material
  17992. * @param camera The camera to apply the render pass to.
  17993. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17995. * @param engine The engine which the post process will be applied. (default: current engine)
  17996. * @param reusable If the post process can be reused on the same frame. (default: false)
  17997. * @param textureType Type of textures used when performing the post process. (default: 0)
  17998. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17999. * @returns the post process created
  18000. */
  18001. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18002. /**
  18003. * Create the post process effect from the material
  18004. * @param postProcess The post process to create the effect for
  18005. */
  18006. createEffectForPostProcess(postProcess: PostProcess): void;
  18007. private _createEffectForPostProcess;
  18008. /**
  18009. * Create a new procedural texture based on this node material
  18010. * @param size defines the size of the texture
  18011. * @param scene defines the hosting scene
  18012. * @returns the new procedural texture attached to this node material
  18013. */
  18014. createProceduralTexture(size: number | {
  18015. width: number;
  18016. height: number;
  18017. layers?: number;
  18018. }, scene: Scene): Nullable<ProceduralTexture>;
  18019. private _createEffectForParticles;
  18020. private _checkInternals;
  18021. /**
  18022. * Create the effect to be used as the custom effect for a particle system
  18023. * @param particleSystem Particle system to create the effect for
  18024. * @param onCompiled defines a function to call when the effect creation is successful
  18025. * @param onError defines a function to call when the effect creation has failed
  18026. */
  18027. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18028. private _processDefines;
  18029. /**
  18030. * Get if the submesh is ready to be used and all its information available.
  18031. * Child classes can use it to update shaders
  18032. * @param mesh defines the mesh to check
  18033. * @param subMesh defines which submesh to check
  18034. * @param useInstances specifies that instances should be used
  18035. * @returns a boolean indicating that the submesh is ready or not
  18036. */
  18037. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18038. /**
  18039. * Get a string representing the shaders built by the current node graph
  18040. */
  18041. get compiledShaders(): string;
  18042. /**
  18043. * Binds the world matrix to the material
  18044. * @param world defines the world transformation matrix
  18045. */
  18046. bindOnlyWorldMatrix(world: Matrix): void;
  18047. /**
  18048. * Binds the submesh to this material by preparing the effect and shader to draw
  18049. * @param world defines the world transformation matrix
  18050. * @param mesh defines the mesh containing the submesh
  18051. * @param subMesh defines the submesh to bind the material to
  18052. */
  18053. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18054. /**
  18055. * Gets the active textures from the material
  18056. * @returns an array of textures
  18057. */
  18058. getActiveTextures(): BaseTexture[];
  18059. /**
  18060. * Gets the list of texture blocks
  18061. * @returns an array of texture blocks
  18062. */
  18063. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18064. /**
  18065. * Specifies if the material uses a texture
  18066. * @param texture defines the texture to check against the material
  18067. * @returns a boolean specifying if the material uses the texture
  18068. */
  18069. hasTexture(texture: BaseTexture): boolean;
  18070. /**
  18071. * Disposes the material
  18072. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18073. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18074. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18075. */
  18076. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18077. /** Creates the node editor window. */
  18078. private _createNodeEditor;
  18079. /**
  18080. * Launch the node material editor
  18081. * @param config Define the configuration of the editor
  18082. * @return a promise fulfilled when the node editor is visible
  18083. */
  18084. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18085. /**
  18086. * Clear the current material
  18087. */
  18088. clear(): void;
  18089. /**
  18090. * Clear the current material and set it to a default state
  18091. */
  18092. setToDefault(): void;
  18093. /**
  18094. * Clear the current material and set it to a default state for post process
  18095. */
  18096. setToDefaultPostProcess(): void;
  18097. /**
  18098. * Clear the current material and set it to a default state for procedural texture
  18099. */
  18100. setToDefaultProceduralTexture(): void;
  18101. /**
  18102. * Clear the current material and set it to a default state for particle
  18103. */
  18104. setToDefaultParticle(): void;
  18105. /**
  18106. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18107. * @param url defines the url to load from
  18108. * @returns a promise that will fullfil when the material is fully loaded
  18109. */
  18110. loadAsync(url: string): Promise<void>;
  18111. private _gatherBlocks;
  18112. /**
  18113. * Generate a string containing the code declaration required to create an equivalent of this material
  18114. * @returns a string
  18115. */
  18116. generateCode(): string;
  18117. /**
  18118. * Serializes this material in a JSON representation
  18119. * @returns the serialized material object
  18120. */
  18121. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18122. private _restoreConnections;
  18123. /**
  18124. * Clear the current graph and load a new one from a serialization object
  18125. * @param source defines the JSON representation of the material
  18126. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18127. * @param merge defines whether or not the source must be merged or replace the current content
  18128. */
  18129. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18130. /**
  18131. * Makes a duplicate of the current material.
  18132. * @param name - name to use for the new material.
  18133. */
  18134. clone(name: string): NodeMaterial;
  18135. /**
  18136. * Creates a node material from parsed material data
  18137. * @param source defines the JSON representation of the material
  18138. * @param scene defines the hosting scene
  18139. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18140. * @returns a new node material
  18141. */
  18142. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18143. /**
  18144. * Creates a node material from a snippet saved in a remote file
  18145. * @param name defines the name of the material to create
  18146. * @param url defines the url to load from
  18147. * @param scene defines the hosting scene
  18148. * @returns a promise that will resolve to the new node material
  18149. */
  18150. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18151. /**
  18152. * Creates a node material from a snippet saved by the node material editor
  18153. * @param snippetId defines the snippet to load
  18154. * @param scene defines the hosting scene
  18155. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18156. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18157. * @returns a promise that will resolve to the new node material
  18158. */
  18159. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18160. /**
  18161. * Creates a new node material set to default basic configuration
  18162. * @param name defines the name of the material
  18163. * @param scene defines the hosting scene
  18164. * @returns a new NodeMaterial
  18165. */
  18166. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18167. }
  18168. }
  18169. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  18170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18171. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  18172. import { Nullable } from "babylonjs/types";
  18173. module "babylonjs/Engines/thinEngine" {
  18174. interface ThinEngine {
  18175. /**
  18176. * Unbind a list of render target textures from the webGL context
  18177. * This is used only when drawBuffer extension or webGL2 are active
  18178. * @param textures defines the render target textures to unbind
  18179. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18180. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18181. */
  18182. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18183. /**
  18184. * Create a multi render target texture
  18185. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18186. * @param size defines the size of the texture
  18187. * @param options defines the creation options
  18188. * @returns the cube texture as an InternalTexture
  18189. */
  18190. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18191. /**
  18192. * Update the sample count for a given multiple render target texture
  18193. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18194. * @param textures defines the textures to update
  18195. * @param samples defines the sample count to set
  18196. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18197. */
  18198. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18199. /**
  18200. * Select a subsets of attachments to draw to.
  18201. * @param attachments gl attachments
  18202. */
  18203. bindAttachments(attachments: number[]): void;
  18204. /**
  18205. * Creates a layout object to draw/clear on specific textures in a MRT
  18206. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18207. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18208. */
  18209. buildTextureLayout(textureStatus: boolean[]): number[];
  18210. /**
  18211. * Restores the webgl state to only draw on the main color attachment
  18212. */
  18213. restoreSingleAttachment(): void;
  18214. }
  18215. }
  18216. }
  18217. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18218. import { Scene } from "babylonjs/scene";
  18219. import { Engine } from "babylonjs/Engines/engine";
  18220. import { Texture } from "babylonjs/Materials/Textures/texture";
  18221. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18222. import "babylonjs/Engines/Extensions/engine.multiRender";
  18223. /**
  18224. * Creation options of the multi render target texture.
  18225. */
  18226. export interface IMultiRenderTargetOptions {
  18227. /**
  18228. * Define if the texture needs to create mip maps after render.
  18229. */
  18230. generateMipMaps?: boolean;
  18231. /**
  18232. * Define the types of all the draw buffers we want to create
  18233. */
  18234. types?: number[];
  18235. /**
  18236. * Define the sampling modes of all the draw buffers we want to create
  18237. */
  18238. samplingModes?: number[];
  18239. /**
  18240. * Define if a depth buffer is required
  18241. */
  18242. generateDepthBuffer?: boolean;
  18243. /**
  18244. * Define if a stencil buffer is required
  18245. */
  18246. generateStencilBuffer?: boolean;
  18247. /**
  18248. * Define if a depth texture is required instead of a depth buffer
  18249. */
  18250. generateDepthTexture?: boolean;
  18251. /**
  18252. * Define the number of desired draw buffers
  18253. */
  18254. textureCount?: number;
  18255. /**
  18256. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18257. */
  18258. doNotChangeAspectRatio?: boolean;
  18259. /**
  18260. * Define the default type of the buffers we are creating
  18261. */
  18262. defaultType?: number;
  18263. }
  18264. /**
  18265. * A multi render target, like a render target provides the ability to render to a texture.
  18266. * Unlike the render target, it can render to several draw buffers in one draw.
  18267. * This is specially interesting in deferred rendering or for any effects requiring more than
  18268. * just one color from a single pass.
  18269. */
  18270. export class MultiRenderTarget extends RenderTargetTexture {
  18271. private _internalTextures;
  18272. private _textures;
  18273. private _multiRenderTargetOptions;
  18274. private _count;
  18275. /**
  18276. * Get if draw buffers are currently supported by the used hardware and browser.
  18277. */
  18278. get isSupported(): boolean;
  18279. /**
  18280. * Get the list of textures generated by the multi render target.
  18281. */
  18282. get textures(): Texture[];
  18283. /**
  18284. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18285. */
  18286. get count(): number;
  18287. /**
  18288. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18289. */
  18290. get depthTexture(): Texture;
  18291. /**
  18292. * Set the wrapping mode on U of all the textures we are rendering to.
  18293. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18294. */
  18295. set wrapU(wrap: number);
  18296. /**
  18297. * Set the wrapping mode on V of all the textures we are rendering to.
  18298. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18299. */
  18300. set wrapV(wrap: number);
  18301. /**
  18302. * Instantiate a new multi render target texture.
  18303. * A multi render target, like a render target provides the ability to render to a texture.
  18304. * Unlike the render target, it can render to several draw buffers in one draw.
  18305. * This is specially interesting in deferred rendering or for any effects requiring more than
  18306. * just one color from a single pass.
  18307. * @param name Define the name of the texture
  18308. * @param size Define the size of the buffers to render to
  18309. * @param count Define the number of target we are rendering into
  18310. * @param scene Define the scene the texture belongs to
  18311. * @param options Define the options used to create the multi render target
  18312. */
  18313. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18314. private _initTypes;
  18315. /** @hidden */
  18316. _rebuild(forceFullRebuild?: boolean): void;
  18317. private _createInternalTextures;
  18318. private _createTextures;
  18319. /**
  18320. * Replaces a texture within the MRT.
  18321. * @param texture The new texture to insert in the MRT
  18322. * @param index The index of the texture to replace
  18323. */
  18324. replaceTexture(texture: Texture, index: number): void;
  18325. /**
  18326. * Define the number of samples used if MSAA is enabled.
  18327. */
  18328. get samples(): number;
  18329. set samples(value: number);
  18330. /**
  18331. * Resize all the textures in the multi render target.
  18332. * Be careful as it will recreate all the data in the new texture.
  18333. * @param size Define the new size
  18334. */
  18335. resize(size: any): void;
  18336. /**
  18337. * Changes the number of render targets in this MRT
  18338. * Be careful as it will recreate all the data in the new texture.
  18339. * @param count new texture count
  18340. * @param options Specifies texture types and sampling modes for new textures
  18341. */
  18342. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18343. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18344. /**
  18345. * Dispose the render targets and their associated resources
  18346. */
  18347. dispose(): void;
  18348. /**
  18349. * Release all the underlying texture used as draw buffers.
  18350. */
  18351. releaseInternalTextures(): void;
  18352. }
  18353. }
  18354. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  18355. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18356. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18357. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18358. /** @hidden */
  18359. export var imageProcessingPixelShader: {
  18360. name: string;
  18361. shader: string;
  18362. };
  18363. }
  18364. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  18365. import { Nullable } from "babylonjs/types";
  18366. import { Color4 } from "babylonjs/Maths/math.color";
  18367. import { Camera } from "babylonjs/Cameras/camera";
  18368. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18369. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  18370. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  18371. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18372. import { Engine } from "babylonjs/Engines/engine";
  18373. import "babylonjs/Shaders/imageProcessing.fragment";
  18374. import "babylonjs/Shaders/postprocess.vertex";
  18375. /**
  18376. * ImageProcessingPostProcess
  18377. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18378. */
  18379. export class ImageProcessingPostProcess extends PostProcess {
  18380. /**
  18381. * Default configuration related to image processing available in the PBR Material.
  18382. */
  18383. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18384. /**
  18385. * Gets the image processing configuration used either in this material.
  18386. */
  18387. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18388. /**
  18389. * Sets the Default image processing configuration used either in the this material.
  18390. *
  18391. * If sets to null, the scene one is in use.
  18392. */
  18393. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18394. /**
  18395. * Keep track of the image processing observer to allow dispose and replace.
  18396. */
  18397. private _imageProcessingObserver;
  18398. /**
  18399. * Attaches a new image processing configuration to the PBR Material.
  18400. * @param configuration
  18401. */
  18402. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18403. /**
  18404. * If the post process is supported.
  18405. */
  18406. get isSupported(): boolean;
  18407. /**
  18408. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18409. */
  18410. get colorCurves(): Nullable<ColorCurves>;
  18411. /**
  18412. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18413. */
  18414. set colorCurves(value: Nullable<ColorCurves>);
  18415. /**
  18416. * Gets wether the color curves effect is enabled.
  18417. */
  18418. get colorCurvesEnabled(): boolean;
  18419. /**
  18420. * Sets wether the color curves effect is enabled.
  18421. */
  18422. set colorCurvesEnabled(value: boolean);
  18423. /**
  18424. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18425. */
  18426. get colorGradingTexture(): Nullable<BaseTexture>;
  18427. /**
  18428. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18429. */
  18430. set colorGradingTexture(value: Nullable<BaseTexture>);
  18431. /**
  18432. * Gets wether the color grading effect is enabled.
  18433. */
  18434. get colorGradingEnabled(): boolean;
  18435. /**
  18436. * Gets wether the color grading effect is enabled.
  18437. */
  18438. set colorGradingEnabled(value: boolean);
  18439. /**
  18440. * Gets exposure used in the effect.
  18441. */
  18442. get exposure(): number;
  18443. /**
  18444. * Sets exposure used in the effect.
  18445. */
  18446. set exposure(value: number);
  18447. /**
  18448. * Gets wether tonemapping is enabled or not.
  18449. */
  18450. get toneMappingEnabled(): boolean;
  18451. /**
  18452. * Sets wether tonemapping is enabled or not
  18453. */
  18454. set toneMappingEnabled(value: boolean);
  18455. /**
  18456. * Gets the type of tone mapping effect.
  18457. */
  18458. get toneMappingType(): number;
  18459. /**
  18460. * Sets the type of tone mapping effect.
  18461. */
  18462. set toneMappingType(value: number);
  18463. /**
  18464. * Gets contrast used in the effect.
  18465. */
  18466. get contrast(): number;
  18467. /**
  18468. * Sets contrast used in the effect.
  18469. */
  18470. set contrast(value: number);
  18471. /**
  18472. * Gets Vignette stretch size.
  18473. */
  18474. get vignetteStretch(): number;
  18475. /**
  18476. * Sets Vignette stretch size.
  18477. */
  18478. set vignetteStretch(value: number);
  18479. /**
  18480. * Gets Vignette centre X Offset.
  18481. */
  18482. get vignetteCentreX(): number;
  18483. /**
  18484. * Sets Vignette centre X Offset.
  18485. */
  18486. set vignetteCentreX(value: number);
  18487. /**
  18488. * Gets Vignette centre Y Offset.
  18489. */
  18490. get vignetteCentreY(): number;
  18491. /**
  18492. * Sets Vignette centre Y Offset.
  18493. */
  18494. set vignetteCentreY(value: number);
  18495. /**
  18496. * Gets Vignette weight or intensity of the vignette effect.
  18497. */
  18498. get vignetteWeight(): number;
  18499. /**
  18500. * Sets Vignette weight or intensity of the vignette effect.
  18501. */
  18502. set vignetteWeight(value: number);
  18503. /**
  18504. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18505. * if vignetteEnabled is set to true.
  18506. */
  18507. get vignetteColor(): Color4;
  18508. /**
  18509. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18510. * if vignetteEnabled is set to true.
  18511. */
  18512. set vignetteColor(value: Color4);
  18513. /**
  18514. * Gets Camera field of view used by the Vignette effect.
  18515. */
  18516. get vignetteCameraFov(): number;
  18517. /**
  18518. * Sets Camera field of view used by the Vignette effect.
  18519. */
  18520. set vignetteCameraFov(value: number);
  18521. /**
  18522. * Gets the vignette blend mode allowing different kind of effect.
  18523. */
  18524. get vignetteBlendMode(): number;
  18525. /**
  18526. * Sets the vignette blend mode allowing different kind of effect.
  18527. */
  18528. set vignetteBlendMode(value: number);
  18529. /**
  18530. * Gets wether the vignette effect is enabled.
  18531. */
  18532. get vignetteEnabled(): boolean;
  18533. /**
  18534. * Sets wether the vignette effect is enabled.
  18535. */
  18536. set vignetteEnabled(value: boolean);
  18537. private _fromLinearSpace;
  18538. /**
  18539. * Gets wether the input of the processing is in Gamma or Linear Space.
  18540. */
  18541. get fromLinearSpace(): boolean;
  18542. /**
  18543. * Sets wether the input of the processing is in Gamma or Linear Space.
  18544. */
  18545. set fromLinearSpace(value: boolean);
  18546. /**
  18547. * Defines cache preventing GC.
  18548. */
  18549. private _defines;
  18550. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18551. /**
  18552. * "ImageProcessingPostProcess"
  18553. * @returns "ImageProcessingPostProcess"
  18554. */
  18555. getClassName(): string;
  18556. /**
  18557. * @hidden
  18558. */
  18559. _updateParameters(): void;
  18560. dispose(camera?: Camera): void;
  18561. }
  18562. }
  18563. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  18564. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18565. /**
  18566. * Interface for defining prepass effects in the prepass post-process pipeline
  18567. */
  18568. export interface PrePassEffectConfiguration {
  18569. /**
  18570. * Name of the effect
  18571. */
  18572. name: string;
  18573. /**
  18574. * Post process to attach for this effect
  18575. */
  18576. postProcess?: PostProcess;
  18577. /**
  18578. * Textures required in the MRT
  18579. */
  18580. texturesRequired: number[];
  18581. /**
  18582. * Is the effect enabled
  18583. */
  18584. enabled: boolean;
  18585. /**
  18586. * Disposes the effect configuration
  18587. */
  18588. dispose?: () => void;
  18589. /**
  18590. * Creates the associated post process
  18591. */
  18592. createPostProcess?: () => PostProcess;
  18593. }
  18594. }
  18595. declare module "babylonjs/Materials/fresnelParameters" {
  18596. import { DeepImmutable } from "babylonjs/types";
  18597. import { Color3 } from "babylonjs/Maths/math.color";
  18598. /**
  18599. * Options to be used when creating a FresnelParameters.
  18600. */
  18601. export type IFresnelParametersCreationOptions = {
  18602. /**
  18603. * Define the color used on edges (grazing angle)
  18604. */
  18605. leftColor?: Color3;
  18606. /**
  18607. * Define the color used on center
  18608. */
  18609. rightColor?: Color3;
  18610. /**
  18611. * Define bias applied to computed fresnel term
  18612. */
  18613. bias?: number;
  18614. /**
  18615. * Defined the power exponent applied to fresnel term
  18616. */
  18617. power?: number;
  18618. /**
  18619. * Define if the fresnel effect is enable or not.
  18620. */
  18621. isEnabled?: boolean;
  18622. };
  18623. /**
  18624. * Serialized format for FresnelParameters.
  18625. */
  18626. export type IFresnelParametersSerialized = {
  18627. /**
  18628. * Define the color used on edges (grazing angle) [as an array]
  18629. */
  18630. leftColor: number[];
  18631. /**
  18632. * Define the color used on center [as an array]
  18633. */
  18634. rightColor: number[];
  18635. /**
  18636. * Define bias applied to computed fresnel term
  18637. */
  18638. bias: number;
  18639. /**
  18640. * Defined the power exponent applied to fresnel term
  18641. */
  18642. power?: number;
  18643. /**
  18644. * Define if the fresnel effect is enable or not.
  18645. */
  18646. isEnabled: boolean;
  18647. };
  18648. /**
  18649. * This represents all the required information to add a fresnel effect on a material:
  18650. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18651. */
  18652. export class FresnelParameters {
  18653. private _isEnabled;
  18654. /**
  18655. * Define if the fresnel effect is enable or not.
  18656. */
  18657. get isEnabled(): boolean;
  18658. set isEnabled(value: boolean);
  18659. /**
  18660. * Define the color used on edges (grazing angle)
  18661. */
  18662. leftColor: Color3;
  18663. /**
  18664. * Define the color used on center
  18665. */
  18666. rightColor: Color3;
  18667. /**
  18668. * Define bias applied to computed fresnel term
  18669. */
  18670. bias: number;
  18671. /**
  18672. * Defined the power exponent applied to fresnel term
  18673. */
  18674. power: number;
  18675. /**
  18676. * Creates a new FresnelParameters object.
  18677. *
  18678. * @param options provide your own settings to optionally to override defaults
  18679. */
  18680. constructor(options?: IFresnelParametersCreationOptions);
  18681. /**
  18682. * Clones the current fresnel and its valuues
  18683. * @returns a clone fresnel configuration
  18684. */
  18685. clone(): FresnelParameters;
  18686. /**
  18687. * Determines equality between FresnelParameters objects
  18688. * @param otherFresnelParameters defines the second operand
  18689. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18690. */
  18691. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18692. /**
  18693. * Serializes the current fresnel parameters to a JSON representation.
  18694. * @return the JSON serialization
  18695. */
  18696. serialize(): IFresnelParametersSerialized;
  18697. /**
  18698. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18699. * @param parsedFresnelParameters Define the JSON representation
  18700. * @returns the parsed parameters
  18701. */
  18702. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18703. }
  18704. }
  18705. declare module "babylonjs/Materials/materialFlags" {
  18706. /**
  18707. * This groups all the flags used to control the materials channel.
  18708. */
  18709. export class MaterialFlags {
  18710. private static _DiffuseTextureEnabled;
  18711. /**
  18712. * Are diffuse textures enabled in the application.
  18713. */
  18714. static get DiffuseTextureEnabled(): boolean;
  18715. static set DiffuseTextureEnabled(value: boolean);
  18716. private static _DetailTextureEnabled;
  18717. /**
  18718. * Are detail textures enabled in the application.
  18719. */
  18720. static get DetailTextureEnabled(): boolean;
  18721. static set DetailTextureEnabled(value: boolean);
  18722. private static _AmbientTextureEnabled;
  18723. /**
  18724. * Are ambient textures enabled in the application.
  18725. */
  18726. static get AmbientTextureEnabled(): boolean;
  18727. static set AmbientTextureEnabled(value: boolean);
  18728. private static _OpacityTextureEnabled;
  18729. /**
  18730. * Are opacity textures enabled in the application.
  18731. */
  18732. static get OpacityTextureEnabled(): boolean;
  18733. static set OpacityTextureEnabled(value: boolean);
  18734. private static _ReflectionTextureEnabled;
  18735. /**
  18736. * Are reflection textures enabled in the application.
  18737. */
  18738. static get ReflectionTextureEnabled(): boolean;
  18739. static set ReflectionTextureEnabled(value: boolean);
  18740. private static _EmissiveTextureEnabled;
  18741. /**
  18742. * Are emissive textures enabled in the application.
  18743. */
  18744. static get EmissiveTextureEnabled(): boolean;
  18745. static set EmissiveTextureEnabled(value: boolean);
  18746. private static _SpecularTextureEnabled;
  18747. /**
  18748. * Are specular textures enabled in the application.
  18749. */
  18750. static get SpecularTextureEnabled(): boolean;
  18751. static set SpecularTextureEnabled(value: boolean);
  18752. private static _BumpTextureEnabled;
  18753. /**
  18754. * Are bump textures enabled in the application.
  18755. */
  18756. static get BumpTextureEnabled(): boolean;
  18757. static set BumpTextureEnabled(value: boolean);
  18758. private static _LightmapTextureEnabled;
  18759. /**
  18760. * Are lightmap textures enabled in the application.
  18761. */
  18762. static get LightmapTextureEnabled(): boolean;
  18763. static set LightmapTextureEnabled(value: boolean);
  18764. private static _RefractionTextureEnabled;
  18765. /**
  18766. * Are refraction textures enabled in the application.
  18767. */
  18768. static get RefractionTextureEnabled(): boolean;
  18769. static set RefractionTextureEnabled(value: boolean);
  18770. private static _ColorGradingTextureEnabled;
  18771. /**
  18772. * Are color grading textures enabled in the application.
  18773. */
  18774. static get ColorGradingTextureEnabled(): boolean;
  18775. static set ColorGradingTextureEnabled(value: boolean);
  18776. private static _FresnelEnabled;
  18777. /**
  18778. * Are fresnels enabled in the application.
  18779. */
  18780. static get FresnelEnabled(): boolean;
  18781. static set FresnelEnabled(value: boolean);
  18782. private static _ClearCoatTextureEnabled;
  18783. /**
  18784. * Are clear coat textures enabled in the application.
  18785. */
  18786. static get ClearCoatTextureEnabled(): boolean;
  18787. static set ClearCoatTextureEnabled(value: boolean);
  18788. private static _ClearCoatBumpTextureEnabled;
  18789. /**
  18790. * Are clear coat bump textures enabled in the application.
  18791. */
  18792. static get ClearCoatBumpTextureEnabled(): boolean;
  18793. static set ClearCoatBumpTextureEnabled(value: boolean);
  18794. private static _ClearCoatTintTextureEnabled;
  18795. /**
  18796. * Are clear coat tint textures enabled in the application.
  18797. */
  18798. static get ClearCoatTintTextureEnabled(): boolean;
  18799. static set ClearCoatTintTextureEnabled(value: boolean);
  18800. private static _SheenTextureEnabled;
  18801. /**
  18802. * Are sheen textures enabled in the application.
  18803. */
  18804. static get SheenTextureEnabled(): boolean;
  18805. static set SheenTextureEnabled(value: boolean);
  18806. private static _AnisotropicTextureEnabled;
  18807. /**
  18808. * Are anisotropic textures enabled in the application.
  18809. */
  18810. static get AnisotropicTextureEnabled(): boolean;
  18811. static set AnisotropicTextureEnabled(value: boolean);
  18812. private static _ThicknessTextureEnabled;
  18813. /**
  18814. * Are thickness textures enabled in the application.
  18815. */
  18816. static get ThicknessTextureEnabled(): boolean;
  18817. static set ThicknessTextureEnabled(value: boolean);
  18818. }
  18819. }
  18820. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  18821. /** @hidden */
  18822. export var defaultFragmentDeclaration: {
  18823. name: string;
  18824. shader: string;
  18825. };
  18826. }
  18827. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  18828. /** @hidden */
  18829. export var defaultUboDeclaration: {
  18830. name: string;
  18831. shader: string;
  18832. };
  18833. }
  18834. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  18835. /** @hidden */
  18836. export var prePassDeclaration: {
  18837. name: string;
  18838. shader: string;
  18839. };
  18840. }
  18841. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  18842. /** @hidden */
  18843. export var lightFragmentDeclaration: {
  18844. name: string;
  18845. shader: string;
  18846. };
  18847. }
  18848. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  18849. /** @hidden */
  18850. export var lightUboDeclaration: {
  18851. name: string;
  18852. shader: string;
  18853. };
  18854. }
  18855. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  18856. /** @hidden */
  18857. export var lightsFragmentFunctions: {
  18858. name: string;
  18859. shader: string;
  18860. };
  18861. }
  18862. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  18863. /** @hidden */
  18864. export var shadowsFragmentFunctions: {
  18865. name: string;
  18866. shader: string;
  18867. };
  18868. }
  18869. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  18870. /** @hidden */
  18871. export var fresnelFunction: {
  18872. name: string;
  18873. shader: string;
  18874. };
  18875. }
  18876. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  18877. /** @hidden */
  18878. export var bumpFragmentMainFunctions: {
  18879. name: string;
  18880. shader: string;
  18881. };
  18882. }
  18883. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  18884. /** @hidden */
  18885. export var bumpFragmentFunctions: {
  18886. name: string;
  18887. shader: string;
  18888. };
  18889. }
  18890. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  18891. /** @hidden */
  18892. export var logDepthDeclaration: {
  18893. name: string;
  18894. shader: string;
  18895. };
  18896. }
  18897. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  18898. /** @hidden */
  18899. export var fogFragmentDeclaration: {
  18900. name: string;
  18901. shader: string;
  18902. };
  18903. }
  18904. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  18905. /** @hidden */
  18906. export var bumpFragment: {
  18907. name: string;
  18908. shader: string;
  18909. };
  18910. }
  18911. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  18912. /** @hidden */
  18913. export var depthPrePass: {
  18914. name: string;
  18915. shader: string;
  18916. };
  18917. }
  18918. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  18919. /** @hidden */
  18920. export var lightFragment: {
  18921. name: string;
  18922. shader: string;
  18923. };
  18924. }
  18925. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  18926. /** @hidden */
  18927. export var logDepthFragment: {
  18928. name: string;
  18929. shader: string;
  18930. };
  18931. }
  18932. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  18933. /** @hidden */
  18934. export var fogFragment: {
  18935. name: string;
  18936. shader: string;
  18937. };
  18938. }
  18939. declare module "babylonjs/Shaders/default.fragment" {
  18940. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  18941. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  18942. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  18943. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18944. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  18945. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  18946. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  18947. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  18948. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  18949. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  18950. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18951. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18952. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  18953. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  18954. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  18955. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  18956. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  18957. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  18958. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  18959. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  18960. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  18961. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  18962. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  18963. /** @hidden */
  18964. export var defaultPixelShader: {
  18965. name: string;
  18966. shader: string;
  18967. };
  18968. }
  18969. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  18970. /** @hidden */
  18971. export var defaultVertexDeclaration: {
  18972. name: string;
  18973. shader: string;
  18974. };
  18975. }
  18976. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  18977. /** @hidden */
  18978. export var bonesDeclaration: {
  18979. name: string;
  18980. shader: string;
  18981. };
  18982. }
  18983. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  18984. /** @hidden */
  18985. export var instancesDeclaration: {
  18986. name: string;
  18987. shader: string;
  18988. };
  18989. }
  18990. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  18991. /** @hidden */
  18992. export var prePassVertexDeclaration: {
  18993. name: string;
  18994. shader: string;
  18995. };
  18996. }
  18997. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  18998. /** @hidden */
  18999. export var bumpVertexDeclaration: {
  19000. name: string;
  19001. shader: string;
  19002. };
  19003. }
  19004. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  19005. /** @hidden */
  19006. export var fogVertexDeclaration: {
  19007. name: string;
  19008. shader: string;
  19009. };
  19010. }
  19011. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  19012. /** @hidden */
  19013. export var morphTargetsVertexGlobalDeclaration: {
  19014. name: string;
  19015. shader: string;
  19016. };
  19017. }
  19018. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  19019. /** @hidden */
  19020. export var morphTargetsVertexDeclaration: {
  19021. name: string;
  19022. shader: string;
  19023. };
  19024. }
  19025. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  19026. /** @hidden */
  19027. export var morphTargetsVertex: {
  19028. name: string;
  19029. shader: string;
  19030. };
  19031. }
  19032. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  19033. /** @hidden */
  19034. export var instancesVertex: {
  19035. name: string;
  19036. shader: string;
  19037. };
  19038. }
  19039. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19040. /** @hidden */
  19041. export var bonesVertex: {
  19042. name: string;
  19043. shader: string;
  19044. };
  19045. }
  19046. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19047. /** @hidden */
  19048. export var prePassVertex: {
  19049. name: string;
  19050. shader: string;
  19051. };
  19052. }
  19053. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19054. /** @hidden */
  19055. export var bumpVertex: {
  19056. name: string;
  19057. shader: string;
  19058. };
  19059. }
  19060. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19061. /** @hidden */
  19062. export var fogVertex: {
  19063. name: string;
  19064. shader: string;
  19065. };
  19066. }
  19067. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19068. /** @hidden */
  19069. export var shadowsVertex: {
  19070. name: string;
  19071. shader: string;
  19072. };
  19073. }
  19074. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19075. /** @hidden */
  19076. export var pointCloudVertex: {
  19077. name: string;
  19078. shader: string;
  19079. };
  19080. }
  19081. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19082. /** @hidden */
  19083. export var logDepthVertex: {
  19084. name: string;
  19085. shader: string;
  19086. };
  19087. }
  19088. declare module "babylonjs/Shaders/default.vertex" {
  19089. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19090. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19091. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19092. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19093. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19094. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19095. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19096. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19097. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19098. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19099. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19100. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19101. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19102. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19103. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19104. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19105. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19106. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19107. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19108. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19109. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19110. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19111. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19112. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19113. /** @hidden */
  19114. export var defaultVertexShader: {
  19115. name: string;
  19116. shader: string;
  19117. };
  19118. }
  19119. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19120. import { Nullable } from "babylonjs/types";
  19121. import { Scene } from "babylonjs/scene";
  19122. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19123. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19124. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19125. /**
  19126. * @hidden
  19127. */
  19128. export interface IMaterialDetailMapDefines {
  19129. DETAIL: boolean;
  19130. DETAILDIRECTUV: number;
  19131. DETAIL_NORMALBLENDMETHOD: number;
  19132. /** @hidden */
  19133. _areTexturesDirty: boolean;
  19134. }
  19135. /**
  19136. * Define the code related to the detail map parameters of a material
  19137. *
  19138. * Inspired from:
  19139. * 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
  19140. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19141. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19142. */
  19143. export class DetailMapConfiguration {
  19144. private _texture;
  19145. /**
  19146. * The detail texture of the material.
  19147. */
  19148. texture: Nullable<BaseTexture>;
  19149. /**
  19150. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19151. * Bigger values mean stronger blending
  19152. */
  19153. diffuseBlendLevel: number;
  19154. /**
  19155. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19156. * Bigger values mean stronger blending. Only used with PBR materials
  19157. */
  19158. roughnessBlendLevel: number;
  19159. /**
  19160. * Defines how strong the bump effect from the detail map is
  19161. * Bigger values mean stronger effect
  19162. */
  19163. bumpLevel: number;
  19164. private _normalBlendMethod;
  19165. /**
  19166. * The method used to blend the bump and detail normals together
  19167. */
  19168. normalBlendMethod: number;
  19169. private _isEnabled;
  19170. /**
  19171. * Enable or disable the detail map on this material
  19172. */
  19173. isEnabled: boolean;
  19174. /** @hidden */
  19175. private _internalMarkAllSubMeshesAsTexturesDirty;
  19176. /** @hidden */
  19177. _markAllSubMeshesAsTexturesDirty(): void;
  19178. /**
  19179. * Instantiate a new detail map
  19180. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19181. */
  19182. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19183. /**
  19184. * Gets whether the submesh is ready to be used or not.
  19185. * @param defines the list of "defines" to update.
  19186. * @param scene defines the scene the material belongs to.
  19187. * @returns - boolean indicating that the submesh is ready or not.
  19188. */
  19189. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19190. /**
  19191. * Update the defines for detail map usage
  19192. * @param defines the list of "defines" to update.
  19193. * @param scene defines the scene the material belongs to.
  19194. */
  19195. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19196. /**
  19197. * Binds the material data.
  19198. * @param uniformBuffer defines the Uniform buffer to fill in.
  19199. * @param scene defines the scene the material belongs to.
  19200. * @param isFrozen defines whether the material is frozen or not.
  19201. */
  19202. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19203. /**
  19204. * Checks to see if a texture is used in the material.
  19205. * @param texture - Base texture to use.
  19206. * @returns - Boolean specifying if a texture is used in the material.
  19207. */
  19208. hasTexture(texture: BaseTexture): boolean;
  19209. /**
  19210. * Returns an array of the actively used textures.
  19211. * @param activeTextures Array of BaseTextures
  19212. */
  19213. getActiveTextures(activeTextures: BaseTexture[]): void;
  19214. /**
  19215. * Returns the animatable textures.
  19216. * @param animatables Array of animatable textures.
  19217. */
  19218. getAnimatables(animatables: IAnimatable[]): void;
  19219. /**
  19220. * Disposes the resources of the material.
  19221. * @param forceDisposeTextures - Forces the disposal of all textures.
  19222. */
  19223. dispose(forceDisposeTextures?: boolean): void;
  19224. /**
  19225. * Get the current class name useful for serialization or dynamic coding.
  19226. * @returns "DetailMap"
  19227. */
  19228. getClassName(): string;
  19229. /**
  19230. * Add the required uniforms to the current list.
  19231. * @param uniforms defines the current uniform list.
  19232. */
  19233. static AddUniforms(uniforms: string[]): void;
  19234. /**
  19235. * Add the required samplers to the current list.
  19236. * @param samplers defines the current sampler list.
  19237. */
  19238. static AddSamplers(samplers: string[]): void;
  19239. /**
  19240. * Add the required uniforms to the current buffer.
  19241. * @param uniformBuffer defines the current uniform buffer.
  19242. */
  19243. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19244. /**
  19245. * Makes a duplicate of the current instance into another one.
  19246. * @param detailMap define the instance where to copy the info
  19247. */
  19248. copyTo(detailMap: DetailMapConfiguration): void;
  19249. /**
  19250. * Serializes this detail map instance
  19251. * @returns - An object with the serialized instance.
  19252. */
  19253. serialize(): any;
  19254. /**
  19255. * Parses a detail map setting from a serialized object.
  19256. * @param source - Serialized object.
  19257. * @param scene Defines the scene we are parsing for
  19258. * @param rootUrl Defines the rootUrl to load from
  19259. */
  19260. parse(source: any, scene: Scene, rootUrl: string): void;
  19261. }
  19262. }
  19263. declare module "babylonjs/Materials/standardMaterial" {
  19264. import { SmartArray } from "babylonjs/Misc/smartArray";
  19265. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19266. import { Nullable } from "babylonjs/types";
  19267. import { Scene } from "babylonjs/scene";
  19268. import { Matrix } from "babylonjs/Maths/math.vector";
  19269. import { Color3 } from "babylonjs/Maths/math.color";
  19270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19272. import { Mesh } from "babylonjs/Meshes/mesh";
  19273. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  19274. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19275. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19276. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  19277. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  19278. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  19279. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19280. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19281. import "babylonjs/Shaders/default.fragment";
  19282. import "babylonjs/Shaders/default.vertex";
  19283. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  19284. /** @hidden */
  19285. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19286. MAINUV1: boolean;
  19287. MAINUV2: boolean;
  19288. DIFFUSE: boolean;
  19289. DIFFUSEDIRECTUV: number;
  19290. DETAIL: boolean;
  19291. DETAILDIRECTUV: number;
  19292. DETAIL_NORMALBLENDMETHOD: number;
  19293. AMBIENT: boolean;
  19294. AMBIENTDIRECTUV: number;
  19295. OPACITY: boolean;
  19296. OPACITYDIRECTUV: number;
  19297. OPACITYRGB: boolean;
  19298. REFLECTION: boolean;
  19299. EMISSIVE: boolean;
  19300. EMISSIVEDIRECTUV: number;
  19301. SPECULAR: boolean;
  19302. SPECULARDIRECTUV: number;
  19303. BUMP: boolean;
  19304. BUMPDIRECTUV: number;
  19305. PARALLAX: boolean;
  19306. PARALLAXOCCLUSION: boolean;
  19307. SPECULAROVERALPHA: boolean;
  19308. CLIPPLANE: boolean;
  19309. CLIPPLANE2: boolean;
  19310. CLIPPLANE3: boolean;
  19311. CLIPPLANE4: boolean;
  19312. CLIPPLANE5: boolean;
  19313. CLIPPLANE6: boolean;
  19314. ALPHATEST: boolean;
  19315. DEPTHPREPASS: boolean;
  19316. ALPHAFROMDIFFUSE: boolean;
  19317. POINTSIZE: boolean;
  19318. FOG: boolean;
  19319. SPECULARTERM: boolean;
  19320. DIFFUSEFRESNEL: boolean;
  19321. OPACITYFRESNEL: boolean;
  19322. REFLECTIONFRESNEL: boolean;
  19323. REFRACTIONFRESNEL: boolean;
  19324. EMISSIVEFRESNEL: boolean;
  19325. FRESNEL: boolean;
  19326. NORMAL: boolean;
  19327. UV1: boolean;
  19328. UV2: boolean;
  19329. VERTEXCOLOR: boolean;
  19330. VERTEXALPHA: boolean;
  19331. NUM_BONE_INFLUENCERS: number;
  19332. BonesPerMesh: number;
  19333. BONETEXTURE: boolean;
  19334. BONES_VELOCITY_ENABLED: boolean;
  19335. INSTANCES: boolean;
  19336. THIN_INSTANCES: boolean;
  19337. GLOSSINESS: boolean;
  19338. ROUGHNESS: boolean;
  19339. EMISSIVEASILLUMINATION: boolean;
  19340. LINKEMISSIVEWITHDIFFUSE: boolean;
  19341. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19342. LIGHTMAP: boolean;
  19343. LIGHTMAPDIRECTUV: number;
  19344. OBJECTSPACE_NORMALMAP: boolean;
  19345. USELIGHTMAPASSHADOWMAP: boolean;
  19346. REFLECTIONMAP_3D: boolean;
  19347. REFLECTIONMAP_SPHERICAL: boolean;
  19348. REFLECTIONMAP_PLANAR: boolean;
  19349. REFLECTIONMAP_CUBIC: boolean;
  19350. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19351. REFLECTIONMAP_PROJECTION: boolean;
  19352. REFLECTIONMAP_SKYBOX: boolean;
  19353. REFLECTIONMAP_EXPLICIT: boolean;
  19354. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19355. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19356. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19357. INVERTCUBICMAP: boolean;
  19358. LOGARITHMICDEPTH: boolean;
  19359. REFRACTION: boolean;
  19360. REFRACTIONMAP_3D: boolean;
  19361. REFLECTIONOVERALPHA: boolean;
  19362. TWOSIDEDLIGHTING: boolean;
  19363. SHADOWFLOAT: boolean;
  19364. MORPHTARGETS: boolean;
  19365. MORPHTARGETS_NORMAL: boolean;
  19366. MORPHTARGETS_TANGENT: boolean;
  19367. MORPHTARGETS_UV: boolean;
  19368. NUM_MORPH_INFLUENCERS: number;
  19369. NONUNIFORMSCALING: boolean;
  19370. PREMULTIPLYALPHA: boolean;
  19371. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19372. ALPHABLEND: boolean;
  19373. PREPASS: boolean;
  19374. PREPASS_IRRADIANCE: boolean;
  19375. PREPASS_IRRADIANCE_INDEX: number;
  19376. PREPASS_ALBEDO: boolean;
  19377. PREPASS_ALBEDO_INDEX: number;
  19378. PREPASS_DEPTHNORMAL: boolean;
  19379. PREPASS_DEPTHNORMAL_INDEX: number;
  19380. PREPASS_POSITION: boolean;
  19381. PREPASS_POSITION_INDEX: number;
  19382. PREPASS_VELOCITY: boolean;
  19383. PREPASS_VELOCITY_INDEX: number;
  19384. PREPASS_REFLECTIVITY: boolean;
  19385. PREPASS_REFLECTIVITY_INDEX: number;
  19386. SCENE_MRT_COUNT: number;
  19387. RGBDLIGHTMAP: boolean;
  19388. RGBDREFLECTION: boolean;
  19389. RGBDREFRACTION: boolean;
  19390. IMAGEPROCESSING: boolean;
  19391. VIGNETTE: boolean;
  19392. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19393. VIGNETTEBLENDMODEOPAQUE: boolean;
  19394. TONEMAPPING: boolean;
  19395. TONEMAPPING_ACES: boolean;
  19396. CONTRAST: boolean;
  19397. COLORCURVES: boolean;
  19398. COLORGRADING: boolean;
  19399. COLORGRADING3D: boolean;
  19400. SAMPLER3DGREENDEPTH: boolean;
  19401. SAMPLER3DBGRMAP: boolean;
  19402. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19403. MULTIVIEW: boolean;
  19404. /**
  19405. * If the reflection texture on this material is in linear color space
  19406. * @hidden
  19407. */
  19408. IS_REFLECTION_LINEAR: boolean;
  19409. /**
  19410. * If the refraction texture on this material is in linear color space
  19411. * @hidden
  19412. */
  19413. IS_REFRACTION_LINEAR: boolean;
  19414. EXPOSURE: boolean;
  19415. constructor();
  19416. setReflectionMode(modeToEnable: string): void;
  19417. }
  19418. /**
  19419. * This is the default material used in Babylon. It is the best trade off between quality
  19420. * and performances.
  19421. * @see https://doc.babylonjs.com/babylon101/materials
  19422. */
  19423. export class StandardMaterial extends PushMaterial {
  19424. private _diffuseTexture;
  19425. /**
  19426. * The basic texture of the material as viewed under a light.
  19427. */
  19428. diffuseTexture: Nullable<BaseTexture>;
  19429. private _ambientTexture;
  19430. /**
  19431. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19432. */
  19433. ambientTexture: Nullable<BaseTexture>;
  19434. private _opacityTexture;
  19435. /**
  19436. * Define the transparency of the material from a texture.
  19437. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19438. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19439. */
  19440. opacityTexture: Nullable<BaseTexture>;
  19441. private _reflectionTexture;
  19442. /**
  19443. * Define the texture used to display the reflection.
  19444. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19445. */
  19446. reflectionTexture: Nullable<BaseTexture>;
  19447. private _emissiveTexture;
  19448. /**
  19449. * Define texture of the material as if self lit.
  19450. * This will be mixed in the final result even in the absence of light.
  19451. */
  19452. emissiveTexture: Nullable<BaseTexture>;
  19453. private _specularTexture;
  19454. /**
  19455. * Define how the color and intensity of the highlight given by the light in the material.
  19456. */
  19457. specularTexture: Nullable<BaseTexture>;
  19458. private _bumpTexture;
  19459. /**
  19460. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19461. * 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.
  19462. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19463. */
  19464. bumpTexture: Nullable<BaseTexture>;
  19465. private _lightmapTexture;
  19466. /**
  19467. * Complex lighting can be computationally expensive to compute at runtime.
  19468. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19469. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19470. */
  19471. lightmapTexture: Nullable<BaseTexture>;
  19472. private _refractionTexture;
  19473. /**
  19474. * Define the texture used to display the refraction.
  19475. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19476. */
  19477. refractionTexture: Nullable<BaseTexture>;
  19478. /**
  19479. * The color of the material lit by the environmental background lighting.
  19480. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19481. */
  19482. ambientColor: Color3;
  19483. /**
  19484. * The basic color of the material as viewed under a light.
  19485. */
  19486. diffuseColor: Color3;
  19487. /**
  19488. * Define how the color and intensity of the highlight given by the light in the material.
  19489. */
  19490. specularColor: Color3;
  19491. /**
  19492. * Define the color of the material as if self lit.
  19493. * This will be mixed in the final result even in the absence of light.
  19494. */
  19495. emissiveColor: Color3;
  19496. /**
  19497. * Defines how sharp are the highlights in the material.
  19498. * The bigger the value the sharper giving a more glossy feeling to the result.
  19499. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19500. */
  19501. specularPower: number;
  19502. private _useAlphaFromDiffuseTexture;
  19503. /**
  19504. * Does the transparency come from the diffuse texture alpha channel.
  19505. */
  19506. useAlphaFromDiffuseTexture: boolean;
  19507. private _useEmissiveAsIllumination;
  19508. /**
  19509. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19510. */
  19511. useEmissiveAsIllumination: boolean;
  19512. private _linkEmissiveWithDiffuse;
  19513. /**
  19514. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19515. * the emissive level when the final color is close to one.
  19516. */
  19517. linkEmissiveWithDiffuse: boolean;
  19518. private _useSpecularOverAlpha;
  19519. /**
  19520. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19521. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19522. */
  19523. useSpecularOverAlpha: boolean;
  19524. private _useReflectionOverAlpha;
  19525. /**
  19526. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19527. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19528. */
  19529. useReflectionOverAlpha: boolean;
  19530. private _disableLighting;
  19531. /**
  19532. * Does lights from the scene impacts this material.
  19533. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19534. */
  19535. disableLighting: boolean;
  19536. private _useObjectSpaceNormalMap;
  19537. /**
  19538. * Allows using an object space normal map (instead of tangent space).
  19539. */
  19540. useObjectSpaceNormalMap: boolean;
  19541. private _useParallax;
  19542. /**
  19543. * Is parallax enabled or not.
  19544. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19545. */
  19546. useParallax: boolean;
  19547. private _useParallaxOcclusion;
  19548. /**
  19549. * Is parallax occlusion enabled or not.
  19550. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19551. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19552. */
  19553. useParallaxOcclusion: boolean;
  19554. /**
  19555. * 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.
  19556. */
  19557. parallaxScaleBias: number;
  19558. private _roughness;
  19559. /**
  19560. * Helps to define how blurry the reflections should appears in the material.
  19561. */
  19562. roughness: number;
  19563. /**
  19564. * In case of refraction, define the value of the index of refraction.
  19565. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19566. */
  19567. indexOfRefraction: number;
  19568. /**
  19569. * Invert the refraction texture alongside the y axis.
  19570. * It can be useful with procedural textures or probe for instance.
  19571. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19572. */
  19573. invertRefractionY: boolean;
  19574. /**
  19575. * Defines the alpha limits in alpha test mode.
  19576. */
  19577. alphaCutOff: number;
  19578. private _useLightmapAsShadowmap;
  19579. /**
  19580. * In case of light mapping, define whether the map contains light or shadow informations.
  19581. */
  19582. useLightmapAsShadowmap: boolean;
  19583. private _diffuseFresnelParameters;
  19584. /**
  19585. * Define the diffuse fresnel parameters of the material.
  19586. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19587. */
  19588. diffuseFresnelParameters: FresnelParameters;
  19589. private _opacityFresnelParameters;
  19590. /**
  19591. * Define the opacity fresnel parameters of the material.
  19592. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19593. */
  19594. opacityFresnelParameters: FresnelParameters;
  19595. private _reflectionFresnelParameters;
  19596. /**
  19597. * Define the reflection fresnel parameters of the material.
  19598. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19599. */
  19600. reflectionFresnelParameters: FresnelParameters;
  19601. private _refractionFresnelParameters;
  19602. /**
  19603. * Define the refraction fresnel parameters of the material.
  19604. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19605. */
  19606. refractionFresnelParameters: FresnelParameters;
  19607. private _emissiveFresnelParameters;
  19608. /**
  19609. * Define the emissive fresnel parameters of the material.
  19610. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19611. */
  19612. emissiveFresnelParameters: FresnelParameters;
  19613. private _useReflectionFresnelFromSpecular;
  19614. /**
  19615. * If true automatically deducts the fresnels values from the material specularity.
  19616. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19617. */
  19618. useReflectionFresnelFromSpecular: boolean;
  19619. private _useGlossinessFromSpecularMapAlpha;
  19620. /**
  19621. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19622. */
  19623. useGlossinessFromSpecularMapAlpha: boolean;
  19624. private _maxSimultaneousLights;
  19625. /**
  19626. * Defines the maximum number of lights that can be used in the material
  19627. */
  19628. maxSimultaneousLights: number;
  19629. private _invertNormalMapX;
  19630. /**
  19631. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19632. */
  19633. invertNormalMapX: boolean;
  19634. private _invertNormalMapY;
  19635. /**
  19636. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19637. */
  19638. invertNormalMapY: boolean;
  19639. private _twoSidedLighting;
  19640. /**
  19641. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19642. */
  19643. twoSidedLighting: boolean;
  19644. /**
  19645. * Default configuration related to image processing available in the standard Material.
  19646. */
  19647. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19648. /**
  19649. * Gets the image processing configuration used either in this material.
  19650. */
  19651. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19652. /**
  19653. * Sets the Default image processing configuration used either in the this material.
  19654. *
  19655. * If sets to null, the scene one is in use.
  19656. */
  19657. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19658. /**
  19659. * Keep track of the image processing observer to allow dispose and replace.
  19660. */
  19661. private _imageProcessingObserver;
  19662. /**
  19663. * Attaches a new image processing configuration to the Standard Material.
  19664. * @param configuration
  19665. */
  19666. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19667. /**
  19668. * Defines additionnal PrePass parameters for the material.
  19669. */
  19670. readonly prePassConfiguration: PrePassConfiguration;
  19671. /**
  19672. * Gets wether the color curves effect is enabled.
  19673. */
  19674. get cameraColorCurvesEnabled(): boolean;
  19675. /**
  19676. * Sets wether the color curves effect is enabled.
  19677. */
  19678. set cameraColorCurvesEnabled(value: boolean);
  19679. /**
  19680. * Gets wether the color grading effect is enabled.
  19681. */
  19682. get cameraColorGradingEnabled(): boolean;
  19683. /**
  19684. * Gets wether the color grading effect is enabled.
  19685. */
  19686. set cameraColorGradingEnabled(value: boolean);
  19687. /**
  19688. * Gets wether tonemapping is enabled or not.
  19689. */
  19690. get cameraToneMappingEnabled(): boolean;
  19691. /**
  19692. * Sets wether tonemapping is enabled or not
  19693. */
  19694. set cameraToneMappingEnabled(value: boolean);
  19695. /**
  19696. * The camera exposure used on this material.
  19697. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19698. * This corresponds to a photographic exposure.
  19699. */
  19700. get cameraExposure(): number;
  19701. /**
  19702. * The camera exposure used on this material.
  19703. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19704. * This corresponds to a photographic exposure.
  19705. */
  19706. set cameraExposure(value: number);
  19707. /**
  19708. * Gets The camera contrast used on this material.
  19709. */
  19710. get cameraContrast(): number;
  19711. /**
  19712. * Sets The camera contrast used on this material.
  19713. */
  19714. set cameraContrast(value: number);
  19715. /**
  19716. * Gets the Color Grading 2D Lookup Texture.
  19717. */
  19718. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19719. /**
  19720. * Sets the Color Grading 2D Lookup Texture.
  19721. */
  19722. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19723. /**
  19724. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19725. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19726. * 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;
  19727. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19728. */
  19729. get cameraColorCurves(): Nullable<ColorCurves>;
  19730. /**
  19731. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19732. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19733. * 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;
  19734. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19735. */
  19736. set cameraColorCurves(value: Nullable<ColorCurves>);
  19737. /**
  19738. * Can this material render to several textures at once
  19739. */
  19740. get canRenderToMRT(): boolean;
  19741. /**
  19742. * Defines the detail map parameters for the material.
  19743. */
  19744. readonly detailMap: DetailMapConfiguration;
  19745. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19746. protected _worldViewProjectionMatrix: Matrix;
  19747. protected _globalAmbientColor: Color3;
  19748. protected _useLogarithmicDepth: boolean;
  19749. protected _rebuildInParallel: boolean;
  19750. /**
  19751. * Instantiates a new standard material.
  19752. * This is the default material used in Babylon. It is the best trade off between quality
  19753. * and performances.
  19754. * @see https://doc.babylonjs.com/babylon101/materials
  19755. * @param name Define the name of the material in the scene
  19756. * @param scene Define the scene the material belong to
  19757. */
  19758. constructor(name: string, scene: Scene);
  19759. /**
  19760. * Gets a boolean indicating that current material needs to register RTT
  19761. */
  19762. get hasRenderTargetTextures(): boolean;
  19763. /**
  19764. * Gets the current class name of the material e.g. "StandardMaterial"
  19765. * Mainly use in serialization.
  19766. * @returns the class name
  19767. */
  19768. getClassName(): string;
  19769. /**
  19770. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19771. * You can try switching to logarithmic depth.
  19772. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19773. */
  19774. get useLogarithmicDepth(): boolean;
  19775. set useLogarithmicDepth(value: boolean);
  19776. /**
  19777. * Specifies if the material will require alpha blending
  19778. * @returns a boolean specifying if alpha blending is needed
  19779. */
  19780. needAlphaBlending(): boolean;
  19781. /**
  19782. * Specifies if this material should be rendered in alpha test mode
  19783. * @returns a boolean specifying if an alpha test is needed.
  19784. */
  19785. needAlphaTesting(): boolean;
  19786. /**
  19787. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19788. */
  19789. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19790. /**
  19791. * Specifies whether or not there is a usable alpha channel for transparency.
  19792. */
  19793. protected _hasAlphaChannel(): boolean;
  19794. /**
  19795. * Get the texture used for alpha test purpose.
  19796. * @returns the diffuse texture in case of the standard material.
  19797. */
  19798. getAlphaTestTexture(): Nullable<BaseTexture>;
  19799. /**
  19800. * Get if the submesh is ready to be used and all its information available.
  19801. * Child classes can use it to update shaders
  19802. * @param mesh defines the mesh to check
  19803. * @param subMesh defines which submesh to check
  19804. * @param useInstances specifies that instances should be used
  19805. * @returns a boolean indicating that the submesh is ready or not
  19806. */
  19807. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19808. /**
  19809. * Builds the material UBO layouts.
  19810. * Used internally during the effect preparation.
  19811. */
  19812. buildUniformLayout(): void;
  19813. /**
  19814. * Unbinds the material from the mesh
  19815. */
  19816. unbind(): void;
  19817. /**
  19818. * Binds the submesh to this material by preparing the effect and shader to draw
  19819. * @param world defines the world transformation matrix
  19820. * @param mesh defines the mesh containing the submesh
  19821. * @param subMesh defines the submesh to bind the material to
  19822. */
  19823. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19824. /**
  19825. * Get the list of animatables in the material.
  19826. * @returns the list of animatables object used in the material
  19827. */
  19828. getAnimatables(): IAnimatable[];
  19829. /**
  19830. * Gets the active textures from the material
  19831. * @returns an array of textures
  19832. */
  19833. getActiveTextures(): BaseTexture[];
  19834. /**
  19835. * Specifies if the material uses a texture
  19836. * @param texture defines the texture to check against the material
  19837. * @returns a boolean specifying if the material uses the texture
  19838. */
  19839. hasTexture(texture: BaseTexture): boolean;
  19840. /**
  19841. * Disposes the material
  19842. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19843. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19844. */
  19845. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19846. /**
  19847. * Makes a duplicate of the material, and gives it a new name
  19848. * @param name defines the new name for the duplicated material
  19849. * @returns the cloned material
  19850. */
  19851. clone(name: string): StandardMaterial;
  19852. /**
  19853. * Serializes this material in a JSON representation
  19854. * @returns the serialized material object
  19855. */
  19856. serialize(): any;
  19857. /**
  19858. * Creates a standard material from parsed material data
  19859. * @param source defines the JSON representation of the material
  19860. * @param scene defines the hosting scene
  19861. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19862. * @returns a new standard material
  19863. */
  19864. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19865. /**
  19866. * Are diffuse textures enabled in the application.
  19867. */
  19868. static get DiffuseTextureEnabled(): boolean;
  19869. static set DiffuseTextureEnabled(value: boolean);
  19870. /**
  19871. * Are detail textures enabled in the application.
  19872. */
  19873. static get DetailTextureEnabled(): boolean;
  19874. static set DetailTextureEnabled(value: boolean);
  19875. /**
  19876. * Are ambient textures enabled in the application.
  19877. */
  19878. static get AmbientTextureEnabled(): boolean;
  19879. static set AmbientTextureEnabled(value: boolean);
  19880. /**
  19881. * Are opacity textures enabled in the application.
  19882. */
  19883. static get OpacityTextureEnabled(): boolean;
  19884. static set OpacityTextureEnabled(value: boolean);
  19885. /**
  19886. * Are reflection textures enabled in the application.
  19887. */
  19888. static get ReflectionTextureEnabled(): boolean;
  19889. static set ReflectionTextureEnabled(value: boolean);
  19890. /**
  19891. * Are emissive textures enabled in the application.
  19892. */
  19893. static get EmissiveTextureEnabled(): boolean;
  19894. static set EmissiveTextureEnabled(value: boolean);
  19895. /**
  19896. * Are specular textures enabled in the application.
  19897. */
  19898. static get SpecularTextureEnabled(): boolean;
  19899. static set SpecularTextureEnabled(value: boolean);
  19900. /**
  19901. * Are bump textures enabled in the application.
  19902. */
  19903. static get BumpTextureEnabled(): boolean;
  19904. static set BumpTextureEnabled(value: boolean);
  19905. /**
  19906. * Are lightmap textures enabled in the application.
  19907. */
  19908. static get LightmapTextureEnabled(): boolean;
  19909. static set LightmapTextureEnabled(value: boolean);
  19910. /**
  19911. * Are refraction textures enabled in the application.
  19912. */
  19913. static get RefractionTextureEnabled(): boolean;
  19914. static set RefractionTextureEnabled(value: boolean);
  19915. /**
  19916. * Are color grading textures enabled in the application.
  19917. */
  19918. static get ColorGradingTextureEnabled(): boolean;
  19919. static set ColorGradingTextureEnabled(value: boolean);
  19920. /**
  19921. * Are fresnels enabled in the application.
  19922. */
  19923. static get FresnelEnabled(): boolean;
  19924. static set FresnelEnabled(value: boolean);
  19925. }
  19926. }
  19927. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  19928. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19929. /** @hidden */
  19930. export var rgbdDecodePixelShader: {
  19931. name: string;
  19932. shader: string;
  19933. };
  19934. }
  19935. declare module "babylonjs/Misc/rgbdTextureTools" {
  19936. import "babylonjs/Shaders/rgbdDecode.fragment";
  19937. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19938. import { Texture } from "babylonjs/Materials/Textures/texture";
  19939. /**
  19940. * Class used to host RGBD texture specific utilities
  19941. */
  19942. export class RGBDTextureTools {
  19943. /**
  19944. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19945. * @param texture the texture to expand.
  19946. */
  19947. static ExpandRGBDTexture(texture: Texture): void;
  19948. }
  19949. }
  19950. declare module "babylonjs/Misc/brdfTextureTools" {
  19951. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19952. import { Scene } from "babylonjs/scene";
  19953. /**
  19954. * Class used to host texture specific utilities
  19955. */
  19956. export class BRDFTextureTools {
  19957. /**
  19958. * Prevents texture cache collision
  19959. */
  19960. private static _instanceNumber;
  19961. /**
  19962. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19963. * @param scene defines the hosting scene
  19964. * @returns the environment BRDF texture
  19965. */
  19966. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19967. private static _environmentBRDFBase64Texture;
  19968. }
  19969. }
  19970. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  19971. import { Nullable } from "babylonjs/types";
  19972. import { Color3 } from "babylonjs/Maths/math.color";
  19973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19974. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19975. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19976. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  19977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19978. import { Engine } from "babylonjs/Engines/engine";
  19979. import { Scene } from "babylonjs/scene";
  19980. /**
  19981. * @hidden
  19982. */
  19983. export interface IMaterialClearCoatDefines {
  19984. CLEARCOAT: boolean;
  19985. CLEARCOAT_DEFAULTIOR: boolean;
  19986. CLEARCOAT_TEXTURE: boolean;
  19987. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19988. CLEARCOAT_TEXTUREDIRECTUV: number;
  19989. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19990. CLEARCOAT_BUMP: boolean;
  19991. CLEARCOAT_BUMPDIRECTUV: number;
  19992. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19993. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19994. CLEARCOAT_REMAP_F0: boolean;
  19995. CLEARCOAT_TINT: boolean;
  19996. CLEARCOAT_TINT_TEXTURE: boolean;
  19997. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19998. /** @hidden */
  19999. _areTexturesDirty: boolean;
  20000. }
  20001. /**
  20002. * Define the code related to the clear coat parameters of the pbr material.
  20003. */
  20004. export class PBRClearCoatConfiguration {
  20005. /**
  20006. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20007. * The default fits with a polyurethane material.
  20008. * @hidden
  20009. */
  20010. static readonly _DefaultIndexOfRefraction: number;
  20011. private _isEnabled;
  20012. /**
  20013. * Defines if the clear coat is enabled in the material.
  20014. */
  20015. isEnabled: boolean;
  20016. /**
  20017. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20018. */
  20019. intensity: number;
  20020. /**
  20021. * Defines the clear coat layer roughness.
  20022. */
  20023. roughness: number;
  20024. private _indexOfRefraction;
  20025. /**
  20026. * Defines the index of refraction of the clear coat.
  20027. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20028. * The default fits with a polyurethane material.
  20029. * Changing the default value is more performance intensive.
  20030. */
  20031. indexOfRefraction: number;
  20032. private _texture;
  20033. /**
  20034. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20035. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20036. * if textureRoughness is not empty, else no texture roughness is used
  20037. */
  20038. texture: Nullable<BaseTexture>;
  20039. private _useRoughnessFromMainTexture;
  20040. /**
  20041. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20042. * If false, the green channel from textureRoughness is used for roughness
  20043. */
  20044. useRoughnessFromMainTexture: boolean;
  20045. private _textureRoughness;
  20046. /**
  20047. * Stores the clear coat roughness in a texture (green channel)
  20048. * Not used if useRoughnessFromMainTexture is true
  20049. */
  20050. textureRoughness: Nullable<BaseTexture>;
  20051. private _remapF0OnInterfaceChange;
  20052. /**
  20053. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20054. */
  20055. remapF0OnInterfaceChange: boolean;
  20056. private _bumpTexture;
  20057. /**
  20058. * Define the clear coat specific bump texture.
  20059. */
  20060. bumpTexture: Nullable<BaseTexture>;
  20061. private _isTintEnabled;
  20062. /**
  20063. * Defines if the clear coat tint is enabled in the material.
  20064. */
  20065. isTintEnabled: boolean;
  20066. /**
  20067. * Defines the clear coat tint of the material.
  20068. * This is only use if tint is enabled
  20069. */
  20070. tintColor: Color3;
  20071. /**
  20072. * Defines the distance at which the tint color should be found in the
  20073. * clear coat media.
  20074. * This is only use if tint is enabled
  20075. */
  20076. tintColorAtDistance: number;
  20077. /**
  20078. * Defines the clear coat layer thickness.
  20079. * This is only use if tint is enabled
  20080. */
  20081. tintThickness: number;
  20082. private _tintTexture;
  20083. /**
  20084. * Stores the clear tint values in a texture.
  20085. * rgb is tint
  20086. * a is a thickness factor
  20087. */
  20088. tintTexture: Nullable<BaseTexture>;
  20089. /** @hidden */
  20090. private _internalMarkAllSubMeshesAsTexturesDirty;
  20091. /** @hidden */
  20092. _markAllSubMeshesAsTexturesDirty(): void;
  20093. /**
  20094. * Instantiate a new istance of clear coat configuration.
  20095. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20096. */
  20097. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20098. /**
  20099. * Gets wehter the submesh is ready to be used or not.
  20100. * @param defines the list of "defines" to update.
  20101. * @param scene defines the scene the material belongs to.
  20102. * @param engine defines the engine the material belongs to.
  20103. * @param disableBumpMap defines wether the material disables bump or not.
  20104. * @returns - boolean indicating that the submesh is ready or not.
  20105. */
  20106. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20107. /**
  20108. * Checks to see if a texture is used in the material.
  20109. * @param defines the list of "defines" to update.
  20110. * @param scene defines the scene to the material belongs to.
  20111. */
  20112. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20113. /**
  20114. * Binds the material data.
  20115. * @param uniformBuffer defines the Uniform buffer to fill in.
  20116. * @param scene defines the scene the material belongs to.
  20117. * @param engine defines the engine the material belongs to.
  20118. * @param disableBumpMap defines wether the material disables bump or not.
  20119. * @param isFrozen defines wether the material is frozen or not.
  20120. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20121. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20122. * @param subMesh the submesh to bind data for
  20123. */
  20124. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20125. /**
  20126. * Checks to see if a texture is used in the material.
  20127. * @param texture - Base texture to use.
  20128. * @returns - Boolean specifying if a texture is used in the material.
  20129. */
  20130. hasTexture(texture: BaseTexture): boolean;
  20131. /**
  20132. * Returns an array of the actively used textures.
  20133. * @param activeTextures Array of BaseTextures
  20134. */
  20135. getActiveTextures(activeTextures: BaseTexture[]): void;
  20136. /**
  20137. * Returns the animatable textures.
  20138. * @param animatables Array of animatable textures.
  20139. */
  20140. getAnimatables(animatables: IAnimatable[]): void;
  20141. /**
  20142. * Disposes the resources of the material.
  20143. * @param forceDisposeTextures - Forces the disposal of all textures.
  20144. */
  20145. dispose(forceDisposeTextures?: boolean): void;
  20146. /**
  20147. * Get the current class name of the texture useful for serialization or dynamic coding.
  20148. * @returns "PBRClearCoatConfiguration"
  20149. */
  20150. getClassName(): string;
  20151. /**
  20152. * Add fallbacks to the effect fallbacks list.
  20153. * @param defines defines the Base texture to use.
  20154. * @param fallbacks defines the current fallback list.
  20155. * @param currentRank defines the current fallback rank.
  20156. * @returns the new fallback rank.
  20157. */
  20158. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20159. /**
  20160. * Add the required uniforms to the current list.
  20161. * @param uniforms defines the current uniform list.
  20162. */
  20163. static AddUniforms(uniforms: string[]): void;
  20164. /**
  20165. * Add the required samplers to the current list.
  20166. * @param samplers defines the current sampler list.
  20167. */
  20168. static AddSamplers(samplers: string[]): void;
  20169. /**
  20170. * Add the required uniforms to the current buffer.
  20171. * @param uniformBuffer defines the current uniform buffer.
  20172. */
  20173. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20174. /**
  20175. * Makes a duplicate of the current configuration into another one.
  20176. * @param clearCoatConfiguration define the config where to copy the info
  20177. */
  20178. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20179. /**
  20180. * Serializes this clear coat configuration.
  20181. * @returns - An object with the serialized config.
  20182. */
  20183. serialize(): any;
  20184. /**
  20185. * Parses a anisotropy Configuration from a serialized object.
  20186. * @param source - Serialized object.
  20187. * @param scene Defines the scene we are parsing for
  20188. * @param rootUrl Defines the rootUrl to load from
  20189. */
  20190. parse(source: any, scene: Scene, rootUrl: string): void;
  20191. }
  20192. }
  20193. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  20194. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20196. import { Vector2 } from "babylonjs/Maths/math.vector";
  20197. import { Scene } from "babylonjs/scene";
  20198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20199. import { Nullable } from "babylonjs/types";
  20200. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20201. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20202. /**
  20203. * @hidden
  20204. */
  20205. export interface IMaterialAnisotropicDefines {
  20206. ANISOTROPIC: boolean;
  20207. ANISOTROPIC_TEXTURE: boolean;
  20208. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20209. MAINUV1: boolean;
  20210. _areTexturesDirty: boolean;
  20211. _needUVs: boolean;
  20212. }
  20213. /**
  20214. * Define the code related to the anisotropic parameters of the pbr material.
  20215. */
  20216. export class PBRAnisotropicConfiguration {
  20217. private _isEnabled;
  20218. /**
  20219. * Defines if the anisotropy is enabled in the material.
  20220. */
  20221. isEnabled: boolean;
  20222. /**
  20223. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20224. */
  20225. intensity: number;
  20226. /**
  20227. * Defines if the effect is along the tangents, bitangents or in between.
  20228. * By default, the effect is "strectching" the highlights along the tangents.
  20229. */
  20230. direction: Vector2;
  20231. private _texture;
  20232. /**
  20233. * Stores the anisotropy values in a texture.
  20234. * rg is direction (like normal from -1 to 1)
  20235. * b is a intensity
  20236. */
  20237. texture: Nullable<BaseTexture>;
  20238. /** @hidden */
  20239. private _internalMarkAllSubMeshesAsTexturesDirty;
  20240. /** @hidden */
  20241. _markAllSubMeshesAsTexturesDirty(): void;
  20242. /**
  20243. * Instantiate a new istance of anisotropy configuration.
  20244. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20245. */
  20246. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20247. /**
  20248. * Specifies that the submesh is ready to be used.
  20249. * @param defines the list of "defines" to update.
  20250. * @param scene defines the scene the material belongs to.
  20251. * @returns - boolean indicating that the submesh is ready or not.
  20252. */
  20253. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20254. /**
  20255. * Checks to see if a texture is used in the material.
  20256. * @param defines the list of "defines" to update.
  20257. * @param mesh the mesh we are preparing the defines for.
  20258. * @param scene defines the scene the material belongs to.
  20259. */
  20260. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20261. /**
  20262. * Binds the material data.
  20263. * @param uniformBuffer defines the Uniform buffer to fill in.
  20264. * @param scene defines the scene the material belongs to.
  20265. * @param isFrozen defines wether the material is frozen or not.
  20266. */
  20267. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20268. /**
  20269. * Checks to see if a texture is used in the material.
  20270. * @param texture - Base texture to use.
  20271. * @returns - Boolean specifying if a texture is used in the material.
  20272. */
  20273. hasTexture(texture: BaseTexture): boolean;
  20274. /**
  20275. * Returns an array of the actively used textures.
  20276. * @param activeTextures Array of BaseTextures
  20277. */
  20278. getActiveTextures(activeTextures: BaseTexture[]): void;
  20279. /**
  20280. * Returns the animatable textures.
  20281. * @param animatables Array of animatable textures.
  20282. */
  20283. getAnimatables(animatables: IAnimatable[]): void;
  20284. /**
  20285. * Disposes the resources of the material.
  20286. * @param forceDisposeTextures - Forces the disposal of all textures.
  20287. */
  20288. dispose(forceDisposeTextures?: boolean): void;
  20289. /**
  20290. * Get the current class name of the texture useful for serialization or dynamic coding.
  20291. * @returns "PBRAnisotropicConfiguration"
  20292. */
  20293. getClassName(): string;
  20294. /**
  20295. * Add fallbacks to the effect fallbacks list.
  20296. * @param defines defines the Base texture to use.
  20297. * @param fallbacks defines the current fallback list.
  20298. * @param currentRank defines the current fallback rank.
  20299. * @returns the new fallback rank.
  20300. */
  20301. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20302. /**
  20303. * Add the required uniforms to the current list.
  20304. * @param uniforms defines the current uniform list.
  20305. */
  20306. static AddUniforms(uniforms: string[]): void;
  20307. /**
  20308. * Add the required uniforms to the current buffer.
  20309. * @param uniformBuffer defines the current uniform buffer.
  20310. */
  20311. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20312. /**
  20313. * Add the required samplers to the current list.
  20314. * @param samplers defines the current sampler list.
  20315. */
  20316. static AddSamplers(samplers: string[]): void;
  20317. /**
  20318. * Makes a duplicate of the current configuration into another one.
  20319. * @param anisotropicConfiguration define the config where to copy the info
  20320. */
  20321. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20322. /**
  20323. * Serializes this anisotropy configuration.
  20324. * @returns - An object with the serialized config.
  20325. */
  20326. serialize(): any;
  20327. /**
  20328. * Parses a anisotropy Configuration from a serialized object.
  20329. * @param source - Serialized object.
  20330. * @param scene Defines the scene we are parsing for
  20331. * @param rootUrl Defines the rootUrl to load from
  20332. */
  20333. parse(source: any, scene: Scene, rootUrl: string): void;
  20334. }
  20335. }
  20336. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  20337. import { Scene } from "babylonjs/scene";
  20338. /**
  20339. * @hidden
  20340. */
  20341. export interface IMaterialBRDFDefines {
  20342. BRDF_V_HEIGHT_CORRELATED: boolean;
  20343. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20344. SPHERICAL_HARMONICS: boolean;
  20345. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20346. /** @hidden */
  20347. _areMiscDirty: boolean;
  20348. }
  20349. /**
  20350. * Define the code related to the BRDF parameters of the pbr material.
  20351. */
  20352. export class PBRBRDFConfiguration {
  20353. /**
  20354. * Default value used for the energy conservation.
  20355. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20356. */
  20357. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20358. /**
  20359. * Default value used for the Smith Visibility Height Correlated mode.
  20360. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20361. */
  20362. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20363. /**
  20364. * Default value used for the IBL diffuse part.
  20365. * This can help switching back to the polynomials mode globally which is a tiny bit
  20366. * less GPU intensive at the drawback of a lower quality.
  20367. */
  20368. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20369. /**
  20370. * Default value used for activating energy conservation for the specular workflow.
  20371. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20372. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20373. */
  20374. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20375. private _useEnergyConservation;
  20376. /**
  20377. * Defines if the material uses energy conservation.
  20378. */
  20379. useEnergyConservation: boolean;
  20380. private _useSmithVisibilityHeightCorrelated;
  20381. /**
  20382. * LEGACY Mode set to false
  20383. * Defines if the material uses height smith correlated visibility term.
  20384. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20385. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20386. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20387. * Not relying on height correlated will also disable energy conservation.
  20388. */
  20389. useSmithVisibilityHeightCorrelated: boolean;
  20390. private _useSphericalHarmonics;
  20391. /**
  20392. * LEGACY Mode set to false
  20393. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20394. * diffuse part of the IBL.
  20395. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20396. * to the ground truth.
  20397. */
  20398. useSphericalHarmonics: boolean;
  20399. private _useSpecularGlossinessInputEnergyConservation;
  20400. /**
  20401. * Defines if the material uses energy conservation, when the specular workflow is active.
  20402. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20403. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20404. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20405. */
  20406. useSpecularGlossinessInputEnergyConservation: boolean;
  20407. /** @hidden */
  20408. private _internalMarkAllSubMeshesAsMiscDirty;
  20409. /** @hidden */
  20410. _markAllSubMeshesAsMiscDirty(): void;
  20411. /**
  20412. * Instantiate a new istance of clear coat configuration.
  20413. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20414. */
  20415. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20416. /**
  20417. * Checks to see if a texture is used in the material.
  20418. * @param defines the list of "defines" to update.
  20419. */
  20420. prepareDefines(defines: IMaterialBRDFDefines): void;
  20421. /**
  20422. * Get the current class name of the texture useful for serialization or dynamic coding.
  20423. * @returns "PBRClearCoatConfiguration"
  20424. */
  20425. getClassName(): string;
  20426. /**
  20427. * Makes a duplicate of the current configuration into another one.
  20428. * @param brdfConfiguration define the config where to copy the info
  20429. */
  20430. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20431. /**
  20432. * Serializes this BRDF configuration.
  20433. * @returns - An object with the serialized config.
  20434. */
  20435. serialize(): any;
  20436. /**
  20437. * Parses a anisotropy Configuration from a serialized object.
  20438. * @param source - Serialized object.
  20439. * @param scene Defines the scene we are parsing for
  20440. * @param rootUrl Defines the rootUrl to load from
  20441. */
  20442. parse(source: any, scene: Scene, rootUrl: string): void;
  20443. }
  20444. }
  20445. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  20446. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20447. import { Color3 } from "babylonjs/Maths/math.color";
  20448. import { Scene } from "babylonjs/scene";
  20449. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20450. import { Nullable } from "babylonjs/types";
  20451. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20452. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20454. /**
  20455. * @hidden
  20456. */
  20457. export interface IMaterialSheenDefines {
  20458. SHEEN: boolean;
  20459. SHEEN_TEXTURE: boolean;
  20460. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20461. SHEEN_TEXTUREDIRECTUV: number;
  20462. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20463. SHEEN_LINKWITHALBEDO: boolean;
  20464. SHEEN_ROUGHNESS: boolean;
  20465. SHEEN_ALBEDOSCALING: boolean;
  20466. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20467. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20468. /** @hidden */
  20469. _areTexturesDirty: boolean;
  20470. }
  20471. /**
  20472. * Define the code related to the Sheen parameters of the pbr material.
  20473. */
  20474. export class PBRSheenConfiguration {
  20475. private _isEnabled;
  20476. /**
  20477. * Defines if the material uses sheen.
  20478. */
  20479. isEnabled: boolean;
  20480. private _linkSheenWithAlbedo;
  20481. /**
  20482. * Defines if the sheen is linked to the sheen color.
  20483. */
  20484. linkSheenWithAlbedo: boolean;
  20485. /**
  20486. * Defines the sheen intensity.
  20487. */
  20488. intensity: number;
  20489. /**
  20490. * Defines the sheen color.
  20491. */
  20492. color: Color3;
  20493. private _texture;
  20494. /**
  20495. * Stores the sheen tint values in a texture.
  20496. * rgb is tint
  20497. * 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)
  20498. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20499. */
  20500. texture: Nullable<BaseTexture>;
  20501. private _useRoughnessFromMainTexture;
  20502. /**
  20503. * Indicates that the alpha channel of the texture property will be used for roughness.
  20504. * Has no effect if the roughness (and texture!) property is not defined
  20505. */
  20506. useRoughnessFromMainTexture: boolean;
  20507. private _roughness;
  20508. /**
  20509. * Defines the sheen roughness.
  20510. * It is not taken into account if linkSheenWithAlbedo is true.
  20511. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20512. */
  20513. roughness: Nullable<number>;
  20514. private _textureRoughness;
  20515. /**
  20516. * Stores the sheen roughness in a texture.
  20517. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20518. */
  20519. textureRoughness: Nullable<BaseTexture>;
  20520. private _albedoScaling;
  20521. /**
  20522. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20523. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20524. * making it easier to setup and tweak the effect
  20525. */
  20526. albedoScaling: boolean;
  20527. /** @hidden */
  20528. private _internalMarkAllSubMeshesAsTexturesDirty;
  20529. /** @hidden */
  20530. _markAllSubMeshesAsTexturesDirty(): void;
  20531. /**
  20532. * Instantiate a new istance of clear coat configuration.
  20533. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20534. */
  20535. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20536. /**
  20537. * Specifies that the submesh is ready to be used.
  20538. * @param defines the list of "defines" to update.
  20539. * @param scene defines the scene the material belongs to.
  20540. * @returns - boolean indicating that the submesh is ready or not.
  20541. */
  20542. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20543. /**
  20544. * Checks to see if a texture is used in the material.
  20545. * @param defines the list of "defines" to update.
  20546. * @param scene defines the scene the material belongs to.
  20547. */
  20548. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20549. /**
  20550. * Binds the material data.
  20551. * @param uniformBuffer defines the Uniform buffer to fill in.
  20552. * @param scene defines the scene the material belongs to.
  20553. * @param isFrozen defines wether the material is frozen or not.
  20554. * @param subMesh the submesh to bind data for
  20555. */
  20556. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20557. /**
  20558. * Checks to see if a texture is used in the material.
  20559. * @param texture - Base texture to use.
  20560. * @returns - Boolean specifying if a texture is used in the material.
  20561. */
  20562. hasTexture(texture: BaseTexture): boolean;
  20563. /**
  20564. * Returns an array of the actively used textures.
  20565. * @param activeTextures Array of BaseTextures
  20566. */
  20567. getActiveTextures(activeTextures: BaseTexture[]): void;
  20568. /**
  20569. * Returns the animatable textures.
  20570. * @param animatables Array of animatable textures.
  20571. */
  20572. getAnimatables(animatables: IAnimatable[]): void;
  20573. /**
  20574. * Disposes the resources of the material.
  20575. * @param forceDisposeTextures - Forces the disposal of all textures.
  20576. */
  20577. dispose(forceDisposeTextures?: boolean): void;
  20578. /**
  20579. * Get the current class name of the texture useful for serialization or dynamic coding.
  20580. * @returns "PBRSheenConfiguration"
  20581. */
  20582. getClassName(): string;
  20583. /**
  20584. * Add fallbacks to the effect fallbacks list.
  20585. * @param defines defines the Base texture to use.
  20586. * @param fallbacks defines the current fallback list.
  20587. * @param currentRank defines the current fallback rank.
  20588. * @returns the new fallback rank.
  20589. */
  20590. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20591. /**
  20592. * Add the required uniforms to the current list.
  20593. * @param uniforms defines the current uniform list.
  20594. */
  20595. static AddUniforms(uniforms: string[]): void;
  20596. /**
  20597. * Add the required uniforms to the current buffer.
  20598. * @param uniformBuffer defines the current uniform buffer.
  20599. */
  20600. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20601. /**
  20602. * Add the required samplers to the current list.
  20603. * @param samplers defines the current sampler list.
  20604. */
  20605. static AddSamplers(samplers: string[]): void;
  20606. /**
  20607. * Makes a duplicate of the current configuration into another one.
  20608. * @param sheenConfiguration define the config where to copy the info
  20609. */
  20610. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20611. /**
  20612. * Serializes this BRDF configuration.
  20613. * @returns - An object with the serialized config.
  20614. */
  20615. serialize(): any;
  20616. /**
  20617. * Parses a anisotropy Configuration from a serialized object.
  20618. * @param source - Serialized object.
  20619. * @param scene Defines the scene we are parsing for
  20620. * @param rootUrl Defines the rootUrl to load from
  20621. */
  20622. parse(source: any, scene: Scene, rootUrl: string): void;
  20623. }
  20624. }
  20625. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  20626. import { Nullable } from "babylonjs/types";
  20627. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20628. import { Color3 } from "babylonjs/Maths/math.color";
  20629. import { SmartArray } from "babylonjs/Misc/smartArray";
  20630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20631. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20632. import { Effect } from "babylonjs/Materials/effect";
  20633. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20634. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20635. import { Engine } from "babylonjs/Engines/engine";
  20636. import { Scene } from "babylonjs/scene";
  20637. /**
  20638. * @hidden
  20639. */
  20640. export interface IMaterialSubSurfaceDefines {
  20641. SUBSURFACE: boolean;
  20642. SS_REFRACTION: boolean;
  20643. SS_TRANSLUCENCY: boolean;
  20644. SS_SCATTERING: boolean;
  20645. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20646. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20647. SS_REFRACTIONMAP_3D: boolean;
  20648. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20649. SS_LODINREFRACTIONALPHA: boolean;
  20650. SS_GAMMAREFRACTION: boolean;
  20651. SS_RGBDREFRACTION: boolean;
  20652. SS_LINEARSPECULARREFRACTION: boolean;
  20653. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20654. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20655. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20656. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20657. /** @hidden */
  20658. _areTexturesDirty: boolean;
  20659. }
  20660. /**
  20661. * Define the code related to the sub surface parameters of the pbr material.
  20662. */
  20663. export class PBRSubSurfaceConfiguration {
  20664. private _isRefractionEnabled;
  20665. /**
  20666. * Defines if the refraction is enabled in the material.
  20667. */
  20668. isRefractionEnabled: boolean;
  20669. private _isTranslucencyEnabled;
  20670. /**
  20671. * Defines if the translucency is enabled in the material.
  20672. */
  20673. isTranslucencyEnabled: boolean;
  20674. private _isScatteringEnabled;
  20675. /**
  20676. * Defines if the sub surface scattering is enabled in the material.
  20677. */
  20678. isScatteringEnabled: boolean;
  20679. private _scatteringDiffusionProfileIndex;
  20680. /**
  20681. * Diffusion profile for subsurface scattering.
  20682. * Useful for better scattering in the skins or foliages.
  20683. */
  20684. get scatteringDiffusionProfile(): Nullable<Color3>;
  20685. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20686. /**
  20687. * Defines the refraction intensity of the material.
  20688. * The refraction when enabled replaces the Diffuse part of the material.
  20689. * The intensity helps transitionning between diffuse and refraction.
  20690. */
  20691. refractionIntensity: number;
  20692. /**
  20693. * Defines the translucency intensity of the material.
  20694. * When translucency has been enabled, this defines how much of the "translucency"
  20695. * is addded to the diffuse part of the material.
  20696. */
  20697. translucencyIntensity: number;
  20698. /**
  20699. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20700. */
  20701. useAlbedoToTintRefraction: boolean;
  20702. private _thicknessTexture;
  20703. /**
  20704. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20705. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20706. * 0 would mean minimumThickness
  20707. * 1 would mean maximumThickness
  20708. * The other channels might be use as a mask to vary the different effects intensity.
  20709. */
  20710. thicknessTexture: Nullable<BaseTexture>;
  20711. private _refractionTexture;
  20712. /**
  20713. * Defines the texture to use for refraction.
  20714. */
  20715. refractionTexture: Nullable<BaseTexture>;
  20716. private _indexOfRefraction;
  20717. /**
  20718. * Index of refraction of the material base layer.
  20719. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20720. *
  20721. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20722. *
  20723. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20724. */
  20725. indexOfRefraction: number;
  20726. private _volumeIndexOfRefraction;
  20727. /**
  20728. * Index of refraction of the material's volume.
  20729. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20730. *
  20731. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20732. * the volume will use the same IOR as the surface.
  20733. */
  20734. get volumeIndexOfRefraction(): number;
  20735. set volumeIndexOfRefraction(value: number);
  20736. private _invertRefractionY;
  20737. /**
  20738. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20739. */
  20740. invertRefractionY: boolean;
  20741. private _linkRefractionWithTransparency;
  20742. /**
  20743. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20744. * Materials half opaque for instance using refraction could benefit from this control.
  20745. */
  20746. linkRefractionWithTransparency: boolean;
  20747. /**
  20748. * Defines the minimum thickness stored in the thickness map.
  20749. * If no thickness map is defined, this value will be used to simulate thickness.
  20750. */
  20751. minimumThickness: number;
  20752. /**
  20753. * Defines the maximum thickness stored in the thickness map.
  20754. */
  20755. maximumThickness: number;
  20756. /**
  20757. * Defines the volume tint of the material.
  20758. * This is used for both translucency and scattering.
  20759. */
  20760. tintColor: Color3;
  20761. /**
  20762. * Defines the distance at which the tint color should be found in the media.
  20763. * This is used for refraction only.
  20764. */
  20765. tintColorAtDistance: number;
  20766. /**
  20767. * Defines how far each channel transmit through the media.
  20768. * It is defined as a color to simplify it selection.
  20769. */
  20770. diffusionDistance: Color3;
  20771. private _useMaskFromThicknessTexture;
  20772. /**
  20773. * Stores the intensity of the different subsurface effects in the thickness texture.
  20774. * * the green channel is the translucency intensity.
  20775. * * the blue channel is the scattering intensity.
  20776. * * the alpha channel is the refraction intensity.
  20777. */
  20778. useMaskFromThicknessTexture: boolean;
  20779. private _scene;
  20780. private _useMaskFromThicknessTextureGltf;
  20781. /**
  20782. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20783. * matches the channel-packing that is used by glTF.
  20784. * * the red channel is the transmission/translucency intensity.
  20785. * * the green channel is the thickness.
  20786. */
  20787. useMaskFromThicknessTextureGltf: boolean;
  20788. /** @hidden */
  20789. private _internalMarkAllSubMeshesAsTexturesDirty;
  20790. private _internalMarkScenePrePassDirty;
  20791. /** @hidden */
  20792. _markAllSubMeshesAsTexturesDirty(): void;
  20793. /** @hidden */
  20794. _markScenePrePassDirty(): void;
  20795. /**
  20796. * Instantiate a new istance of sub surface configuration.
  20797. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20798. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20799. * @param scene The scene
  20800. */
  20801. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20802. /**
  20803. * Gets wehter the submesh is ready to be used or not.
  20804. * @param defines the list of "defines" to update.
  20805. * @param scene defines the scene the material belongs to.
  20806. * @returns - boolean indicating that the submesh is ready or not.
  20807. */
  20808. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20809. /**
  20810. * Checks to see if a texture is used in the material.
  20811. * @param defines the list of "defines" to update.
  20812. * @param scene defines the scene to the material belongs to.
  20813. */
  20814. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20815. /**
  20816. * Binds the material data.
  20817. * @param uniformBuffer defines the Uniform buffer to fill in.
  20818. * @param scene defines the scene the material belongs to.
  20819. * @param engine defines the engine the material belongs to.
  20820. * @param isFrozen defines whether the material is frozen or not.
  20821. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20822. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20823. */
  20824. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20825. /**
  20826. * Unbinds the material from the mesh.
  20827. * @param activeEffect defines the effect that should be unbound from.
  20828. * @returns true if unbound, otherwise false
  20829. */
  20830. unbind(activeEffect: Effect): boolean;
  20831. /**
  20832. * Returns the texture used for refraction or null if none is used.
  20833. * @param scene defines the scene the material belongs to.
  20834. * @returns - Refraction texture if present. If no refraction texture and refraction
  20835. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20836. */
  20837. private _getRefractionTexture;
  20838. /**
  20839. * Returns true if alpha blending should be disabled.
  20840. */
  20841. get disableAlphaBlending(): boolean;
  20842. /**
  20843. * Fills the list of render target textures.
  20844. * @param renderTargets the list of render targets to update
  20845. */
  20846. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20847. /**
  20848. * Checks to see if a texture is used in the material.
  20849. * @param texture - Base texture to use.
  20850. * @returns - Boolean specifying if a texture is used in the material.
  20851. */
  20852. hasTexture(texture: BaseTexture): boolean;
  20853. /**
  20854. * Gets a boolean indicating that current material needs to register RTT
  20855. * @returns true if this uses a render target otherwise false.
  20856. */
  20857. hasRenderTargetTextures(): boolean;
  20858. /**
  20859. * Returns an array of the actively used textures.
  20860. * @param activeTextures Array of BaseTextures
  20861. */
  20862. getActiveTextures(activeTextures: BaseTexture[]): void;
  20863. /**
  20864. * Returns the animatable textures.
  20865. * @param animatables Array of animatable textures.
  20866. */
  20867. getAnimatables(animatables: IAnimatable[]): void;
  20868. /**
  20869. * Disposes the resources of the material.
  20870. * @param forceDisposeTextures - Forces the disposal of all textures.
  20871. */
  20872. dispose(forceDisposeTextures?: boolean): void;
  20873. /**
  20874. * Get the current class name of the texture useful for serialization or dynamic coding.
  20875. * @returns "PBRSubSurfaceConfiguration"
  20876. */
  20877. getClassName(): string;
  20878. /**
  20879. * Add fallbacks to the effect fallbacks list.
  20880. * @param defines defines the Base texture to use.
  20881. * @param fallbacks defines the current fallback list.
  20882. * @param currentRank defines the current fallback rank.
  20883. * @returns the new fallback rank.
  20884. */
  20885. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20886. /**
  20887. * Add the required uniforms to the current list.
  20888. * @param uniforms defines the current uniform list.
  20889. */
  20890. static AddUniforms(uniforms: string[]): void;
  20891. /**
  20892. * Add the required samplers to the current list.
  20893. * @param samplers defines the current sampler list.
  20894. */
  20895. static AddSamplers(samplers: string[]): void;
  20896. /**
  20897. * Add the required uniforms to the current buffer.
  20898. * @param uniformBuffer defines the current uniform buffer.
  20899. */
  20900. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20901. /**
  20902. * Makes a duplicate of the current configuration into another one.
  20903. * @param configuration define the config where to copy the info
  20904. */
  20905. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20906. /**
  20907. * Serializes this Sub Surface configuration.
  20908. * @returns - An object with the serialized config.
  20909. */
  20910. serialize(): any;
  20911. /**
  20912. * Parses a anisotropy Configuration from a serialized object.
  20913. * @param source - Serialized object.
  20914. * @param scene Defines the scene we are parsing for
  20915. * @param rootUrl Defines the rootUrl to load from
  20916. */
  20917. parse(source: any, scene: Scene, rootUrl: string): void;
  20918. }
  20919. }
  20920. declare module "babylonjs/Maths/sphericalPolynomial" {
  20921. import { Vector3 } from "babylonjs/Maths/math.vector";
  20922. import { Color3 } from "babylonjs/Maths/math.color";
  20923. /**
  20924. * Class representing spherical harmonics coefficients to the 3rd degree
  20925. */
  20926. export class SphericalHarmonics {
  20927. /**
  20928. * Defines whether or not the harmonics have been prescaled for rendering.
  20929. */
  20930. preScaled: boolean;
  20931. /**
  20932. * The l0,0 coefficients of the spherical harmonics
  20933. */
  20934. l00: Vector3;
  20935. /**
  20936. * The l1,-1 coefficients of the spherical harmonics
  20937. */
  20938. l1_1: Vector3;
  20939. /**
  20940. * The l1,0 coefficients of the spherical harmonics
  20941. */
  20942. l10: Vector3;
  20943. /**
  20944. * The l1,1 coefficients of the spherical harmonics
  20945. */
  20946. l11: Vector3;
  20947. /**
  20948. * The l2,-2 coefficients of the spherical harmonics
  20949. */
  20950. l2_2: Vector3;
  20951. /**
  20952. * The l2,-1 coefficients of the spherical harmonics
  20953. */
  20954. l2_1: Vector3;
  20955. /**
  20956. * The l2,0 coefficients of the spherical harmonics
  20957. */
  20958. l20: Vector3;
  20959. /**
  20960. * The l2,1 coefficients of the spherical harmonics
  20961. */
  20962. l21: Vector3;
  20963. /**
  20964. * The l2,2 coefficients of the spherical harmonics
  20965. */
  20966. l22: Vector3;
  20967. /**
  20968. * Adds a light to the spherical harmonics
  20969. * @param direction the direction of the light
  20970. * @param color the color of the light
  20971. * @param deltaSolidAngle the delta solid angle of the light
  20972. */
  20973. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20974. /**
  20975. * Scales the spherical harmonics by the given amount
  20976. * @param scale the amount to scale
  20977. */
  20978. scaleInPlace(scale: number): void;
  20979. /**
  20980. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20981. *
  20982. * ```
  20983. * E_lm = A_l * L_lm
  20984. * ```
  20985. *
  20986. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20987. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20988. * the scaling factors are given in equation 9.
  20989. */
  20990. convertIncidentRadianceToIrradiance(): void;
  20991. /**
  20992. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20993. *
  20994. * ```
  20995. * L = (1/pi) * E * rho
  20996. * ```
  20997. *
  20998. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20999. */
  21000. convertIrradianceToLambertianRadiance(): void;
  21001. /**
  21002. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21003. * required operations at run time.
  21004. *
  21005. * This is simply done by scaling back the SH with Ylm constants parameter.
  21006. * The trigonometric part being applied by the shader at run time.
  21007. */
  21008. preScaleForRendering(): void;
  21009. /**
  21010. * Constructs a spherical harmonics from an array.
  21011. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21012. * @returns the spherical harmonics
  21013. */
  21014. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21015. /**
  21016. * Gets the spherical harmonics from polynomial
  21017. * @param polynomial the spherical polynomial
  21018. * @returns the spherical harmonics
  21019. */
  21020. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21021. }
  21022. /**
  21023. * Class representing spherical polynomial coefficients to the 3rd degree
  21024. */
  21025. export class SphericalPolynomial {
  21026. private _harmonics;
  21027. /**
  21028. * The spherical harmonics used to create the polynomials.
  21029. */
  21030. get preScaledHarmonics(): SphericalHarmonics;
  21031. /**
  21032. * The x coefficients of the spherical polynomial
  21033. */
  21034. x: Vector3;
  21035. /**
  21036. * The y coefficients of the spherical polynomial
  21037. */
  21038. y: Vector3;
  21039. /**
  21040. * The z coefficients of the spherical polynomial
  21041. */
  21042. z: Vector3;
  21043. /**
  21044. * The xx coefficients of the spherical polynomial
  21045. */
  21046. xx: Vector3;
  21047. /**
  21048. * The yy coefficients of the spherical polynomial
  21049. */
  21050. yy: Vector3;
  21051. /**
  21052. * The zz coefficients of the spherical polynomial
  21053. */
  21054. zz: Vector3;
  21055. /**
  21056. * The xy coefficients of the spherical polynomial
  21057. */
  21058. xy: Vector3;
  21059. /**
  21060. * The yz coefficients of the spherical polynomial
  21061. */
  21062. yz: Vector3;
  21063. /**
  21064. * The zx coefficients of the spherical polynomial
  21065. */
  21066. zx: Vector3;
  21067. /**
  21068. * Adds an ambient color to the spherical polynomial
  21069. * @param color the color to add
  21070. */
  21071. addAmbient(color: Color3): void;
  21072. /**
  21073. * Scales the spherical polynomial by the given amount
  21074. * @param scale the amount to scale
  21075. */
  21076. scaleInPlace(scale: number): void;
  21077. /**
  21078. * Gets the spherical polynomial from harmonics
  21079. * @param harmonics the spherical harmonics
  21080. * @returns the spherical polynomial
  21081. */
  21082. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21083. /**
  21084. * Constructs a spherical polynomial from an array.
  21085. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21086. * @returns the spherical polynomial
  21087. */
  21088. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21089. }
  21090. }
  21091. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  21092. import { Nullable } from "babylonjs/types";
  21093. /**
  21094. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21095. */
  21096. export interface CubeMapInfo {
  21097. /**
  21098. * The pixel array for the front face.
  21099. * This is stored in format, left to right, up to down format.
  21100. */
  21101. front: Nullable<ArrayBufferView>;
  21102. /**
  21103. * The pixel array for the back face.
  21104. * This is stored in format, left to right, up to down format.
  21105. */
  21106. back: Nullable<ArrayBufferView>;
  21107. /**
  21108. * The pixel array for the left face.
  21109. * This is stored in format, left to right, up to down format.
  21110. */
  21111. left: Nullable<ArrayBufferView>;
  21112. /**
  21113. * The pixel array for the right face.
  21114. * This is stored in format, left to right, up to down format.
  21115. */
  21116. right: Nullable<ArrayBufferView>;
  21117. /**
  21118. * The pixel array for the up face.
  21119. * This is stored in format, left to right, up to down format.
  21120. */
  21121. up: Nullable<ArrayBufferView>;
  21122. /**
  21123. * The pixel array for the down face.
  21124. * This is stored in format, left to right, up to down format.
  21125. */
  21126. down: Nullable<ArrayBufferView>;
  21127. /**
  21128. * The size of the cubemap stored.
  21129. *
  21130. * Each faces will be size * size pixels.
  21131. */
  21132. size: number;
  21133. /**
  21134. * The format of the texture.
  21135. *
  21136. * RGBA, RGB.
  21137. */
  21138. format: number;
  21139. /**
  21140. * The type of the texture data.
  21141. *
  21142. * UNSIGNED_INT, FLOAT.
  21143. */
  21144. type: number;
  21145. /**
  21146. * Specifies whether the texture is in gamma space.
  21147. */
  21148. gammaSpace: boolean;
  21149. }
  21150. /**
  21151. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21152. */
  21153. export class PanoramaToCubeMapTools {
  21154. private static FACE_LEFT;
  21155. private static FACE_RIGHT;
  21156. private static FACE_FRONT;
  21157. private static FACE_BACK;
  21158. private static FACE_DOWN;
  21159. private static FACE_UP;
  21160. /**
  21161. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21162. *
  21163. * @param float32Array The source data.
  21164. * @param inputWidth The width of the input panorama.
  21165. * @param inputHeight The height of the input panorama.
  21166. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21167. * @return The cubemap data
  21168. */
  21169. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21170. private static CreateCubemapTexture;
  21171. private static CalcProjectionSpherical;
  21172. }
  21173. }
  21174. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  21175. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21176. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21177. import { Nullable } from "babylonjs/types";
  21178. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  21179. /**
  21180. * Helper class dealing with the extraction of spherical polynomial dataArray
  21181. * from a cube map.
  21182. */
  21183. export class CubeMapToSphericalPolynomialTools {
  21184. private static FileFaces;
  21185. /**
  21186. * Converts a texture to the according Spherical Polynomial data.
  21187. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21188. *
  21189. * @param texture The texture to extract the information from.
  21190. * @return The Spherical Polynomial data.
  21191. */
  21192. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  21193. /**
  21194. * Converts a cubemap to the according Spherical Polynomial data.
  21195. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21196. *
  21197. * @param cubeInfo The Cube map to extract the information from.
  21198. * @return The Spherical Polynomial data.
  21199. */
  21200. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21201. }
  21202. }
  21203. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  21204. import { Nullable } from "babylonjs/types";
  21205. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21206. module "babylonjs/Materials/Textures/baseTexture" {
  21207. interface BaseTexture {
  21208. /**
  21209. * Get the polynomial representation of the texture data.
  21210. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21211. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21212. */
  21213. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21214. }
  21215. }
  21216. }
  21217. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  21218. /** @hidden */
  21219. export var pbrFragmentDeclaration: {
  21220. name: string;
  21221. shader: string;
  21222. };
  21223. }
  21224. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  21225. /** @hidden */
  21226. export var pbrUboDeclaration: {
  21227. name: string;
  21228. shader: string;
  21229. };
  21230. }
  21231. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  21232. /** @hidden */
  21233. export var pbrFragmentExtraDeclaration: {
  21234. name: string;
  21235. shader: string;
  21236. };
  21237. }
  21238. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  21239. /** @hidden */
  21240. export var pbrFragmentSamplersDeclaration: {
  21241. name: string;
  21242. shader: string;
  21243. };
  21244. }
  21245. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  21246. /** @hidden */
  21247. export var subSurfaceScatteringFunctions: {
  21248. name: string;
  21249. shader: string;
  21250. };
  21251. }
  21252. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  21253. /** @hidden */
  21254. export var importanceSampling: {
  21255. name: string;
  21256. shader: string;
  21257. };
  21258. }
  21259. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  21260. /** @hidden */
  21261. export var pbrHelperFunctions: {
  21262. name: string;
  21263. shader: string;
  21264. };
  21265. }
  21266. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  21267. /** @hidden */
  21268. export var harmonicsFunctions: {
  21269. name: string;
  21270. shader: string;
  21271. };
  21272. }
  21273. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  21274. /** @hidden */
  21275. export var pbrDirectLightingSetupFunctions: {
  21276. name: string;
  21277. shader: string;
  21278. };
  21279. }
  21280. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  21281. /** @hidden */
  21282. export var pbrDirectLightingFalloffFunctions: {
  21283. name: string;
  21284. shader: string;
  21285. };
  21286. }
  21287. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  21288. /** @hidden */
  21289. export var pbrBRDFFunctions: {
  21290. name: string;
  21291. shader: string;
  21292. };
  21293. }
  21294. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  21295. /** @hidden */
  21296. export var hdrFilteringFunctions: {
  21297. name: string;
  21298. shader: string;
  21299. };
  21300. }
  21301. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  21302. /** @hidden */
  21303. export var pbrDirectLightingFunctions: {
  21304. name: string;
  21305. shader: string;
  21306. };
  21307. }
  21308. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  21309. /** @hidden */
  21310. export var pbrIBLFunctions: {
  21311. name: string;
  21312. shader: string;
  21313. };
  21314. }
  21315. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  21316. /** @hidden */
  21317. export var pbrBlockAlbedoOpacity: {
  21318. name: string;
  21319. shader: string;
  21320. };
  21321. }
  21322. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  21323. /** @hidden */
  21324. export var pbrBlockReflectivity: {
  21325. name: string;
  21326. shader: string;
  21327. };
  21328. }
  21329. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  21330. /** @hidden */
  21331. export var pbrBlockAmbientOcclusion: {
  21332. name: string;
  21333. shader: string;
  21334. };
  21335. }
  21336. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  21337. /** @hidden */
  21338. export var pbrBlockAlphaFresnel: {
  21339. name: string;
  21340. shader: string;
  21341. };
  21342. }
  21343. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  21344. /** @hidden */
  21345. export var pbrBlockAnisotropic: {
  21346. name: string;
  21347. shader: string;
  21348. };
  21349. }
  21350. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  21351. /** @hidden */
  21352. export var pbrBlockReflection: {
  21353. name: string;
  21354. shader: string;
  21355. };
  21356. }
  21357. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  21358. /** @hidden */
  21359. export var pbrBlockSheen: {
  21360. name: string;
  21361. shader: string;
  21362. };
  21363. }
  21364. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  21365. /** @hidden */
  21366. export var pbrBlockClearcoat: {
  21367. name: string;
  21368. shader: string;
  21369. };
  21370. }
  21371. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  21372. /** @hidden */
  21373. export var pbrBlockSubSurface: {
  21374. name: string;
  21375. shader: string;
  21376. };
  21377. }
  21378. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  21379. /** @hidden */
  21380. export var pbrBlockNormalGeometric: {
  21381. name: string;
  21382. shader: string;
  21383. };
  21384. }
  21385. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  21386. /** @hidden */
  21387. export var pbrBlockNormalFinal: {
  21388. name: string;
  21389. shader: string;
  21390. };
  21391. }
  21392. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  21393. /** @hidden */
  21394. export var pbrBlockLightmapInit: {
  21395. name: string;
  21396. shader: string;
  21397. };
  21398. }
  21399. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  21400. /** @hidden */
  21401. export var pbrBlockGeometryInfo: {
  21402. name: string;
  21403. shader: string;
  21404. };
  21405. }
  21406. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  21407. /** @hidden */
  21408. export var pbrBlockReflectance0: {
  21409. name: string;
  21410. shader: string;
  21411. };
  21412. }
  21413. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  21414. /** @hidden */
  21415. export var pbrBlockReflectance: {
  21416. name: string;
  21417. shader: string;
  21418. };
  21419. }
  21420. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  21421. /** @hidden */
  21422. export var pbrBlockDirectLighting: {
  21423. name: string;
  21424. shader: string;
  21425. };
  21426. }
  21427. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  21428. /** @hidden */
  21429. export var pbrBlockFinalLitComponents: {
  21430. name: string;
  21431. shader: string;
  21432. };
  21433. }
  21434. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  21435. /** @hidden */
  21436. export var pbrBlockFinalUnlitComponents: {
  21437. name: string;
  21438. shader: string;
  21439. };
  21440. }
  21441. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  21442. /** @hidden */
  21443. export var pbrBlockFinalColorComposition: {
  21444. name: string;
  21445. shader: string;
  21446. };
  21447. }
  21448. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  21449. /** @hidden */
  21450. export var pbrBlockImageProcessing: {
  21451. name: string;
  21452. shader: string;
  21453. };
  21454. }
  21455. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  21456. /** @hidden */
  21457. export var pbrDebug: {
  21458. name: string;
  21459. shader: string;
  21460. };
  21461. }
  21462. declare module "babylonjs/Shaders/pbr.fragment" {
  21463. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  21464. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  21465. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21466. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  21467. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21468. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21469. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  21470. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  21471. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  21472. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21473. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  21474. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21475. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  21476. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  21477. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  21478. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  21479. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  21480. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21481. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  21482. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  21483. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  21484. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  21485. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  21486. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  21487. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  21488. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  21489. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21490. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  21491. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  21492. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  21493. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  21494. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  21495. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  21496. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  21497. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  21498. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  21499. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  21500. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  21501. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  21502. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  21503. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  21504. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  21505. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  21506. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  21507. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  21508. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  21509. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  21510. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  21511. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  21512. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  21513. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  21514. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  21515. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  21516. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  21517. /** @hidden */
  21518. export var pbrPixelShader: {
  21519. name: string;
  21520. shader: string;
  21521. };
  21522. }
  21523. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  21524. /** @hidden */
  21525. export var pbrVertexDeclaration: {
  21526. name: string;
  21527. shader: string;
  21528. };
  21529. }
  21530. declare module "babylonjs/Shaders/pbr.vertex" {
  21531. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  21532. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21533. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21534. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  21535. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  21536. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  21537. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21538. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  21539. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  21540. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  21541. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21542. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21543. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  21544. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  21545. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  21547. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  21548. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  21549. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  21550. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  21551. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  21552. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  21553. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  21554. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  21555. /** @hidden */
  21556. export var pbrVertexShader: {
  21557. name: string;
  21558. shader: string;
  21559. };
  21560. }
  21561. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  21562. import { Nullable } from "babylonjs/types";
  21563. import { Scene } from "babylonjs/scene";
  21564. import { Matrix } from "babylonjs/Maths/math.vector";
  21565. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21567. import { Mesh } from "babylonjs/Meshes/mesh";
  21568. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  21569. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  21570. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  21571. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  21572. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  21573. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  21574. import { Color3 } from "babylonjs/Maths/math.color";
  21575. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  21576. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  21577. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21578. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  21579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21580. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21581. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  21582. import "babylonjs/Shaders/pbr.fragment";
  21583. import "babylonjs/Shaders/pbr.vertex";
  21584. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  21585. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  21586. /**
  21587. * Manages the defines for the PBR Material.
  21588. * @hidden
  21589. */
  21590. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21591. PBR: boolean;
  21592. NUM_SAMPLES: string;
  21593. REALTIME_FILTERING: boolean;
  21594. MAINUV1: boolean;
  21595. MAINUV2: boolean;
  21596. UV1: boolean;
  21597. UV2: boolean;
  21598. ALBEDO: boolean;
  21599. GAMMAALBEDO: boolean;
  21600. ALBEDODIRECTUV: number;
  21601. VERTEXCOLOR: boolean;
  21602. DETAIL: boolean;
  21603. DETAILDIRECTUV: number;
  21604. DETAIL_NORMALBLENDMETHOD: number;
  21605. AMBIENT: boolean;
  21606. AMBIENTDIRECTUV: number;
  21607. AMBIENTINGRAYSCALE: boolean;
  21608. OPACITY: boolean;
  21609. VERTEXALPHA: boolean;
  21610. OPACITYDIRECTUV: number;
  21611. OPACITYRGB: boolean;
  21612. ALPHATEST: boolean;
  21613. DEPTHPREPASS: boolean;
  21614. ALPHABLEND: boolean;
  21615. ALPHAFROMALBEDO: boolean;
  21616. ALPHATESTVALUE: string;
  21617. SPECULAROVERALPHA: boolean;
  21618. RADIANCEOVERALPHA: boolean;
  21619. ALPHAFRESNEL: boolean;
  21620. LINEARALPHAFRESNEL: boolean;
  21621. PREMULTIPLYALPHA: boolean;
  21622. EMISSIVE: boolean;
  21623. EMISSIVEDIRECTUV: number;
  21624. REFLECTIVITY: boolean;
  21625. REFLECTIVITYDIRECTUV: number;
  21626. SPECULARTERM: boolean;
  21627. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21628. MICROSURFACEAUTOMATIC: boolean;
  21629. LODBASEDMICROSFURACE: boolean;
  21630. MICROSURFACEMAP: boolean;
  21631. MICROSURFACEMAPDIRECTUV: number;
  21632. METALLICWORKFLOW: boolean;
  21633. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21634. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21635. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21636. AOSTOREINMETALMAPRED: boolean;
  21637. METALLIC_REFLECTANCE: boolean;
  21638. METALLIC_REFLECTANCEDIRECTUV: number;
  21639. ENVIRONMENTBRDF: boolean;
  21640. ENVIRONMENTBRDF_RGBD: boolean;
  21641. NORMAL: boolean;
  21642. TANGENT: boolean;
  21643. BUMP: boolean;
  21644. BUMPDIRECTUV: number;
  21645. OBJECTSPACE_NORMALMAP: boolean;
  21646. PARALLAX: boolean;
  21647. PARALLAXOCCLUSION: boolean;
  21648. NORMALXYSCALE: boolean;
  21649. LIGHTMAP: boolean;
  21650. LIGHTMAPDIRECTUV: number;
  21651. USELIGHTMAPASSHADOWMAP: boolean;
  21652. GAMMALIGHTMAP: boolean;
  21653. RGBDLIGHTMAP: boolean;
  21654. REFLECTION: boolean;
  21655. REFLECTIONMAP_3D: boolean;
  21656. REFLECTIONMAP_SPHERICAL: boolean;
  21657. REFLECTIONMAP_PLANAR: boolean;
  21658. REFLECTIONMAP_CUBIC: boolean;
  21659. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21660. REFLECTIONMAP_PROJECTION: boolean;
  21661. REFLECTIONMAP_SKYBOX: boolean;
  21662. REFLECTIONMAP_EXPLICIT: boolean;
  21663. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21664. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21665. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21666. INVERTCUBICMAP: boolean;
  21667. USESPHERICALFROMREFLECTIONMAP: boolean;
  21668. USEIRRADIANCEMAP: boolean;
  21669. SPHERICAL_HARMONICS: boolean;
  21670. USESPHERICALINVERTEX: boolean;
  21671. REFLECTIONMAP_OPPOSITEZ: boolean;
  21672. LODINREFLECTIONALPHA: boolean;
  21673. GAMMAREFLECTION: boolean;
  21674. RGBDREFLECTION: boolean;
  21675. LINEARSPECULARREFLECTION: boolean;
  21676. RADIANCEOCCLUSION: boolean;
  21677. HORIZONOCCLUSION: boolean;
  21678. INSTANCES: boolean;
  21679. THIN_INSTANCES: boolean;
  21680. PREPASS: boolean;
  21681. PREPASS_IRRADIANCE: boolean;
  21682. PREPASS_IRRADIANCE_INDEX: number;
  21683. PREPASS_ALBEDO: boolean;
  21684. PREPASS_ALBEDO_INDEX: number;
  21685. PREPASS_DEPTHNORMAL: boolean;
  21686. PREPASS_DEPTHNORMAL_INDEX: number;
  21687. PREPASS_POSITION: boolean;
  21688. PREPASS_POSITION_INDEX: number;
  21689. PREPASS_VELOCITY: boolean;
  21690. PREPASS_VELOCITY_INDEX: number;
  21691. PREPASS_REFLECTIVITY: boolean;
  21692. PREPASS_REFLECTIVITY_INDEX: number;
  21693. SCENE_MRT_COUNT: number;
  21694. NUM_BONE_INFLUENCERS: number;
  21695. BonesPerMesh: number;
  21696. BONETEXTURE: boolean;
  21697. BONES_VELOCITY_ENABLED: boolean;
  21698. NONUNIFORMSCALING: boolean;
  21699. MORPHTARGETS: boolean;
  21700. MORPHTARGETS_NORMAL: boolean;
  21701. MORPHTARGETS_TANGENT: boolean;
  21702. MORPHTARGETS_UV: boolean;
  21703. NUM_MORPH_INFLUENCERS: number;
  21704. IMAGEPROCESSING: boolean;
  21705. VIGNETTE: boolean;
  21706. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21707. VIGNETTEBLENDMODEOPAQUE: boolean;
  21708. TONEMAPPING: boolean;
  21709. TONEMAPPING_ACES: boolean;
  21710. CONTRAST: boolean;
  21711. COLORCURVES: boolean;
  21712. COLORGRADING: boolean;
  21713. COLORGRADING3D: boolean;
  21714. SAMPLER3DGREENDEPTH: boolean;
  21715. SAMPLER3DBGRMAP: boolean;
  21716. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21717. EXPOSURE: boolean;
  21718. MULTIVIEW: boolean;
  21719. USEPHYSICALLIGHTFALLOFF: boolean;
  21720. USEGLTFLIGHTFALLOFF: boolean;
  21721. TWOSIDEDLIGHTING: boolean;
  21722. SHADOWFLOAT: boolean;
  21723. CLIPPLANE: boolean;
  21724. CLIPPLANE2: boolean;
  21725. CLIPPLANE3: boolean;
  21726. CLIPPLANE4: boolean;
  21727. CLIPPLANE5: boolean;
  21728. CLIPPLANE6: boolean;
  21729. POINTSIZE: boolean;
  21730. FOG: boolean;
  21731. LOGARITHMICDEPTH: boolean;
  21732. FORCENORMALFORWARD: boolean;
  21733. SPECULARAA: boolean;
  21734. CLEARCOAT: boolean;
  21735. CLEARCOAT_DEFAULTIOR: boolean;
  21736. CLEARCOAT_TEXTURE: boolean;
  21737. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21738. CLEARCOAT_TEXTUREDIRECTUV: number;
  21739. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21740. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21741. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21742. CLEARCOAT_BUMP: boolean;
  21743. CLEARCOAT_BUMPDIRECTUV: number;
  21744. CLEARCOAT_REMAP_F0: boolean;
  21745. CLEARCOAT_TINT: boolean;
  21746. CLEARCOAT_TINT_TEXTURE: boolean;
  21747. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21748. ANISOTROPIC: boolean;
  21749. ANISOTROPIC_TEXTURE: boolean;
  21750. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21751. BRDF_V_HEIGHT_CORRELATED: boolean;
  21752. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21753. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21754. SHEEN: boolean;
  21755. SHEEN_TEXTURE: boolean;
  21756. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21757. SHEEN_TEXTUREDIRECTUV: number;
  21758. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21759. SHEEN_LINKWITHALBEDO: boolean;
  21760. SHEEN_ROUGHNESS: boolean;
  21761. SHEEN_ALBEDOSCALING: boolean;
  21762. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21763. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21764. SUBSURFACE: boolean;
  21765. SS_REFRACTION: boolean;
  21766. SS_TRANSLUCENCY: boolean;
  21767. SS_SCATTERING: boolean;
  21768. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21769. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21770. SS_REFRACTIONMAP_3D: boolean;
  21771. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21772. SS_LODINREFRACTIONALPHA: boolean;
  21773. SS_GAMMAREFRACTION: boolean;
  21774. SS_RGBDREFRACTION: boolean;
  21775. SS_LINEARSPECULARREFRACTION: boolean;
  21776. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21777. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21778. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21779. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21780. UNLIT: boolean;
  21781. DEBUGMODE: number;
  21782. /**
  21783. * Initializes the PBR Material defines.
  21784. */
  21785. constructor();
  21786. /**
  21787. * Resets the PBR Material defines.
  21788. */
  21789. reset(): void;
  21790. }
  21791. /**
  21792. * The Physically based material base class of BJS.
  21793. *
  21794. * This offers the main features of a standard PBR material.
  21795. * For more information, please refer to the documentation :
  21796. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21797. */
  21798. export abstract class PBRBaseMaterial extends PushMaterial {
  21799. /**
  21800. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21801. */
  21802. static readonly PBRMATERIAL_OPAQUE: number;
  21803. /**
  21804. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21805. */
  21806. static readonly PBRMATERIAL_ALPHATEST: number;
  21807. /**
  21808. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21809. */
  21810. static readonly PBRMATERIAL_ALPHABLEND: number;
  21811. /**
  21812. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21813. * They are also discarded below the alpha cutoff threshold to improve performances.
  21814. */
  21815. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21816. /**
  21817. * Defines the default value of how much AO map is occluding the analytical lights
  21818. * (point spot...).
  21819. */
  21820. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21821. /**
  21822. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21823. */
  21824. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21825. /**
  21826. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21827. * to enhance interoperability with other engines.
  21828. */
  21829. static readonly LIGHTFALLOFF_GLTF: number;
  21830. /**
  21831. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21832. * to enhance interoperability with other materials.
  21833. */
  21834. static readonly LIGHTFALLOFF_STANDARD: number;
  21835. /**
  21836. * Intensity of the direct lights e.g. the four lights available in your scene.
  21837. * This impacts both the direct diffuse and specular highlights.
  21838. */
  21839. protected _directIntensity: number;
  21840. /**
  21841. * Intensity of the emissive part of the material.
  21842. * This helps controlling the emissive effect without modifying the emissive color.
  21843. */
  21844. protected _emissiveIntensity: number;
  21845. /**
  21846. * Intensity of the environment e.g. how much the environment will light the object
  21847. * either through harmonics for rough material or through the refelction for shiny ones.
  21848. */
  21849. protected _environmentIntensity: number;
  21850. /**
  21851. * This is a special control allowing the reduction of the specular highlights coming from the
  21852. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21853. */
  21854. protected _specularIntensity: number;
  21855. /**
  21856. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21857. */
  21858. private _lightingInfos;
  21859. /**
  21860. * Debug Control allowing disabling the bump map on this material.
  21861. */
  21862. protected _disableBumpMap: boolean;
  21863. /**
  21864. * AKA Diffuse Texture in standard nomenclature.
  21865. */
  21866. protected _albedoTexture: Nullable<BaseTexture>;
  21867. /**
  21868. * AKA Occlusion Texture in other nomenclature.
  21869. */
  21870. protected _ambientTexture: Nullable<BaseTexture>;
  21871. /**
  21872. * AKA Occlusion Texture Intensity in other nomenclature.
  21873. */
  21874. protected _ambientTextureStrength: number;
  21875. /**
  21876. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21877. * 1 means it completely occludes it
  21878. * 0 mean it has no impact
  21879. */
  21880. protected _ambientTextureImpactOnAnalyticalLights: number;
  21881. /**
  21882. * Stores the alpha values in a texture.
  21883. */
  21884. protected _opacityTexture: Nullable<BaseTexture>;
  21885. /**
  21886. * Stores the reflection values in a texture.
  21887. */
  21888. protected _reflectionTexture: Nullable<BaseTexture>;
  21889. /**
  21890. * Stores the emissive values in a texture.
  21891. */
  21892. protected _emissiveTexture: Nullable<BaseTexture>;
  21893. /**
  21894. * AKA Specular texture in other nomenclature.
  21895. */
  21896. protected _reflectivityTexture: Nullable<BaseTexture>;
  21897. /**
  21898. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21899. */
  21900. protected _metallicTexture: Nullable<BaseTexture>;
  21901. /**
  21902. * Specifies the metallic scalar of the metallic/roughness workflow.
  21903. * Can also be used to scale the metalness values of the metallic texture.
  21904. */
  21905. protected _metallic: Nullable<number>;
  21906. /**
  21907. * Specifies the roughness scalar of the metallic/roughness workflow.
  21908. * Can also be used to scale the roughness values of the metallic texture.
  21909. */
  21910. protected _roughness: Nullable<number>;
  21911. /**
  21912. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21913. * By default the indexOfrefraction is used to compute F0;
  21914. *
  21915. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21916. *
  21917. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21918. * F90 = metallicReflectanceColor;
  21919. */
  21920. protected _metallicF0Factor: number;
  21921. /**
  21922. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21923. * By default the F90 is always 1;
  21924. *
  21925. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21926. *
  21927. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21928. * F90 = metallicReflectanceColor;
  21929. */
  21930. protected _metallicReflectanceColor: Color3;
  21931. /**
  21932. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21933. * This is multiply against the scalar values defined in the material.
  21934. */
  21935. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21936. /**
  21937. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21938. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21939. */
  21940. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21941. /**
  21942. * Stores surface normal data used to displace a mesh in a texture.
  21943. */
  21944. protected _bumpTexture: Nullable<BaseTexture>;
  21945. /**
  21946. * Stores the pre-calculated light information of a mesh in a texture.
  21947. */
  21948. protected _lightmapTexture: Nullable<BaseTexture>;
  21949. /**
  21950. * The color of a material in ambient lighting.
  21951. */
  21952. protected _ambientColor: Color3;
  21953. /**
  21954. * AKA Diffuse Color in other nomenclature.
  21955. */
  21956. protected _albedoColor: Color3;
  21957. /**
  21958. * AKA Specular Color in other nomenclature.
  21959. */
  21960. protected _reflectivityColor: Color3;
  21961. /**
  21962. * The color applied when light is reflected from a material.
  21963. */
  21964. protected _reflectionColor: Color3;
  21965. /**
  21966. * The color applied when light is emitted from a material.
  21967. */
  21968. protected _emissiveColor: Color3;
  21969. /**
  21970. * AKA Glossiness in other nomenclature.
  21971. */
  21972. protected _microSurface: number;
  21973. /**
  21974. * Specifies that the material will use the light map as a show map.
  21975. */
  21976. protected _useLightmapAsShadowmap: boolean;
  21977. /**
  21978. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21979. * makes the reflect vector face the model (under horizon).
  21980. */
  21981. protected _useHorizonOcclusion: boolean;
  21982. /**
  21983. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21984. * too much the area relying on ambient texture to define their ambient occlusion.
  21985. */
  21986. protected _useRadianceOcclusion: boolean;
  21987. /**
  21988. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21989. */
  21990. protected _useAlphaFromAlbedoTexture: boolean;
  21991. /**
  21992. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21993. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21994. */
  21995. protected _useSpecularOverAlpha: boolean;
  21996. /**
  21997. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21998. */
  21999. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22000. /**
  22001. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22002. */
  22003. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  22004. /**
  22005. * Specifies if the metallic texture contains the roughness information in its green channel.
  22006. */
  22007. protected _useRoughnessFromMetallicTextureGreen: boolean;
  22008. /**
  22009. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22010. */
  22011. protected _useMetallnessFromMetallicTextureBlue: boolean;
  22012. /**
  22013. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22014. */
  22015. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  22016. /**
  22017. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22018. */
  22019. protected _useAmbientInGrayScale: boolean;
  22020. /**
  22021. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22022. * The material will try to infer what glossiness each pixel should be.
  22023. */
  22024. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22025. /**
  22026. * Defines the falloff type used in this material.
  22027. * It by default is Physical.
  22028. */
  22029. protected _lightFalloff: number;
  22030. /**
  22031. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22032. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22033. */
  22034. protected _useRadianceOverAlpha: boolean;
  22035. /**
  22036. * Allows using an object space normal map (instead of tangent space).
  22037. */
  22038. protected _useObjectSpaceNormalMap: boolean;
  22039. /**
  22040. * Allows using the bump map in parallax mode.
  22041. */
  22042. protected _useParallax: boolean;
  22043. /**
  22044. * Allows using the bump map in parallax occlusion mode.
  22045. */
  22046. protected _useParallaxOcclusion: boolean;
  22047. /**
  22048. * Controls the scale bias of the parallax mode.
  22049. */
  22050. protected _parallaxScaleBias: number;
  22051. /**
  22052. * If sets to true, disables all the lights affecting the material.
  22053. */
  22054. protected _disableLighting: boolean;
  22055. /**
  22056. * Number of Simultaneous lights allowed on the material.
  22057. */
  22058. protected _maxSimultaneousLights: number;
  22059. /**
  22060. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22061. */
  22062. protected _invertNormalMapX: boolean;
  22063. /**
  22064. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22065. */
  22066. protected _invertNormalMapY: boolean;
  22067. /**
  22068. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22069. */
  22070. protected _twoSidedLighting: boolean;
  22071. /**
  22072. * Defines the alpha limits in alpha test mode.
  22073. */
  22074. protected _alphaCutOff: number;
  22075. /**
  22076. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22077. */
  22078. protected _forceAlphaTest: boolean;
  22079. /**
  22080. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22081. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22082. */
  22083. protected _useAlphaFresnel: boolean;
  22084. /**
  22085. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22086. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22087. */
  22088. protected _useLinearAlphaFresnel: boolean;
  22089. /**
  22090. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22091. * from cos thetav and roughness:
  22092. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22093. */
  22094. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22095. /**
  22096. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22097. */
  22098. protected _forceIrradianceInFragment: boolean;
  22099. private _realTimeFiltering;
  22100. /**
  22101. * Enables realtime filtering on the texture.
  22102. */
  22103. get realTimeFiltering(): boolean;
  22104. set realTimeFiltering(b: boolean);
  22105. private _realTimeFilteringQuality;
  22106. /**
  22107. * Quality switch for realtime filtering
  22108. */
  22109. get realTimeFilteringQuality(): number;
  22110. set realTimeFilteringQuality(n: number);
  22111. /**
  22112. * Can this material render to several textures at once
  22113. */
  22114. get canRenderToMRT(): boolean;
  22115. /**
  22116. * Force normal to face away from face.
  22117. */
  22118. protected _forceNormalForward: boolean;
  22119. /**
  22120. * Enables specular anti aliasing in the PBR shader.
  22121. * It will both interacts on the Geometry for analytical and IBL lighting.
  22122. * It also prefilter the roughness map based on the bump values.
  22123. */
  22124. protected _enableSpecularAntiAliasing: boolean;
  22125. /**
  22126. * Default configuration related to image processing available in the PBR Material.
  22127. */
  22128. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22129. /**
  22130. * Keep track of the image processing observer to allow dispose and replace.
  22131. */
  22132. private _imageProcessingObserver;
  22133. /**
  22134. * Attaches a new image processing configuration to the PBR Material.
  22135. * @param configuration
  22136. */
  22137. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22138. /**
  22139. * Stores the available render targets.
  22140. */
  22141. private _renderTargets;
  22142. /**
  22143. * Sets the global ambient color for the material used in lighting calculations.
  22144. */
  22145. private _globalAmbientColor;
  22146. /**
  22147. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22148. */
  22149. private _useLogarithmicDepth;
  22150. /**
  22151. * If set to true, no lighting calculations will be applied.
  22152. */
  22153. private _unlit;
  22154. private _debugMode;
  22155. /**
  22156. * @hidden
  22157. * This is reserved for the inspector.
  22158. * Defines the material debug mode.
  22159. * It helps seeing only some components of the material while troubleshooting.
  22160. */
  22161. debugMode: number;
  22162. /**
  22163. * @hidden
  22164. * This is reserved for the inspector.
  22165. * Specify from where on screen the debug mode should start.
  22166. * The value goes from -1 (full screen) to 1 (not visible)
  22167. * It helps with side by side comparison against the final render
  22168. * This defaults to -1
  22169. */
  22170. private debugLimit;
  22171. /**
  22172. * @hidden
  22173. * This is reserved for the inspector.
  22174. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22175. * You can use the factor to better multiply the final value.
  22176. */
  22177. private debugFactor;
  22178. /**
  22179. * Defines the clear coat layer parameters for the material.
  22180. */
  22181. readonly clearCoat: PBRClearCoatConfiguration;
  22182. /**
  22183. * Defines the anisotropic parameters for the material.
  22184. */
  22185. readonly anisotropy: PBRAnisotropicConfiguration;
  22186. /**
  22187. * Defines the BRDF parameters for the material.
  22188. */
  22189. readonly brdf: PBRBRDFConfiguration;
  22190. /**
  22191. * Defines the Sheen parameters for the material.
  22192. */
  22193. readonly sheen: PBRSheenConfiguration;
  22194. /**
  22195. * Defines the SubSurface parameters for the material.
  22196. */
  22197. readonly subSurface: PBRSubSurfaceConfiguration;
  22198. /**
  22199. * Defines additionnal PrePass parameters for the material.
  22200. */
  22201. readonly prePassConfiguration: PrePassConfiguration;
  22202. /**
  22203. * Defines the detail map parameters for the material.
  22204. */
  22205. readonly detailMap: DetailMapConfiguration;
  22206. protected _rebuildInParallel: boolean;
  22207. /**
  22208. * Instantiates a new PBRMaterial instance.
  22209. *
  22210. * @param name The material name
  22211. * @param scene The scene the material will be use in.
  22212. */
  22213. constructor(name: string, scene: Scene);
  22214. /**
  22215. * Gets a boolean indicating that current material needs to register RTT
  22216. */
  22217. get hasRenderTargetTextures(): boolean;
  22218. /**
  22219. * Gets the name of the material class.
  22220. */
  22221. getClassName(): string;
  22222. /**
  22223. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22224. */
  22225. get useLogarithmicDepth(): boolean;
  22226. /**
  22227. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22228. */
  22229. set useLogarithmicDepth(value: boolean);
  22230. /**
  22231. * Returns true if alpha blending should be disabled.
  22232. */
  22233. protected get _disableAlphaBlending(): boolean;
  22234. /**
  22235. * Specifies whether or not this material should be rendered in alpha blend mode.
  22236. */
  22237. needAlphaBlending(): boolean;
  22238. /**
  22239. * Specifies whether or not this material should be rendered in alpha test mode.
  22240. */
  22241. needAlphaTesting(): boolean;
  22242. /**
  22243. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22244. */
  22245. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22246. /**
  22247. * Specifies whether or not there is a usable alpha channel for transparency.
  22248. */
  22249. protected _hasAlphaChannel(): boolean;
  22250. /**
  22251. * Gets the texture used for the alpha test.
  22252. */
  22253. getAlphaTestTexture(): Nullable<BaseTexture>;
  22254. /**
  22255. * Specifies that the submesh is ready to be used.
  22256. * @param mesh - BJS mesh.
  22257. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22258. * @param useInstances - Specifies that instances should be used.
  22259. * @returns - boolean indicating that the submesh is ready or not.
  22260. */
  22261. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22262. /**
  22263. * Specifies if the material uses metallic roughness workflow.
  22264. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22265. */
  22266. isMetallicWorkflow(): boolean;
  22267. private _prepareEffect;
  22268. private _prepareDefines;
  22269. /**
  22270. * Force shader compilation
  22271. */
  22272. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22273. /**
  22274. * Initializes the uniform buffer layout for the shader.
  22275. */
  22276. buildUniformLayout(): void;
  22277. /**
  22278. * Unbinds the material from the mesh
  22279. */
  22280. unbind(): void;
  22281. /**
  22282. * Binds the submesh data.
  22283. * @param world - The world matrix.
  22284. * @param mesh - The BJS mesh.
  22285. * @param subMesh - A submesh of the BJS mesh.
  22286. */
  22287. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22288. /**
  22289. * Returns the animatable textures.
  22290. * @returns - Array of animatable textures.
  22291. */
  22292. getAnimatables(): IAnimatable[];
  22293. /**
  22294. * Returns the texture used for reflections.
  22295. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22296. */
  22297. private _getReflectionTexture;
  22298. /**
  22299. * Returns an array of the actively used textures.
  22300. * @returns - Array of BaseTextures
  22301. */
  22302. getActiveTextures(): BaseTexture[];
  22303. /**
  22304. * Checks to see if a texture is used in the material.
  22305. * @param texture - Base texture to use.
  22306. * @returns - Boolean specifying if a texture is used in the material.
  22307. */
  22308. hasTexture(texture: BaseTexture): boolean;
  22309. /**
  22310. * Sets the required values to the prepass renderer.
  22311. * @param prePassRenderer defines the prepass renderer to setup
  22312. */
  22313. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22314. /**
  22315. * Disposes the resources of the material.
  22316. * @param forceDisposeEffect - Forces the disposal of effects.
  22317. * @param forceDisposeTextures - Forces the disposal of all textures.
  22318. */
  22319. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22320. }
  22321. }
  22322. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  22323. import { Nullable } from "babylonjs/types";
  22324. import { Scene } from "babylonjs/scene";
  22325. import { Color3 } from "babylonjs/Maths/math.color";
  22326. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  22327. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  22328. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22329. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  22330. /**
  22331. * The Physically based material of BJS.
  22332. *
  22333. * This offers the main features of a standard PBR material.
  22334. * For more information, please refer to the documentation :
  22335. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22336. */
  22337. export class PBRMaterial extends PBRBaseMaterial {
  22338. /**
  22339. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22340. */
  22341. static readonly PBRMATERIAL_OPAQUE: number;
  22342. /**
  22343. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22344. */
  22345. static readonly PBRMATERIAL_ALPHATEST: number;
  22346. /**
  22347. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22348. */
  22349. static readonly PBRMATERIAL_ALPHABLEND: number;
  22350. /**
  22351. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22352. * They are also discarded below the alpha cutoff threshold to improve performances.
  22353. */
  22354. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22355. /**
  22356. * Defines the default value of how much AO map is occluding the analytical lights
  22357. * (point spot...).
  22358. */
  22359. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22360. /**
  22361. * Intensity of the direct lights e.g. the four lights available in your scene.
  22362. * This impacts both the direct diffuse and specular highlights.
  22363. */
  22364. directIntensity: number;
  22365. /**
  22366. * Intensity of the emissive part of the material.
  22367. * This helps controlling the emissive effect without modifying the emissive color.
  22368. */
  22369. emissiveIntensity: number;
  22370. /**
  22371. * Intensity of the environment e.g. how much the environment will light the object
  22372. * either through harmonics for rough material or through the refelction for shiny ones.
  22373. */
  22374. environmentIntensity: number;
  22375. /**
  22376. * This is a special control allowing the reduction of the specular highlights coming from the
  22377. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22378. */
  22379. specularIntensity: number;
  22380. /**
  22381. * Debug Control allowing disabling the bump map on this material.
  22382. */
  22383. disableBumpMap: boolean;
  22384. /**
  22385. * AKA Diffuse Texture in standard nomenclature.
  22386. */
  22387. albedoTexture: BaseTexture;
  22388. /**
  22389. * AKA Occlusion Texture in other nomenclature.
  22390. */
  22391. ambientTexture: BaseTexture;
  22392. /**
  22393. * AKA Occlusion Texture Intensity in other nomenclature.
  22394. */
  22395. ambientTextureStrength: number;
  22396. /**
  22397. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22398. * 1 means it completely occludes it
  22399. * 0 mean it has no impact
  22400. */
  22401. ambientTextureImpactOnAnalyticalLights: number;
  22402. /**
  22403. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22404. */
  22405. opacityTexture: BaseTexture;
  22406. /**
  22407. * Stores the reflection values in a texture.
  22408. */
  22409. reflectionTexture: Nullable<BaseTexture>;
  22410. /**
  22411. * Stores the emissive values in a texture.
  22412. */
  22413. emissiveTexture: BaseTexture;
  22414. /**
  22415. * AKA Specular texture in other nomenclature.
  22416. */
  22417. reflectivityTexture: BaseTexture;
  22418. /**
  22419. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22420. */
  22421. metallicTexture: BaseTexture;
  22422. /**
  22423. * Specifies the metallic scalar of the metallic/roughness workflow.
  22424. * Can also be used to scale the metalness values of the metallic texture.
  22425. */
  22426. metallic: Nullable<number>;
  22427. /**
  22428. * Specifies the roughness scalar of the metallic/roughness workflow.
  22429. * Can also be used to scale the roughness values of the metallic texture.
  22430. */
  22431. roughness: Nullable<number>;
  22432. /**
  22433. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22434. * By default the indexOfrefraction is used to compute F0;
  22435. *
  22436. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22437. *
  22438. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22439. * F90 = metallicReflectanceColor;
  22440. */
  22441. metallicF0Factor: number;
  22442. /**
  22443. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22444. * By default the F90 is always 1;
  22445. *
  22446. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22447. *
  22448. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22449. * F90 = metallicReflectanceColor;
  22450. */
  22451. metallicReflectanceColor: Color3;
  22452. /**
  22453. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22454. * This is multiply against the scalar values defined in the material.
  22455. */
  22456. metallicReflectanceTexture: Nullable<BaseTexture>;
  22457. /**
  22458. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22459. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22460. */
  22461. microSurfaceTexture: BaseTexture;
  22462. /**
  22463. * Stores surface normal data used to displace a mesh in a texture.
  22464. */
  22465. bumpTexture: BaseTexture;
  22466. /**
  22467. * Stores the pre-calculated light information of a mesh in a texture.
  22468. */
  22469. lightmapTexture: BaseTexture;
  22470. /**
  22471. * Stores the refracted light information in a texture.
  22472. */
  22473. get refractionTexture(): Nullable<BaseTexture>;
  22474. set refractionTexture(value: Nullable<BaseTexture>);
  22475. /**
  22476. * The color of a material in ambient lighting.
  22477. */
  22478. ambientColor: Color3;
  22479. /**
  22480. * AKA Diffuse Color in other nomenclature.
  22481. */
  22482. albedoColor: Color3;
  22483. /**
  22484. * AKA Specular Color in other nomenclature.
  22485. */
  22486. reflectivityColor: Color3;
  22487. /**
  22488. * The color reflected from the material.
  22489. */
  22490. reflectionColor: Color3;
  22491. /**
  22492. * The color emitted from the material.
  22493. */
  22494. emissiveColor: Color3;
  22495. /**
  22496. * AKA Glossiness in other nomenclature.
  22497. */
  22498. microSurface: number;
  22499. /**
  22500. * Index of refraction of the material base layer.
  22501. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22502. *
  22503. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22504. *
  22505. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22506. */
  22507. get indexOfRefraction(): number;
  22508. set indexOfRefraction(value: number);
  22509. /**
  22510. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22511. */
  22512. get invertRefractionY(): boolean;
  22513. set invertRefractionY(value: boolean);
  22514. /**
  22515. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22516. * Materials half opaque for instance using refraction could benefit from this control.
  22517. */
  22518. get linkRefractionWithTransparency(): boolean;
  22519. set linkRefractionWithTransparency(value: boolean);
  22520. /**
  22521. * If true, the light map contains occlusion information instead of lighting info.
  22522. */
  22523. useLightmapAsShadowmap: boolean;
  22524. /**
  22525. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22526. */
  22527. useAlphaFromAlbedoTexture: boolean;
  22528. /**
  22529. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22530. */
  22531. forceAlphaTest: boolean;
  22532. /**
  22533. * Defines the alpha limits in alpha test mode.
  22534. */
  22535. alphaCutOff: number;
  22536. /**
  22537. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22538. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22539. */
  22540. useSpecularOverAlpha: boolean;
  22541. /**
  22542. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22543. */
  22544. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22545. /**
  22546. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22547. */
  22548. useRoughnessFromMetallicTextureAlpha: boolean;
  22549. /**
  22550. * Specifies if the metallic texture contains the roughness information in its green channel.
  22551. */
  22552. useRoughnessFromMetallicTextureGreen: boolean;
  22553. /**
  22554. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22555. */
  22556. useMetallnessFromMetallicTextureBlue: boolean;
  22557. /**
  22558. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22559. */
  22560. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22561. /**
  22562. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22563. */
  22564. useAmbientInGrayScale: boolean;
  22565. /**
  22566. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22567. * The material will try to infer what glossiness each pixel should be.
  22568. */
  22569. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22570. /**
  22571. * BJS is using an harcoded light falloff based on a manually sets up range.
  22572. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22573. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22574. */
  22575. get usePhysicalLightFalloff(): boolean;
  22576. /**
  22577. * BJS is using an harcoded light falloff based on a manually sets up range.
  22578. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22579. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22580. */
  22581. set usePhysicalLightFalloff(value: boolean);
  22582. /**
  22583. * In order to support the falloff compatibility with gltf, a special mode has been added
  22584. * to reproduce the gltf light falloff.
  22585. */
  22586. get useGLTFLightFalloff(): boolean;
  22587. /**
  22588. * In order to support the falloff compatibility with gltf, a special mode has been added
  22589. * to reproduce the gltf light falloff.
  22590. */
  22591. set useGLTFLightFalloff(value: boolean);
  22592. /**
  22593. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22594. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22595. */
  22596. useRadianceOverAlpha: boolean;
  22597. /**
  22598. * Allows using an object space normal map (instead of tangent space).
  22599. */
  22600. useObjectSpaceNormalMap: boolean;
  22601. /**
  22602. * Allows using the bump map in parallax mode.
  22603. */
  22604. useParallax: boolean;
  22605. /**
  22606. * Allows using the bump map in parallax occlusion mode.
  22607. */
  22608. useParallaxOcclusion: boolean;
  22609. /**
  22610. * Controls the scale bias of the parallax mode.
  22611. */
  22612. parallaxScaleBias: number;
  22613. /**
  22614. * If sets to true, disables all the lights affecting the material.
  22615. */
  22616. disableLighting: boolean;
  22617. /**
  22618. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22619. */
  22620. forceIrradianceInFragment: boolean;
  22621. /**
  22622. * Number of Simultaneous lights allowed on the material.
  22623. */
  22624. maxSimultaneousLights: number;
  22625. /**
  22626. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22627. */
  22628. invertNormalMapX: boolean;
  22629. /**
  22630. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22631. */
  22632. invertNormalMapY: boolean;
  22633. /**
  22634. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22635. */
  22636. twoSidedLighting: boolean;
  22637. /**
  22638. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22639. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22640. */
  22641. useAlphaFresnel: boolean;
  22642. /**
  22643. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22644. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22645. */
  22646. useLinearAlphaFresnel: boolean;
  22647. /**
  22648. * Let user defines the brdf lookup texture used for IBL.
  22649. * A default 8bit version is embedded but you could point at :
  22650. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22651. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22652. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22653. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22654. */
  22655. environmentBRDFTexture: Nullable<BaseTexture>;
  22656. /**
  22657. * Force normal to face away from face.
  22658. */
  22659. forceNormalForward: boolean;
  22660. /**
  22661. * Enables specular anti aliasing in the PBR shader.
  22662. * It will both interacts on the Geometry for analytical and IBL lighting.
  22663. * It also prefilter the roughness map based on the bump values.
  22664. */
  22665. enableSpecularAntiAliasing: boolean;
  22666. /**
  22667. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22668. * makes the reflect vector face the model (under horizon).
  22669. */
  22670. useHorizonOcclusion: boolean;
  22671. /**
  22672. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22673. * too much the area relying on ambient texture to define their ambient occlusion.
  22674. */
  22675. useRadianceOcclusion: boolean;
  22676. /**
  22677. * If set to true, no lighting calculations will be applied.
  22678. */
  22679. unlit: boolean;
  22680. /**
  22681. * Gets the image processing configuration used either in this material.
  22682. */
  22683. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22684. /**
  22685. * Sets the Default image processing configuration used either in the this material.
  22686. *
  22687. * If sets to null, the scene one is in use.
  22688. */
  22689. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22690. /**
  22691. * Gets wether the color curves effect is enabled.
  22692. */
  22693. get cameraColorCurvesEnabled(): boolean;
  22694. /**
  22695. * Sets wether the color curves effect is enabled.
  22696. */
  22697. set cameraColorCurvesEnabled(value: boolean);
  22698. /**
  22699. * Gets wether the color grading effect is enabled.
  22700. */
  22701. get cameraColorGradingEnabled(): boolean;
  22702. /**
  22703. * Gets wether the color grading effect is enabled.
  22704. */
  22705. set cameraColorGradingEnabled(value: boolean);
  22706. /**
  22707. * Gets wether tonemapping is enabled or not.
  22708. */
  22709. get cameraToneMappingEnabled(): boolean;
  22710. /**
  22711. * Sets wether tonemapping is enabled or not
  22712. */
  22713. set cameraToneMappingEnabled(value: boolean);
  22714. /**
  22715. * The camera exposure used on this material.
  22716. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22717. * This corresponds to a photographic exposure.
  22718. */
  22719. get cameraExposure(): number;
  22720. /**
  22721. * The camera exposure used on this material.
  22722. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22723. * This corresponds to a photographic exposure.
  22724. */
  22725. set cameraExposure(value: number);
  22726. /**
  22727. * Gets The camera contrast used on this material.
  22728. */
  22729. get cameraContrast(): number;
  22730. /**
  22731. * Sets The camera contrast used on this material.
  22732. */
  22733. set cameraContrast(value: number);
  22734. /**
  22735. * Gets the Color Grading 2D Lookup Texture.
  22736. */
  22737. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22738. /**
  22739. * Sets the Color Grading 2D Lookup Texture.
  22740. */
  22741. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22742. /**
  22743. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22744. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22745. * 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;
  22746. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22747. */
  22748. get cameraColorCurves(): Nullable<ColorCurves>;
  22749. /**
  22750. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22751. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22752. * 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;
  22753. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22754. */
  22755. set cameraColorCurves(value: Nullable<ColorCurves>);
  22756. /**
  22757. * Instantiates a new PBRMaterial instance.
  22758. *
  22759. * @param name The material name
  22760. * @param scene The scene the material will be use in.
  22761. */
  22762. constructor(name: string, scene: Scene);
  22763. /**
  22764. * Returns the name of this material class.
  22765. */
  22766. getClassName(): string;
  22767. /**
  22768. * Makes a duplicate of the current material.
  22769. * @param name - name to use for the new material.
  22770. */
  22771. clone(name: string): PBRMaterial;
  22772. /**
  22773. * Serializes this PBR Material.
  22774. * @returns - An object with the serialized material.
  22775. */
  22776. serialize(): any;
  22777. /**
  22778. * Parses a PBR Material from a serialized object.
  22779. * @param source - Serialized object.
  22780. * @param scene - BJS scene instance.
  22781. * @param rootUrl - url for the scene object
  22782. * @returns - PBRMaterial
  22783. */
  22784. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22785. }
  22786. }
  22787. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  22788. /** @hidden */
  22789. export var mrtFragmentDeclaration: {
  22790. name: string;
  22791. shader: string;
  22792. };
  22793. }
  22794. declare module "babylonjs/Shaders/geometry.fragment" {
  22795. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  22796. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22797. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22798. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22799. /** @hidden */
  22800. export var geometryPixelShader: {
  22801. name: string;
  22802. shader: string;
  22803. };
  22804. }
  22805. declare module "babylonjs/Shaders/geometry.vertex" {
  22806. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22807. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22808. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22809. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  22810. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22811. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22812. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22813. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22814. /** @hidden */
  22815. export var geometryVertexShader: {
  22816. name: string;
  22817. shader: string;
  22818. };
  22819. }
  22820. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  22821. import { Matrix } from "babylonjs/Maths/math.vector";
  22822. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22823. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22824. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  22825. import { Effect } from "babylonjs/Materials/effect";
  22826. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22827. import { Scene } from "babylonjs/scene";
  22828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22829. import { Nullable } from "babylonjs/types";
  22830. import "babylonjs/Shaders/geometry.fragment";
  22831. import "babylonjs/Shaders/geometry.vertex";
  22832. /** @hidden */
  22833. interface ISavedTransformationMatrix {
  22834. world: Matrix;
  22835. viewProjection: Matrix;
  22836. }
  22837. /**
  22838. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22839. */
  22840. export class GeometryBufferRenderer {
  22841. /**
  22842. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22843. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22844. */
  22845. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22846. /**
  22847. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22848. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22849. */
  22850. static readonly POSITION_TEXTURE_TYPE: number;
  22851. /**
  22852. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22853. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22854. */
  22855. static readonly VELOCITY_TEXTURE_TYPE: number;
  22856. /**
  22857. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22858. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22859. */
  22860. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22861. /**
  22862. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22863. * in order to compute objects velocities when enableVelocity is set to "true"
  22864. * @hidden
  22865. */
  22866. _previousTransformationMatrices: {
  22867. [index: number]: ISavedTransformationMatrix;
  22868. };
  22869. /**
  22870. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22871. * in order to compute objects velocities when enableVelocity is set to "true"
  22872. * @hidden
  22873. */
  22874. _previousBonesTransformationMatrices: {
  22875. [index: number]: Float32Array;
  22876. };
  22877. /**
  22878. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22879. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22880. */
  22881. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22882. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22883. renderTransparentMeshes: boolean;
  22884. private _scene;
  22885. private _resizeObserver;
  22886. private _multiRenderTarget;
  22887. private _ratio;
  22888. private _enablePosition;
  22889. private _enableVelocity;
  22890. private _enableReflectivity;
  22891. private _positionIndex;
  22892. private _velocityIndex;
  22893. private _reflectivityIndex;
  22894. private _depthNormalIndex;
  22895. private _linkedWithPrePass;
  22896. private _prePassRenderer;
  22897. private _attachments;
  22898. protected _effect: Effect;
  22899. protected _cachedDefines: string;
  22900. /**
  22901. * @hidden
  22902. * Sets up internal structures to share outputs with PrePassRenderer
  22903. * This method should only be called by the PrePassRenderer itself
  22904. */
  22905. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22906. /**
  22907. * @hidden
  22908. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22909. * This method should only be called by the PrePassRenderer itself
  22910. */
  22911. _unlinkPrePassRenderer(): void;
  22912. /**
  22913. * @hidden
  22914. * Resets the geometry buffer layout
  22915. */
  22916. _resetLayout(): void;
  22917. /**
  22918. * @hidden
  22919. * Replaces a texture in the geometry buffer renderer
  22920. * Useful when linking textures of the prepass renderer
  22921. */
  22922. _forceTextureType(geometryBufferType: number, index: number): void;
  22923. /**
  22924. * @hidden
  22925. * Sets texture attachments
  22926. * Useful when linking textures of the prepass renderer
  22927. */
  22928. _setAttachments(attachments: number[]): void;
  22929. /**
  22930. * @hidden
  22931. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22932. * Useful when linking textures of the prepass renderer
  22933. */
  22934. _linkInternalTexture(internalTexture: InternalTexture): void;
  22935. /**
  22936. * Gets the render list (meshes to be rendered) used in the G buffer.
  22937. */
  22938. get renderList(): Nullable<AbstractMesh[]>;
  22939. /**
  22940. * Set the render list (meshes to be rendered) used in the G buffer.
  22941. */
  22942. set renderList(meshes: Nullable<AbstractMesh[]>);
  22943. /**
  22944. * Gets wether or not G buffer are supported by the running hardware.
  22945. * This requires draw buffer supports
  22946. */
  22947. get isSupported(): boolean;
  22948. /**
  22949. * Returns the index of the given texture type in the G-Buffer textures array
  22950. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22951. * @returns the index of the given texture type in the G-Buffer textures array
  22952. */
  22953. getTextureIndex(textureType: number): number;
  22954. /**
  22955. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22956. */
  22957. get enablePosition(): boolean;
  22958. /**
  22959. * Sets whether or not objects positions are enabled for the G buffer.
  22960. */
  22961. set enablePosition(enable: boolean);
  22962. /**
  22963. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22964. */
  22965. get enableVelocity(): boolean;
  22966. /**
  22967. * Sets wether or not objects velocities are enabled for the G buffer.
  22968. */
  22969. set enableVelocity(enable: boolean);
  22970. /**
  22971. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22972. */
  22973. get enableReflectivity(): boolean;
  22974. /**
  22975. * Sets wether or not objects roughness are enabled for the G buffer.
  22976. */
  22977. set enableReflectivity(enable: boolean);
  22978. /**
  22979. * Gets the scene associated with the buffer.
  22980. */
  22981. get scene(): Scene;
  22982. /**
  22983. * Gets the ratio used by the buffer during its creation.
  22984. * How big is the buffer related to the main canvas.
  22985. */
  22986. get ratio(): number;
  22987. /** @hidden */
  22988. static _SceneComponentInitialization: (scene: Scene) => void;
  22989. /**
  22990. * Creates a new G Buffer for the scene
  22991. * @param scene The scene the buffer belongs to
  22992. * @param ratio How big is the buffer related to the main canvas.
  22993. */
  22994. constructor(scene: Scene, ratio?: number);
  22995. /**
  22996. * Checks wether everything is ready to render a submesh to the G buffer.
  22997. * @param subMesh the submesh to check readiness for
  22998. * @param useInstances is the mesh drawn using instance or not
  22999. * @returns true if ready otherwise false
  23000. */
  23001. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  23002. /**
  23003. * Gets the current underlying G Buffer.
  23004. * @returns the buffer
  23005. */
  23006. getGBuffer(): MultiRenderTarget;
  23007. /**
  23008. * Gets the number of samples used to render the buffer (anti aliasing).
  23009. */
  23010. get samples(): number;
  23011. /**
  23012. * Sets the number of samples used to render the buffer (anti aliasing).
  23013. */
  23014. set samples(value: number);
  23015. /**
  23016. * Disposes the renderer and frees up associated resources.
  23017. */
  23018. dispose(): void;
  23019. private _assignRenderTargetIndices;
  23020. protected _createRenderTargets(): void;
  23021. private _copyBonesTransformationMatrices;
  23022. }
  23023. }
  23024. declare module "babylonjs/Rendering/prePassRenderer" {
  23025. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23026. import { Scene } from "babylonjs/scene";
  23027. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  23028. import { Effect } from "babylonjs/Materials/effect";
  23029. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23031. import { Material } from "babylonjs/Materials/material";
  23032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23033. /**
  23034. * Renders a pre pass of the scene
  23035. * This means every mesh in the scene will be rendered to a render target texture
  23036. * And then this texture will be composited to the rendering canvas with post processes
  23037. * It is necessary for effects like subsurface scattering or deferred shading
  23038. */
  23039. export class PrePassRenderer {
  23040. /** @hidden */
  23041. static _SceneComponentInitialization: (scene: Scene) => void;
  23042. private _textureFormats;
  23043. /**
  23044. * To save performance, we can excluded skinned meshes from the prepass
  23045. */
  23046. excludedSkinnedMesh: AbstractMesh[];
  23047. /**
  23048. * Force material to be excluded from the prepass
  23049. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23050. * and you don't want a material to show in the effect.
  23051. */
  23052. excludedMaterials: Material[];
  23053. private _textureIndices;
  23054. private _scene;
  23055. private _engine;
  23056. private _isDirty;
  23057. /**
  23058. * Number of textures in the multi render target texture where the scene is directly rendered
  23059. */
  23060. mrtCount: number;
  23061. /**
  23062. * The render target where the scene is directly rendered
  23063. */
  23064. prePassRT: MultiRenderTarget;
  23065. private _multiRenderAttachments;
  23066. private _defaultAttachments;
  23067. private _clearAttachments;
  23068. private _postProcesses;
  23069. private readonly _clearColor;
  23070. /**
  23071. * Image processing post process for composition
  23072. */
  23073. imageProcessingPostProcess: ImageProcessingPostProcess;
  23074. /**
  23075. * Configuration for prepass effects
  23076. */
  23077. private _effectConfigurations;
  23078. private _mrtFormats;
  23079. private _mrtLayout;
  23080. private _enabled;
  23081. /**
  23082. * Indicates if the prepass is enabled
  23083. */
  23084. get enabled(): boolean;
  23085. /**
  23086. * How many samples are used for MSAA of the scene render target
  23087. */
  23088. get samples(): number;
  23089. set samples(n: number);
  23090. private _geometryBuffer;
  23091. private _useGeometryBufferFallback;
  23092. /**
  23093. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23094. */
  23095. get useGeometryBufferFallback(): boolean;
  23096. set useGeometryBufferFallback(value: boolean);
  23097. /**
  23098. * Set to true to disable gamma transform in PrePass.
  23099. * Can be useful in case you already proceed to gamma transform on a material level
  23100. * and your post processes don't need to be in linear color space.
  23101. */
  23102. disableGammaTransform: boolean;
  23103. /**
  23104. * Instanciates a prepass renderer
  23105. * @param scene The scene
  23106. */
  23107. constructor(scene: Scene);
  23108. private _initializeAttachments;
  23109. private _createCompositionEffect;
  23110. /**
  23111. * Indicates if rendering a prepass is supported
  23112. */
  23113. get isSupported(): boolean;
  23114. /**
  23115. * Sets the proper output textures to draw in the engine.
  23116. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23117. * @param subMesh Submesh on which the effect is applied
  23118. */
  23119. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23120. /**
  23121. * Restores attachments for single texture draw.
  23122. */
  23123. restoreAttachments(): void;
  23124. /**
  23125. * @hidden
  23126. */
  23127. _beforeCameraDraw(): void;
  23128. /**
  23129. * @hidden
  23130. */
  23131. _afterCameraDraw(): void;
  23132. private _checkRTSize;
  23133. private _bindFrameBuffer;
  23134. /**
  23135. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23136. */
  23137. clear(): void;
  23138. private _setState;
  23139. private _updateGeometryBufferLayout;
  23140. /**
  23141. * Adds an effect configuration to the prepass.
  23142. * If an effect has already been added, it won't add it twice and will return the configuration
  23143. * already present.
  23144. * @param cfg the effect configuration
  23145. * @return the effect configuration now used by the prepass
  23146. */
  23147. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23148. /**
  23149. * Returns the index of a texture in the multi render target texture array.
  23150. * @param type Texture type
  23151. * @return The index
  23152. */
  23153. getIndex(type: number): number;
  23154. private _enable;
  23155. private _disable;
  23156. private _resetLayout;
  23157. private _resetPostProcessChain;
  23158. private _bindPostProcessChain;
  23159. /**
  23160. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23161. */
  23162. markAsDirty(): void;
  23163. /**
  23164. * Enables a texture on the MultiRenderTarget for prepass
  23165. */
  23166. private _enableTextures;
  23167. private _update;
  23168. private _markAllMaterialsAsPrePassDirty;
  23169. /**
  23170. * Disposes the prepass renderer.
  23171. */
  23172. dispose(): void;
  23173. }
  23174. }
  23175. declare module "babylonjs/PostProcesses/postProcess" {
  23176. import { Nullable } from "babylonjs/types";
  23177. import { SmartArray } from "babylonjs/Misc/smartArray";
  23178. import { Observable } from "babylonjs/Misc/observable";
  23179. import { Vector2 } from "babylonjs/Maths/math.vector";
  23180. import { Camera } from "babylonjs/Cameras/camera";
  23181. import { Effect } from "babylonjs/Materials/effect";
  23182. import "babylonjs/Shaders/postprocess.vertex";
  23183. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23184. import { Engine } from "babylonjs/Engines/engine";
  23185. import { Color4 } from "babylonjs/Maths/math.color";
  23186. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23187. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23188. import { Scene } from "babylonjs/scene";
  23189. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23190. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23191. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23192. /**
  23193. * Size options for a post process
  23194. */
  23195. export type PostProcessOptions = {
  23196. width: number;
  23197. height: number;
  23198. };
  23199. /**
  23200. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23201. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23202. */
  23203. export class PostProcess {
  23204. /**
  23205. * Gets or sets the unique id of the post process
  23206. */
  23207. uniqueId: number;
  23208. /** Name of the PostProcess. */
  23209. name: string;
  23210. /**
  23211. * Width of the texture to apply the post process on
  23212. */
  23213. width: number;
  23214. /**
  23215. * Height of the texture to apply the post process on
  23216. */
  23217. height: number;
  23218. /**
  23219. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23220. */
  23221. nodeMaterialSource: Nullable<NodeMaterial>;
  23222. /**
  23223. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23224. * @hidden
  23225. */
  23226. _outputTexture: Nullable<InternalTexture>;
  23227. /**
  23228. * Sampling mode used by the shader
  23229. * See https://doc.babylonjs.com/classes/3.1/texture
  23230. */
  23231. renderTargetSamplingMode: number;
  23232. /**
  23233. * Clear color to use when screen clearing
  23234. */
  23235. clearColor: Color4;
  23236. /**
  23237. * If the buffer needs to be cleared before applying the post process. (default: true)
  23238. * Should be set to false if shader will overwrite all previous pixels.
  23239. */
  23240. autoClear: boolean;
  23241. /**
  23242. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23243. */
  23244. alphaMode: number;
  23245. /**
  23246. * Sets the setAlphaBlendConstants of the babylon engine
  23247. */
  23248. alphaConstants: Color4;
  23249. /**
  23250. * Animations to be used for the post processing
  23251. */
  23252. animations: import("babylonjs/Animations/animation").Animation[];
  23253. /**
  23254. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23255. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23256. */
  23257. enablePixelPerfectMode: boolean;
  23258. /**
  23259. * Force the postprocess to be applied without taking in account viewport
  23260. */
  23261. forceFullscreenViewport: boolean;
  23262. /**
  23263. * List of inspectable custom properties (used by the Inspector)
  23264. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23265. */
  23266. inspectableCustomProperties: IInspectable[];
  23267. /**
  23268. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23269. *
  23270. * | Value | Type | Description |
  23271. * | ----- | ----------------------------------- | ----------- |
  23272. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23273. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23274. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23275. *
  23276. */
  23277. scaleMode: number;
  23278. /**
  23279. * Force textures to be a power of two (default: false)
  23280. */
  23281. alwaysForcePOT: boolean;
  23282. private _samples;
  23283. /**
  23284. * Number of sample textures (default: 1)
  23285. */
  23286. get samples(): number;
  23287. set samples(n: number);
  23288. /**
  23289. * Modify the scale of the post process to be the same as the viewport (default: false)
  23290. */
  23291. adaptScaleToCurrentViewport: boolean;
  23292. private _camera;
  23293. protected _scene: Scene;
  23294. private _engine;
  23295. private _options;
  23296. private _reusable;
  23297. private _textureType;
  23298. private _textureFormat;
  23299. /**
  23300. * Smart array of input and output textures for the post process.
  23301. * @hidden
  23302. */
  23303. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23304. /**
  23305. * The index in _textures that corresponds to the output texture.
  23306. * @hidden
  23307. */
  23308. _currentRenderTextureInd: number;
  23309. private _effect;
  23310. private _samplers;
  23311. private _fragmentUrl;
  23312. private _vertexUrl;
  23313. private _parameters;
  23314. private _scaleRatio;
  23315. protected _indexParameters: any;
  23316. private _shareOutputWithPostProcess;
  23317. private _texelSize;
  23318. private _forcedOutputTexture;
  23319. /**
  23320. * Prepass configuration in case this post process needs a texture from prepass
  23321. * @hidden
  23322. */
  23323. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23324. /**
  23325. * Returns the fragment url or shader name used in the post process.
  23326. * @returns the fragment url or name in the shader store.
  23327. */
  23328. getEffectName(): string;
  23329. /**
  23330. * An event triggered when the postprocess is activated.
  23331. */
  23332. onActivateObservable: Observable<Camera>;
  23333. private _onActivateObserver;
  23334. /**
  23335. * A function that is added to the onActivateObservable
  23336. */
  23337. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23338. /**
  23339. * An event triggered when the postprocess changes its size.
  23340. */
  23341. onSizeChangedObservable: Observable<PostProcess>;
  23342. private _onSizeChangedObserver;
  23343. /**
  23344. * A function that is added to the onSizeChangedObservable
  23345. */
  23346. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23347. /**
  23348. * An event triggered when the postprocess applies its effect.
  23349. */
  23350. onApplyObservable: Observable<Effect>;
  23351. private _onApplyObserver;
  23352. /**
  23353. * A function that is added to the onApplyObservable
  23354. */
  23355. set onApply(callback: (effect: Effect) => void);
  23356. /**
  23357. * An event triggered before rendering the postprocess
  23358. */
  23359. onBeforeRenderObservable: Observable<Effect>;
  23360. private _onBeforeRenderObserver;
  23361. /**
  23362. * A function that is added to the onBeforeRenderObservable
  23363. */
  23364. set onBeforeRender(callback: (effect: Effect) => void);
  23365. /**
  23366. * An event triggered after rendering the postprocess
  23367. */
  23368. onAfterRenderObservable: Observable<Effect>;
  23369. private _onAfterRenderObserver;
  23370. /**
  23371. * A function that is added to the onAfterRenderObservable
  23372. */
  23373. set onAfterRender(callback: (efect: Effect) => void);
  23374. /**
  23375. * 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
  23376. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23377. */
  23378. get inputTexture(): InternalTexture;
  23379. set inputTexture(value: InternalTexture);
  23380. /**
  23381. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23382. * the only way to unset it is to use this function to restore its internal state
  23383. */
  23384. restoreDefaultInputTexture(): void;
  23385. /**
  23386. * Gets the camera which post process is applied to.
  23387. * @returns The camera the post process is applied to.
  23388. */
  23389. getCamera(): Camera;
  23390. /**
  23391. * Gets the texel size of the postprocess.
  23392. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23393. */
  23394. get texelSize(): Vector2;
  23395. /**
  23396. * Creates a new instance PostProcess
  23397. * @param name The name of the PostProcess.
  23398. * @param fragmentUrl The url of the fragment shader to be used.
  23399. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23400. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23401. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23402. * @param camera The camera to apply the render pass to.
  23403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23404. * @param engine The engine which the post process will be applied. (default: current engine)
  23405. * @param reusable If the post process can be reused on the same frame. (default: false)
  23406. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23407. * @param textureType Type of textures used when performing the post process. (default: 0)
  23408. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23409. * @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
  23410. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23411. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23412. */
  23413. 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);
  23414. /**
  23415. * Gets a string identifying the name of the class
  23416. * @returns "PostProcess" string
  23417. */
  23418. getClassName(): string;
  23419. /**
  23420. * Gets the engine which this post process belongs to.
  23421. * @returns The engine the post process was enabled with.
  23422. */
  23423. getEngine(): Engine;
  23424. /**
  23425. * The effect that is created when initializing the post process.
  23426. * @returns The created effect corresponding the the postprocess.
  23427. */
  23428. getEffect(): Effect;
  23429. /**
  23430. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23431. * @param postProcess The post process to share the output with.
  23432. * @returns This post process.
  23433. */
  23434. shareOutputWith(postProcess: PostProcess): PostProcess;
  23435. /**
  23436. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23437. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23438. */
  23439. useOwnOutput(): void;
  23440. /**
  23441. * Updates the effect with the current post process compile time values and recompiles the shader.
  23442. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23443. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23444. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23445. * @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
  23446. * @param onCompiled Called when the shader has been compiled.
  23447. * @param onError Called if there is an error when compiling a shader.
  23448. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23449. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23450. */
  23451. 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;
  23452. /**
  23453. * The post process is reusable if it can be used multiple times within one frame.
  23454. * @returns If the post process is reusable
  23455. */
  23456. isReusable(): boolean;
  23457. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23458. markTextureDirty(): void;
  23459. /**
  23460. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23461. * 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.
  23462. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23463. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23464. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23465. * @returns The target texture that was bound to be written to.
  23466. */
  23467. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23468. /**
  23469. * If the post process is supported.
  23470. */
  23471. get isSupported(): boolean;
  23472. /**
  23473. * The aspect ratio of the output texture.
  23474. */
  23475. get aspectRatio(): number;
  23476. /**
  23477. * Get a value indicating if the post-process is ready to be used
  23478. * @returns true if the post-process is ready (shader is compiled)
  23479. */
  23480. isReady(): boolean;
  23481. /**
  23482. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23483. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23484. */
  23485. apply(): Nullable<Effect>;
  23486. private _disposeTextures;
  23487. /**
  23488. * Sets the required values to the prepass renderer.
  23489. * @param prePassRenderer defines the prepass renderer to setup.
  23490. * @returns true if the pre pass is needed.
  23491. */
  23492. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23493. /**
  23494. * Disposes the post process.
  23495. * @param camera The camera to dispose the post process on.
  23496. */
  23497. dispose(camera?: Camera): void;
  23498. /**
  23499. * Serializes the particle system to a JSON object
  23500. * @returns the JSON object
  23501. */
  23502. serialize(): any;
  23503. /**
  23504. * Creates a material from parsed material data
  23505. * @param parsedPostProcess defines parsed post process data
  23506. * @param scene defines the hosting scene
  23507. * @param rootUrl defines the root URL to use to load textures
  23508. * @returns a new post process
  23509. */
  23510. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23511. }
  23512. }
  23513. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23514. /** @hidden */
  23515. export var kernelBlurVaryingDeclaration: {
  23516. name: string;
  23517. shader: string;
  23518. };
  23519. }
  23520. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  23521. /** @hidden */
  23522. export var packingFunctions: {
  23523. name: string;
  23524. shader: string;
  23525. };
  23526. }
  23527. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23528. /** @hidden */
  23529. export var kernelBlurFragment: {
  23530. name: string;
  23531. shader: string;
  23532. };
  23533. }
  23534. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23535. /** @hidden */
  23536. export var kernelBlurFragment2: {
  23537. name: string;
  23538. shader: string;
  23539. };
  23540. }
  23541. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23542. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23543. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23544. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23545. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23546. /** @hidden */
  23547. export var kernelBlurPixelShader: {
  23548. name: string;
  23549. shader: string;
  23550. };
  23551. }
  23552. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23553. /** @hidden */
  23554. export var kernelBlurVertex: {
  23555. name: string;
  23556. shader: string;
  23557. };
  23558. }
  23559. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23560. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23561. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23562. /** @hidden */
  23563. export var kernelBlurVertexShader: {
  23564. name: string;
  23565. shader: string;
  23566. };
  23567. }
  23568. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23569. import { Vector2 } from "babylonjs/Maths/math.vector";
  23570. import { Nullable } from "babylonjs/types";
  23571. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23572. import { Camera } from "babylonjs/Cameras/camera";
  23573. import { Effect } from "babylonjs/Materials/effect";
  23574. import { Engine } from "babylonjs/Engines/engine";
  23575. import "babylonjs/Shaders/kernelBlur.fragment";
  23576. import "babylonjs/Shaders/kernelBlur.vertex";
  23577. import { Scene } from "babylonjs/scene";
  23578. /**
  23579. * The Blur Post Process which blurs an image based on a kernel and direction.
  23580. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23581. */
  23582. export class BlurPostProcess extends PostProcess {
  23583. private blockCompilation;
  23584. protected _kernel: number;
  23585. protected _idealKernel: number;
  23586. protected _packedFloat: boolean;
  23587. private _staticDefines;
  23588. /** The direction in which to blur the image. */
  23589. direction: Vector2;
  23590. /**
  23591. * Sets the length in pixels of the blur sample region
  23592. */
  23593. set kernel(v: number);
  23594. /**
  23595. * Gets the length in pixels of the blur sample region
  23596. */
  23597. get kernel(): number;
  23598. /**
  23599. * Sets wether or not the blur needs to unpack/repack floats
  23600. */
  23601. set packedFloat(v: boolean);
  23602. /**
  23603. * Gets wether or not the blur is unpacking/repacking floats
  23604. */
  23605. get packedFloat(): boolean;
  23606. /**
  23607. * Gets a string identifying the name of the class
  23608. * @returns "BlurPostProcess" string
  23609. */
  23610. getClassName(): string;
  23611. /**
  23612. * Creates a new instance BlurPostProcess
  23613. * @param name The name of the effect.
  23614. * @param direction The direction in which to blur the image.
  23615. * @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.
  23616. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23617. * @param camera The camera to apply the render pass to.
  23618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23619. * @param engine The engine which the post process will be applied. (default: current engine)
  23620. * @param reusable If the post process can be reused on the same frame. (default: false)
  23621. * @param textureType Type of textures used when performing the post process. (default: 0)
  23622. * @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)
  23623. */
  23624. 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);
  23625. /**
  23626. * Updates the effect with the current post process compile time values and recompiles the shader.
  23627. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23628. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23629. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23630. * @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
  23631. * @param onCompiled Called when the shader has been compiled.
  23632. * @param onError Called if there is an error when compiling a shader.
  23633. */
  23634. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23635. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23636. /**
  23637. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23638. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23639. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23640. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23641. * The gaps between physical kernels are compensated for in the weighting of the samples
  23642. * @param idealKernel Ideal blur kernel.
  23643. * @return Nearest best kernel.
  23644. */
  23645. protected _nearestBestKernel(idealKernel: number): number;
  23646. /**
  23647. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23648. * @param x The point on the Gaussian distribution to sample.
  23649. * @return the value of the Gaussian function at x.
  23650. */
  23651. protected _gaussianWeight(x: number): number;
  23652. /**
  23653. * Generates a string that can be used as a floating point number in GLSL.
  23654. * @param x Value to print.
  23655. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23656. * @return GLSL float string.
  23657. */
  23658. protected _glslFloat(x: number, decimalFigures?: number): string;
  23659. /** @hidden */
  23660. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23661. }
  23662. }
  23663. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23664. import { Scene } from "babylonjs/scene";
  23665. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23666. import { Plane } from "babylonjs/Maths/math.plane";
  23667. /**
  23668. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23669. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23670. * You can then easily use it as a reflectionTexture on a flat surface.
  23671. * In case the surface is not a plane, please consider relying on reflection probes.
  23672. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23673. */
  23674. export class MirrorTexture extends RenderTargetTexture {
  23675. private scene;
  23676. /**
  23677. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23678. * 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.
  23679. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23680. */
  23681. mirrorPlane: Plane;
  23682. /**
  23683. * Define the blur ratio used to blur the reflection if needed.
  23684. */
  23685. set blurRatio(value: number);
  23686. get blurRatio(): number;
  23687. /**
  23688. * Define the adaptive blur kernel used to blur the reflection if needed.
  23689. * This will autocompute the closest best match for the `blurKernel`
  23690. */
  23691. set adaptiveBlurKernel(value: number);
  23692. /**
  23693. * Define the blur kernel used to blur the reflection if needed.
  23694. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23695. */
  23696. set blurKernel(value: number);
  23697. /**
  23698. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23699. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23700. */
  23701. set blurKernelX(value: number);
  23702. get blurKernelX(): number;
  23703. /**
  23704. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23705. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23706. */
  23707. set blurKernelY(value: number);
  23708. get blurKernelY(): number;
  23709. private _autoComputeBlurKernel;
  23710. protected _onRatioRescale(): void;
  23711. private _updateGammaSpace;
  23712. private _imageProcessingConfigChangeObserver;
  23713. private _transformMatrix;
  23714. private _mirrorMatrix;
  23715. private _savedViewMatrix;
  23716. private _blurX;
  23717. private _blurY;
  23718. private _adaptiveBlurKernel;
  23719. private _blurKernelX;
  23720. private _blurKernelY;
  23721. private _blurRatio;
  23722. /**
  23723. * Instantiates a Mirror Texture.
  23724. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23725. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23726. * You can then easily use it as a reflectionTexture on a flat surface.
  23727. * In case the surface is not a plane, please consider relying on reflection probes.
  23728. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23729. * @param name
  23730. * @param size
  23731. * @param scene
  23732. * @param generateMipMaps
  23733. * @param type
  23734. * @param samplingMode
  23735. * @param generateDepthBuffer
  23736. */
  23737. constructor(name: string, size: number | {
  23738. width: number;
  23739. height: number;
  23740. } | {
  23741. ratio: number;
  23742. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23743. private _preparePostProcesses;
  23744. /**
  23745. * Clone the mirror texture.
  23746. * @returns the cloned texture
  23747. */
  23748. clone(): MirrorTexture;
  23749. /**
  23750. * Serialize the texture to a JSON representation you could use in Parse later on
  23751. * @returns the serialized JSON representation
  23752. */
  23753. serialize(): any;
  23754. /**
  23755. * Dispose the texture and release its associated resources.
  23756. */
  23757. dispose(): void;
  23758. }
  23759. }
  23760. declare module "babylonjs/Materials/Textures/texture" {
  23761. import { Observable } from "babylonjs/Misc/observable";
  23762. import { Nullable } from "babylonjs/types";
  23763. import { Matrix } from "babylonjs/Maths/math.vector";
  23764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23765. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23766. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23767. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23768. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23769. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23770. import { Scene } from "babylonjs/scene";
  23771. /**
  23772. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23773. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23774. */
  23775. export class Texture extends BaseTexture {
  23776. /**
  23777. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23778. */
  23779. static SerializeBuffers: boolean;
  23780. /**
  23781. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23782. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23783. */
  23784. static ForceSerializeBuffers: boolean;
  23785. /** @hidden */
  23786. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23787. /** @hidden */
  23788. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23789. /** @hidden */
  23790. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23791. /** nearest is mag = nearest and min = nearest and mip = linear */
  23792. static readonly NEAREST_SAMPLINGMODE: number;
  23793. /** nearest is mag = nearest and min = nearest and mip = linear */
  23794. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23795. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23796. static readonly BILINEAR_SAMPLINGMODE: number;
  23797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23798. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23799. /** Trilinear is mag = linear and min = linear and mip = linear */
  23800. static readonly TRILINEAR_SAMPLINGMODE: number;
  23801. /** Trilinear is mag = linear and min = linear and mip = linear */
  23802. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23803. /** mag = nearest and min = nearest and mip = nearest */
  23804. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23805. /** mag = nearest and min = linear and mip = nearest */
  23806. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23807. /** mag = nearest and min = linear and mip = linear */
  23808. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23809. /** mag = nearest and min = linear and mip = none */
  23810. static readonly NEAREST_LINEAR: number;
  23811. /** mag = nearest and min = nearest and mip = none */
  23812. static readonly NEAREST_NEAREST: number;
  23813. /** mag = linear and min = nearest and mip = nearest */
  23814. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23815. /** mag = linear and min = nearest and mip = linear */
  23816. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23817. /** mag = linear and min = linear and mip = none */
  23818. static readonly LINEAR_LINEAR: number;
  23819. /** mag = linear and min = nearest and mip = none */
  23820. static readonly LINEAR_NEAREST: number;
  23821. /** Explicit coordinates mode */
  23822. static readonly EXPLICIT_MODE: number;
  23823. /** Spherical coordinates mode */
  23824. static readonly SPHERICAL_MODE: number;
  23825. /** Planar coordinates mode */
  23826. static readonly PLANAR_MODE: number;
  23827. /** Cubic coordinates mode */
  23828. static readonly CUBIC_MODE: number;
  23829. /** Projection coordinates mode */
  23830. static readonly PROJECTION_MODE: number;
  23831. /** Inverse Cubic coordinates mode */
  23832. static readonly SKYBOX_MODE: number;
  23833. /** Inverse Cubic coordinates mode */
  23834. static readonly INVCUBIC_MODE: number;
  23835. /** Equirectangular coordinates mode */
  23836. static readonly EQUIRECTANGULAR_MODE: number;
  23837. /** Equirectangular Fixed coordinates mode */
  23838. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23839. /** Equirectangular Fixed Mirrored coordinates mode */
  23840. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23841. /** Texture is not repeating outside of 0..1 UVs */
  23842. static readonly CLAMP_ADDRESSMODE: number;
  23843. /** Texture is repeating outside of 0..1 UVs */
  23844. static readonly WRAP_ADDRESSMODE: number;
  23845. /** Texture is repeating and mirrored */
  23846. static readonly MIRROR_ADDRESSMODE: number;
  23847. /**
  23848. * 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
  23849. */
  23850. static UseSerializedUrlIfAny: boolean;
  23851. /**
  23852. * Define the url of the texture.
  23853. */
  23854. url: Nullable<string>;
  23855. /**
  23856. * Define an offset on the texture to offset the u coordinates of the UVs
  23857. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23858. */
  23859. uOffset: number;
  23860. /**
  23861. * Define an offset on the texture to offset the v coordinates of the UVs
  23862. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23863. */
  23864. vOffset: number;
  23865. /**
  23866. * Define an offset on the texture to scale the u coordinates of the UVs
  23867. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23868. */
  23869. uScale: number;
  23870. /**
  23871. * Define an offset on the texture to scale the v coordinates of the UVs
  23872. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23873. */
  23874. vScale: number;
  23875. /**
  23876. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23877. * @see https://doc.babylonjs.com/how_to/more_materials
  23878. */
  23879. uAng: number;
  23880. /**
  23881. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23882. * @see https://doc.babylonjs.com/how_to/more_materials
  23883. */
  23884. vAng: number;
  23885. /**
  23886. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23887. * @see https://doc.babylonjs.com/how_to/more_materials
  23888. */
  23889. wAng: number;
  23890. /**
  23891. * Defines the center of rotation (U)
  23892. */
  23893. uRotationCenter: number;
  23894. /**
  23895. * Defines the center of rotation (V)
  23896. */
  23897. vRotationCenter: number;
  23898. /**
  23899. * Defines the center of rotation (W)
  23900. */
  23901. wRotationCenter: number;
  23902. /**
  23903. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23904. */
  23905. homogeneousRotationInUVTransform: boolean;
  23906. /**
  23907. * Are mip maps generated for this texture or not.
  23908. */
  23909. get noMipmap(): boolean;
  23910. /**
  23911. * List of inspectable custom properties (used by the Inspector)
  23912. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23913. */
  23914. inspectableCustomProperties: Nullable<IInspectable[]>;
  23915. private _noMipmap;
  23916. /** @hidden */
  23917. _invertY: boolean;
  23918. private _rowGenerationMatrix;
  23919. private _cachedTextureMatrix;
  23920. private _projectionModeMatrix;
  23921. private _t0;
  23922. private _t1;
  23923. private _t2;
  23924. private _cachedUOffset;
  23925. private _cachedVOffset;
  23926. private _cachedUScale;
  23927. private _cachedVScale;
  23928. private _cachedUAng;
  23929. private _cachedVAng;
  23930. private _cachedWAng;
  23931. private _cachedProjectionMatrixId;
  23932. private _cachedURotationCenter;
  23933. private _cachedVRotationCenter;
  23934. private _cachedWRotationCenter;
  23935. private _cachedHomogeneousRotationInUVTransform;
  23936. private _cachedCoordinatesMode;
  23937. /** @hidden */
  23938. protected _initialSamplingMode: number;
  23939. /** @hidden */
  23940. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23941. private _deleteBuffer;
  23942. protected _format: Nullable<number>;
  23943. private _delayedOnLoad;
  23944. private _delayedOnError;
  23945. private _mimeType?;
  23946. private _loaderOptions?;
  23947. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23948. get mimeType(): string | undefined;
  23949. /**
  23950. * Observable triggered once the texture has been loaded.
  23951. */
  23952. onLoadObservable: Observable<Texture>;
  23953. protected _isBlocking: boolean;
  23954. /**
  23955. * Is the texture preventing material to render while loading.
  23956. * If false, a default texture will be used instead of the loading one during the preparation step.
  23957. */
  23958. set isBlocking(value: boolean);
  23959. get isBlocking(): boolean;
  23960. /**
  23961. * Get the current sampling mode associated with the texture.
  23962. */
  23963. get samplingMode(): number;
  23964. /**
  23965. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23966. */
  23967. get invertY(): boolean;
  23968. /**
  23969. * Instantiates a new texture.
  23970. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23971. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23972. * @param url defines the url of the picture to load as a texture
  23973. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23974. * @param noMipmap defines if the texture will require mip maps or not
  23975. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23976. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23977. * @param onLoad defines a callback triggered when the texture has been loaded
  23978. * @param onError defines a callback triggered when an error occurred during the loading session
  23979. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23980. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23981. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23982. * @param mimeType defines an optional mime type information
  23983. * @param loaderOptions options to be passed to the loader
  23984. */
  23985. 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);
  23986. /**
  23987. * Update the url (and optional buffer) of this texture if url was null during construction.
  23988. * @param url the url of the texture
  23989. * @param buffer the buffer of the texture (defaults to null)
  23990. * @param onLoad callback called when the texture is loaded (defaults to null)
  23991. */
  23992. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23993. /**
  23994. * Finish the loading sequence of a texture flagged as delayed load.
  23995. * @hidden
  23996. */
  23997. delayLoad(): void;
  23998. private _prepareRowForTextureGeneration;
  23999. /**
  24000. * Checks if the texture has the same transform matrix than another texture
  24001. * @param texture texture to check against
  24002. * @returns true if the transforms are the same, else false
  24003. */
  24004. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  24005. /**
  24006. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24007. * @returns the transform matrix of the texture.
  24008. */
  24009. getTextureMatrix(uBase?: number): Matrix;
  24010. /**
  24011. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24012. * @returns The reflection texture transform
  24013. */
  24014. getReflectionTextureMatrix(): Matrix;
  24015. /**
  24016. * Clones the texture.
  24017. * @returns the cloned texture
  24018. */
  24019. clone(): Texture;
  24020. /**
  24021. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24022. * @returns The JSON representation of the texture
  24023. */
  24024. serialize(): any;
  24025. /**
  24026. * Get the current class name of the texture useful for serialization or dynamic coding.
  24027. * @returns "Texture"
  24028. */
  24029. getClassName(): string;
  24030. /**
  24031. * Dispose the texture and release its associated resources.
  24032. */
  24033. dispose(): void;
  24034. /**
  24035. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24036. * @param parsedTexture Define the JSON representation of the texture
  24037. * @param scene Define the scene the parsed texture should be instantiated in
  24038. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24039. * @returns The parsed texture if successful
  24040. */
  24041. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24042. /**
  24043. * Creates a texture from its base 64 representation.
  24044. * @param data Define the base64 payload without the data: prefix
  24045. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24046. * @param scene Define the scene the texture should belong to
  24047. * @param noMipmap Forces the texture to not create mip map information if true
  24048. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24049. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24050. * @param onLoad define a callback triggered when the texture has been loaded
  24051. * @param onError define a callback triggered when an error occurred during the loading session
  24052. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24053. * @returns the created texture
  24054. */
  24055. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24056. /**
  24057. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24058. * @param data Define the base64 payload without the data: prefix
  24059. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24060. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24061. * @param scene Define the scene the texture should belong to
  24062. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24063. * @param noMipmap Forces the texture to not create mip map information if true
  24064. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24065. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24066. * @param onLoad define a callback triggered when the texture has been loaded
  24067. * @param onError define a callback triggered when an error occurred during the loading session
  24068. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24069. * @returns the created texture
  24070. */
  24071. 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;
  24072. }
  24073. }
  24074. declare module "babylonjs/Sprites/thinSprite" {
  24075. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  24076. import { Nullable } from "babylonjs/types";
  24077. /**
  24078. * ThinSprite Class used to represent a thin sprite
  24079. * This is the base class for sprites but can also directly be used with ThinEngine
  24080. * @see https://doc.babylonjs.com/babylon101/sprites
  24081. */
  24082. export class ThinSprite {
  24083. /** Gets or sets the cell index in the sprite sheet */
  24084. cellIndex: number;
  24085. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24086. cellRef: string;
  24087. /** Gets or sets the current world position */
  24088. position: IVector3Like;
  24089. /** Gets or sets the main color */
  24090. color: IColor4Like;
  24091. /** Gets or sets the width */
  24092. width: number;
  24093. /** Gets or sets the height */
  24094. height: number;
  24095. /** Gets or sets rotation angle */
  24096. angle: number;
  24097. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24098. invertU: boolean;
  24099. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24100. invertV: boolean;
  24101. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24102. isVisible: boolean;
  24103. /**
  24104. * Returns a boolean indicating if the animation is started
  24105. */
  24106. get animationStarted(): boolean;
  24107. /** Gets the initial key for the animation (setting it will restart the animation) */
  24108. get fromIndex(): number;
  24109. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24110. get toIndex(): number;
  24111. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24112. get loopAnimation(): boolean;
  24113. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24114. get delay(): number;
  24115. /** @hidden */
  24116. _xOffset: number;
  24117. /** @hidden */
  24118. _yOffset: number;
  24119. /** @hidden */
  24120. _xSize: number;
  24121. /** @hidden */
  24122. _ySize: number;
  24123. private _animationStarted;
  24124. protected _loopAnimation: boolean;
  24125. protected _fromIndex: number;
  24126. protected _toIndex: number;
  24127. protected _delay: number;
  24128. private _direction;
  24129. private _time;
  24130. private _onBaseAnimationEnd;
  24131. /**
  24132. * Creates a new Thin Sprite
  24133. */
  24134. constructor();
  24135. /**
  24136. * Starts an animation
  24137. * @param from defines the initial key
  24138. * @param to defines the end key
  24139. * @param loop defines if the animation must loop
  24140. * @param delay defines the start delay (in ms)
  24141. * @param onAnimationEnd defines a callback for when the animation ends
  24142. */
  24143. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24144. /** Stops current animation (if any) */
  24145. stopAnimation(): void;
  24146. /** @hidden */
  24147. _animate(deltaTime: number): void;
  24148. }
  24149. }
  24150. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  24151. /** @hidden */
  24152. export var imageProcessingCompatibility: {
  24153. name: string;
  24154. shader: string;
  24155. };
  24156. }
  24157. declare module "babylonjs/Shaders/sprites.fragment" {
  24158. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24159. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24160. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  24161. /** @hidden */
  24162. export var spritesPixelShader: {
  24163. name: string;
  24164. shader: string;
  24165. };
  24166. }
  24167. declare module "babylonjs/Shaders/sprites.vertex" {
  24168. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24169. /** @hidden */
  24170. export var spritesVertexShader: {
  24171. name: string;
  24172. shader: string;
  24173. };
  24174. }
  24175. declare module "babylonjs/Sprites/spriteRenderer" {
  24176. import { Nullable } from "babylonjs/types";
  24177. import { IMatrixLike } from "babylonjs/Maths/math.like";
  24178. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24179. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24180. import { ISize } from "babylonjs/Maths/math.size";
  24181. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  24182. import { Scene } from "babylonjs/scene";
  24183. import "babylonjs/Engines/Extensions/engine.alpha";
  24184. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  24185. import "babylonjs/Shaders/sprites.fragment";
  24186. import "babylonjs/Shaders/sprites.vertex";
  24187. /**
  24188. * Class used to render sprites.
  24189. *
  24190. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24191. */
  24192. export class SpriteRenderer {
  24193. /**
  24194. * Defines the texture of the spritesheet
  24195. */
  24196. texture: Nullable<ThinTexture>;
  24197. /**
  24198. * Defines the default width of a cell in the spritesheet
  24199. */
  24200. cellWidth: number;
  24201. /**
  24202. * Defines the default height of a cell in the spritesheet
  24203. */
  24204. cellHeight: number;
  24205. /**
  24206. * Blend mode use to render the particle, it can be any of
  24207. * the static Constants.ALPHA_x properties provided in this class.
  24208. * Default value is Constants.ALPHA_COMBINE
  24209. */
  24210. blendMode: number;
  24211. /**
  24212. * Gets or sets a boolean indicating if alpha mode is automatically
  24213. * reset.
  24214. */
  24215. autoResetAlpha: boolean;
  24216. /**
  24217. * Disables writing to the depth buffer when rendering the sprites.
  24218. * It can be handy to disable depth writing when using textures without alpha channel
  24219. * and setting some specific blend modes.
  24220. */
  24221. disableDepthWrite: boolean;
  24222. /**
  24223. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24224. */
  24225. fogEnabled: boolean;
  24226. /**
  24227. * Gets the capacity of the manager
  24228. */
  24229. get capacity(): number;
  24230. private readonly _engine;
  24231. private readonly _useVAO;
  24232. private readonly _useInstancing;
  24233. private readonly _scene;
  24234. private readonly _capacity;
  24235. private readonly _epsilon;
  24236. private _vertexBufferSize;
  24237. private _vertexData;
  24238. private _buffer;
  24239. private _vertexBuffers;
  24240. private _spriteBuffer;
  24241. private _indexBuffer;
  24242. private _effectBase;
  24243. private _effectFog;
  24244. private _vertexArrayObject;
  24245. /**
  24246. * Creates a new sprite Renderer
  24247. * @param engine defines the engine the renderer works with
  24248. * @param capacity defines the maximum allowed number of sprites
  24249. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24250. * @param scene defines the hosting scene
  24251. */
  24252. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24253. /**
  24254. * Render all child sprites
  24255. * @param sprites defines the list of sprites to render
  24256. * @param deltaTime defines the time since last frame
  24257. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24258. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24259. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24260. */
  24261. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24262. private _appendSpriteVertex;
  24263. /**
  24264. * Release associated resources
  24265. */
  24266. dispose(): void;
  24267. }
  24268. }
  24269. declare module "babylonjs/Sprites/spriteManager" {
  24270. import { IDisposable, Scene } from "babylonjs/scene";
  24271. import { Nullable } from "babylonjs/types";
  24272. import { Observable } from "babylonjs/Misc/observable";
  24273. import { Sprite } from "babylonjs/Sprites/sprite";
  24274. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24275. import { Camera } from "babylonjs/Cameras/camera";
  24276. import { Texture } from "babylonjs/Materials/Textures/texture";
  24277. import { Ray } from "babylonjs/Culling/ray";
  24278. /**
  24279. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24280. */
  24281. export interface ISpriteManager extends IDisposable {
  24282. /**
  24283. * Gets manager's name
  24284. */
  24285. name: string;
  24286. /**
  24287. * Restricts the camera to viewing objects with the same layerMask.
  24288. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24289. */
  24290. layerMask: number;
  24291. /**
  24292. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24293. */
  24294. isPickable: boolean;
  24295. /**
  24296. * Gets the hosting scene
  24297. */
  24298. scene: Scene;
  24299. /**
  24300. * Specifies the rendering group id for this mesh (0 by default)
  24301. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24302. */
  24303. renderingGroupId: number;
  24304. /**
  24305. * Defines the list of sprites managed by the manager.
  24306. */
  24307. sprites: Array<Sprite>;
  24308. /**
  24309. * Gets or sets the spritesheet texture
  24310. */
  24311. texture: Texture;
  24312. /** Defines the default width of a cell in the spritesheet */
  24313. cellWidth: number;
  24314. /** Defines the default height of a cell in the spritesheet */
  24315. cellHeight: number;
  24316. /**
  24317. * Tests the intersection of a sprite with a specific ray.
  24318. * @param ray The ray we are sending to test the collision
  24319. * @param camera The camera space we are sending rays in
  24320. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24321. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24322. * @returns picking info or null.
  24323. */
  24324. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24325. /**
  24326. * Intersects the sprites with a ray
  24327. * @param ray defines the ray to intersect with
  24328. * @param camera defines the current active camera
  24329. * @param predicate defines a predicate used to select candidate sprites
  24330. * @returns null if no hit or a PickingInfo array
  24331. */
  24332. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24333. /**
  24334. * Renders the list of sprites on screen.
  24335. */
  24336. render(): void;
  24337. }
  24338. /**
  24339. * Class used to manage multiple sprites on the same spritesheet
  24340. * @see https://doc.babylonjs.com/babylon101/sprites
  24341. */
  24342. export class SpriteManager implements ISpriteManager {
  24343. /** defines the manager's name */
  24344. name: string;
  24345. /** Define the Url to load snippets */
  24346. static SnippetUrl: string;
  24347. /** Snippet ID if the manager was created from the snippet server */
  24348. snippetId: string;
  24349. /** Gets the list of sprites */
  24350. sprites: Sprite[];
  24351. /** Gets or sets the rendering group id (0 by default) */
  24352. renderingGroupId: number;
  24353. /** Gets or sets camera layer mask */
  24354. layerMask: number;
  24355. /** Gets or sets a boolean indicating if the sprites are pickable */
  24356. isPickable: boolean;
  24357. /**
  24358. * An event triggered when the manager is disposed.
  24359. */
  24360. onDisposeObservable: Observable<SpriteManager>;
  24361. /**
  24362. * Callback called when the manager is disposed
  24363. */
  24364. set onDispose(callback: () => void);
  24365. /**
  24366. * Gets or sets the unique id of the sprite
  24367. */
  24368. uniqueId: number;
  24369. /**
  24370. * Gets the array of sprites
  24371. */
  24372. get children(): Sprite[];
  24373. /**
  24374. * Gets the hosting scene
  24375. */
  24376. get scene(): Scene;
  24377. /**
  24378. * Gets the capacity of the manager
  24379. */
  24380. get capacity(): number;
  24381. /**
  24382. * Gets or sets the spritesheet texture
  24383. */
  24384. get texture(): Texture;
  24385. set texture(value: Texture);
  24386. /** Defines the default width of a cell in the spritesheet */
  24387. get cellWidth(): number;
  24388. set cellWidth(value: number);
  24389. /** Defines the default height of a cell in the spritesheet */
  24390. get cellHeight(): number;
  24391. set cellHeight(value: number);
  24392. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24393. get fogEnabled(): boolean;
  24394. set fogEnabled(value: boolean);
  24395. /**
  24396. * Blend mode use to render the particle, it can be any of
  24397. * the static Constants.ALPHA_x properties provided in this class.
  24398. * Default value is Constants.ALPHA_COMBINE
  24399. */
  24400. get blendMode(): number;
  24401. set blendMode(blendMode: number);
  24402. /** Disables writing to the depth buffer when rendering the sprites.
  24403. * It can be handy to disable depth writing when using textures without alpha channel
  24404. * and setting some specific blend modes.
  24405. */
  24406. disableDepthWrite: boolean;
  24407. private _spriteRenderer;
  24408. /** Associative array from JSON sprite data file */
  24409. private _cellData;
  24410. /** Array of sprite names from JSON sprite data file */
  24411. private _spriteMap;
  24412. /** True when packed cell data from JSON file is ready*/
  24413. private _packedAndReady;
  24414. private _textureContent;
  24415. private _onDisposeObserver;
  24416. private _fromPacked;
  24417. private _scene;
  24418. /**
  24419. * Creates a new sprite manager
  24420. * @param name defines the manager's name
  24421. * @param imgUrl defines the sprite sheet url
  24422. * @param capacity defines the maximum allowed number of sprites
  24423. * @param cellSize defines the size of a sprite cell
  24424. * @param scene defines the hosting scene
  24425. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24426. * @param samplingMode defines the smapling mode to use with spritesheet
  24427. * @param fromPacked set to false; do not alter
  24428. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24429. */
  24430. constructor(
  24431. /** defines the manager's name */
  24432. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24433. /**
  24434. * Returns the string "SpriteManager"
  24435. * @returns "SpriteManager"
  24436. */
  24437. getClassName(): string;
  24438. private _makePacked;
  24439. private _checkTextureAlpha;
  24440. /**
  24441. * Intersects the sprites with a ray
  24442. * @param ray defines the ray to intersect with
  24443. * @param camera defines the current active camera
  24444. * @param predicate defines a predicate used to select candidate sprites
  24445. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24446. * @returns null if no hit or a PickingInfo
  24447. */
  24448. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24449. /**
  24450. * Intersects the sprites with a ray
  24451. * @param ray defines the ray to intersect with
  24452. * @param camera defines the current active camera
  24453. * @param predicate defines a predicate used to select candidate sprites
  24454. * @returns null if no hit or a PickingInfo array
  24455. */
  24456. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24457. /**
  24458. * Render all child sprites
  24459. */
  24460. render(): void;
  24461. private _customUpdate;
  24462. /**
  24463. * Release associated resources
  24464. */
  24465. dispose(): void;
  24466. /**
  24467. * Serializes the sprite manager to a JSON object
  24468. * @param serializeTexture defines if the texture must be serialized as well
  24469. * @returns the JSON object
  24470. */
  24471. serialize(serializeTexture?: boolean): any;
  24472. /**
  24473. * Parses a JSON object to create a new sprite manager.
  24474. * @param parsedManager The JSON object to parse
  24475. * @param scene The scene to create the sprite managerin
  24476. * @param rootUrl The root url to use to load external dependencies like texture
  24477. * @returns the new sprite manager
  24478. */
  24479. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24480. /**
  24481. * Creates a sprite manager from a snippet saved in a remote file
  24482. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24483. * @param url defines the url to load from
  24484. * @param scene defines the hosting scene
  24485. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24486. * @returns a promise that will resolve to the new sprite manager
  24487. */
  24488. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24489. /**
  24490. * Creates a sprite manager from a snippet saved by the sprite editor
  24491. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24492. * @param scene defines the hosting scene
  24493. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24494. * @returns a promise that will resolve to the new sprite manager
  24495. */
  24496. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24497. }
  24498. }
  24499. declare module "babylonjs/Sprites/sprite" {
  24500. import { Vector3 } from "babylonjs/Maths/math.vector";
  24501. import { Nullable } from "babylonjs/types";
  24502. import { ActionManager } from "babylonjs/Actions/actionManager";
  24503. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  24504. import { Color4 } from "babylonjs/Maths/math.color";
  24505. import { Observable } from "babylonjs/Misc/observable";
  24506. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24507. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24508. import { Animation } from "babylonjs/Animations/animation";
  24509. /**
  24510. * Class used to represent a sprite
  24511. * @see https://doc.babylonjs.com/babylon101/sprites
  24512. */
  24513. export class Sprite extends ThinSprite implements IAnimatable {
  24514. /** defines the name */
  24515. name: string;
  24516. /** Gets or sets the current world position */
  24517. position: Vector3;
  24518. /** Gets or sets the main color */
  24519. color: Color4;
  24520. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24521. disposeWhenFinishedAnimating: boolean;
  24522. /** Gets the list of attached animations */
  24523. animations: Nullable<Array<Animation>>;
  24524. /** Gets or sets a boolean indicating if the sprite can be picked */
  24525. isPickable: boolean;
  24526. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24527. useAlphaForPicking: boolean;
  24528. /**
  24529. * Gets or sets the associated action manager
  24530. */
  24531. actionManager: Nullable<ActionManager>;
  24532. /**
  24533. * An event triggered when the control has been disposed
  24534. */
  24535. onDisposeObservable: Observable<Sprite>;
  24536. private _manager;
  24537. private _onAnimationEnd;
  24538. /**
  24539. * Gets or sets the sprite size
  24540. */
  24541. get size(): number;
  24542. set size(value: number);
  24543. /**
  24544. * Gets or sets the unique id of the sprite
  24545. */
  24546. uniqueId: number;
  24547. /**
  24548. * Gets the manager of this sprite
  24549. */
  24550. get manager(): ISpriteManager;
  24551. /**
  24552. * Creates a new Sprite
  24553. * @param name defines the name
  24554. * @param manager defines the manager
  24555. */
  24556. constructor(
  24557. /** defines the name */
  24558. name: string, manager: ISpriteManager);
  24559. /**
  24560. * Returns the string "Sprite"
  24561. * @returns "Sprite"
  24562. */
  24563. getClassName(): string;
  24564. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24565. get fromIndex(): number;
  24566. set fromIndex(value: number);
  24567. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24568. get toIndex(): number;
  24569. set toIndex(value: number);
  24570. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24571. get loopAnimation(): boolean;
  24572. set loopAnimation(value: boolean);
  24573. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24574. get delay(): number;
  24575. set delay(value: number);
  24576. /**
  24577. * Starts an animation
  24578. * @param from defines the initial key
  24579. * @param to defines the end key
  24580. * @param loop defines if the animation must loop
  24581. * @param delay defines the start delay (in ms)
  24582. * @param onAnimationEnd defines a callback to call when animation ends
  24583. */
  24584. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24585. private _endAnimation;
  24586. /** Release associated resources */
  24587. dispose(): void;
  24588. /**
  24589. * Serializes the sprite to a JSON object
  24590. * @returns the JSON object
  24591. */
  24592. serialize(): any;
  24593. /**
  24594. * Parses a JSON object to create a new sprite
  24595. * @param parsedSprite The JSON object to parse
  24596. * @param manager defines the hosting manager
  24597. * @returns the new sprite
  24598. */
  24599. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24600. }
  24601. }
  24602. declare module "babylonjs/Collisions/pickingInfo" {
  24603. import { Nullable } from "babylonjs/types";
  24604. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  24605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24606. import { Sprite } from "babylonjs/Sprites/sprite";
  24607. import { Ray } from "babylonjs/Culling/ray";
  24608. /**
  24609. * Information about the result of picking within a scene
  24610. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24611. */
  24612. export class PickingInfo {
  24613. /** @hidden */
  24614. _pickingUnavailable: boolean;
  24615. /**
  24616. * If the pick collided with an object
  24617. */
  24618. hit: boolean;
  24619. /**
  24620. * Distance away where the pick collided
  24621. */
  24622. distance: number;
  24623. /**
  24624. * The location of pick collision
  24625. */
  24626. pickedPoint: Nullable<Vector3>;
  24627. /**
  24628. * The mesh corresponding the the pick collision
  24629. */
  24630. pickedMesh: Nullable<AbstractMesh>;
  24631. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24632. bu: number;
  24633. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24634. bv: number;
  24635. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24636. faceId: number;
  24637. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24638. subMeshFaceId: number;
  24639. /** Id of the the submesh that was picked */
  24640. subMeshId: number;
  24641. /** If a sprite was picked, this will be the sprite the pick collided with */
  24642. pickedSprite: Nullable<Sprite>;
  24643. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24644. thinInstanceIndex: number;
  24645. /**
  24646. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24647. */
  24648. originMesh: Nullable<AbstractMesh>;
  24649. /**
  24650. * The ray that was used to perform the picking.
  24651. */
  24652. ray: Nullable<Ray>;
  24653. /**
  24654. * Gets the normal correspodning to the face the pick collided with
  24655. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24656. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24657. * @returns The normal correspodning to the face the pick collided with
  24658. */
  24659. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24660. /**
  24661. * Gets the texture coordinates of where the pick occured
  24662. * @returns the vector containing the coordnates of the texture
  24663. */
  24664. getTextureCoordinates(): Nullable<Vector2>;
  24665. }
  24666. }
  24667. declare module "babylonjs/Events/pointerEvents" {
  24668. import { Nullable } from "babylonjs/types";
  24669. import { Vector2 } from "babylonjs/Maths/math.vector";
  24670. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24671. import { Ray } from "babylonjs/Culling/ray";
  24672. /**
  24673. * Gather the list of pointer event types as constants.
  24674. */
  24675. export class PointerEventTypes {
  24676. /**
  24677. * 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.
  24678. */
  24679. static readonly POINTERDOWN: number;
  24680. /**
  24681. * The pointerup event is fired when a pointer is no longer active.
  24682. */
  24683. static readonly POINTERUP: number;
  24684. /**
  24685. * The pointermove event is fired when a pointer changes coordinates.
  24686. */
  24687. static readonly POINTERMOVE: number;
  24688. /**
  24689. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24690. */
  24691. static readonly POINTERWHEEL: number;
  24692. /**
  24693. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24694. */
  24695. static readonly POINTERPICK: number;
  24696. /**
  24697. * The pointertap event is fired when a the object has been touched and released without drag.
  24698. */
  24699. static readonly POINTERTAP: number;
  24700. /**
  24701. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24702. */
  24703. static readonly POINTERDOUBLETAP: number;
  24704. }
  24705. /**
  24706. * Base class of pointer info types.
  24707. */
  24708. export class PointerInfoBase {
  24709. /**
  24710. * Defines the type of event (PointerEventTypes)
  24711. */
  24712. type: number;
  24713. /**
  24714. * Defines the related dom event
  24715. */
  24716. event: PointerEvent | MouseWheelEvent;
  24717. /**
  24718. * Instantiates the base class of pointers info.
  24719. * @param type Defines the type of event (PointerEventTypes)
  24720. * @param event Defines the related dom event
  24721. */
  24722. constructor(
  24723. /**
  24724. * Defines the type of event (PointerEventTypes)
  24725. */
  24726. type: number,
  24727. /**
  24728. * Defines the related dom event
  24729. */
  24730. event: PointerEvent | MouseWheelEvent);
  24731. }
  24732. /**
  24733. * This class is used to store pointer related info for the onPrePointerObservable event.
  24734. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24735. */
  24736. export class PointerInfoPre extends PointerInfoBase {
  24737. /**
  24738. * Ray from a pointer if availible (eg. 6dof controller)
  24739. */
  24740. ray: Nullable<Ray>;
  24741. /**
  24742. * Defines the local position of the pointer on the canvas.
  24743. */
  24744. localPosition: Vector2;
  24745. /**
  24746. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24747. */
  24748. skipOnPointerObservable: boolean;
  24749. /**
  24750. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24751. * @param type Defines the type of event (PointerEventTypes)
  24752. * @param event Defines the related dom event
  24753. * @param localX Defines the local x coordinates of the pointer when the event occured
  24754. * @param localY Defines the local y coordinates of the pointer when the event occured
  24755. */
  24756. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24757. }
  24758. /**
  24759. * This type contains all the data related to a pointer event in Babylon.js.
  24760. * 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.
  24761. */
  24762. export class PointerInfo extends PointerInfoBase {
  24763. /**
  24764. * Defines the picking info associated to the info (if any)\
  24765. */
  24766. pickInfo: Nullable<PickingInfo>;
  24767. /**
  24768. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24769. * @param type Defines the type of event (PointerEventTypes)
  24770. * @param event Defines the related dom event
  24771. * @param pickInfo Defines the picking info associated to the info (if any)\
  24772. */
  24773. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24774. /**
  24775. * Defines the picking info associated to the info (if any)\
  24776. */
  24777. pickInfo: Nullable<PickingInfo>);
  24778. }
  24779. /**
  24780. * Data relating to a touch event on the screen.
  24781. */
  24782. export interface PointerTouch {
  24783. /**
  24784. * X coordinate of touch.
  24785. */
  24786. x: number;
  24787. /**
  24788. * Y coordinate of touch.
  24789. */
  24790. y: number;
  24791. /**
  24792. * Id of touch. Unique for each finger.
  24793. */
  24794. pointerId: number;
  24795. /**
  24796. * Event type passed from DOM.
  24797. */
  24798. type: any;
  24799. }
  24800. }
  24801. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  24802. import { Observable } from "babylonjs/Misc/observable";
  24803. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24804. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24805. /**
  24806. * Manage the mouse inputs to control the movement of a free camera.
  24807. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24808. */
  24809. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24810. /**
  24811. * Define if touch is enabled in the mouse input
  24812. */
  24813. touchEnabled: boolean;
  24814. /**
  24815. * Defines the camera the input is attached to.
  24816. */
  24817. camera: FreeCamera;
  24818. /**
  24819. * Defines the buttons associated with the input to handle camera move.
  24820. */
  24821. buttons: number[];
  24822. /**
  24823. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24824. */
  24825. angularSensibility: number;
  24826. private _pointerInput;
  24827. private _onMouseMove;
  24828. private _observer;
  24829. private previousPosition;
  24830. /**
  24831. * Observable for when a pointer move event occurs containing the move offset
  24832. */
  24833. onPointerMovedObservable: Observable<{
  24834. offsetX: number;
  24835. offsetY: number;
  24836. }>;
  24837. /**
  24838. * @hidden
  24839. * If the camera should be rotated automatically based on pointer movement
  24840. */
  24841. _allowCameraRotation: boolean;
  24842. /**
  24843. * Manage the mouse inputs to control the movement of a free camera.
  24844. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24845. * @param touchEnabled Defines if touch is enabled or not
  24846. */
  24847. constructor(
  24848. /**
  24849. * Define if touch is enabled in the mouse input
  24850. */
  24851. touchEnabled?: boolean);
  24852. /**
  24853. * Attach the input controls to a specific dom element to get the input from.
  24854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24855. */
  24856. attachControl(noPreventDefault?: boolean): void;
  24857. /**
  24858. * Called on JS contextmenu event.
  24859. * Override this method to provide functionality.
  24860. */
  24861. protected onContextMenu(evt: PointerEvent): void;
  24862. /**
  24863. * Detach the current controls from the specified dom element.
  24864. */
  24865. detachControl(): void;
  24866. /**
  24867. * Gets the class name of the current intput.
  24868. * @returns the class name
  24869. */
  24870. getClassName(): string;
  24871. /**
  24872. * Get the friendly name associated with the input class.
  24873. * @returns the input friendly name
  24874. */
  24875. getSimpleName(): string;
  24876. }
  24877. }
  24878. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  24879. import { Observable } from "babylonjs/Misc/observable";
  24880. import { Camera } from "babylonjs/Cameras/camera";
  24881. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24882. /**
  24883. * Base class for mouse wheel input..
  24884. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24885. * for example usage.
  24886. */
  24887. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24888. /**
  24889. * Defines the camera the input is attached to.
  24890. */
  24891. abstract camera: Camera;
  24892. /**
  24893. * How fast is the camera moves in relation to X axis mouseWheel events.
  24894. * Use negative value to reverse direction.
  24895. */
  24896. wheelPrecisionX: number;
  24897. /**
  24898. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24899. * Use negative value to reverse direction.
  24900. */
  24901. wheelPrecisionY: number;
  24902. /**
  24903. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24904. * Use negative value to reverse direction.
  24905. */
  24906. wheelPrecisionZ: number;
  24907. /**
  24908. * Observable for when a mouse wheel move event occurs.
  24909. */
  24910. onChangedObservable: Observable<{
  24911. wheelDeltaX: number;
  24912. wheelDeltaY: number;
  24913. wheelDeltaZ: number;
  24914. }>;
  24915. private _wheel;
  24916. private _observer;
  24917. /**
  24918. * Attach the input controls to a specific dom element to get the input from.
  24919. * @param noPreventDefault Defines whether event caught by the controls
  24920. * should call preventdefault().
  24921. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24922. */
  24923. attachControl(noPreventDefault?: boolean): void;
  24924. /**
  24925. * Detach the current controls from the specified dom element.
  24926. */
  24927. detachControl(): void;
  24928. /**
  24929. * Called for each rendered frame.
  24930. */
  24931. checkInputs(): void;
  24932. /**
  24933. * Gets the class name of the current intput.
  24934. * @returns the class name
  24935. */
  24936. getClassName(): string;
  24937. /**
  24938. * Get the friendly name associated with the input class.
  24939. * @returns the input friendly name
  24940. */
  24941. getSimpleName(): string;
  24942. /**
  24943. * Incremental value of multiple mouse wheel movements of the X axis.
  24944. * Should be zero-ed when read.
  24945. */
  24946. protected _wheelDeltaX: number;
  24947. /**
  24948. * Incremental value of multiple mouse wheel movements of the Y axis.
  24949. * Should be zero-ed when read.
  24950. */
  24951. protected _wheelDeltaY: number;
  24952. /**
  24953. * Incremental value of multiple mouse wheel movements of the Z axis.
  24954. * Should be zero-ed when read.
  24955. */
  24956. protected _wheelDeltaZ: number;
  24957. /**
  24958. * Firefox uses a different scheme to report scroll distances to other
  24959. * browsers. Rather than use complicated methods to calculate the exact
  24960. * multiple we need to apply, let's just cheat and use a constant.
  24961. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24962. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24963. */
  24964. private readonly _ffMultiplier;
  24965. /**
  24966. * Different event attributes for wheel data fall into a few set ranges.
  24967. * Some relevant but dated date here:
  24968. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24969. */
  24970. private readonly _normalize;
  24971. }
  24972. }
  24973. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  24974. import { Nullable } from "babylonjs/types";
  24975. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24976. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  24977. import { Coordinate } from "babylonjs/Maths/math.axis";
  24978. /**
  24979. * Manage the mouse wheel inputs to control a free camera.
  24980. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24981. */
  24982. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24983. /**
  24984. * Defines the camera the input is attached to.
  24985. */
  24986. camera: FreeCamera;
  24987. /**
  24988. * Gets the class name of the current input.
  24989. * @returns the class name
  24990. */
  24991. getClassName(): string;
  24992. /**
  24993. * Set which movement axis (relative to camera's orientation) the mouse
  24994. * wheel's X axis controls.
  24995. * @param axis The axis to be moved. Set null to clear.
  24996. */
  24997. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24998. /**
  24999. * Get the configured movement axis (relative to camera's orientation) the
  25000. * mouse wheel's X axis controls.
  25001. * @returns The configured axis or null if none.
  25002. */
  25003. get wheelXMoveRelative(): Nullable<Coordinate>;
  25004. /**
  25005. * Set which movement axis (relative to camera's orientation) the mouse
  25006. * wheel's Y axis controls.
  25007. * @param axis The axis to be moved. Set null to clear.
  25008. */
  25009. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  25010. /**
  25011. * Get the configured movement axis (relative to camera's orientation) the
  25012. * mouse wheel's Y axis controls.
  25013. * @returns The configured axis or null if none.
  25014. */
  25015. get wheelYMoveRelative(): Nullable<Coordinate>;
  25016. /**
  25017. * Set which movement axis (relative to camera's orientation) the mouse
  25018. * wheel's Z axis controls.
  25019. * @param axis The axis to be moved. Set null to clear.
  25020. */
  25021. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  25022. /**
  25023. * Get the configured movement axis (relative to camera's orientation) the
  25024. * mouse wheel's Z axis controls.
  25025. * @returns The configured axis or null if none.
  25026. */
  25027. get wheelZMoveRelative(): Nullable<Coordinate>;
  25028. /**
  25029. * Set which rotation axis (relative to camera's orientation) the mouse
  25030. * wheel's X axis controls.
  25031. * @param axis The axis to be moved. Set null to clear.
  25032. */
  25033. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25034. /**
  25035. * Get the configured rotation axis (relative to camera's orientation) the
  25036. * mouse wheel's X axis controls.
  25037. * @returns The configured axis or null if none.
  25038. */
  25039. get wheelXRotateRelative(): Nullable<Coordinate>;
  25040. /**
  25041. * Set which rotation axis (relative to camera's orientation) the mouse
  25042. * wheel's Y axis controls.
  25043. * @param axis The axis to be moved. Set null to clear.
  25044. */
  25045. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25046. /**
  25047. * Get the configured rotation axis (relative to camera's orientation) the
  25048. * mouse wheel's Y axis controls.
  25049. * @returns The configured axis or null if none.
  25050. */
  25051. get wheelYRotateRelative(): Nullable<Coordinate>;
  25052. /**
  25053. * Set which rotation axis (relative to camera's orientation) the mouse
  25054. * wheel's Z axis controls.
  25055. * @param axis The axis to be moved. Set null to clear.
  25056. */
  25057. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25058. /**
  25059. * Get the configured rotation axis (relative to camera's orientation) the
  25060. * mouse wheel's Z axis controls.
  25061. * @returns The configured axis or null if none.
  25062. */
  25063. get wheelZRotateRelative(): Nullable<Coordinate>;
  25064. /**
  25065. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25066. * controls.
  25067. * @param axis The axis to be moved. Set null to clear.
  25068. */
  25069. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25070. /**
  25071. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25072. * X axis controls.
  25073. * @returns The configured axis or null if none.
  25074. */
  25075. get wheelXMoveScene(): Nullable<Coordinate>;
  25076. /**
  25077. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25078. * controls.
  25079. * @param axis The axis to be moved. Set null to clear.
  25080. */
  25081. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25082. /**
  25083. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25084. * Y axis controls.
  25085. * @returns The configured axis or null if none.
  25086. */
  25087. get wheelYMoveScene(): Nullable<Coordinate>;
  25088. /**
  25089. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25090. * controls.
  25091. * @param axis The axis to be moved. Set null to clear.
  25092. */
  25093. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25094. /**
  25095. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25096. * Z axis controls.
  25097. * @returns The configured axis or null if none.
  25098. */
  25099. get wheelZMoveScene(): Nullable<Coordinate>;
  25100. /**
  25101. * Called for each rendered frame.
  25102. */
  25103. checkInputs(): void;
  25104. private _moveRelative;
  25105. private _rotateRelative;
  25106. private _moveScene;
  25107. /**
  25108. * These are set to the desired default behaviour.
  25109. */
  25110. private _wheelXAction;
  25111. private _wheelXActionCoordinate;
  25112. private _wheelYAction;
  25113. private _wheelYActionCoordinate;
  25114. private _wheelZAction;
  25115. private _wheelZActionCoordinate;
  25116. /**
  25117. * Update the camera according to any configured properties for the 3
  25118. * mouse-wheel axis.
  25119. */
  25120. private _updateCamera;
  25121. }
  25122. }
  25123. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  25124. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25125. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25126. /**
  25127. * Manage the touch inputs to control the movement of a free camera.
  25128. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25129. */
  25130. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25131. /**
  25132. * Define if mouse events can be treated as touch events
  25133. */
  25134. allowMouse: boolean;
  25135. /**
  25136. * Defines the camera the input is attached to.
  25137. */
  25138. camera: FreeCamera;
  25139. /**
  25140. * Defines the touch sensibility for rotation.
  25141. * The higher the faster.
  25142. */
  25143. touchAngularSensibility: number;
  25144. /**
  25145. * Defines the touch sensibility for move.
  25146. * The higher the faster.
  25147. */
  25148. touchMoveSensibility: number;
  25149. private _offsetX;
  25150. private _offsetY;
  25151. private _pointerPressed;
  25152. private _pointerInput?;
  25153. private _observer;
  25154. private _onLostFocus;
  25155. /**
  25156. * Manage the touch inputs to control the movement of a free camera.
  25157. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25158. * @param allowMouse Defines if mouse events can be treated as touch events
  25159. */
  25160. constructor(
  25161. /**
  25162. * Define if mouse events can be treated as touch events
  25163. */
  25164. allowMouse?: boolean);
  25165. /**
  25166. * Attach the input controls to a specific dom element to get the input from.
  25167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25168. */
  25169. attachControl(noPreventDefault?: boolean): void;
  25170. /**
  25171. * Detach the current controls from the specified dom element.
  25172. */
  25173. detachControl(): void;
  25174. /**
  25175. * Update the current camera state depending on the inputs that have been used this frame.
  25176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25177. */
  25178. checkInputs(): void;
  25179. /**
  25180. * Gets the class name of the current intput.
  25181. * @returns the class name
  25182. */
  25183. getClassName(): string;
  25184. /**
  25185. * Get the friendly name associated with the input class.
  25186. * @returns the input friendly name
  25187. */
  25188. getSimpleName(): string;
  25189. }
  25190. }
  25191. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  25192. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25193. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25194. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  25195. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  25196. import { Nullable } from "babylonjs/types";
  25197. /**
  25198. * Default Inputs manager for the FreeCamera.
  25199. * It groups all the default supported inputs for ease of use.
  25200. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25201. */
  25202. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25203. /**
  25204. * @hidden
  25205. */
  25206. _mouseInput: Nullable<FreeCameraMouseInput>;
  25207. /**
  25208. * @hidden
  25209. */
  25210. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25211. /**
  25212. * Instantiates a new FreeCameraInputsManager.
  25213. * @param camera Defines the camera the inputs belong to
  25214. */
  25215. constructor(camera: FreeCamera);
  25216. /**
  25217. * Add keyboard input support to the input manager.
  25218. * @returns the current input manager
  25219. */
  25220. addKeyboard(): FreeCameraInputsManager;
  25221. /**
  25222. * Add mouse input support to the input manager.
  25223. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25224. * @returns the current input manager
  25225. */
  25226. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25227. /**
  25228. * Removes the mouse input support from the manager
  25229. * @returns the current input manager
  25230. */
  25231. removeMouse(): FreeCameraInputsManager;
  25232. /**
  25233. * Add mouse wheel input support to the input manager.
  25234. * @returns the current input manager
  25235. */
  25236. addMouseWheel(): FreeCameraInputsManager;
  25237. /**
  25238. * Removes the mouse wheel input support from the manager
  25239. * @returns the current input manager
  25240. */
  25241. removeMouseWheel(): FreeCameraInputsManager;
  25242. /**
  25243. * Add touch input support to the input manager.
  25244. * @returns the current input manager
  25245. */
  25246. addTouch(): FreeCameraInputsManager;
  25247. /**
  25248. * Remove all attached input methods from a camera
  25249. */
  25250. clear(): void;
  25251. }
  25252. }
  25253. declare module "babylonjs/Cameras/freeCamera" {
  25254. import { Vector3 } from "babylonjs/Maths/math.vector";
  25255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25256. import { Scene } from "babylonjs/scene";
  25257. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  25258. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  25259. /**
  25260. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25261. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25262. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25263. */
  25264. export class FreeCamera extends TargetCamera {
  25265. /**
  25266. * Define the collision ellipsoid of the camera.
  25267. * This is helpful to simulate a camera body like the player body around the camera
  25268. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25269. */
  25270. ellipsoid: Vector3;
  25271. /**
  25272. * Define an offset for the position of the ellipsoid around the camera.
  25273. * This can be helpful to determine the center of the body near the gravity center of the body
  25274. * instead of its head.
  25275. */
  25276. ellipsoidOffset: Vector3;
  25277. /**
  25278. * Enable or disable collisions of the camera with the rest of the scene objects.
  25279. */
  25280. checkCollisions: boolean;
  25281. /**
  25282. * Enable or disable gravity on the camera.
  25283. */
  25284. applyGravity: boolean;
  25285. /**
  25286. * Define the input manager associated to the camera.
  25287. */
  25288. inputs: FreeCameraInputsManager;
  25289. /**
  25290. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25291. * Higher values reduce sensitivity.
  25292. */
  25293. get angularSensibility(): number;
  25294. /**
  25295. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25296. * Higher values reduce sensitivity.
  25297. */
  25298. set angularSensibility(value: number);
  25299. /**
  25300. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25301. */
  25302. get keysUp(): number[];
  25303. set keysUp(value: number[]);
  25304. /**
  25305. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25306. */
  25307. get keysUpward(): number[];
  25308. set keysUpward(value: number[]);
  25309. /**
  25310. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25311. */
  25312. get keysDown(): number[];
  25313. set keysDown(value: number[]);
  25314. /**
  25315. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25316. */
  25317. get keysDownward(): number[];
  25318. set keysDownward(value: number[]);
  25319. /**
  25320. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25321. */
  25322. get keysLeft(): number[];
  25323. set keysLeft(value: number[]);
  25324. /**
  25325. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25326. */
  25327. get keysRight(): number[];
  25328. set keysRight(value: number[]);
  25329. /**
  25330. * Event raised when the camera collide with a mesh in the scene.
  25331. */
  25332. onCollide: (collidedMesh: AbstractMesh) => void;
  25333. private _collider;
  25334. private _needMoveForGravity;
  25335. private _oldPosition;
  25336. private _diffPosition;
  25337. private _newPosition;
  25338. /** @hidden */
  25339. _localDirection: Vector3;
  25340. /** @hidden */
  25341. _transformedDirection: Vector3;
  25342. /**
  25343. * Instantiates a Free Camera.
  25344. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25345. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25346. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25347. * @param name Define the name of the camera in the scene
  25348. * @param position Define the start position of the camera in the scene
  25349. * @param scene Define the scene the camera belongs to
  25350. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25351. */
  25352. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25353. /**
  25354. * Attach the input controls to a specific dom element to get the input from.
  25355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25356. */
  25357. attachControl(noPreventDefault?: boolean): void;
  25358. /**
  25359. * Attach the input controls to a specific dom element to get the input from.
  25360. * @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
  25361. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25362. * BACK COMPAT SIGNATURE ONLY.
  25363. */
  25364. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25365. /**
  25366. * Detach the current controls from the specified dom element.
  25367. */
  25368. detachControl(): void;
  25369. /**
  25370. * Detach the current controls from the specified dom element.
  25371. * @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
  25372. */
  25373. detachControl(ignored: any): void;
  25374. private _collisionMask;
  25375. /**
  25376. * Define a collision mask to limit the list of object the camera can collide with
  25377. */
  25378. get collisionMask(): number;
  25379. set collisionMask(mask: number);
  25380. /** @hidden */
  25381. _collideWithWorld(displacement: Vector3): void;
  25382. private _onCollisionPositionChange;
  25383. /** @hidden */
  25384. _checkInputs(): void;
  25385. /** @hidden */
  25386. _decideIfNeedsToMove(): boolean;
  25387. /** @hidden */
  25388. _updatePosition(): void;
  25389. /**
  25390. * Destroy the camera and release the current resources hold by it.
  25391. */
  25392. dispose(): void;
  25393. /**
  25394. * Gets the current object class name.
  25395. * @return the class name
  25396. */
  25397. getClassName(): string;
  25398. }
  25399. }
  25400. declare module "babylonjs/Gamepads/gamepad" {
  25401. import { Observable } from "babylonjs/Misc/observable";
  25402. /**
  25403. * Represents a gamepad control stick position
  25404. */
  25405. export class StickValues {
  25406. /**
  25407. * The x component of the control stick
  25408. */
  25409. x: number;
  25410. /**
  25411. * The y component of the control stick
  25412. */
  25413. y: number;
  25414. /**
  25415. * Initializes the gamepad x and y control stick values
  25416. * @param x The x component of the gamepad control stick value
  25417. * @param y The y component of the gamepad control stick value
  25418. */
  25419. constructor(
  25420. /**
  25421. * The x component of the control stick
  25422. */
  25423. x: number,
  25424. /**
  25425. * The y component of the control stick
  25426. */
  25427. y: number);
  25428. }
  25429. /**
  25430. * An interface which manages callbacks for gamepad button changes
  25431. */
  25432. export interface GamepadButtonChanges {
  25433. /**
  25434. * Called when a gamepad has been changed
  25435. */
  25436. changed: boolean;
  25437. /**
  25438. * Called when a gamepad press event has been triggered
  25439. */
  25440. pressChanged: boolean;
  25441. /**
  25442. * Called when a touch event has been triggered
  25443. */
  25444. touchChanged: boolean;
  25445. /**
  25446. * Called when a value has changed
  25447. */
  25448. valueChanged: boolean;
  25449. }
  25450. /**
  25451. * Represents a gamepad
  25452. */
  25453. export class Gamepad {
  25454. /**
  25455. * The id of the gamepad
  25456. */
  25457. id: string;
  25458. /**
  25459. * The index of the gamepad
  25460. */
  25461. index: number;
  25462. /**
  25463. * The browser gamepad
  25464. */
  25465. browserGamepad: any;
  25466. /**
  25467. * Specifies what type of gamepad this represents
  25468. */
  25469. type: number;
  25470. private _leftStick;
  25471. private _rightStick;
  25472. /** @hidden */
  25473. _isConnected: boolean;
  25474. private _leftStickAxisX;
  25475. private _leftStickAxisY;
  25476. private _rightStickAxisX;
  25477. private _rightStickAxisY;
  25478. /**
  25479. * Triggered when the left control stick has been changed
  25480. */
  25481. private _onleftstickchanged;
  25482. /**
  25483. * Triggered when the right control stick has been changed
  25484. */
  25485. private _onrightstickchanged;
  25486. /**
  25487. * Represents a gamepad controller
  25488. */
  25489. static GAMEPAD: number;
  25490. /**
  25491. * Represents a generic controller
  25492. */
  25493. static GENERIC: number;
  25494. /**
  25495. * Represents an XBox controller
  25496. */
  25497. static XBOX: number;
  25498. /**
  25499. * Represents a pose-enabled controller
  25500. */
  25501. static POSE_ENABLED: number;
  25502. /**
  25503. * Represents an Dual Shock controller
  25504. */
  25505. static DUALSHOCK: number;
  25506. /**
  25507. * Specifies whether the left control stick should be Y-inverted
  25508. */
  25509. protected _invertLeftStickY: boolean;
  25510. /**
  25511. * Specifies if the gamepad has been connected
  25512. */
  25513. get isConnected(): boolean;
  25514. /**
  25515. * Initializes the gamepad
  25516. * @param id The id of the gamepad
  25517. * @param index The index of the gamepad
  25518. * @param browserGamepad The browser gamepad
  25519. * @param leftStickX The x component of the left joystick
  25520. * @param leftStickY The y component of the left joystick
  25521. * @param rightStickX The x component of the right joystick
  25522. * @param rightStickY The y component of the right joystick
  25523. */
  25524. constructor(
  25525. /**
  25526. * The id of the gamepad
  25527. */
  25528. id: string,
  25529. /**
  25530. * The index of the gamepad
  25531. */
  25532. index: number,
  25533. /**
  25534. * The browser gamepad
  25535. */
  25536. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25537. /**
  25538. * Callback triggered when the left joystick has changed
  25539. * @param callback
  25540. */
  25541. onleftstickchanged(callback: (values: StickValues) => void): void;
  25542. /**
  25543. * Callback triggered when the right joystick has changed
  25544. * @param callback
  25545. */
  25546. onrightstickchanged(callback: (values: StickValues) => void): void;
  25547. /**
  25548. * Gets the left joystick
  25549. */
  25550. get leftStick(): StickValues;
  25551. /**
  25552. * Sets the left joystick values
  25553. */
  25554. set leftStick(newValues: StickValues);
  25555. /**
  25556. * Gets the right joystick
  25557. */
  25558. get rightStick(): StickValues;
  25559. /**
  25560. * Sets the right joystick value
  25561. */
  25562. set rightStick(newValues: StickValues);
  25563. /**
  25564. * Updates the gamepad joystick positions
  25565. */
  25566. update(): void;
  25567. /**
  25568. * Disposes the gamepad
  25569. */
  25570. dispose(): void;
  25571. }
  25572. /**
  25573. * Represents a generic gamepad
  25574. */
  25575. export class GenericPad extends Gamepad {
  25576. private _buttons;
  25577. private _onbuttondown;
  25578. private _onbuttonup;
  25579. /**
  25580. * Observable triggered when a button has been pressed
  25581. */
  25582. onButtonDownObservable: Observable<number>;
  25583. /**
  25584. * Observable triggered when a button has been released
  25585. */
  25586. onButtonUpObservable: Observable<number>;
  25587. /**
  25588. * Callback triggered when a button has been pressed
  25589. * @param callback Called when a button has been pressed
  25590. */
  25591. onbuttondown(callback: (buttonPressed: number) => void): void;
  25592. /**
  25593. * Callback triggered when a button has been released
  25594. * @param callback Called when a button has been released
  25595. */
  25596. onbuttonup(callback: (buttonReleased: number) => void): void;
  25597. /**
  25598. * Initializes the generic gamepad
  25599. * @param id The id of the generic gamepad
  25600. * @param index The index of the generic gamepad
  25601. * @param browserGamepad The browser gamepad
  25602. */
  25603. constructor(id: string, index: number, browserGamepad: any);
  25604. private _setButtonValue;
  25605. /**
  25606. * Updates the generic gamepad
  25607. */
  25608. update(): void;
  25609. /**
  25610. * Disposes the generic gamepad
  25611. */
  25612. dispose(): void;
  25613. }
  25614. }
  25615. declare module "babylonjs/Animations/runtimeAnimation" {
  25616. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  25617. import { Animatable } from "babylonjs/Animations/animatable";
  25618. import { Scene } from "babylonjs/scene";
  25619. /**
  25620. * Defines a runtime animation
  25621. */
  25622. export class RuntimeAnimation {
  25623. private _events;
  25624. /**
  25625. * The current frame of the runtime animation
  25626. */
  25627. private _currentFrame;
  25628. /**
  25629. * The animation used by the runtime animation
  25630. */
  25631. private _animation;
  25632. /**
  25633. * The target of the runtime animation
  25634. */
  25635. private _target;
  25636. /**
  25637. * The initiating animatable
  25638. */
  25639. private _host;
  25640. /**
  25641. * The original value of the runtime animation
  25642. */
  25643. private _originalValue;
  25644. /**
  25645. * The original blend value of the runtime animation
  25646. */
  25647. private _originalBlendValue;
  25648. /**
  25649. * The offsets cache of the runtime animation
  25650. */
  25651. private _offsetsCache;
  25652. /**
  25653. * The high limits cache of the runtime animation
  25654. */
  25655. private _highLimitsCache;
  25656. /**
  25657. * Specifies if the runtime animation has been stopped
  25658. */
  25659. private _stopped;
  25660. /**
  25661. * The blending factor of the runtime animation
  25662. */
  25663. private _blendingFactor;
  25664. /**
  25665. * The BabylonJS scene
  25666. */
  25667. private _scene;
  25668. /**
  25669. * The current value of the runtime animation
  25670. */
  25671. private _currentValue;
  25672. /** @hidden */
  25673. _animationState: _IAnimationState;
  25674. /**
  25675. * The active target of the runtime animation
  25676. */
  25677. private _activeTargets;
  25678. private _currentActiveTarget;
  25679. private _directTarget;
  25680. /**
  25681. * The target path of the runtime animation
  25682. */
  25683. private _targetPath;
  25684. /**
  25685. * The weight of the runtime animation
  25686. */
  25687. private _weight;
  25688. /**
  25689. * The ratio offset of the runtime animation
  25690. */
  25691. private _ratioOffset;
  25692. /**
  25693. * The previous delay of the runtime animation
  25694. */
  25695. private _previousDelay;
  25696. /**
  25697. * The previous ratio of the runtime animation
  25698. */
  25699. private _previousRatio;
  25700. private _enableBlending;
  25701. private _keys;
  25702. private _minFrame;
  25703. private _maxFrame;
  25704. private _minValue;
  25705. private _maxValue;
  25706. private _targetIsArray;
  25707. /**
  25708. * Gets the current frame of the runtime animation
  25709. */
  25710. get currentFrame(): number;
  25711. /**
  25712. * Gets the weight of the runtime animation
  25713. */
  25714. get weight(): number;
  25715. /**
  25716. * Gets the current value of the runtime animation
  25717. */
  25718. get currentValue(): any;
  25719. /**
  25720. * Gets the target path of the runtime animation
  25721. */
  25722. get targetPath(): string;
  25723. /**
  25724. * Gets the actual target of the runtime animation
  25725. */
  25726. get target(): any;
  25727. /**
  25728. * Gets the additive state of the runtime animation
  25729. */
  25730. get isAdditive(): boolean;
  25731. /** @hidden */
  25732. _onLoop: () => void;
  25733. /**
  25734. * Create a new RuntimeAnimation object
  25735. * @param target defines the target of the animation
  25736. * @param animation defines the source animation object
  25737. * @param scene defines the hosting scene
  25738. * @param host defines the initiating Animatable
  25739. */
  25740. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25741. private _preparePath;
  25742. /**
  25743. * Gets the animation from the runtime animation
  25744. */
  25745. get animation(): Animation;
  25746. /**
  25747. * Resets the runtime animation to the beginning
  25748. * @param restoreOriginal defines whether to restore the target property to the original value
  25749. */
  25750. reset(restoreOriginal?: boolean): void;
  25751. /**
  25752. * Specifies if the runtime animation is stopped
  25753. * @returns Boolean specifying if the runtime animation is stopped
  25754. */
  25755. isStopped(): boolean;
  25756. /**
  25757. * Disposes of the runtime animation
  25758. */
  25759. dispose(): void;
  25760. /**
  25761. * Apply the interpolated value to the target
  25762. * @param currentValue defines the value computed by the animation
  25763. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25764. */
  25765. setValue(currentValue: any, weight: number): void;
  25766. private _getOriginalValues;
  25767. private _setValue;
  25768. /**
  25769. * Gets the loop pmode of the runtime animation
  25770. * @returns Loop Mode
  25771. */
  25772. private _getCorrectLoopMode;
  25773. /**
  25774. * Move the current animation to a given frame
  25775. * @param frame defines the frame to move to
  25776. */
  25777. goToFrame(frame: number): void;
  25778. /**
  25779. * @hidden Internal use only
  25780. */
  25781. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25782. /**
  25783. * Execute the current animation
  25784. * @param delay defines the delay to add to the current frame
  25785. * @param from defines the lower bound of the animation range
  25786. * @param to defines the upper bound of the animation range
  25787. * @param loop defines if the current animation must loop
  25788. * @param speedRatio defines the current speed ratio
  25789. * @param weight defines the weight of the animation (default is -1 so no weight)
  25790. * @param onLoop optional callback called when animation loops
  25791. * @returns a boolean indicating if the animation is running
  25792. */
  25793. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25794. }
  25795. }
  25796. declare module "babylonjs/Animations/animatable" {
  25797. import { Animation } from "babylonjs/Animations/animation";
  25798. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25799. import { Nullable } from "babylonjs/types";
  25800. import { Observable } from "babylonjs/Misc/observable";
  25801. import { Scene } from "babylonjs/scene";
  25802. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  25803. import { Node } from "babylonjs/node";
  25804. /**
  25805. * Class used to store an actual running animation
  25806. */
  25807. export class Animatable {
  25808. /** defines the target object */
  25809. target: any;
  25810. /** defines the starting frame number (default is 0) */
  25811. fromFrame: number;
  25812. /** defines the ending frame number (default is 100) */
  25813. toFrame: number;
  25814. /** defines if the animation must loop (default is false) */
  25815. loopAnimation: boolean;
  25816. /** defines a callback to call when animation ends if it is not looping */
  25817. onAnimationEnd?: (() => void) | null | undefined;
  25818. /** defines a callback to call when animation loops */
  25819. onAnimationLoop?: (() => void) | null | undefined;
  25820. /** defines whether the animation should be evaluated additively */
  25821. isAdditive: boolean;
  25822. private _localDelayOffset;
  25823. private _pausedDelay;
  25824. private _runtimeAnimations;
  25825. private _paused;
  25826. private _scene;
  25827. private _speedRatio;
  25828. private _weight;
  25829. private _syncRoot;
  25830. /**
  25831. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25832. * This will only apply for non looping animation (default is true)
  25833. */
  25834. disposeOnEnd: boolean;
  25835. /**
  25836. * Gets a boolean indicating if the animation has started
  25837. */
  25838. animationStarted: boolean;
  25839. /**
  25840. * Observer raised when the animation ends
  25841. */
  25842. onAnimationEndObservable: Observable<Animatable>;
  25843. /**
  25844. * Observer raised when the animation loops
  25845. */
  25846. onAnimationLoopObservable: Observable<Animatable>;
  25847. /**
  25848. * Gets the root Animatable used to synchronize and normalize animations
  25849. */
  25850. get syncRoot(): Nullable<Animatable>;
  25851. /**
  25852. * Gets the current frame of the first RuntimeAnimation
  25853. * Used to synchronize Animatables
  25854. */
  25855. get masterFrame(): number;
  25856. /**
  25857. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25858. */
  25859. get weight(): number;
  25860. set weight(value: number);
  25861. /**
  25862. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25863. */
  25864. get speedRatio(): number;
  25865. set speedRatio(value: number);
  25866. /**
  25867. * Creates a new Animatable
  25868. * @param scene defines the hosting scene
  25869. * @param target defines the target object
  25870. * @param fromFrame defines the starting frame number (default is 0)
  25871. * @param toFrame defines the ending frame number (default is 100)
  25872. * @param loopAnimation defines if the animation must loop (default is false)
  25873. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25874. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25875. * @param animations defines a group of animation to add to the new Animatable
  25876. * @param onAnimationLoop defines a callback to call when animation loops
  25877. * @param isAdditive defines whether the animation should be evaluated additively
  25878. */
  25879. constructor(scene: Scene,
  25880. /** defines the target object */
  25881. target: any,
  25882. /** defines the starting frame number (default is 0) */
  25883. fromFrame?: number,
  25884. /** defines the ending frame number (default is 100) */
  25885. toFrame?: number,
  25886. /** defines if the animation must loop (default is false) */
  25887. loopAnimation?: boolean, speedRatio?: number,
  25888. /** defines a callback to call when animation ends if it is not looping */
  25889. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25890. /** defines a callback to call when animation loops */
  25891. onAnimationLoop?: (() => void) | null | undefined,
  25892. /** defines whether the animation should be evaluated additively */
  25893. isAdditive?: boolean);
  25894. /**
  25895. * Synchronize and normalize current Animatable with a source Animatable
  25896. * This is useful when using animation weights and when animations are not of the same length
  25897. * @param root defines the root Animatable to synchronize with
  25898. * @returns the current Animatable
  25899. */
  25900. syncWith(root: Animatable): Animatable;
  25901. /**
  25902. * Gets the list of runtime animations
  25903. * @returns an array of RuntimeAnimation
  25904. */
  25905. getAnimations(): RuntimeAnimation[];
  25906. /**
  25907. * Adds more animations to the current animatable
  25908. * @param target defines the target of the animations
  25909. * @param animations defines the new animations to add
  25910. */
  25911. appendAnimations(target: any, animations: Animation[]): void;
  25912. /**
  25913. * Gets the source animation for a specific property
  25914. * @param property defines the propertyu to look for
  25915. * @returns null or the source animation for the given property
  25916. */
  25917. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25918. /**
  25919. * Gets the runtime animation for a specific property
  25920. * @param property defines the propertyu to look for
  25921. * @returns null or the runtime animation for the given property
  25922. */
  25923. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25924. /**
  25925. * Resets the animatable to its original state
  25926. */
  25927. reset(): void;
  25928. /**
  25929. * Allows the animatable to blend with current running animations
  25930. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25931. * @param blendingSpeed defines the blending speed to use
  25932. */
  25933. enableBlending(blendingSpeed: number): void;
  25934. /**
  25935. * Disable animation blending
  25936. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25937. */
  25938. disableBlending(): void;
  25939. /**
  25940. * Jump directly to a given frame
  25941. * @param frame defines the frame to jump to
  25942. */
  25943. goToFrame(frame: number): void;
  25944. /**
  25945. * Pause the animation
  25946. */
  25947. pause(): void;
  25948. /**
  25949. * Restart the animation
  25950. */
  25951. restart(): void;
  25952. private _raiseOnAnimationEnd;
  25953. /**
  25954. * Stop and delete the current animation
  25955. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25956. * @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)
  25957. */
  25958. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25959. /**
  25960. * Wait asynchronously for the animation to end
  25961. * @returns a promise which will be fullfilled when the animation ends
  25962. */
  25963. waitAsync(): Promise<Animatable>;
  25964. /** @hidden */
  25965. _animate(delay: number): boolean;
  25966. }
  25967. module "babylonjs/scene" {
  25968. interface Scene {
  25969. /** @hidden */
  25970. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25971. /** @hidden */
  25972. _processLateAnimationBindingsForMatrices(holder: {
  25973. totalWeight: number;
  25974. totalAdditiveWeight: number;
  25975. animations: RuntimeAnimation[];
  25976. additiveAnimations: RuntimeAnimation[];
  25977. originalValue: Matrix;
  25978. }): any;
  25979. /** @hidden */
  25980. _processLateAnimationBindingsForQuaternions(holder: {
  25981. totalWeight: number;
  25982. totalAdditiveWeight: number;
  25983. animations: RuntimeAnimation[];
  25984. additiveAnimations: RuntimeAnimation[];
  25985. originalValue: Quaternion;
  25986. }, refQuaternion: Quaternion): Quaternion;
  25987. /** @hidden */
  25988. _processLateAnimationBindings(): void;
  25989. /**
  25990. * Will start the animation sequence of a given target
  25991. * @param target defines the target
  25992. * @param from defines from which frame should animation start
  25993. * @param to defines until which frame should animation run.
  25994. * @param weight defines the weight to apply to the animation (1.0 by default)
  25995. * @param loop defines if the animation loops
  25996. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25997. * @param onAnimationEnd defines the function to be executed when the animation ends
  25998. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25999. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26000. * @param onAnimationLoop defines the callback to call when an animation loops
  26001. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26002. * @returns the animatable object created for this animation
  26003. */
  26004. 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;
  26005. /**
  26006. * Will start the animation sequence of a given target
  26007. * @param target defines the target
  26008. * @param from defines from which frame should animation start
  26009. * @param to defines until which frame should animation run.
  26010. * @param loop defines if the animation loops
  26011. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26012. * @param onAnimationEnd defines the function to be executed when the animation ends
  26013. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26014. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26015. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  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 animatable object created for this animation
  26019. */
  26020. 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;
  26021. /**
  26022. * Will start the animation sequence of a given target and its hierarchy
  26023. * @param target defines the target
  26024. * @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.
  26025. * @param from defines from which frame should animation start
  26026. * @param to defines until which frame should animation run.
  26027. * @param loop defines if the animation loops
  26028. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26029. * @param onAnimationEnd defines the function to be executed when the animation ends
  26030. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26031. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26032. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26033. * @param onAnimationLoop defines the callback to call when an animation loops
  26034. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26035. * @returns the list of created animatables
  26036. */
  26037. 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[];
  26038. /**
  26039. * Begin a new animation on a given node
  26040. * @param target defines the target where the animation will take place
  26041. * @param animations defines the list of animations to start
  26042. * @param from defines the initial value
  26043. * @param to defines the final value
  26044. * @param loop defines if you want animation to loop (off by default)
  26045. * @param speedRatio defines the speed ratio to apply to all animations
  26046. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26047. * @param onAnimationLoop defines the callback to call when an animation loops
  26048. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26049. * @returns the list of created animatables
  26050. */
  26051. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26052. /**
  26053. * Begin a new animation on a given node and its hierarchy
  26054. * @param target defines the root node where the animation will take place
  26055. * @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.
  26056. * @param animations defines the list of animations to start
  26057. * @param from defines the initial value
  26058. * @param to defines the final value
  26059. * @param loop defines if you want animation to loop (off by default)
  26060. * @param speedRatio defines the speed ratio to apply to all animations
  26061. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26062. * @param onAnimationLoop defines the callback to call when an animation loops
  26063. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26064. * @returns the list of animatables created for all nodes
  26065. */
  26066. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26067. /**
  26068. * Gets the animatable associated with a specific target
  26069. * @param target defines the target of the animatable
  26070. * @returns the required animatable if found
  26071. */
  26072. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26073. /**
  26074. * Gets all animatables associated with a given target
  26075. * @param target defines the target to look animatables for
  26076. * @returns an array of Animatables
  26077. */
  26078. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26079. /**
  26080. * Stops and removes all animations that have been applied to the scene
  26081. */
  26082. stopAllAnimations(): void;
  26083. /**
  26084. * Gets the current delta time used by animation engine
  26085. */
  26086. deltaTime: number;
  26087. }
  26088. }
  26089. module "babylonjs/Bones/bone" {
  26090. interface Bone {
  26091. /**
  26092. * Copy an animation range from another bone
  26093. * @param source defines the source bone
  26094. * @param rangeName defines the range name to copy
  26095. * @param frameOffset defines the frame offset
  26096. * @param rescaleAsRequired defines if rescaling must be applied if required
  26097. * @param skelDimensionsRatio defines the scaling ratio
  26098. * @returns true if operation was successful
  26099. */
  26100. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26101. }
  26102. }
  26103. }
  26104. declare module "babylonjs/Animations/animationPropertiesOverride" {
  26105. /**
  26106. * Class used to override all child animations of a given target
  26107. */
  26108. export class AnimationPropertiesOverride {
  26109. /**
  26110. * Gets or sets a value indicating if animation blending must be used
  26111. */
  26112. enableBlending: boolean;
  26113. /**
  26114. * Gets or sets the blending speed to use when enableBlending is true
  26115. */
  26116. blendingSpeed: number;
  26117. /**
  26118. * Gets or sets the default loop mode to use
  26119. */
  26120. loopMode: number;
  26121. }
  26122. }
  26123. declare module "babylonjs/Bones/skeleton" {
  26124. import { Bone } from "babylonjs/Bones/bone";
  26125. import { Observable } from "babylonjs/Misc/observable";
  26126. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  26127. import { Scene } from "babylonjs/scene";
  26128. import { Nullable } from "babylonjs/types";
  26129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26130. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26131. import { Animatable } from "babylonjs/Animations/animatable";
  26132. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26133. import { Animation } from "babylonjs/Animations/animation";
  26134. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26135. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26136. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26137. /**
  26138. * Class used to handle skinning animations
  26139. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26140. */
  26141. export class Skeleton implements IAnimatable {
  26142. /** defines the skeleton name */
  26143. name: string;
  26144. /** defines the skeleton Id */
  26145. id: string;
  26146. /**
  26147. * Defines the list of child bones
  26148. */
  26149. bones: Bone[];
  26150. /**
  26151. * Defines an estimate of the dimension of the skeleton at rest
  26152. */
  26153. dimensionsAtRest: Vector3;
  26154. /**
  26155. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26156. */
  26157. needInitialSkinMatrix: boolean;
  26158. /**
  26159. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26160. */
  26161. overrideMesh: Nullable<AbstractMesh>;
  26162. /**
  26163. * Gets the list of animations attached to this skeleton
  26164. */
  26165. animations: Array<Animation>;
  26166. private _scene;
  26167. private _isDirty;
  26168. private _transformMatrices;
  26169. private _transformMatrixTexture;
  26170. private _meshesWithPoseMatrix;
  26171. private _animatables;
  26172. private _identity;
  26173. private _synchronizedWithMesh;
  26174. private _ranges;
  26175. private _lastAbsoluteTransformsUpdateId;
  26176. private _canUseTextureForBones;
  26177. private _uniqueId;
  26178. /** @hidden */
  26179. _numBonesWithLinkedTransformNode: number;
  26180. /** @hidden */
  26181. _hasWaitingData: Nullable<boolean>;
  26182. /** @hidden */
  26183. _waitingOverrideMeshId: Nullable<string>;
  26184. /**
  26185. * Specifies if the skeleton should be serialized
  26186. */
  26187. doNotSerialize: boolean;
  26188. private _useTextureToStoreBoneMatrices;
  26189. /**
  26190. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26191. * Please note that this option is not available if the hardware does not support it
  26192. */
  26193. get useTextureToStoreBoneMatrices(): boolean;
  26194. set useTextureToStoreBoneMatrices(value: boolean);
  26195. private _animationPropertiesOverride;
  26196. /**
  26197. * Gets or sets the animation properties override
  26198. */
  26199. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26200. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26201. /**
  26202. * List of inspectable custom properties (used by the Inspector)
  26203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26204. */
  26205. inspectableCustomProperties: IInspectable[];
  26206. /**
  26207. * An observable triggered before computing the skeleton's matrices
  26208. */
  26209. onBeforeComputeObservable: Observable<Skeleton>;
  26210. /**
  26211. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26212. */
  26213. get isUsingTextureForMatrices(): boolean;
  26214. /**
  26215. * Gets the unique ID of this skeleton
  26216. */
  26217. get uniqueId(): number;
  26218. /**
  26219. * Creates a new skeleton
  26220. * @param name defines the skeleton name
  26221. * @param id defines the skeleton Id
  26222. * @param scene defines the hosting scene
  26223. */
  26224. constructor(
  26225. /** defines the skeleton name */
  26226. name: string,
  26227. /** defines the skeleton Id */
  26228. id: string, scene: Scene);
  26229. /**
  26230. * Gets the current object class name.
  26231. * @return the class name
  26232. */
  26233. getClassName(): string;
  26234. /**
  26235. * Returns an array containing the root bones
  26236. * @returns an array containing the root bones
  26237. */
  26238. getChildren(): Array<Bone>;
  26239. /**
  26240. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26241. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26242. * @returns a Float32Array containing matrices data
  26243. */
  26244. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26245. /**
  26246. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26247. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26248. * @returns a raw texture containing the data
  26249. */
  26250. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26251. /**
  26252. * Gets the current hosting scene
  26253. * @returns a scene object
  26254. */
  26255. getScene(): Scene;
  26256. /**
  26257. * Gets a string representing the current skeleton data
  26258. * @param fullDetails defines a boolean indicating if we want a verbose version
  26259. * @returns a string representing the current skeleton data
  26260. */
  26261. toString(fullDetails?: boolean): string;
  26262. /**
  26263. * Get bone's index searching by name
  26264. * @param name defines bone's name to search for
  26265. * @return the indice of the bone. Returns -1 if not found
  26266. */
  26267. getBoneIndexByName(name: string): number;
  26268. /**
  26269. * Creater a new animation range
  26270. * @param name defines the name of the range
  26271. * @param from defines the start key
  26272. * @param to defines the end key
  26273. */
  26274. createAnimationRange(name: string, from: number, to: number): void;
  26275. /**
  26276. * Delete a specific animation range
  26277. * @param name defines the name of the range
  26278. * @param deleteFrames defines if frames must be removed as well
  26279. */
  26280. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26281. /**
  26282. * Gets a specific animation range
  26283. * @param name defines the name of the range to look for
  26284. * @returns the requested animation range or null if not found
  26285. */
  26286. getAnimationRange(name: string): Nullable<AnimationRange>;
  26287. /**
  26288. * Gets the list of all animation ranges defined on this skeleton
  26289. * @returns an array
  26290. */
  26291. getAnimationRanges(): Nullable<AnimationRange>[];
  26292. /**
  26293. * Copy animation range from a source skeleton.
  26294. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26295. * @param source defines the source skeleton
  26296. * @param name defines the name of the range to copy
  26297. * @param rescaleAsRequired defines if rescaling must be applied if required
  26298. * @returns true if operation was successful
  26299. */
  26300. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26301. /**
  26302. * Forces the skeleton to go to rest pose
  26303. */
  26304. returnToRest(): void;
  26305. private _getHighestAnimationFrame;
  26306. /**
  26307. * Begin a specific animation range
  26308. * @param name defines the name of the range to start
  26309. * @param loop defines if looping must be turned on (false by default)
  26310. * @param speedRatio defines the speed ratio to apply (1 by default)
  26311. * @param onAnimationEnd defines a callback which will be called when animation will end
  26312. * @returns a new animatable
  26313. */
  26314. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26315. /**
  26316. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26317. * @param skeleton defines the Skeleton containing the animation range to convert
  26318. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26319. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26320. * @returns the original skeleton
  26321. */
  26322. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26323. /** @hidden */
  26324. _markAsDirty(): void;
  26325. /** @hidden */
  26326. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26327. /** @hidden */
  26328. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26329. private _computeTransformMatrices;
  26330. /**
  26331. * Build all resources required to render a skeleton
  26332. */
  26333. prepare(): void;
  26334. /**
  26335. * Gets the list of animatables currently running for this skeleton
  26336. * @returns an array of animatables
  26337. */
  26338. getAnimatables(): IAnimatable[];
  26339. /**
  26340. * Clone the current skeleton
  26341. * @param name defines the name of the new skeleton
  26342. * @param id defines the id of the new skeleton
  26343. * @returns the new skeleton
  26344. */
  26345. clone(name: string, id?: string): Skeleton;
  26346. /**
  26347. * Enable animation blending for this skeleton
  26348. * @param blendingSpeed defines the blending speed to apply
  26349. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26350. */
  26351. enableBlending(blendingSpeed?: number): void;
  26352. /**
  26353. * Releases all resources associated with the current skeleton
  26354. */
  26355. dispose(): void;
  26356. /**
  26357. * Serialize the skeleton in a JSON object
  26358. * @returns a JSON object
  26359. */
  26360. serialize(): any;
  26361. /**
  26362. * Creates a new skeleton from serialized data
  26363. * @param parsedSkeleton defines the serialized data
  26364. * @param scene defines the hosting scene
  26365. * @returns a new skeleton
  26366. */
  26367. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26368. /**
  26369. * Compute all node absolute transforms
  26370. * @param forceUpdate defines if computation must be done even if cache is up to date
  26371. */
  26372. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26373. /**
  26374. * Gets the root pose matrix
  26375. * @returns a matrix
  26376. */
  26377. getPoseMatrix(): Nullable<Matrix>;
  26378. /**
  26379. * Sorts bones per internal index
  26380. */
  26381. sortBones(): void;
  26382. private _sortBones;
  26383. /**
  26384. * Set the current local matrix as the restPose for all bones in the skeleton.
  26385. */
  26386. setCurrentPoseAsRest(): void;
  26387. }
  26388. }
  26389. declare module "babylonjs/Bones/bone" {
  26390. import { Skeleton } from "babylonjs/Bones/skeleton";
  26391. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  26392. import { Nullable } from "babylonjs/types";
  26393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26394. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26395. import { Node } from "babylonjs/node";
  26396. import { Space } from "babylonjs/Maths/math.axis";
  26397. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26398. /**
  26399. * Class used to store bone information
  26400. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26401. */
  26402. export class Bone extends Node {
  26403. /**
  26404. * defines the bone name
  26405. */
  26406. name: string;
  26407. private static _tmpVecs;
  26408. private static _tmpQuat;
  26409. private static _tmpMats;
  26410. /**
  26411. * Gets the list of child bones
  26412. */
  26413. children: Bone[];
  26414. /** Gets the animations associated with this bone */
  26415. animations: import("babylonjs/Animations/animation").Animation[];
  26416. /**
  26417. * Gets or sets bone length
  26418. */
  26419. length: number;
  26420. /**
  26421. * @hidden Internal only
  26422. * Set this value to map this bone to a different index in the transform matrices
  26423. * Set this value to -1 to exclude the bone from the transform matrices
  26424. */
  26425. _index: Nullable<number>;
  26426. private _skeleton;
  26427. private _localMatrix;
  26428. private _restPose;
  26429. private _bindPose;
  26430. private _baseMatrix;
  26431. private _absoluteTransform;
  26432. private _invertedAbsoluteTransform;
  26433. private _parent;
  26434. private _scalingDeterminant;
  26435. private _worldTransform;
  26436. private _localScaling;
  26437. private _localRotation;
  26438. private _localPosition;
  26439. private _needToDecompose;
  26440. private _needToCompose;
  26441. /** @hidden */
  26442. _linkedTransformNode: Nullable<TransformNode>;
  26443. /** @hidden */
  26444. _waitingTransformNodeId: Nullable<string>;
  26445. /** @hidden */
  26446. get _matrix(): Matrix;
  26447. /** @hidden */
  26448. set _matrix(value: Matrix);
  26449. /**
  26450. * Create a new bone
  26451. * @param name defines the bone name
  26452. * @param skeleton defines the parent skeleton
  26453. * @param parentBone defines the parent (can be null if the bone is the root)
  26454. * @param localMatrix defines the local matrix
  26455. * @param restPose defines the rest pose matrix
  26456. * @param baseMatrix defines the base matrix
  26457. * @param index defines index of the bone in the hiearchy
  26458. */
  26459. constructor(
  26460. /**
  26461. * defines the bone name
  26462. */
  26463. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26464. /**
  26465. * Gets the current object class name.
  26466. * @return the class name
  26467. */
  26468. getClassName(): string;
  26469. /**
  26470. * Gets the parent skeleton
  26471. * @returns a skeleton
  26472. */
  26473. getSkeleton(): Skeleton;
  26474. /**
  26475. * Gets parent bone
  26476. * @returns a bone or null if the bone is the root of the bone hierarchy
  26477. */
  26478. getParent(): Nullable<Bone>;
  26479. /**
  26480. * Returns an array containing the root bones
  26481. * @returns an array containing the root bones
  26482. */
  26483. getChildren(): Array<Bone>;
  26484. /**
  26485. * Gets the node index in matrix array generated for rendering
  26486. * @returns the node index
  26487. */
  26488. getIndex(): number;
  26489. /**
  26490. * Sets the parent bone
  26491. * @param parent defines the parent (can be null if the bone is the root)
  26492. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26493. */
  26494. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26495. /**
  26496. * Gets the local matrix
  26497. * @returns a matrix
  26498. */
  26499. getLocalMatrix(): Matrix;
  26500. /**
  26501. * Gets the base matrix (initial matrix which remains unchanged)
  26502. * @returns a matrix
  26503. */
  26504. getBaseMatrix(): Matrix;
  26505. /**
  26506. * Gets the rest pose matrix
  26507. * @returns a matrix
  26508. */
  26509. getRestPose(): Matrix;
  26510. /**
  26511. * Sets the rest pose matrix
  26512. * @param matrix the local-space rest pose to set for this bone
  26513. */
  26514. setRestPose(matrix: Matrix): void;
  26515. /**
  26516. * Gets the bind pose matrix
  26517. * @returns the bind pose matrix
  26518. */
  26519. getBindPose(): Matrix;
  26520. /**
  26521. * Sets the bind pose matrix
  26522. * @param matrix the local-space bind pose to set for this bone
  26523. */
  26524. setBindPose(matrix: Matrix): void;
  26525. /**
  26526. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26527. */
  26528. getWorldMatrix(): Matrix;
  26529. /**
  26530. * Sets the local matrix to rest pose matrix
  26531. */
  26532. returnToRest(): void;
  26533. /**
  26534. * Gets the inverse of the absolute transform matrix.
  26535. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26536. * @returns a matrix
  26537. */
  26538. getInvertedAbsoluteTransform(): Matrix;
  26539. /**
  26540. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26541. * @returns a matrix
  26542. */
  26543. getAbsoluteTransform(): Matrix;
  26544. /**
  26545. * Links with the given transform node.
  26546. * The local matrix of this bone is copied from the transform node every frame.
  26547. * @param transformNode defines the transform node to link to
  26548. */
  26549. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26550. /**
  26551. * Gets the node used to drive the bone's transformation
  26552. * @returns a transform node or null
  26553. */
  26554. getTransformNode(): Nullable<TransformNode>;
  26555. /** Gets or sets current position (in local space) */
  26556. get position(): Vector3;
  26557. set position(newPosition: Vector3);
  26558. /** Gets or sets current rotation (in local space) */
  26559. get rotation(): Vector3;
  26560. set rotation(newRotation: Vector3);
  26561. /** Gets or sets current rotation quaternion (in local space) */
  26562. get rotationQuaternion(): Quaternion;
  26563. set rotationQuaternion(newRotation: Quaternion);
  26564. /** Gets or sets current scaling (in local space) */
  26565. get scaling(): Vector3;
  26566. set scaling(newScaling: Vector3);
  26567. /**
  26568. * Gets the animation properties override
  26569. */
  26570. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26571. private _decompose;
  26572. private _compose;
  26573. /**
  26574. * Update the base and local matrices
  26575. * @param matrix defines the new base or local matrix
  26576. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26577. * @param updateLocalMatrix defines if the local matrix should be updated
  26578. */
  26579. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26580. /** @hidden */
  26581. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26582. /**
  26583. * Flag the bone as dirty (Forcing it to update everything)
  26584. */
  26585. markAsDirty(): void;
  26586. /** @hidden */
  26587. _markAsDirtyAndCompose(): void;
  26588. private _markAsDirtyAndDecompose;
  26589. /**
  26590. * Translate the bone in local or world space
  26591. * @param vec The amount to translate the bone
  26592. * @param space The space that the translation is in
  26593. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26594. */
  26595. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26596. /**
  26597. * Set the postion of the bone in local or world space
  26598. * @param position The position to set the bone
  26599. * @param space The space that the position is in
  26600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26601. */
  26602. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26603. /**
  26604. * Set the absolute position of the bone (world space)
  26605. * @param position The position to set the bone
  26606. * @param mesh The mesh that this bone is attached to
  26607. */
  26608. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26609. /**
  26610. * Scale the bone on the x, y and z axes (in local space)
  26611. * @param x The amount to scale the bone on the x axis
  26612. * @param y The amount to scale the bone on the y axis
  26613. * @param z The amount to scale the bone on the z axis
  26614. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26615. */
  26616. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26617. /**
  26618. * Set the bone scaling in local space
  26619. * @param scale defines the scaling vector
  26620. */
  26621. setScale(scale: Vector3): void;
  26622. /**
  26623. * Gets the current scaling in local space
  26624. * @returns the current scaling vector
  26625. */
  26626. getScale(): Vector3;
  26627. /**
  26628. * Gets the current scaling in local space and stores it in a target vector
  26629. * @param result defines the target vector
  26630. */
  26631. getScaleToRef(result: Vector3): void;
  26632. /**
  26633. * Set the yaw, pitch, and roll of the bone in local or world space
  26634. * @param yaw The rotation of the bone on the y axis
  26635. * @param pitch The rotation of the bone on the x axis
  26636. * @param roll The rotation of the bone on the z axis
  26637. * @param space The space that the axes of rotation are in
  26638. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26639. */
  26640. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26641. /**
  26642. * Add a rotation to the bone on an axis in local or world space
  26643. * @param axis The axis to rotate the bone on
  26644. * @param amount The amount to rotate the bone
  26645. * @param space The space that the axis is in
  26646. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26647. */
  26648. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26649. /**
  26650. * Set the rotation of the bone to a particular axis angle in local or world space
  26651. * @param axis The axis to rotate the bone on
  26652. * @param angle The angle that the bone should be rotated to
  26653. * @param space The space that the axis is in
  26654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26655. */
  26656. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26657. /**
  26658. * Set the euler rotation of the bone in local or world space
  26659. * @param rotation The euler rotation that the bone should be set to
  26660. * @param space The space that the rotation is in
  26661. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26662. */
  26663. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26664. /**
  26665. * Set the quaternion rotation of the bone in local or world space
  26666. * @param quat The quaternion rotation that the bone should be set to
  26667. * @param space The space that the rotation is in
  26668. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26669. */
  26670. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26671. /**
  26672. * Set the rotation matrix of the bone in local or world space
  26673. * @param rotMat The rotation matrix that the bone should be set to
  26674. * @param space The space that the rotation is in
  26675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26676. */
  26677. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26678. private _rotateWithMatrix;
  26679. private _getNegativeRotationToRef;
  26680. /**
  26681. * Get the position of the bone in local or world space
  26682. * @param space The space that the returned position is in
  26683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26684. * @returns The position of the bone
  26685. */
  26686. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26687. /**
  26688. * Copy the position of the bone to a vector3 in local or world space
  26689. * @param space The space that the returned position is in
  26690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26691. * @param result The vector3 to copy the position to
  26692. */
  26693. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26694. /**
  26695. * Get the absolute position of the bone (world space)
  26696. * @param mesh The mesh that this bone is attached to
  26697. * @returns The absolute position of the bone
  26698. */
  26699. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26700. /**
  26701. * Copy the absolute position of the bone (world space) to the result param
  26702. * @param mesh The mesh that this bone is attached to
  26703. * @param result The vector3 to copy the absolute position to
  26704. */
  26705. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26706. /**
  26707. * Compute the absolute transforms of this bone and its children
  26708. */
  26709. computeAbsoluteTransforms(): void;
  26710. /**
  26711. * Get the world direction from an axis that is in the local space of the bone
  26712. * @param localAxis The local direction that is used to compute the world direction
  26713. * @param mesh The mesh that this bone is attached to
  26714. * @returns The world direction
  26715. */
  26716. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26717. /**
  26718. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26719. * @param localAxis The local direction that is used to compute the world direction
  26720. * @param mesh The mesh that this bone is attached to
  26721. * @param result The vector3 that the world direction will be copied to
  26722. */
  26723. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26724. /**
  26725. * Get the euler rotation of the bone in local or world space
  26726. * @param space The space that the rotation should be in
  26727. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26728. * @returns The euler rotation
  26729. */
  26730. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26731. /**
  26732. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26733. * @param space The space that the rotation should be in
  26734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26735. * @param result The vector3 that the rotation should be copied to
  26736. */
  26737. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26738. /**
  26739. * Get the quaternion rotation of the bone in either local or world space
  26740. * @param space The space that the rotation should be in
  26741. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26742. * @returns The quaternion rotation
  26743. */
  26744. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26745. /**
  26746. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26747. * @param space The space that the rotation should be in
  26748. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26749. * @param result The quaternion that the rotation should be copied to
  26750. */
  26751. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26752. /**
  26753. * Get the rotation matrix of the bone in local or world space
  26754. * @param space The space that the rotation should be in
  26755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26756. * @returns The rotation matrix
  26757. */
  26758. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26759. /**
  26760. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26761. * @param space The space that the rotation should be in
  26762. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26763. * @param result The quaternion that the rotation should be copied to
  26764. */
  26765. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26766. /**
  26767. * Get the world position of a point that is in the local space of the bone
  26768. * @param position The local position
  26769. * @param mesh The mesh that this bone is attached to
  26770. * @returns The world position
  26771. */
  26772. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26773. /**
  26774. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26775. * @param position The local position
  26776. * @param mesh The mesh that this bone is attached to
  26777. * @param result The vector3 that the world position should be copied to
  26778. */
  26779. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26780. /**
  26781. * Get the local position of a point that is in world space
  26782. * @param position The world position
  26783. * @param mesh The mesh that this bone is attached to
  26784. * @returns The local position
  26785. */
  26786. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26787. /**
  26788. * Get the local position of a point that is in world space and copy it to the result param
  26789. * @param position The world position
  26790. * @param mesh The mesh that this bone is attached to
  26791. * @param result The vector3 that the local position should be copied to
  26792. */
  26793. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26794. /**
  26795. * Set the current local matrix as the restPose for this bone.
  26796. */
  26797. setCurrentPoseAsRest(): void;
  26798. }
  26799. }
  26800. declare module "babylonjs/Meshes/transformNode" {
  26801. import { DeepImmutable } from "babylonjs/types";
  26802. import { Observable } from "babylonjs/Misc/observable";
  26803. import { Nullable } from "babylonjs/types";
  26804. import { Camera } from "babylonjs/Cameras/camera";
  26805. import { Scene } from "babylonjs/scene";
  26806. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26807. import { Node } from "babylonjs/node";
  26808. import { Bone } from "babylonjs/Bones/bone";
  26809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26810. import { Space } from "babylonjs/Maths/math.axis";
  26811. /**
  26812. * 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.
  26813. * @see https://doc.babylonjs.com/how_to/transformnode
  26814. */
  26815. export class TransformNode extends Node {
  26816. /**
  26817. * Object will not rotate to face the camera
  26818. */
  26819. static BILLBOARDMODE_NONE: number;
  26820. /**
  26821. * Object will rotate to face the camera but only on the x axis
  26822. */
  26823. static BILLBOARDMODE_X: number;
  26824. /**
  26825. * Object will rotate to face the camera but only on the y axis
  26826. */
  26827. static BILLBOARDMODE_Y: number;
  26828. /**
  26829. * Object will rotate to face the camera but only on the z axis
  26830. */
  26831. static BILLBOARDMODE_Z: number;
  26832. /**
  26833. * Object will rotate to face the camera
  26834. */
  26835. static BILLBOARDMODE_ALL: number;
  26836. /**
  26837. * Object will rotate to face the camera's position instead of orientation
  26838. */
  26839. static BILLBOARDMODE_USE_POSITION: number;
  26840. private static _TmpRotation;
  26841. private static _TmpScaling;
  26842. private static _TmpTranslation;
  26843. private _forward;
  26844. private _forwardInverted;
  26845. private _up;
  26846. private _right;
  26847. private _rightInverted;
  26848. private _position;
  26849. private _rotation;
  26850. private _rotationQuaternion;
  26851. protected _scaling: Vector3;
  26852. protected _isDirty: boolean;
  26853. private _transformToBoneReferal;
  26854. private _isAbsoluteSynced;
  26855. private _billboardMode;
  26856. /**
  26857. * Gets or sets the billboard mode. Default is 0.
  26858. *
  26859. * | Value | Type | Description |
  26860. * | --- | --- | --- |
  26861. * | 0 | BILLBOARDMODE_NONE | |
  26862. * | 1 | BILLBOARDMODE_X | |
  26863. * | 2 | BILLBOARDMODE_Y | |
  26864. * | 4 | BILLBOARDMODE_Z | |
  26865. * | 7 | BILLBOARDMODE_ALL | |
  26866. *
  26867. */
  26868. get billboardMode(): number;
  26869. set billboardMode(value: number);
  26870. private _preserveParentRotationForBillboard;
  26871. /**
  26872. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26873. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26874. */
  26875. get preserveParentRotationForBillboard(): boolean;
  26876. set preserveParentRotationForBillboard(value: boolean);
  26877. /**
  26878. * 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
  26879. */
  26880. scalingDeterminant: number;
  26881. private _infiniteDistance;
  26882. /**
  26883. * Gets or sets the distance of the object to max, often used by skybox
  26884. */
  26885. get infiniteDistance(): boolean;
  26886. set infiniteDistance(value: boolean);
  26887. /**
  26888. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26889. * By default the system will update normals to compensate
  26890. */
  26891. ignoreNonUniformScaling: boolean;
  26892. /**
  26893. * 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
  26894. */
  26895. reIntegrateRotationIntoRotationQuaternion: boolean;
  26896. /** @hidden */
  26897. _poseMatrix: Nullable<Matrix>;
  26898. /** @hidden */
  26899. _localMatrix: Matrix;
  26900. private _usePivotMatrix;
  26901. private _absolutePosition;
  26902. private _absoluteScaling;
  26903. private _absoluteRotationQuaternion;
  26904. private _pivotMatrix;
  26905. private _pivotMatrixInverse;
  26906. /** @hidden */
  26907. _postMultiplyPivotMatrix: boolean;
  26908. protected _isWorldMatrixFrozen: boolean;
  26909. /** @hidden */
  26910. _indexInSceneTransformNodesArray: number;
  26911. /**
  26912. * An event triggered after the world matrix is updated
  26913. */
  26914. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26915. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26916. /**
  26917. * Gets a string identifying the name of the class
  26918. * @returns "TransformNode" string
  26919. */
  26920. getClassName(): string;
  26921. /**
  26922. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26923. */
  26924. get position(): Vector3;
  26925. set position(newPosition: Vector3);
  26926. /**
  26927. * 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)).
  26928. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26929. */
  26930. get rotation(): Vector3;
  26931. set rotation(newRotation: Vector3);
  26932. /**
  26933. * 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)).
  26934. */
  26935. get scaling(): Vector3;
  26936. set scaling(newScaling: Vector3);
  26937. /**
  26938. * 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).
  26939. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26940. */
  26941. get rotationQuaternion(): Nullable<Quaternion>;
  26942. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26943. /**
  26944. * The forward direction of that transform in world space.
  26945. */
  26946. get forward(): Vector3;
  26947. /**
  26948. * The up direction of that transform in world space.
  26949. */
  26950. get up(): Vector3;
  26951. /**
  26952. * The right direction of that transform in world space.
  26953. */
  26954. get right(): Vector3;
  26955. /**
  26956. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26957. * @param matrix the matrix to copy the pose from
  26958. * @returns this TransformNode.
  26959. */
  26960. updatePoseMatrix(matrix: Matrix): TransformNode;
  26961. /**
  26962. * Returns the mesh Pose matrix.
  26963. * @returns the pose matrix
  26964. */
  26965. getPoseMatrix(): Matrix;
  26966. /** @hidden */
  26967. _isSynchronized(): boolean;
  26968. /** @hidden */
  26969. _initCache(): void;
  26970. /**
  26971. * Flag the transform node as dirty (Forcing it to update everything)
  26972. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26973. * @returns this transform node
  26974. */
  26975. markAsDirty(property: string): TransformNode;
  26976. /**
  26977. * Returns the current mesh absolute position.
  26978. * Returns a Vector3.
  26979. */
  26980. get absolutePosition(): Vector3;
  26981. /**
  26982. * Returns the current mesh absolute scaling.
  26983. * Returns a Vector3.
  26984. */
  26985. get absoluteScaling(): Vector3;
  26986. /**
  26987. * Returns the current mesh absolute rotation.
  26988. * Returns a Quaternion.
  26989. */
  26990. get absoluteRotationQuaternion(): Quaternion;
  26991. /**
  26992. * Sets a new matrix to apply before all other transformation
  26993. * @param matrix defines the transform matrix
  26994. * @returns the current TransformNode
  26995. */
  26996. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26997. /**
  26998. * Sets a new pivot matrix to the current node
  26999. * @param matrix defines the new pivot matrix to use
  27000. * @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
  27001. * @returns the current TransformNode
  27002. */
  27003. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  27004. /**
  27005. * Returns the mesh pivot matrix.
  27006. * Default : Identity.
  27007. * @returns the matrix
  27008. */
  27009. getPivotMatrix(): Matrix;
  27010. /**
  27011. * Instantiate (when possible) or clone that node with its hierarchy
  27012. * @param newParent defines the new parent to use for the instance (or clone)
  27013. * @param options defines options to configure how copy is done
  27014. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  27015. * @returns an instance (or a clone) of the current node with its hiearchy
  27016. */
  27017. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27018. doNotInstantiate: boolean;
  27019. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27020. /**
  27021. * Prevents the World matrix to be computed any longer
  27022. * @param newWorldMatrix defines an optional matrix to use as world matrix
  27023. * @returns the TransformNode.
  27024. */
  27025. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27026. /**
  27027. * Allows back the World matrix computation.
  27028. * @returns the TransformNode.
  27029. */
  27030. unfreezeWorldMatrix(): this;
  27031. /**
  27032. * True if the World matrix has been frozen.
  27033. */
  27034. get isWorldMatrixFrozen(): boolean;
  27035. /**
  27036. * Retuns the mesh absolute position in the World.
  27037. * @returns a Vector3.
  27038. */
  27039. getAbsolutePosition(): Vector3;
  27040. /**
  27041. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27042. * @param absolutePosition the absolute position to set
  27043. * @returns the TransformNode.
  27044. */
  27045. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27046. /**
  27047. * Sets the mesh position in its local space.
  27048. * @param vector3 the position to set in localspace
  27049. * @returns the TransformNode.
  27050. */
  27051. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27052. /**
  27053. * Returns the mesh position in the local space from the current World matrix values.
  27054. * @returns a new Vector3.
  27055. */
  27056. getPositionExpressedInLocalSpace(): Vector3;
  27057. /**
  27058. * Translates the mesh along the passed Vector3 in its local space.
  27059. * @param vector3 the distance to translate in localspace
  27060. * @returns the TransformNode.
  27061. */
  27062. locallyTranslate(vector3: Vector3): TransformNode;
  27063. private static _lookAtVectorCache;
  27064. /**
  27065. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27066. * @param targetPoint the position (must be in same space as current mesh) to look at
  27067. * @param yawCor optional yaw (y-axis) correction in radians
  27068. * @param pitchCor optional pitch (x-axis) correction in radians
  27069. * @param rollCor optional roll (z-axis) correction in radians
  27070. * @param space the choosen space of the target
  27071. * @returns the TransformNode.
  27072. */
  27073. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27074. /**
  27075. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27076. * This Vector3 is expressed in the World space.
  27077. * @param localAxis axis to rotate
  27078. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27079. */
  27080. getDirection(localAxis: Vector3): Vector3;
  27081. /**
  27082. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27083. * localAxis is expressed in the mesh local space.
  27084. * result is computed in the Wordl space from the mesh World matrix.
  27085. * @param localAxis axis to rotate
  27086. * @param result the resulting transformnode
  27087. * @returns this TransformNode.
  27088. */
  27089. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27090. /**
  27091. * Sets this transform node rotation to the given local axis.
  27092. * @param localAxis the axis in local space
  27093. * @param yawCor optional yaw (y-axis) correction in radians
  27094. * @param pitchCor optional pitch (x-axis) correction in radians
  27095. * @param rollCor optional roll (z-axis) correction in radians
  27096. * @returns this TransformNode
  27097. */
  27098. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27099. /**
  27100. * Sets a new pivot point to the current node
  27101. * @param point defines the new pivot point to use
  27102. * @param space defines if the point is in world or local space (local by default)
  27103. * @returns the current TransformNode
  27104. */
  27105. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27106. /**
  27107. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27108. * @returns the pivot point
  27109. */
  27110. getPivotPoint(): Vector3;
  27111. /**
  27112. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27113. * @param result the vector3 to store the result
  27114. * @returns this TransformNode.
  27115. */
  27116. getPivotPointToRef(result: Vector3): TransformNode;
  27117. /**
  27118. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27119. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27120. */
  27121. getAbsolutePivotPoint(): Vector3;
  27122. /**
  27123. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27124. * @param result vector3 to store the result
  27125. * @returns this TransformNode.
  27126. */
  27127. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27128. /**
  27129. * Defines the passed node as the parent of the current node.
  27130. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27131. * @see https://doc.babylonjs.com/how_to/parenting
  27132. * @param node the node ot set as the parent
  27133. * @returns this TransformNode.
  27134. */
  27135. setParent(node: Nullable<Node>): TransformNode;
  27136. private _nonUniformScaling;
  27137. /**
  27138. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27139. */
  27140. get nonUniformScaling(): boolean;
  27141. /** @hidden */
  27142. _updateNonUniformScalingState(value: boolean): boolean;
  27143. /**
  27144. * Attach the current TransformNode to another TransformNode associated with a bone
  27145. * @param bone Bone affecting the TransformNode
  27146. * @param affectedTransformNode TransformNode associated with the bone
  27147. * @returns this object
  27148. */
  27149. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27150. /**
  27151. * Detach the transform node if its associated with a bone
  27152. * @returns this object
  27153. */
  27154. detachFromBone(): TransformNode;
  27155. private static _rotationAxisCache;
  27156. /**
  27157. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27158. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27159. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27160. * The passed axis is also normalized.
  27161. * @param axis the axis to rotate around
  27162. * @param amount the amount to rotate in radians
  27163. * @param space Space to rotate in (Default: local)
  27164. * @returns the TransformNode.
  27165. */
  27166. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27167. /**
  27168. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27169. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27170. * The passed axis is also normalized. .
  27171. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27172. * @param point the point to rotate around
  27173. * @param axis the axis to rotate around
  27174. * @param amount the amount to rotate in radians
  27175. * @returns the TransformNode
  27176. */
  27177. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27178. /**
  27179. * Translates the mesh along the axis vector for the passed distance in the given space.
  27180. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27181. * @param axis the axis to translate in
  27182. * @param distance the distance to translate
  27183. * @param space Space to rotate in (Default: local)
  27184. * @returns the TransformNode.
  27185. */
  27186. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27187. /**
  27188. * Adds a rotation step to the mesh current rotation.
  27189. * x, y, z are Euler angles expressed in radians.
  27190. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27191. * This means this rotation is made in the mesh local space only.
  27192. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27193. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27194. * ```javascript
  27195. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27196. * ```
  27197. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27198. * 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.
  27199. * @param x Rotation to add
  27200. * @param y Rotation to add
  27201. * @param z Rotation to add
  27202. * @returns the TransformNode.
  27203. */
  27204. addRotation(x: number, y: number, z: number): TransformNode;
  27205. /**
  27206. * @hidden
  27207. */
  27208. protected _getEffectiveParent(): Nullable<Node>;
  27209. /**
  27210. * Computes the world matrix of the node
  27211. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27212. * @returns the world matrix
  27213. */
  27214. computeWorldMatrix(force?: boolean): Matrix;
  27215. /**
  27216. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27217. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27218. */
  27219. resetLocalMatrix(independentOfChildren?: boolean): void;
  27220. protected _afterComputeWorldMatrix(): void;
  27221. /**
  27222. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27223. * @param func callback function to add
  27224. *
  27225. * @returns the TransformNode.
  27226. */
  27227. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27228. /**
  27229. * Removes a registered callback function.
  27230. * @param func callback function to remove
  27231. * @returns the TransformNode.
  27232. */
  27233. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27234. /**
  27235. * Gets the position of the current mesh in camera space
  27236. * @param camera defines the camera to use
  27237. * @returns a position
  27238. */
  27239. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27240. /**
  27241. * Returns the distance from the mesh to the active camera
  27242. * @param camera defines the camera to use
  27243. * @returns the distance
  27244. */
  27245. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27246. /**
  27247. * Clone the current transform node
  27248. * @param name Name of the new clone
  27249. * @param newParent New parent for the clone
  27250. * @param doNotCloneChildren Do not clone children hierarchy
  27251. * @returns the new transform node
  27252. */
  27253. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27254. /**
  27255. * Serializes the objects information.
  27256. * @param currentSerializationObject defines the object to serialize in
  27257. * @returns the serialized object
  27258. */
  27259. serialize(currentSerializationObject?: any): any;
  27260. /**
  27261. * Returns a new TransformNode object parsed from the source provided.
  27262. * @param parsedTransformNode is the source.
  27263. * @param scene the scne the object belongs to
  27264. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27265. * @returns a new TransformNode object parsed from the source provided.
  27266. */
  27267. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27268. /**
  27269. * Get all child-transformNodes of this node
  27270. * @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
  27271. * @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
  27272. * @returns an array of TransformNode
  27273. */
  27274. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27275. /**
  27276. * Releases resources associated with this transform node.
  27277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27279. */
  27280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27281. /**
  27282. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27283. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27284. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27285. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27286. * @returns the current mesh
  27287. */
  27288. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27289. private _syncAbsoluteScalingAndRotation;
  27290. }
  27291. }
  27292. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  27293. import { Observable } from "babylonjs/Misc/observable";
  27294. import { Nullable } from "babylonjs/types";
  27295. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27298. import { Ray } from "babylonjs/Culling/ray";
  27299. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  27300. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  27301. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  27302. /**
  27303. * Defines the types of pose enabled controllers that are supported
  27304. */
  27305. export enum PoseEnabledControllerType {
  27306. /**
  27307. * HTC Vive
  27308. */
  27309. VIVE = 0,
  27310. /**
  27311. * Oculus Rift
  27312. */
  27313. OCULUS = 1,
  27314. /**
  27315. * Windows mixed reality
  27316. */
  27317. WINDOWS = 2,
  27318. /**
  27319. * Samsung gear VR
  27320. */
  27321. GEAR_VR = 3,
  27322. /**
  27323. * Google Daydream
  27324. */
  27325. DAYDREAM = 4,
  27326. /**
  27327. * Generic
  27328. */
  27329. GENERIC = 5
  27330. }
  27331. /**
  27332. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27333. */
  27334. export interface MutableGamepadButton {
  27335. /**
  27336. * Value of the button/trigger
  27337. */
  27338. value: number;
  27339. /**
  27340. * If the button/trigger is currently touched
  27341. */
  27342. touched: boolean;
  27343. /**
  27344. * If the button/trigger is currently pressed
  27345. */
  27346. pressed: boolean;
  27347. }
  27348. /**
  27349. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27350. * @hidden
  27351. */
  27352. export interface ExtendedGamepadButton extends GamepadButton {
  27353. /**
  27354. * If the button/trigger is currently pressed
  27355. */
  27356. readonly pressed: boolean;
  27357. /**
  27358. * If the button/trigger is currently touched
  27359. */
  27360. readonly touched: boolean;
  27361. /**
  27362. * Value of the button/trigger
  27363. */
  27364. readonly value: number;
  27365. }
  27366. /** @hidden */
  27367. export interface _GamePadFactory {
  27368. /**
  27369. * Returns whether or not the current gamepad can be created for this type of controller.
  27370. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27371. * @returns true if it can be created, otherwise false
  27372. */
  27373. canCreate(gamepadInfo: any): boolean;
  27374. /**
  27375. * Creates a new instance of the Gamepad.
  27376. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27377. * @returns the new gamepad instance
  27378. */
  27379. create(gamepadInfo: any): Gamepad;
  27380. }
  27381. /**
  27382. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27383. */
  27384. export class PoseEnabledControllerHelper {
  27385. /** @hidden */
  27386. static _ControllerFactories: _GamePadFactory[];
  27387. /** @hidden */
  27388. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27389. /**
  27390. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27391. * @param vrGamepad the gamepad to initialized
  27392. * @returns a vr controller of the type the gamepad identified as
  27393. */
  27394. static InitiateController(vrGamepad: any): Gamepad;
  27395. }
  27396. /**
  27397. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27398. */
  27399. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27400. /**
  27401. * If the controller is used in a webXR session
  27402. */
  27403. isXR: boolean;
  27404. private _deviceRoomPosition;
  27405. private _deviceRoomRotationQuaternion;
  27406. /**
  27407. * The device position in babylon space
  27408. */
  27409. devicePosition: Vector3;
  27410. /**
  27411. * The device rotation in babylon space
  27412. */
  27413. deviceRotationQuaternion: Quaternion;
  27414. /**
  27415. * The scale factor of the device in babylon space
  27416. */
  27417. deviceScaleFactor: number;
  27418. /**
  27419. * (Likely devicePosition should be used instead) The device position in its room space
  27420. */
  27421. position: Vector3;
  27422. /**
  27423. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27424. */
  27425. rotationQuaternion: Quaternion;
  27426. /**
  27427. * The type of controller (Eg. Windows mixed reality)
  27428. */
  27429. controllerType: PoseEnabledControllerType;
  27430. protected _calculatedPosition: Vector3;
  27431. private _calculatedRotation;
  27432. /**
  27433. * The raw pose from the device
  27434. */
  27435. rawPose: DevicePose;
  27436. private _trackPosition;
  27437. private _maxRotationDistFromHeadset;
  27438. private _draggedRoomRotation;
  27439. /**
  27440. * @hidden
  27441. */
  27442. _disableTrackPosition(fixedPosition: Vector3): void;
  27443. /**
  27444. * Internal, the mesh attached to the controller
  27445. * @hidden
  27446. */
  27447. _mesh: Nullable<AbstractMesh>;
  27448. private _poseControlledCamera;
  27449. private _leftHandSystemQuaternion;
  27450. /**
  27451. * Internal, matrix used to convert room space to babylon space
  27452. * @hidden
  27453. */
  27454. _deviceToWorld: Matrix;
  27455. /**
  27456. * Node to be used when casting a ray from the controller
  27457. * @hidden
  27458. */
  27459. _pointingPoseNode: Nullable<TransformNode>;
  27460. /**
  27461. * Name of the child mesh that can be used to cast a ray from the controller
  27462. */
  27463. static readonly POINTING_POSE: string;
  27464. /**
  27465. * Creates a new PoseEnabledController from a gamepad
  27466. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27467. */
  27468. constructor(browserGamepad: any);
  27469. private _workingMatrix;
  27470. /**
  27471. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27472. */
  27473. update(): void;
  27474. /**
  27475. * Updates only the pose device and mesh without doing any button event checking
  27476. */
  27477. protected _updatePoseAndMesh(): void;
  27478. /**
  27479. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27480. * @param poseData raw pose fromthe device
  27481. */
  27482. updateFromDevice(poseData: DevicePose): void;
  27483. /**
  27484. * @hidden
  27485. */
  27486. _meshAttachedObservable: Observable<AbstractMesh>;
  27487. /**
  27488. * Attaches a mesh to the controller
  27489. * @param mesh the mesh to be attached
  27490. */
  27491. attachToMesh(mesh: AbstractMesh): void;
  27492. /**
  27493. * Attaches the controllers mesh to a camera
  27494. * @param camera the camera the mesh should be attached to
  27495. */
  27496. attachToPoseControlledCamera(camera: TargetCamera): void;
  27497. /**
  27498. * Disposes of the controller
  27499. */
  27500. dispose(): void;
  27501. /**
  27502. * The mesh that is attached to the controller
  27503. */
  27504. get mesh(): Nullable<AbstractMesh>;
  27505. /**
  27506. * Gets the ray of the controller in the direction the controller is pointing
  27507. * @param length the length the resulting ray should be
  27508. * @returns a ray in the direction the controller is pointing
  27509. */
  27510. getForwardRay(length?: number): Ray;
  27511. }
  27512. }
  27513. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  27514. import { Observable } from "babylonjs/Misc/observable";
  27515. import { Scene } from "babylonjs/scene";
  27516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27517. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  27518. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  27519. import { Nullable } from "babylonjs/types";
  27520. /**
  27521. * Defines the WebVRController object that represents controllers tracked in 3D space
  27522. */
  27523. export abstract class WebVRController extends PoseEnabledController {
  27524. /**
  27525. * Internal, the default controller model for the controller
  27526. */
  27527. protected _defaultModel: Nullable<AbstractMesh>;
  27528. /**
  27529. * Fired when the trigger state has changed
  27530. */
  27531. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27532. /**
  27533. * Fired when the main button state has changed
  27534. */
  27535. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27536. /**
  27537. * Fired when the secondary button state has changed
  27538. */
  27539. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27540. /**
  27541. * Fired when the pad state has changed
  27542. */
  27543. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27544. /**
  27545. * Fired when controllers stick values have changed
  27546. */
  27547. onPadValuesChangedObservable: Observable<StickValues>;
  27548. /**
  27549. * Array of button availible on the controller
  27550. */
  27551. protected _buttons: Array<MutableGamepadButton>;
  27552. private _onButtonStateChange;
  27553. /**
  27554. * Fired when a controller button's state has changed
  27555. * @param callback the callback containing the button that was modified
  27556. */
  27557. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27558. /**
  27559. * X and Y axis corresponding to the controllers joystick
  27560. */
  27561. pad: StickValues;
  27562. /**
  27563. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27564. */
  27565. hand: string;
  27566. /**
  27567. * The default controller model for the controller
  27568. */
  27569. get defaultModel(): Nullable<AbstractMesh>;
  27570. /**
  27571. * Creates a new WebVRController from a gamepad
  27572. * @param vrGamepad the gamepad that the WebVRController should be created from
  27573. */
  27574. constructor(vrGamepad: any);
  27575. /**
  27576. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27577. */
  27578. update(): void;
  27579. /**
  27580. * Function to be called when a button is modified
  27581. */
  27582. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27583. /**
  27584. * Loads a mesh and attaches it to the controller
  27585. * @param scene the scene the mesh should be added to
  27586. * @param meshLoaded callback for when the mesh has been loaded
  27587. */
  27588. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27589. private _setButtonValue;
  27590. private _changes;
  27591. private _checkChanges;
  27592. /**
  27593. * Disposes of th webVRCOntroller
  27594. */
  27595. dispose(): void;
  27596. }
  27597. }
  27598. declare module "babylonjs/Lights/hemisphericLight" {
  27599. import { Nullable } from "babylonjs/types";
  27600. import { Scene } from "babylonjs/scene";
  27601. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27602. import { Color3 } from "babylonjs/Maths/math.color";
  27603. import { Effect } from "babylonjs/Materials/effect";
  27604. import { Light } from "babylonjs/Lights/light";
  27605. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  27606. /**
  27607. * The HemisphericLight simulates the ambient environment light,
  27608. * so the passed direction is the light reflection direction, not the incoming direction.
  27609. */
  27610. export class HemisphericLight extends Light {
  27611. /**
  27612. * The groundColor is the light in the opposite direction to the one specified during creation.
  27613. * 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.
  27614. */
  27615. groundColor: Color3;
  27616. /**
  27617. * The light reflection direction, not the incoming direction.
  27618. */
  27619. direction: Vector3;
  27620. /**
  27621. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27622. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27623. * The HemisphericLight can't cast shadows.
  27624. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27625. * @param name The friendly name of the light
  27626. * @param direction The direction of the light reflection
  27627. * @param scene The scene the light belongs to
  27628. */
  27629. constructor(name: string, direction: Vector3, scene: Scene);
  27630. protected _buildUniformLayout(): void;
  27631. /**
  27632. * Returns the string "HemisphericLight".
  27633. * @return The class name
  27634. */
  27635. getClassName(): string;
  27636. /**
  27637. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27638. * Returns the updated direction.
  27639. * @param target The target the direction should point to
  27640. * @return The computed direction
  27641. */
  27642. setDirectionToTarget(target: Vector3): Vector3;
  27643. /**
  27644. * Returns the shadow generator associated to the light.
  27645. * @returns Always null for hemispheric lights because it does not support shadows.
  27646. */
  27647. getShadowGenerator(): Nullable<IShadowGenerator>;
  27648. /**
  27649. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27650. * @param effect The effect to update
  27651. * @param lightIndex The index of the light in the effect to update
  27652. * @returns The hemispheric light
  27653. */
  27654. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27655. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27656. /**
  27657. * Computes the world matrix of the node
  27658. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27659. * @param useWasUpdatedFlag defines a reserved property
  27660. * @returns the world matrix
  27661. */
  27662. computeWorldMatrix(): Matrix;
  27663. /**
  27664. * Returns the integer 3.
  27665. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27666. */
  27667. getTypeID(): number;
  27668. /**
  27669. * Prepares the list of defines specific to the light type.
  27670. * @param defines the list of defines
  27671. * @param lightIndex defines the index of the light for the effect
  27672. */
  27673. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27674. }
  27675. }
  27676. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  27677. /** @hidden */
  27678. export var vrMultiviewToSingleviewPixelShader: {
  27679. name: string;
  27680. shader: string;
  27681. };
  27682. }
  27683. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  27684. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27685. import { Scene } from "babylonjs/scene";
  27686. /**
  27687. * Renders to multiple views with a single draw call
  27688. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27689. */
  27690. export class MultiviewRenderTarget extends RenderTargetTexture {
  27691. /**
  27692. * Creates a multiview render target
  27693. * @param scene scene used with the render target
  27694. * @param size the size of the render target (used for each view)
  27695. */
  27696. constructor(scene: Scene, size?: number | {
  27697. width: number;
  27698. height: number;
  27699. } | {
  27700. ratio: number;
  27701. });
  27702. /**
  27703. * @hidden
  27704. * @param faceIndex the face index, if its a cube texture
  27705. */
  27706. _bindFrameBuffer(faceIndex?: number): void;
  27707. /**
  27708. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27709. * @returns the view count
  27710. */
  27711. getViewCount(): number;
  27712. }
  27713. }
  27714. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  27715. import { Camera } from "babylonjs/Cameras/camera";
  27716. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27717. import { Nullable } from "babylonjs/types";
  27718. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27719. import { Matrix } from "babylonjs/Maths/math.vector";
  27720. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27721. module "babylonjs/Engines/engine" {
  27722. interface Engine {
  27723. /**
  27724. * Creates a new multiview render target
  27725. * @param width defines the width of the texture
  27726. * @param height defines the height of the texture
  27727. * @returns the created multiview texture
  27728. */
  27729. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27730. /**
  27731. * Binds a multiview framebuffer to be drawn to
  27732. * @param multiviewTexture texture to bind
  27733. */
  27734. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27735. }
  27736. }
  27737. module "babylonjs/Cameras/camera" {
  27738. interface Camera {
  27739. /**
  27740. * @hidden
  27741. * 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)
  27742. */
  27743. _useMultiviewToSingleView: boolean;
  27744. /**
  27745. * @hidden
  27746. * 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)
  27747. */
  27748. _multiviewTexture: Nullable<RenderTargetTexture>;
  27749. /**
  27750. * @hidden
  27751. * ensures the multiview texture of the camera exists and has the specified width/height
  27752. * @param width height to set on the multiview texture
  27753. * @param height width to set on the multiview texture
  27754. */
  27755. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27756. }
  27757. }
  27758. module "babylonjs/scene" {
  27759. interface Scene {
  27760. /** @hidden */
  27761. _transformMatrixR: Matrix;
  27762. /** @hidden */
  27763. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27764. /** @hidden */
  27765. _createMultiviewUbo(): void;
  27766. /** @hidden */
  27767. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27768. /** @hidden */
  27769. _renderMultiviewToSingleView(camera: Camera): void;
  27770. }
  27771. }
  27772. }
  27773. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  27774. import { Camera } from "babylonjs/Cameras/camera";
  27775. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27776. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  27777. import "babylonjs/Engines/Extensions/engine.multiview";
  27778. /**
  27779. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27780. * This will not be used for webXR as it supports displaying texture arrays directly
  27781. */
  27782. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27783. /**
  27784. * Gets a string identifying the name of the class
  27785. * @returns "VRMultiviewToSingleviewPostProcess" string
  27786. */
  27787. getClassName(): string;
  27788. /**
  27789. * Initializes a VRMultiviewToSingleview
  27790. * @param name name of the post process
  27791. * @param camera camera to be applied to
  27792. * @param scaleFactor scaling factor to the size of the output texture
  27793. */
  27794. constructor(name: string, camera: Camera, scaleFactor: number);
  27795. }
  27796. }
  27797. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  27798. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  27799. import { Nullable } from "babylonjs/types";
  27800. import { Size } from "babylonjs/Maths/math.size";
  27801. import { Observable } from "babylonjs/Misc/observable";
  27802. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  27803. /**
  27804. * Interface used to define additional presentation attributes
  27805. */
  27806. export interface IVRPresentationAttributes {
  27807. /**
  27808. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27809. */
  27810. highRefreshRate: boolean;
  27811. /**
  27812. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27813. */
  27814. foveationLevel: number;
  27815. }
  27816. module "babylonjs/Engines/engine" {
  27817. interface Engine {
  27818. /** @hidden */
  27819. _vrDisplay: any;
  27820. /** @hidden */
  27821. _vrSupported: boolean;
  27822. /** @hidden */
  27823. _oldSize: Size;
  27824. /** @hidden */
  27825. _oldHardwareScaleFactor: number;
  27826. /** @hidden */
  27827. _vrExclusivePointerMode: boolean;
  27828. /** @hidden */
  27829. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27830. /** @hidden */
  27831. _onVRDisplayPointerRestricted: () => void;
  27832. /** @hidden */
  27833. _onVRDisplayPointerUnrestricted: () => void;
  27834. /** @hidden */
  27835. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27836. /** @hidden */
  27837. _onVrDisplayDisconnect: Nullable<() => void>;
  27838. /** @hidden */
  27839. _onVrDisplayPresentChange: Nullable<() => void>;
  27840. /**
  27841. * Observable signaled when VR display mode changes
  27842. */
  27843. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27844. /**
  27845. * Observable signaled when VR request present is complete
  27846. */
  27847. onVRRequestPresentComplete: Observable<boolean>;
  27848. /**
  27849. * Observable signaled when VR request present starts
  27850. */
  27851. onVRRequestPresentStart: Observable<Engine>;
  27852. /**
  27853. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27854. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27855. */
  27856. isInVRExclusivePointerMode: boolean;
  27857. /**
  27858. * Gets a boolean indicating if a webVR device was detected
  27859. * @returns true if a webVR device was detected
  27860. */
  27861. isVRDevicePresent(): boolean;
  27862. /**
  27863. * Gets the current webVR device
  27864. * @returns the current webVR device (or null)
  27865. */
  27866. getVRDevice(): any;
  27867. /**
  27868. * Initializes a webVR display and starts listening to display change events
  27869. * The onVRDisplayChangedObservable will be notified upon these changes
  27870. * @returns A promise containing a VRDisplay and if vr is supported
  27871. */
  27872. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27873. /** @hidden */
  27874. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27875. /**
  27876. * Gets or sets the presentation attributes used to configure VR rendering
  27877. */
  27878. vrPresentationAttributes?: IVRPresentationAttributes;
  27879. /**
  27880. * Call this function to switch to webVR mode
  27881. * Will do nothing if webVR is not supported or if there is no webVR device
  27882. * @param options the webvr options provided to the camera. mainly used for multiview
  27883. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27884. */
  27885. enableVR(options: WebVROptions): void;
  27886. /** @hidden */
  27887. _onVRFullScreenTriggered(): void;
  27888. }
  27889. }
  27890. }
  27891. declare module "babylonjs/Cameras/VR/webVRCamera" {
  27892. import { Nullable } from "babylonjs/types";
  27893. import { Observable } from "babylonjs/Misc/observable";
  27894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  27895. import { Scene } from "babylonjs/scene";
  27896. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27897. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  27898. import { Node } from "babylonjs/node";
  27899. import { Ray } from "babylonjs/Culling/ray";
  27900. import "babylonjs/Cameras/RigModes/webVRRigMode";
  27901. import "babylonjs/Engines/Extensions/engine.webVR";
  27902. /**
  27903. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27904. * IMPORTANT!! The data is right-hand data.
  27905. * @export
  27906. * @interface DevicePose
  27907. */
  27908. export interface DevicePose {
  27909. /**
  27910. * The position of the device, values in array are [x,y,z].
  27911. */
  27912. readonly position: Nullable<Float32Array>;
  27913. /**
  27914. * The linearVelocity of the device, values in array are [x,y,z].
  27915. */
  27916. readonly linearVelocity: Nullable<Float32Array>;
  27917. /**
  27918. * The linearAcceleration of the device, values in array are [x,y,z].
  27919. */
  27920. readonly linearAcceleration: Nullable<Float32Array>;
  27921. /**
  27922. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27923. */
  27924. readonly orientation: Nullable<Float32Array>;
  27925. /**
  27926. * The angularVelocity of the device, values in array are [x,y,z].
  27927. */
  27928. readonly angularVelocity: Nullable<Float32Array>;
  27929. /**
  27930. * The angularAcceleration of the device, values in array are [x,y,z].
  27931. */
  27932. readonly angularAcceleration: Nullable<Float32Array>;
  27933. }
  27934. /**
  27935. * Interface representing a pose controlled object in Babylon.
  27936. * A pose controlled object has both regular pose values as well as pose values
  27937. * from an external device such as a VR head mounted display
  27938. */
  27939. export interface PoseControlled {
  27940. /**
  27941. * The position of the object in babylon space.
  27942. */
  27943. position: Vector3;
  27944. /**
  27945. * The rotation quaternion of the object in babylon space.
  27946. */
  27947. rotationQuaternion: Quaternion;
  27948. /**
  27949. * The position of the device in babylon space.
  27950. */
  27951. devicePosition?: Vector3;
  27952. /**
  27953. * The rotation quaternion of the device in babylon space.
  27954. */
  27955. deviceRotationQuaternion: Quaternion;
  27956. /**
  27957. * The raw pose coming from the device.
  27958. */
  27959. rawPose: Nullable<DevicePose>;
  27960. /**
  27961. * The scale of the device to be used when translating from device space to babylon space.
  27962. */
  27963. deviceScaleFactor: number;
  27964. /**
  27965. * Updates the poseControlled values based on the input device pose.
  27966. * @param poseData the pose data to update the object with
  27967. */
  27968. updateFromDevice(poseData: DevicePose): void;
  27969. }
  27970. /**
  27971. * Set of options to customize the webVRCamera
  27972. */
  27973. export interface WebVROptions {
  27974. /**
  27975. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27976. */
  27977. trackPosition?: boolean;
  27978. /**
  27979. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27980. */
  27981. positionScale?: number;
  27982. /**
  27983. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27984. */
  27985. displayName?: string;
  27986. /**
  27987. * Should the native controller meshes be initialized. (default: true)
  27988. */
  27989. controllerMeshes?: boolean;
  27990. /**
  27991. * Creating a default HemiLight only on controllers. (default: true)
  27992. */
  27993. defaultLightingOnControllers?: boolean;
  27994. /**
  27995. * If you don't want to use the default VR button of the helper. (default: false)
  27996. */
  27997. useCustomVRButton?: boolean;
  27998. /**
  27999. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  28000. */
  28001. customVRButton?: HTMLButtonElement;
  28002. /**
  28003. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  28004. */
  28005. rayLength?: number;
  28006. /**
  28007. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  28008. */
  28009. defaultHeight?: number;
  28010. /**
  28011. * If multiview should be used if availible (default: false)
  28012. */
  28013. useMultiview?: boolean;
  28014. }
  28015. /**
  28016. * This represents a WebVR camera.
  28017. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  28018. * @example https://doc.babylonjs.com/how_to/webvr_camera
  28019. */
  28020. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  28021. private webVROptions;
  28022. /**
  28023. * @hidden
  28024. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  28025. */
  28026. _vrDevice: any;
  28027. /**
  28028. * The rawPose of the vrDevice.
  28029. */
  28030. rawPose: Nullable<DevicePose>;
  28031. private _onVREnabled;
  28032. private _specsVersion;
  28033. private _attached;
  28034. private _frameData;
  28035. protected _descendants: Array<Node>;
  28036. private _deviceRoomPosition;
  28037. /** @hidden */
  28038. _deviceRoomRotationQuaternion: Quaternion;
  28039. private _standingMatrix;
  28040. /**
  28041. * Represents device position in babylon space.
  28042. */
  28043. devicePosition: Vector3;
  28044. /**
  28045. * Represents device rotation in babylon space.
  28046. */
  28047. deviceRotationQuaternion: Quaternion;
  28048. /**
  28049. * The scale of the device to be used when translating from device space to babylon space.
  28050. */
  28051. deviceScaleFactor: number;
  28052. private _deviceToWorld;
  28053. private _worldToDevice;
  28054. /**
  28055. * References to the webVR controllers for the vrDevice.
  28056. */
  28057. controllers: Array<WebVRController>;
  28058. /**
  28059. * Emits an event when a controller is attached.
  28060. */
  28061. onControllersAttachedObservable: Observable<WebVRController[]>;
  28062. /**
  28063. * Emits an event when a controller's mesh has been loaded;
  28064. */
  28065. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28066. /**
  28067. * Emits an event when the HMD's pose has been updated.
  28068. */
  28069. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28070. private _poseSet;
  28071. /**
  28072. * If the rig cameras be used as parent instead of this camera.
  28073. */
  28074. rigParenting: boolean;
  28075. private _lightOnControllers;
  28076. private _defaultHeight?;
  28077. /**
  28078. * Instantiates a WebVRFreeCamera.
  28079. * @param name The name of the WebVRFreeCamera
  28080. * @param position The starting anchor position for the camera
  28081. * @param scene The scene the camera belongs to
  28082. * @param webVROptions a set of customizable options for the webVRCamera
  28083. */
  28084. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28085. /**
  28086. * Gets the device distance from the ground in meters.
  28087. * @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.
  28088. */
  28089. deviceDistanceToRoomGround(): number;
  28090. /**
  28091. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28092. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28093. */
  28094. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28095. /**
  28096. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28097. * @returns A promise with a boolean set to if the standing matrix is supported.
  28098. */
  28099. useStandingMatrixAsync(): Promise<boolean>;
  28100. /**
  28101. * Disposes the camera
  28102. */
  28103. dispose(): void;
  28104. /**
  28105. * Gets a vrController by name.
  28106. * @param name The name of the controller to retreive
  28107. * @returns the controller matching the name specified or null if not found
  28108. */
  28109. getControllerByName(name: string): Nullable<WebVRController>;
  28110. private _leftController;
  28111. /**
  28112. * The controller corresponding to the users left hand.
  28113. */
  28114. get leftController(): Nullable<WebVRController>;
  28115. private _rightController;
  28116. /**
  28117. * The controller corresponding to the users right hand.
  28118. */
  28119. get rightController(): Nullable<WebVRController>;
  28120. /**
  28121. * Casts a ray forward from the vrCamera's gaze.
  28122. * @param length Length of the ray (default: 100)
  28123. * @returns the ray corresponding to the gaze
  28124. */
  28125. getForwardRay(length?: number): Ray;
  28126. /**
  28127. * @hidden
  28128. * Updates the camera based on device's frame data
  28129. */
  28130. _checkInputs(): void;
  28131. /**
  28132. * Updates the poseControlled values based on the input device pose.
  28133. * @param poseData Pose coming from the device
  28134. */
  28135. updateFromDevice(poseData: DevicePose): void;
  28136. private _detachIfAttached;
  28137. /**
  28138. * WebVR's attach control will start broadcasting frames to the device.
  28139. * Note that in certain browsers (chrome for example) this function must be called
  28140. * within a user-interaction callback. Example:
  28141. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28142. *
  28143. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28144. */
  28145. attachControl(noPreventDefault?: boolean): void;
  28146. /**
  28147. * Detach the current controls from the specified dom element.
  28148. */
  28149. detachControl(): void;
  28150. /**
  28151. * @returns the name of this class
  28152. */
  28153. getClassName(): string;
  28154. /**
  28155. * Calls resetPose on the vrDisplay
  28156. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28157. */
  28158. resetToCurrentRotation(): void;
  28159. /**
  28160. * @hidden
  28161. * Updates the rig cameras (left and right eye)
  28162. */
  28163. _updateRigCameras(): void;
  28164. private _workingVector;
  28165. private _oneVector;
  28166. private _workingMatrix;
  28167. private updateCacheCalled;
  28168. private _correctPositionIfNotTrackPosition;
  28169. /**
  28170. * @hidden
  28171. * Updates the cached values of the camera
  28172. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28173. */
  28174. _updateCache(ignoreParentClass?: boolean): void;
  28175. /**
  28176. * @hidden
  28177. * Get current device position in babylon world
  28178. */
  28179. _computeDevicePosition(): void;
  28180. /**
  28181. * Updates the current device position and rotation in the babylon world
  28182. */
  28183. update(): void;
  28184. /**
  28185. * @hidden
  28186. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28187. * @returns an identity matrix
  28188. */
  28189. _getViewMatrix(): Matrix;
  28190. private _tmpMatrix;
  28191. /**
  28192. * This function is called by the two RIG cameras.
  28193. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28194. * @hidden
  28195. */
  28196. _getWebVRViewMatrix(): Matrix;
  28197. /** @hidden */
  28198. _getWebVRProjectionMatrix(): Matrix;
  28199. private _onGamepadConnectedObserver;
  28200. private _onGamepadDisconnectedObserver;
  28201. private _updateCacheWhenTrackingDisabledObserver;
  28202. /**
  28203. * Initializes the controllers and their meshes
  28204. */
  28205. initControllers(): void;
  28206. }
  28207. }
  28208. declare module "babylonjs/Materials/materialHelper" {
  28209. import { Nullable } from "babylonjs/types";
  28210. import { Scene } from "babylonjs/scene";
  28211. import { Engine } from "babylonjs/Engines/engine";
  28212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28213. import { Light } from "babylonjs/Lights/light";
  28214. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  28215. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28216. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  28217. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28218. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  28219. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  28220. /**
  28221. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28222. *
  28223. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28224. *
  28225. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28226. */
  28227. export class MaterialHelper {
  28228. /**
  28229. * Bind the current view position to an effect.
  28230. * @param effect The effect to be bound
  28231. * @param scene The scene the eyes position is used from
  28232. * @param variableName name of the shader variable that will hold the eye position
  28233. */
  28234. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  28235. /**
  28236. * Helps preparing the defines values about the UVs in used in the effect.
  28237. * UVs are shared as much as we can accross channels in the shaders.
  28238. * @param texture The texture we are preparing the UVs for
  28239. * @param defines The defines to update
  28240. * @param key The channel key "diffuse", "specular"... used in the shader
  28241. */
  28242. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28243. /**
  28244. * Binds a texture matrix value to its corrsponding uniform
  28245. * @param texture The texture to bind the matrix for
  28246. * @param uniformBuffer The uniform buffer receivin the data
  28247. * @param key The channel key "diffuse", "specular"... used in the shader
  28248. */
  28249. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28250. /**
  28251. * Gets the current status of the fog (should it be enabled?)
  28252. * @param mesh defines the mesh to evaluate for fog support
  28253. * @param scene defines the hosting scene
  28254. * @returns true if fog must be enabled
  28255. */
  28256. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28257. /**
  28258. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28259. * @param mesh defines the current mesh
  28260. * @param scene defines the current scene
  28261. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28262. * @param pointsCloud defines if point cloud rendering has to be turned on
  28263. * @param fogEnabled defines if fog has to be turned on
  28264. * @param alphaTest defines if alpha testing has to be turned on
  28265. * @param defines defines the current list of defines
  28266. */
  28267. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28268. /**
  28269. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28270. * @param scene defines the current scene
  28271. * @param engine defines the current engine
  28272. * @param defines specifies the list of active defines
  28273. * @param useInstances defines if instances have to be turned on
  28274. * @param useClipPlane defines if clip plane have to be turned on
  28275. * @param useInstances defines if instances have to be turned on
  28276. * @param useThinInstances defines if thin instances have to be turned on
  28277. */
  28278. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28279. /**
  28280. * Prepares the defines for bones
  28281. * @param mesh The mesh containing the geometry data we will draw
  28282. * @param defines The defines to update
  28283. */
  28284. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28285. /**
  28286. * Prepares the defines for morph targets
  28287. * @param mesh The mesh containing the geometry data we will draw
  28288. * @param defines The defines to update
  28289. */
  28290. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28291. /**
  28292. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28293. * @param mesh The mesh containing the geometry data we will draw
  28294. * @param defines The defines to update
  28295. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28296. * @param useBones Precise whether bones should be used or not (override mesh info)
  28297. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28298. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28299. * @returns false if defines are considered not dirty and have not been checked
  28300. */
  28301. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28302. /**
  28303. * Prepares the defines related to multiview
  28304. * @param scene The scene we are intending to draw
  28305. * @param defines The defines to update
  28306. */
  28307. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28308. /**
  28309. * Prepares the defines related to the prepass
  28310. * @param scene The scene we are intending to draw
  28311. * @param defines The defines to update
  28312. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28313. */
  28314. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28315. /**
  28316. * Prepares the defines related to the light information passed in parameter
  28317. * @param scene The scene we are intending to draw
  28318. * @param mesh The mesh the effect is compiling for
  28319. * @param light The light the effect is compiling for
  28320. * @param lightIndex The index of the light
  28321. * @param defines The defines to update
  28322. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28323. * @param state Defines the current state regarding what is needed (normals, etc...)
  28324. */
  28325. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28326. needNormals: boolean;
  28327. needRebuild: boolean;
  28328. shadowEnabled: boolean;
  28329. specularEnabled: boolean;
  28330. lightmapMode: boolean;
  28331. }): void;
  28332. /**
  28333. * Prepares the defines related to the light information passed in parameter
  28334. * @param scene The scene we are intending to draw
  28335. * @param mesh The mesh the effect is compiling for
  28336. * @param defines The defines to update
  28337. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28338. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28339. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28340. * @returns true if normals will be required for the rest of the effect
  28341. */
  28342. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28343. /**
  28344. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28345. * @param lightIndex defines the light index
  28346. * @param uniformsList The uniform list
  28347. * @param samplersList The sampler list
  28348. * @param projectedLightTexture defines if projected texture must be used
  28349. * @param uniformBuffersList defines an optional list of uniform buffers
  28350. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28351. */
  28352. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28353. /**
  28354. * Prepares the uniforms and samplers list to be used in the effect
  28355. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28356. * @param samplersList The sampler list
  28357. * @param defines The defines helping in the list generation
  28358. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28359. */
  28360. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28361. /**
  28362. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28363. * @param defines The defines to update while falling back
  28364. * @param fallbacks The authorized effect fallbacks
  28365. * @param maxSimultaneousLights The maximum number of lights allowed
  28366. * @param rank the current rank of the Effect
  28367. * @returns The newly affected rank
  28368. */
  28369. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28370. private static _TmpMorphInfluencers;
  28371. /**
  28372. * Prepares the list of attributes required for morph targets according to the effect defines.
  28373. * @param attribs The current list of supported attribs
  28374. * @param mesh The mesh to prepare the morph targets attributes for
  28375. * @param influencers The number of influencers
  28376. */
  28377. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28378. /**
  28379. * Prepares the list of attributes required for morph targets according to the effect defines.
  28380. * @param attribs The current list of supported attribs
  28381. * @param mesh The mesh to prepare the morph targets attributes for
  28382. * @param defines The current Defines of the effect
  28383. */
  28384. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28385. /**
  28386. * Prepares the list of attributes required for bones according to the effect defines.
  28387. * @param attribs The current list of supported attribs
  28388. * @param mesh The mesh to prepare the bones attributes for
  28389. * @param defines The current Defines of the effect
  28390. * @param fallbacks The current efffect fallback strategy
  28391. */
  28392. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28393. /**
  28394. * Check and prepare the list of attributes required for instances according to the effect defines.
  28395. * @param attribs The current list of supported attribs
  28396. * @param defines The current MaterialDefines of the effect
  28397. */
  28398. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28399. /**
  28400. * Add the list of attributes required for instances to the attribs array.
  28401. * @param attribs The current list of supported attribs
  28402. */
  28403. static PushAttributesForInstances(attribs: string[]): void;
  28404. /**
  28405. * Binds the light information to the effect.
  28406. * @param light The light containing the generator
  28407. * @param effect The effect we are binding the data to
  28408. * @param lightIndex The light index in the effect used to render
  28409. */
  28410. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28411. /**
  28412. * Binds the lights information from the scene to the effect for the given mesh.
  28413. * @param light Light to bind
  28414. * @param lightIndex Light index
  28415. * @param scene The scene where the light belongs to
  28416. * @param effect The effect we are binding the data to
  28417. * @param useSpecular Defines if specular is supported
  28418. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28419. */
  28420. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28421. /**
  28422. * Binds the lights information from the scene to the effect for the given mesh.
  28423. * @param scene The scene the lights belongs to
  28424. * @param mesh The mesh we are binding the information to render
  28425. * @param effect The effect we are binding the data to
  28426. * @param defines The generated defines for the effect
  28427. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28428. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28429. */
  28430. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28431. private static _tempFogColor;
  28432. /**
  28433. * Binds the fog information from the scene to the effect for the given mesh.
  28434. * @param scene The scene the lights belongs to
  28435. * @param mesh The mesh we are binding the information to render
  28436. * @param effect The effect we are binding the data to
  28437. * @param linearSpace Defines if the fog effect is applied in linear space
  28438. */
  28439. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28440. /**
  28441. * Binds the bones information from the mesh to the effect.
  28442. * @param mesh The mesh we are binding the information to render
  28443. * @param effect The effect we are binding the data to
  28444. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28445. */
  28446. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28447. private static _CopyBonesTransformationMatrices;
  28448. /**
  28449. * Binds the morph targets information from the mesh to the effect.
  28450. * @param abstractMesh The mesh we are binding the information to render
  28451. * @param effect The effect we are binding the data to
  28452. */
  28453. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28454. /**
  28455. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28456. * @param defines The generated defines used in the effect
  28457. * @param effect The effect we are binding the data to
  28458. * @param scene The scene we are willing to render with logarithmic scale for
  28459. */
  28460. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28461. /**
  28462. * Binds the clip plane information from the scene to the effect.
  28463. * @param scene The scene the clip plane information are extracted from
  28464. * @param effect The effect we are binding the data to
  28465. */
  28466. static BindClipPlane(effect: Effect, scene: Scene): void;
  28467. }
  28468. }
  28469. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  28470. /** @hidden */
  28471. export var bayerDitherFunctions: {
  28472. name: string;
  28473. shader: string;
  28474. };
  28475. }
  28476. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  28477. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28478. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  28479. /** @hidden */
  28480. export var shadowMapFragmentDeclaration: {
  28481. name: string;
  28482. shader: string;
  28483. };
  28484. }
  28485. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  28486. /** @hidden */
  28487. export var shadowMapFragment: {
  28488. name: string;
  28489. shader: string;
  28490. };
  28491. }
  28492. declare module "babylonjs/Shaders/shadowMap.fragment" {
  28493. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  28494. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  28495. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  28496. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  28497. /** @hidden */
  28498. export var shadowMapPixelShader: {
  28499. name: string;
  28500. shader: string;
  28501. };
  28502. }
  28503. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  28504. /** @hidden */
  28505. export var shadowMapVertexDeclaration: {
  28506. name: string;
  28507. shader: string;
  28508. };
  28509. }
  28510. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  28511. /** @hidden */
  28512. export var shadowMapVertexNormalBias: {
  28513. name: string;
  28514. shader: string;
  28515. };
  28516. }
  28517. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  28518. /** @hidden */
  28519. export var shadowMapVertexMetric: {
  28520. name: string;
  28521. shader: string;
  28522. };
  28523. }
  28524. declare module "babylonjs/Shaders/shadowMap.vertex" {
  28525. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28528. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28529. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  28530. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  28531. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  28532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28533. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28534. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28535. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  28536. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  28537. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  28538. /** @hidden */
  28539. export var shadowMapVertexShader: {
  28540. name: string;
  28541. shader: string;
  28542. };
  28543. }
  28544. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  28545. /** @hidden */
  28546. export var depthBoxBlurPixelShader: {
  28547. name: string;
  28548. shader: string;
  28549. };
  28550. }
  28551. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  28552. /** @hidden */
  28553. export var shadowMapFragmentSoftTransparentShadow: {
  28554. name: string;
  28555. shader: string;
  28556. };
  28557. }
  28558. declare module "babylonjs/Meshes/instancedMesh" {
  28559. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28560. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  28561. import { Camera } from "babylonjs/Cameras/camera";
  28562. import { Node } from "babylonjs/node";
  28563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28564. import { Mesh } from "babylonjs/Meshes/mesh";
  28565. import { Material } from "babylonjs/Materials/material";
  28566. import { Skeleton } from "babylonjs/Bones/skeleton";
  28567. import { Light } from "babylonjs/Lights/light";
  28568. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28569. /**
  28570. * Creates an instance based on a source mesh.
  28571. */
  28572. export class InstancedMesh extends AbstractMesh {
  28573. private _sourceMesh;
  28574. private _currentLOD;
  28575. /** @hidden */
  28576. _indexInSourceMeshInstanceArray: number;
  28577. constructor(name: string, source: Mesh);
  28578. /**
  28579. * Returns the string "InstancedMesh".
  28580. */
  28581. getClassName(): string;
  28582. /** Gets the list of lights affecting that mesh */
  28583. get lightSources(): Light[];
  28584. _resyncLightSources(): void;
  28585. _resyncLightSource(light: Light): void;
  28586. _removeLightSource(light: Light, dispose: boolean): void;
  28587. /**
  28588. * If the source mesh receives shadows
  28589. */
  28590. get receiveShadows(): boolean;
  28591. /**
  28592. * The material of the source mesh
  28593. */
  28594. get material(): Nullable<Material>;
  28595. /**
  28596. * Visibility of the source mesh
  28597. */
  28598. get visibility(): number;
  28599. /**
  28600. * Skeleton of the source mesh
  28601. */
  28602. get skeleton(): Nullable<Skeleton>;
  28603. /**
  28604. * Rendering ground id of the source mesh
  28605. */
  28606. get renderingGroupId(): number;
  28607. set renderingGroupId(value: number);
  28608. /**
  28609. * Returns the total number of vertices (integer).
  28610. */
  28611. getTotalVertices(): number;
  28612. /**
  28613. * Returns a positive integer : the total number of indices in this mesh geometry.
  28614. * @returns the numner of indices or zero if the mesh has no geometry.
  28615. */
  28616. getTotalIndices(): number;
  28617. /**
  28618. * The source mesh of the instance
  28619. */
  28620. get sourceMesh(): Mesh;
  28621. /**
  28622. * Creates a new InstancedMesh object from the mesh model.
  28623. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28624. * @param name defines the name of the new instance
  28625. * @returns a new InstancedMesh
  28626. */
  28627. createInstance(name: string): InstancedMesh;
  28628. /**
  28629. * Is this node ready to be used/rendered
  28630. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28631. * @return {boolean} is it ready
  28632. */
  28633. isReady(completeCheck?: boolean): boolean;
  28634. /**
  28635. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28636. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28637. * @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.
  28638. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28639. */
  28640. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28641. /**
  28642. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28643. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28644. * The `data` are either a numeric array either a Float32Array.
  28645. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28646. * 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).
  28647. * Note that a new underlying VertexBuffer object is created each call.
  28648. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28649. *
  28650. * Possible `kind` values :
  28651. * - VertexBuffer.PositionKind
  28652. * - VertexBuffer.UVKind
  28653. * - VertexBuffer.UV2Kind
  28654. * - VertexBuffer.UV3Kind
  28655. * - VertexBuffer.UV4Kind
  28656. * - VertexBuffer.UV5Kind
  28657. * - VertexBuffer.UV6Kind
  28658. * - VertexBuffer.ColorKind
  28659. * - VertexBuffer.MatricesIndicesKind
  28660. * - VertexBuffer.MatricesIndicesExtraKind
  28661. * - VertexBuffer.MatricesWeightsKind
  28662. * - VertexBuffer.MatricesWeightsExtraKind
  28663. *
  28664. * Returns the Mesh.
  28665. */
  28666. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28667. /**
  28668. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28669. * If the mesh has no geometry, it is simply returned as it is.
  28670. * The `data` are either a numeric array either a Float32Array.
  28671. * No new underlying VertexBuffer object is created.
  28672. * 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.
  28673. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28674. *
  28675. * Possible `kind` values :
  28676. * - VertexBuffer.PositionKind
  28677. * - VertexBuffer.UVKind
  28678. * - VertexBuffer.UV2Kind
  28679. * - VertexBuffer.UV3Kind
  28680. * - VertexBuffer.UV4Kind
  28681. * - VertexBuffer.UV5Kind
  28682. * - VertexBuffer.UV6Kind
  28683. * - VertexBuffer.ColorKind
  28684. * - VertexBuffer.MatricesIndicesKind
  28685. * - VertexBuffer.MatricesIndicesExtraKind
  28686. * - VertexBuffer.MatricesWeightsKind
  28687. * - VertexBuffer.MatricesWeightsExtraKind
  28688. *
  28689. * Returns the Mesh.
  28690. */
  28691. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28692. /**
  28693. * Sets the mesh indices.
  28694. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28695. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28696. * This method creates a new index buffer each call.
  28697. * Returns the Mesh.
  28698. */
  28699. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28700. /**
  28701. * Boolean : True if the mesh owns the requested kind of data.
  28702. */
  28703. isVerticesDataPresent(kind: string): boolean;
  28704. /**
  28705. * Returns an array of indices (IndicesArray).
  28706. */
  28707. getIndices(): Nullable<IndicesArray>;
  28708. get _positions(): Nullable<Vector3[]>;
  28709. /**
  28710. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28711. * This means the mesh underlying bounding box and sphere are recomputed.
  28712. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28713. * @returns the current mesh
  28714. */
  28715. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28716. /** @hidden */
  28717. _preActivate(): InstancedMesh;
  28718. /** @hidden */
  28719. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28720. /** @hidden */
  28721. _postActivate(): void;
  28722. getWorldMatrix(): Matrix;
  28723. get isAnInstance(): boolean;
  28724. /**
  28725. * Returns the current associated LOD AbstractMesh.
  28726. */
  28727. getLOD(camera: Camera): AbstractMesh;
  28728. /** @hidden */
  28729. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28730. /** @hidden */
  28731. _syncSubMeshes(): InstancedMesh;
  28732. /** @hidden */
  28733. _generatePointsArray(): boolean;
  28734. /** @hidden */
  28735. _updateBoundingInfo(): AbstractMesh;
  28736. /**
  28737. * Creates a new InstancedMesh from the current mesh.
  28738. * - name (string) : the cloned mesh name
  28739. * - newParent (optional Node) : the optional Node to parent the clone to.
  28740. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28741. *
  28742. * Returns the clone.
  28743. */
  28744. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28745. /**
  28746. * Disposes the InstancedMesh.
  28747. * Returns nothing.
  28748. */
  28749. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28750. }
  28751. module "babylonjs/Meshes/mesh" {
  28752. interface Mesh {
  28753. /**
  28754. * Register a custom buffer that will be instanced
  28755. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28756. * @param kind defines the buffer kind
  28757. * @param stride defines the stride in floats
  28758. */
  28759. registerInstancedBuffer(kind: string, stride: number): void;
  28760. /**
  28761. * true to use the edge renderer for all instances of this mesh
  28762. */
  28763. edgesShareWithInstances: boolean;
  28764. /** @hidden */
  28765. _userInstancedBuffersStorage: {
  28766. data: {
  28767. [key: string]: Float32Array;
  28768. };
  28769. sizes: {
  28770. [key: string]: number;
  28771. };
  28772. vertexBuffers: {
  28773. [key: string]: Nullable<VertexBuffer>;
  28774. };
  28775. strides: {
  28776. [key: string]: number;
  28777. };
  28778. };
  28779. }
  28780. }
  28781. module "babylonjs/Meshes/abstractMesh" {
  28782. interface AbstractMesh {
  28783. /**
  28784. * Object used to store instanced buffers defined by user
  28785. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28786. */
  28787. instancedBuffers: {
  28788. [key: string]: any;
  28789. };
  28790. }
  28791. }
  28792. }
  28793. declare module "babylonjs/Materials/shaderMaterial" {
  28794. import { Nullable } from "babylonjs/types";
  28795. import { Scene } from "babylonjs/scene";
  28796. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28798. import { Mesh } from "babylonjs/Meshes/mesh";
  28799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28800. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28801. import { Effect } from "babylonjs/Materials/effect";
  28802. import { Material } from "babylonjs/Materials/material";
  28803. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28804. /**
  28805. * Defines the options associated with the creation of a shader material.
  28806. */
  28807. export interface IShaderMaterialOptions {
  28808. /**
  28809. * Does the material work in alpha blend mode
  28810. */
  28811. needAlphaBlending: boolean;
  28812. /**
  28813. * Does the material work in alpha test mode
  28814. */
  28815. needAlphaTesting: boolean;
  28816. /**
  28817. * The list of attribute names used in the shader
  28818. */
  28819. attributes: string[];
  28820. /**
  28821. * The list of unifrom names used in the shader
  28822. */
  28823. uniforms: string[];
  28824. /**
  28825. * The list of UBO names used in the shader
  28826. */
  28827. uniformBuffers: string[];
  28828. /**
  28829. * The list of sampler names used in the shader
  28830. */
  28831. samplers: string[];
  28832. /**
  28833. * The list of defines used in the shader
  28834. */
  28835. defines: string[];
  28836. }
  28837. /**
  28838. * 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.
  28839. *
  28840. * This returned material effects how the mesh will look based on the code in the shaders.
  28841. *
  28842. * @see https://doc.babylonjs.com/how_to/shader_material
  28843. */
  28844. export class ShaderMaterial extends Material {
  28845. private _shaderPath;
  28846. private _options;
  28847. private _textures;
  28848. private _textureArrays;
  28849. private _floats;
  28850. private _ints;
  28851. private _floatsArrays;
  28852. private _colors3;
  28853. private _colors3Arrays;
  28854. private _colors4;
  28855. private _colors4Arrays;
  28856. private _vectors2;
  28857. private _vectors3;
  28858. private _vectors4;
  28859. private _matrices;
  28860. private _matrixArrays;
  28861. private _matrices3x3;
  28862. private _matrices2x2;
  28863. private _vectors2Arrays;
  28864. private _vectors3Arrays;
  28865. private _vectors4Arrays;
  28866. private _cachedWorldViewMatrix;
  28867. private _cachedWorldViewProjectionMatrix;
  28868. private _renderId;
  28869. private _multiview;
  28870. private _cachedDefines;
  28871. /** Define the Url to load snippets */
  28872. static SnippetUrl: string;
  28873. /** Snippet ID if the material was created from the snippet server */
  28874. snippetId: string;
  28875. /**
  28876. * Instantiate a new shader material.
  28877. * 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.
  28878. * This returned material effects how the mesh will look based on the code in the shaders.
  28879. * @see https://doc.babylonjs.com/how_to/shader_material
  28880. * @param name Define the name of the material in the scene
  28881. * @param scene Define the scene the material belongs to
  28882. * @param shaderPath Defines the route to the shader code in one of three ways:
  28883. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28884. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28885. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28886. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28887. * @param options Define the options used to create the shader
  28888. */
  28889. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28890. /**
  28891. * Gets the shader path used to define the shader code
  28892. * It can be modified to trigger a new compilation
  28893. */
  28894. get shaderPath(): any;
  28895. /**
  28896. * Sets the shader path used to define the shader code
  28897. * It can be modified to trigger a new compilation
  28898. */
  28899. set shaderPath(shaderPath: any);
  28900. /**
  28901. * Gets the options used to compile the shader.
  28902. * They can be modified to trigger a new compilation
  28903. */
  28904. get options(): IShaderMaterialOptions;
  28905. /**
  28906. * Gets the current class name of the material e.g. "ShaderMaterial"
  28907. * Mainly use in serialization.
  28908. * @returns the class name
  28909. */
  28910. getClassName(): string;
  28911. /**
  28912. * Specifies if the material will require alpha blending
  28913. * @returns a boolean specifying if alpha blending is needed
  28914. */
  28915. needAlphaBlending(): boolean;
  28916. /**
  28917. * Specifies if this material should be rendered in alpha test mode
  28918. * @returns a boolean specifying if an alpha test is needed.
  28919. */
  28920. needAlphaTesting(): boolean;
  28921. private _checkUniform;
  28922. /**
  28923. * Set a texture in the shader.
  28924. * @param name Define the name of the uniform samplers as defined in the shader
  28925. * @param texture Define the texture to bind to this sampler
  28926. * @return the material itself allowing "fluent" like uniform updates
  28927. */
  28928. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28929. /**
  28930. * Set a texture array in the shader.
  28931. * @param name Define the name of the uniform sampler array as defined in the shader
  28932. * @param textures Define the list of textures to bind to this sampler
  28933. * @return the material itself allowing "fluent" like uniform updates
  28934. */
  28935. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28936. /**
  28937. * Set a float in the shader.
  28938. * @param name Define the name of the uniform as defined in the shader
  28939. * @param value Define the value to give to the uniform
  28940. * @return the material itself allowing "fluent" like uniform updates
  28941. */
  28942. setFloat(name: string, value: number): ShaderMaterial;
  28943. /**
  28944. * Set a int in the shader.
  28945. * @param name Define the name of the uniform as defined in the shader
  28946. * @param value Define the value to give to the uniform
  28947. * @return the material itself allowing "fluent" like uniform updates
  28948. */
  28949. setInt(name: string, value: number): ShaderMaterial;
  28950. /**
  28951. * Set an array of floats in the shader.
  28952. * @param name Define the name of the uniform as defined in the shader
  28953. * @param value Define the value to give to the uniform
  28954. * @return the material itself allowing "fluent" like uniform updates
  28955. */
  28956. setFloats(name: string, value: number[]): ShaderMaterial;
  28957. /**
  28958. * Set a vec3 in the shader from a Color3.
  28959. * @param name Define the name of the uniform as defined in the shader
  28960. * @param value Define the value to give to the uniform
  28961. * @return the material itself allowing "fluent" like uniform updates
  28962. */
  28963. setColor3(name: string, value: Color3): ShaderMaterial;
  28964. /**
  28965. * Set a vec3 array in the shader from a Color3 array.
  28966. * @param name Define the name of the uniform as defined in the shader
  28967. * @param value Define the value to give to the uniform
  28968. * @return the material itself allowing "fluent" like uniform updates
  28969. */
  28970. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28971. /**
  28972. * Set a vec4 in the shader from a Color4.
  28973. * @param name Define the name of the uniform as defined in the shader
  28974. * @param value Define the value to give to the uniform
  28975. * @return the material itself allowing "fluent" like uniform updates
  28976. */
  28977. setColor4(name: string, value: Color4): ShaderMaterial;
  28978. /**
  28979. * Set a vec4 array in the shader from a Color4 array.
  28980. * @param name Define the name of the uniform as defined in the shader
  28981. * @param value Define the value to give to the uniform
  28982. * @return the material itself allowing "fluent" like uniform updates
  28983. */
  28984. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28985. /**
  28986. * Set a vec2 in the shader from a Vector2.
  28987. * @param name Define the name of the uniform as defined in the shader
  28988. * @param value Define the value to give to the uniform
  28989. * @return the material itself allowing "fluent" like uniform updates
  28990. */
  28991. setVector2(name: string, value: Vector2): ShaderMaterial;
  28992. /**
  28993. * Set a vec3 in the shader from a Vector3.
  28994. * @param name Define the name of the uniform as defined in the shader
  28995. * @param value Define the value to give to the uniform
  28996. * @return the material itself allowing "fluent" like uniform updates
  28997. */
  28998. setVector3(name: string, value: Vector3): ShaderMaterial;
  28999. /**
  29000. * Set a vec4 in the shader from a Vector4.
  29001. * @param name Define the name of the uniform as defined in the shader
  29002. * @param value Define the value to give to the uniform
  29003. * @return the material itself allowing "fluent" like uniform updates
  29004. */
  29005. setVector4(name: string, value: Vector4): ShaderMaterial;
  29006. /**
  29007. * Set a mat4 in the shader from a Matrix.
  29008. * @param name Define the name of the uniform as defined in the shader
  29009. * @param value Define the value to give to the uniform
  29010. * @return the material itself allowing "fluent" like uniform updates
  29011. */
  29012. setMatrix(name: string, value: Matrix): ShaderMaterial;
  29013. /**
  29014. * Set a float32Array in the shader from a matrix array.
  29015. * @param name Define the name of the uniform as defined in the shader
  29016. * @param value Define the value to give to the uniform
  29017. * @return the material itself allowing "fluent" like uniform updates
  29018. */
  29019. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  29020. /**
  29021. * Set a mat3 in the shader from a Float32Array.
  29022. * @param name Define the name of the uniform as defined in the shader
  29023. * @param value Define the value to give to the uniform
  29024. * @return the material itself allowing "fluent" like uniform updates
  29025. */
  29026. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29027. /**
  29028. * Set a mat2 in the shader from a Float32Array.
  29029. * @param name Define the name of the uniform as defined in the shader
  29030. * @param value Define the value to give to the uniform
  29031. * @return the material itself allowing "fluent" like uniform updates
  29032. */
  29033. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29034. /**
  29035. * Set a vec2 array in the shader from a number array.
  29036. * @param name Define the name of the uniform as defined in the shader
  29037. * @param value Define the value to give to the uniform
  29038. * @return the material itself allowing "fluent" like uniform updates
  29039. */
  29040. setArray2(name: string, value: number[]): ShaderMaterial;
  29041. /**
  29042. * Set a vec3 array in the shader from a number array.
  29043. * @param name Define the name of the uniform as defined in the shader
  29044. * @param value Define the value to give to the uniform
  29045. * @return the material itself allowing "fluent" like uniform updates
  29046. */
  29047. setArray3(name: string, value: number[]): ShaderMaterial;
  29048. /**
  29049. * Set a vec4 array in the shader from a number array.
  29050. * @param name Define the name of the uniform as defined in the shader
  29051. * @param value Define the value to give to the uniform
  29052. * @return the material itself allowing "fluent" like uniform updates
  29053. */
  29054. setArray4(name: string, value: number[]): ShaderMaterial;
  29055. private _checkCache;
  29056. /**
  29057. * Specifies that the submesh is ready to be used
  29058. * @param mesh defines the mesh to check
  29059. * @param subMesh defines which submesh to check
  29060. * @param useInstances specifies that instances should be used
  29061. * @returns a boolean indicating that the submesh is ready or not
  29062. */
  29063. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29064. /**
  29065. * Checks if the material is ready to render the requested mesh
  29066. * @param mesh Define the mesh to render
  29067. * @param useInstances Define whether or not the material is used with instances
  29068. * @returns true if ready, otherwise false
  29069. */
  29070. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29071. /**
  29072. * Binds the world matrix to the material
  29073. * @param world defines the world transformation matrix
  29074. * @param effectOverride - If provided, use this effect instead of internal effect
  29075. */
  29076. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29077. /**
  29078. * Binds the submesh to this material by preparing the effect and shader to draw
  29079. * @param world defines the world transformation matrix
  29080. * @param mesh defines the mesh containing the submesh
  29081. * @param subMesh defines the submesh to bind the material to
  29082. */
  29083. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29084. /**
  29085. * Binds the material to the mesh
  29086. * @param world defines the world transformation matrix
  29087. * @param mesh defines the mesh to bind the material to
  29088. * @param effectOverride - If provided, use this effect instead of internal effect
  29089. */
  29090. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29091. protected _afterBind(mesh?: Mesh): void;
  29092. /**
  29093. * Gets the active textures from the material
  29094. * @returns an array of textures
  29095. */
  29096. getActiveTextures(): BaseTexture[];
  29097. /**
  29098. * Specifies if the material uses a texture
  29099. * @param texture defines the texture to check against the material
  29100. * @returns a boolean specifying if the material uses the texture
  29101. */
  29102. hasTexture(texture: BaseTexture): boolean;
  29103. /**
  29104. * Makes a duplicate of the material, and gives it a new name
  29105. * @param name defines the new name for the duplicated material
  29106. * @returns the cloned material
  29107. */
  29108. clone(name: string): ShaderMaterial;
  29109. /**
  29110. * Disposes the material
  29111. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29112. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29113. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29114. */
  29115. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29116. /**
  29117. * Serializes this material in a JSON representation
  29118. * @returns the serialized material object
  29119. */
  29120. serialize(): any;
  29121. /**
  29122. * Creates a shader material from parsed shader material data
  29123. * @param source defines the JSON represnetation of the material
  29124. * @param scene defines the hosting scene
  29125. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29126. * @returns a new material
  29127. */
  29128. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29129. /**
  29130. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29131. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29132. * @param url defines the url to load from
  29133. * @param scene defines the hosting scene
  29134. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29135. * @returns a promise that will resolve to the new ShaderMaterial
  29136. */
  29137. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29138. /**
  29139. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29140. * @param snippetId defines the snippet to load
  29141. * @param scene defines the hosting scene
  29142. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29143. * @returns a promise that will resolve to the new ShaderMaterial
  29144. */
  29145. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29146. }
  29147. }
  29148. declare module "babylonjs/Shaders/color.fragment" {
  29149. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29150. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29151. /** @hidden */
  29152. export var colorPixelShader: {
  29153. name: string;
  29154. shader: string;
  29155. };
  29156. }
  29157. declare module "babylonjs/Shaders/color.vertex" {
  29158. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29159. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29160. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29161. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29162. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29163. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29164. /** @hidden */
  29165. export var colorVertexShader: {
  29166. name: string;
  29167. shader: string;
  29168. };
  29169. }
  29170. declare module "babylonjs/Meshes/linesMesh" {
  29171. import { Nullable } from "babylonjs/types";
  29172. import { Scene } from "babylonjs/scene";
  29173. import { Color3 } from "babylonjs/Maths/math.color";
  29174. import { Node } from "babylonjs/node";
  29175. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29176. import { Mesh } from "babylonjs/Meshes/mesh";
  29177. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29178. import { Effect } from "babylonjs/Materials/effect";
  29179. import { Material } from "babylonjs/Materials/material";
  29180. import "babylonjs/Shaders/color.fragment";
  29181. import "babylonjs/Shaders/color.vertex";
  29182. /**
  29183. * Line mesh
  29184. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29185. */
  29186. export class LinesMesh extends Mesh {
  29187. /**
  29188. * If vertex color should be applied to the mesh
  29189. */
  29190. readonly useVertexColor?: boolean | undefined;
  29191. /**
  29192. * If vertex alpha should be applied to the mesh
  29193. */
  29194. readonly useVertexAlpha?: boolean | undefined;
  29195. /**
  29196. * Color of the line (Default: White)
  29197. */
  29198. color: Color3;
  29199. /**
  29200. * Alpha of the line (Default: 1)
  29201. */
  29202. alpha: number;
  29203. /**
  29204. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29205. * This margin is expressed in world space coordinates, so its value may vary.
  29206. * Default value is 0.1
  29207. */
  29208. intersectionThreshold: number;
  29209. private _colorShader;
  29210. private color4;
  29211. /**
  29212. * Creates a new LinesMesh
  29213. * @param name defines the name
  29214. * @param scene defines the hosting scene
  29215. * @param parent defines the parent mesh if any
  29216. * @param source defines the optional source LinesMesh used to clone data from
  29217. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29218. * When false, achieved by calling a clone(), also passing False.
  29219. * This will make creation of children, recursive.
  29220. * @param useVertexColor defines if this LinesMesh supports vertex color
  29221. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29222. */
  29223. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29224. /**
  29225. * If vertex color should be applied to the mesh
  29226. */
  29227. useVertexColor?: boolean | undefined,
  29228. /**
  29229. * If vertex alpha should be applied to the mesh
  29230. */
  29231. useVertexAlpha?: boolean | undefined);
  29232. private _addClipPlaneDefine;
  29233. private _removeClipPlaneDefine;
  29234. isReady(): boolean;
  29235. /**
  29236. * Returns the string "LineMesh"
  29237. */
  29238. getClassName(): string;
  29239. /**
  29240. * @hidden
  29241. */
  29242. get material(): Material;
  29243. /**
  29244. * @hidden
  29245. */
  29246. set material(value: Material);
  29247. /**
  29248. * @hidden
  29249. */
  29250. get checkCollisions(): boolean;
  29251. /** @hidden */
  29252. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29253. /** @hidden */
  29254. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29255. /**
  29256. * Disposes of the line mesh
  29257. * @param doNotRecurse If children should be disposed
  29258. */
  29259. dispose(doNotRecurse?: boolean): void;
  29260. /**
  29261. * Returns a new LineMesh object cloned from the current one.
  29262. */
  29263. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29264. /**
  29265. * Creates a new InstancedLinesMesh object from the mesh model.
  29266. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29267. * @param name defines the name of the new instance
  29268. * @returns a new InstancedLinesMesh
  29269. */
  29270. createInstance(name: string): InstancedLinesMesh;
  29271. }
  29272. /**
  29273. * Creates an instance based on a source LinesMesh
  29274. */
  29275. export class InstancedLinesMesh extends InstancedMesh {
  29276. /**
  29277. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29278. * This margin is expressed in world space coordinates, so its value may vary.
  29279. * Initilized with the intersectionThreshold value of the source LinesMesh
  29280. */
  29281. intersectionThreshold: number;
  29282. constructor(name: string, source: LinesMesh);
  29283. /**
  29284. * Returns the string "InstancedLinesMesh".
  29285. */
  29286. getClassName(): string;
  29287. }
  29288. }
  29289. declare module "babylonjs/Shaders/line.fragment" {
  29290. /** @hidden */
  29291. export var linePixelShader: {
  29292. name: string;
  29293. shader: string;
  29294. };
  29295. }
  29296. declare module "babylonjs/Shaders/line.vertex" {
  29297. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29298. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29299. /** @hidden */
  29300. export var lineVertexShader: {
  29301. name: string;
  29302. shader: string;
  29303. };
  29304. }
  29305. declare module "babylonjs/Rendering/edgesRenderer" {
  29306. import { Immutable, Nullable } from "babylonjs/types";
  29307. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29309. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29310. import { IDisposable } from "babylonjs/scene";
  29311. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  29312. import "babylonjs/Shaders/line.fragment";
  29313. import "babylonjs/Shaders/line.vertex";
  29314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29315. import { SmartArray } from "babylonjs/Misc/smartArray";
  29316. module "babylonjs/scene" {
  29317. interface Scene {
  29318. /** @hidden */
  29319. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29320. }
  29321. }
  29322. module "babylonjs/Meshes/abstractMesh" {
  29323. interface AbstractMesh {
  29324. /**
  29325. * Gets the edgesRenderer associated with the mesh
  29326. */
  29327. edgesRenderer: Nullable<EdgesRenderer>;
  29328. }
  29329. }
  29330. module "babylonjs/Meshes/linesMesh" {
  29331. interface LinesMesh {
  29332. /**
  29333. * Enables the edge rendering mode on the mesh.
  29334. * This mode makes the mesh edges visible
  29335. * @param epsilon defines the maximal distance between two angles to detect a face
  29336. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29337. * @returns the currentAbstractMesh
  29338. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29339. */
  29340. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29341. }
  29342. }
  29343. module "babylonjs/Meshes/linesMesh" {
  29344. interface InstancedLinesMesh {
  29345. /**
  29346. * Enables the edge rendering mode on the mesh.
  29347. * This mode makes the mesh edges visible
  29348. * @param epsilon defines the maximal distance between two angles to detect a face
  29349. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29350. * @returns the current InstancedLinesMesh
  29351. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29352. */
  29353. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29354. }
  29355. }
  29356. /**
  29357. * Defines the minimum contract an Edges renderer should follow.
  29358. */
  29359. export interface IEdgesRenderer extends IDisposable {
  29360. /**
  29361. * Gets or sets a boolean indicating if the edgesRenderer is active
  29362. */
  29363. isEnabled: boolean;
  29364. /**
  29365. * Renders the edges of the attached mesh,
  29366. */
  29367. render(): void;
  29368. /**
  29369. * Checks wether or not the edges renderer is ready to render.
  29370. * @return true if ready, otherwise false.
  29371. */
  29372. isReady(): boolean;
  29373. /**
  29374. * List of instances to render in case the source mesh has instances
  29375. */
  29376. customInstances: SmartArray<Matrix>;
  29377. }
  29378. /**
  29379. * Defines the additional options of the edges renderer
  29380. */
  29381. export interface IEdgesRendererOptions {
  29382. /**
  29383. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29384. * If not defined, the default value is true
  29385. */
  29386. useAlternateEdgeFinder?: boolean;
  29387. /**
  29388. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29389. * If not defined, the default value is true.
  29390. * 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)
  29391. * This option is used only if useAlternateEdgeFinder = true
  29392. */
  29393. useFastVertexMerger?: boolean;
  29394. /**
  29395. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  29396. * The default value is 1e-6
  29397. * This option is used only if useAlternateEdgeFinder = true
  29398. */
  29399. epsilonVertexMerge?: number;
  29400. /**
  29401. * 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
  29402. * 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.
  29403. * This option is used only if useAlternateEdgeFinder = true
  29404. */
  29405. applyTessellation?: boolean;
  29406. /**
  29407. * 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
  29408. * The default value is 1e-6
  29409. * This option is used only if useAlternateEdgeFinder = true
  29410. */
  29411. epsilonVertexAligned?: number;
  29412. }
  29413. /**
  29414. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29415. */
  29416. export class EdgesRenderer implements IEdgesRenderer {
  29417. /**
  29418. * Define the size of the edges with an orthographic camera
  29419. */
  29420. edgesWidthScalerForOrthographic: number;
  29421. /**
  29422. * Define the size of the edges with a perspective camera
  29423. */
  29424. edgesWidthScalerForPerspective: number;
  29425. protected _source: AbstractMesh;
  29426. protected _linesPositions: number[];
  29427. protected _linesNormals: number[];
  29428. protected _linesIndices: number[];
  29429. protected _epsilon: number;
  29430. protected _indicesCount: number;
  29431. protected _lineShader: ShaderMaterial;
  29432. protected _ib: DataBuffer;
  29433. protected _buffers: {
  29434. [key: string]: Nullable<VertexBuffer>;
  29435. };
  29436. protected _buffersForInstances: {
  29437. [key: string]: Nullable<VertexBuffer>;
  29438. };
  29439. protected _checkVerticesInsteadOfIndices: boolean;
  29440. protected _options: Nullable<IEdgesRendererOptions>;
  29441. private _meshRebuildObserver;
  29442. private _meshDisposeObserver;
  29443. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29444. isEnabled: boolean;
  29445. /** Gets the vertices generated by the edge renderer */
  29446. get linesPositions(): Immutable<Array<number>>;
  29447. /** Gets the normals generated by the edge renderer */
  29448. get linesNormals(): Immutable<Array<number>>;
  29449. /** Gets the indices generated by the edge renderer */
  29450. get linesIndices(): Immutable<Array<number>>;
  29451. /**
  29452. * List of instances to render in case the source mesh has instances
  29453. */
  29454. customInstances: SmartArray<Matrix>;
  29455. private static GetShader;
  29456. /**
  29457. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29458. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29459. * @param source Mesh used to create edges
  29460. * @param epsilon sum of angles in adjacency to check for edge
  29461. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29462. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29463. * @param options The options to apply when generating the edges
  29464. */
  29465. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29466. protected _prepareRessources(): void;
  29467. /** @hidden */
  29468. _rebuild(): void;
  29469. /**
  29470. * Releases the required resources for the edges renderer
  29471. */
  29472. dispose(): void;
  29473. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29474. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29475. /**
  29476. * Checks if the pair of p0 and p1 is en edge
  29477. * @param faceIndex
  29478. * @param edge
  29479. * @param faceNormals
  29480. * @param p0
  29481. * @param p1
  29482. * @private
  29483. */
  29484. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29485. /**
  29486. * push line into the position, normal and index buffer
  29487. * @protected
  29488. */
  29489. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29490. /**
  29491. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29492. */
  29493. private _tessellateTriangle;
  29494. private _generateEdgesLinesAlternate;
  29495. /**
  29496. * Generates lines edges from adjacencjes
  29497. * @private
  29498. */
  29499. _generateEdgesLines(): void;
  29500. /**
  29501. * Checks wether or not the edges renderer is ready to render.
  29502. * @return true if ready, otherwise false.
  29503. */
  29504. isReady(): boolean;
  29505. /**
  29506. * Renders the edges of the attached mesh,
  29507. */
  29508. render(): void;
  29509. }
  29510. /**
  29511. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29512. */
  29513. export class LineEdgesRenderer extends EdgesRenderer {
  29514. /**
  29515. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29516. * @param source LineMesh used to generate edges
  29517. * @param epsilon not important (specified angle for edge detection)
  29518. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29519. */
  29520. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29521. /**
  29522. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29523. */
  29524. _generateEdgesLines(): void;
  29525. }
  29526. }
  29527. declare module "babylonjs/Rendering/renderingGroup" {
  29528. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  29529. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29531. import { Nullable } from "babylonjs/types";
  29532. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29533. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29534. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29535. import { Material } from "babylonjs/Materials/material";
  29536. import { Scene } from "babylonjs/scene";
  29537. /**
  29538. * This represents the object necessary to create a rendering group.
  29539. * This is exclusively used and created by the rendering manager.
  29540. * To modify the behavior, you use the available helpers in your scene or meshes.
  29541. * @hidden
  29542. */
  29543. export class RenderingGroup {
  29544. index: number;
  29545. private static _zeroVector;
  29546. private _scene;
  29547. private _opaqueSubMeshes;
  29548. private _transparentSubMeshes;
  29549. private _alphaTestSubMeshes;
  29550. private _depthOnlySubMeshes;
  29551. private _particleSystems;
  29552. private _spriteManagers;
  29553. private _opaqueSortCompareFn;
  29554. private _alphaTestSortCompareFn;
  29555. private _transparentSortCompareFn;
  29556. private _renderOpaque;
  29557. private _renderAlphaTest;
  29558. private _renderTransparent;
  29559. /** @hidden */
  29560. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29561. onBeforeTransparentRendering: () => void;
  29562. /**
  29563. * Set the opaque sort comparison function.
  29564. * If null the sub meshes will be render in the order they were created
  29565. */
  29566. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29567. /**
  29568. * Set the alpha test sort comparison function.
  29569. * If null the sub meshes will be render in the order they were created
  29570. */
  29571. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29572. /**
  29573. * Set the transparent sort comparison function.
  29574. * If null the sub meshes will be render in the order they were created
  29575. */
  29576. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29577. /**
  29578. * Creates a new rendering group.
  29579. * @param index The rendering group index
  29580. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29581. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29582. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29583. */
  29584. 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>);
  29585. /**
  29586. * Render all the sub meshes contained in the group.
  29587. * @param customRenderFunction Used to override the default render behaviour of the group.
  29588. * @returns true if rendered some submeshes.
  29589. */
  29590. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29591. /**
  29592. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29593. * @param subMeshes The submeshes to render
  29594. */
  29595. private renderOpaqueSorted;
  29596. /**
  29597. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29598. * @param subMeshes The submeshes to render
  29599. */
  29600. private renderAlphaTestSorted;
  29601. /**
  29602. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29603. * @param subMeshes The submeshes to render
  29604. */
  29605. private renderTransparentSorted;
  29606. /**
  29607. * Renders the submeshes in a specified order.
  29608. * @param subMeshes The submeshes to sort before render
  29609. * @param sortCompareFn The comparison function use to sort
  29610. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29611. * @param transparent Specifies to activate blending if true
  29612. */
  29613. private static renderSorted;
  29614. /**
  29615. * Renders the submeshes in the order they were dispatched (no sort applied).
  29616. * @param subMeshes The submeshes to render
  29617. */
  29618. private static renderUnsorted;
  29619. /**
  29620. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29621. * are rendered back to front if in the same alpha index.
  29622. *
  29623. * @param a The first submesh
  29624. * @param b The second submesh
  29625. * @returns The result of the comparison
  29626. */
  29627. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29628. /**
  29629. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29630. * are rendered back to front.
  29631. *
  29632. * @param a The first submesh
  29633. * @param b The second submesh
  29634. * @returns The result of the comparison
  29635. */
  29636. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29637. /**
  29638. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29639. * are rendered front to back (prevent overdraw).
  29640. *
  29641. * @param a The first submesh
  29642. * @param b The second submesh
  29643. * @returns The result of the comparison
  29644. */
  29645. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29646. /**
  29647. * Resets the different lists of submeshes to prepare a new frame.
  29648. */
  29649. prepare(): void;
  29650. dispose(): void;
  29651. /**
  29652. * Inserts the submesh in its correct queue depending on its material.
  29653. * @param subMesh The submesh to dispatch
  29654. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29655. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29656. */
  29657. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29658. dispatchSprites(spriteManager: ISpriteManager): void;
  29659. dispatchParticles(particleSystem: IParticleSystem): void;
  29660. private _renderParticles;
  29661. private _renderSprites;
  29662. }
  29663. }
  29664. declare module "babylonjs/Rendering/renderingManager" {
  29665. import { Nullable } from "babylonjs/types";
  29666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29667. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29668. import { SmartArray } from "babylonjs/Misc/smartArray";
  29669. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29670. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29671. import { Material } from "babylonjs/Materials/material";
  29672. import { Scene } from "babylonjs/scene";
  29673. import { Camera } from "babylonjs/Cameras/camera";
  29674. /**
  29675. * Interface describing the different options available in the rendering manager
  29676. * regarding Auto Clear between groups.
  29677. */
  29678. export interface IRenderingManagerAutoClearSetup {
  29679. /**
  29680. * Defines whether or not autoclear is enable.
  29681. */
  29682. autoClear: boolean;
  29683. /**
  29684. * Defines whether or not to autoclear the depth buffer.
  29685. */
  29686. depth: boolean;
  29687. /**
  29688. * Defines whether or not to autoclear the stencil buffer.
  29689. */
  29690. stencil: boolean;
  29691. }
  29692. /**
  29693. * This class is used by the onRenderingGroupObservable
  29694. */
  29695. export class RenderingGroupInfo {
  29696. /**
  29697. * The Scene that being rendered
  29698. */
  29699. scene: Scene;
  29700. /**
  29701. * The camera currently used for the rendering pass
  29702. */
  29703. camera: Nullable<Camera>;
  29704. /**
  29705. * The ID of the renderingGroup being processed
  29706. */
  29707. renderingGroupId: number;
  29708. }
  29709. /**
  29710. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29711. * It is enable to manage the different groups as well as the different necessary sort functions.
  29712. * This should not be used directly aside of the few static configurations
  29713. */
  29714. export class RenderingManager {
  29715. /**
  29716. * The max id used for rendering groups (not included)
  29717. */
  29718. static MAX_RENDERINGGROUPS: number;
  29719. /**
  29720. * The min id used for rendering groups (included)
  29721. */
  29722. static MIN_RENDERINGGROUPS: number;
  29723. /**
  29724. * Used to globally prevent autoclearing scenes.
  29725. */
  29726. static AUTOCLEAR: boolean;
  29727. /**
  29728. * @hidden
  29729. */
  29730. _useSceneAutoClearSetup: boolean;
  29731. private _scene;
  29732. private _renderingGroups;
  29733. private _depthStencilBufferAlreadyCleaned;
  29734. private _autoClearDepthStencil;
  29735. private _customOpaqueSortCompareFn;
  29736. private _customAlphaTestSortCompareFn;
  29737. private _customTransparentSortCompareFn;
  29738. private _renderingGroupInfo;
  29739. /**
  29740. * Instantiates a new rendering group for a particular scene
  29741. * @param scene Defines the scene the groups belongs to
  29742. */
  29743. constructor(scene: Scene);
  29744. private _clearDepthStencilBuffer;
  29745. /**
  29746. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29747. * @hidden
  29748. */
  29749. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29750. /**
  29751. * Resets the different information of the group to prepare a new frame
  29752. * @hidden
  29753. */
  29754. reset(): void;
  29755. /**
  29756. * Dispose and release the group and its associated resources.
  29757. * @hidden
  29758. */
  29759. dispose(): void;
  29760. /**
  29761. * Clear the info related to rendering groups preventing retention points during dispose.
  29762. */
  29763. freeRenderingGroups(): void;
  29764. private _prepareRenderingGroup;
  29765. /**
  29766. * Add a sprite manager to the rendering manager in order to render it this frame.
  29767. * @param spriteManager Define the sprite manager to render
  29768. */
  29769. dispatchSprites(spriteManager: ISpriteManager): void;
  29770. /**
  29771. * Add a particle system to the rendering manager in order to render it this frame.
  29772. * @param particleSystem Define the particle system to render
  29773. */
  29774. dispatchParticles(particleSystem: IParticleSystem): void;
  29775. /**
  29776. * Add a submesh to the manager in order to render it this frame
  29777. * @param subMesh The submesh to dispatch
  29778. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29779. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29780. */
  29781. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29782. /**
  29783. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29784. * This allowed control for front to back rendering or reversly depending of the special needs.
  29785. *
  29786. * @param renderingGroupId The rendering group id corresponding to its index
  29787. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29788. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29789. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29790. */
  29791. 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;
  29792. /**
  29793. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29794. *
  29795. * @param renderingGroupId The rendering group id corresponding to its index
  29796. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29797. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29798. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29799. */
  29800. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29801. /**
  29802. * Gets the current auto clear configuration for one rendering group of the rendering
  29803. * manager.
  29804. * @param index the rendering group index to get the information for
  29805. * @returns The auto clear setup for the requested rendering group
  29806. */
  29807. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29808. }
  29809. }
  29810. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  29811. import { SmartArray } from "babylonjs/Misc/smartArray";
  29812. import { Nullable } from "babylonjs/types";
  29813. import { Scene } from "babylonjs/scene";
  29814. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29815. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29817. import { Mesh } from "babylonjs/Meshes/mesh";
  29818. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  29819. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29820. import { Effect } from "babylonjs/Materials/effect";
  29821. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29822. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29823. import "babylonjs/Shaders/shadowMap.fragment";
  29824. import "babylonjs/Shaders/shadowMap.vertex";
  29825. import "babylonjs/Shaders/depthBoxBlur.fragment";
  29826. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  29827. import { Observable } from "babylonjs/Misc/observable";
  29828. /**
  29829. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29830. */
  29831. export interface ICustomShaderOptions {
  29832. /**
  29833. * Gets or sets the custom shader name to use
  29834. */
  29835. shaderName: string;
  29836. /**
  29837. * The list of attribute names used in the shader
  29838. */
  29839. attributes?: string[];
  29840. /**
  29841. * The list of unifrom names used in the shader
  29842. */
  29843. uniforms?: string[];
  29844. /**
  29845. * The list of sampler names used in the shader
  29846. */
  29847. samplers?: string[];
  29848. /**
  29849. * The list of defines used in the shader
  29850. */
  29851. defines?: string[];
  29852. }
  29853. /**
  29854. * Interface to implement to create a shadow generator compatible with BJS.
  29855. */
  29856. export interface IShadowGenerator {
  29857. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29858. id: string;
  29859. /**
  29860. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29861. * @returns The render target texture if present otherwise, null
  29862. */
  29863. getShadowMap(): Nullable<RenderTargetTexture>;
  29864. /**
  29865. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29866. * @param subMesh The submesh we want to render in the shadow map
  29867. * @param useInstances Defines wether will draw in the map using instances
  29868. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29869. * @returns true if ready otherwise, false
  29870. */
  29871. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29872. /**
  29873. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29874. * @param defines Defines of the material we want to update
  29875. * @param lightIndex Index of the light in the enabled light list of the material
  29876. */
  29877. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29878. /**
  29879. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29880. * defined in the generator but impacting the effect).
  29881. * It implies the unifroms available on the materials are the standard BJS ones.
  29882. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29883. * @param effect The effect we are binfing the information for
  29884. */
  29885. bindShadowLight(lightIndex: string, effect: Effect): void;
  29886. /**
  29887. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29888. * (eq to shadow prjection matrix * light transform matrix)
  29889. * @returns The transform matrix used to create the shadow map
  29890. */
  29891. getTransformMatrix(): Matrix;
  29892. /**
  29893. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29894. * Cube and 2D textures for instance.
  29895. */
  29896. recreateShadowMap(): void;
  29897. /**
  29898. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29899. * @param onCompiled Callback triggered at the and of the effects compilation
  29900. * @param options Sets of optional options forcing the compilation with different modes
  29901. */
  29902. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29903. useInstances: boolean;
  29904. }>): void;
  29905. /**
  29906. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29907. * @param options Sets of optional options forcing the compilation with different modes
  29908. * @returns A promise that resolves when the compilation completes
  29909. */
  29910. forceCompilationAsync(options?: Partial<{
  29911. useInstances: boolean;
  29912. }>): Promise<void>;
  29913. /**
  29914. * Serializes the shadow generator setup to a json object.
  29915. * @returns The serialized JSON object
  29916. */
  29917. serialize(): any;
  29918. /**
  29919. * Disposes the Shadow map and related Textures and effects.
  29920. */
  29921. dispose(): void;
  29922. }
  29923. /**
  29924. * Default implementation IShadowGenerator.
  29925. * This is the main object responsible of generating shadows in the framework.
  29926. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29927. */
  29928. export class ShadowGenerator implements IShadowGenerator {
  29929. /**
  29930. * Name of the shadow generator class
  29931. */
  29932. static CLASSNAME: string;
  29933. /**
  29934. * Shadow generator mode None: no filtering applied.
  29935. */
  29936. static readonly FILTER_NONE: number;
  29937. /**
  29938. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29939. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29940. */
  29941. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29942. /**
  29943. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29944. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29945. */
  29946. static readonly FILTER_POISSONSAMPLING: number;
  29947. /**
  29948. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29949. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29950. */
  29951. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29952. /**
  29953. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29954. * edge artifacts on steep falloff.
  29955. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29956. */
  29957. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29958. /**
  29959. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29960. * edge artifacts on steep falloff.
  29961. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29962. */
  29963. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29964. /**
  29965. * Shadow generator mode PCF: Percentage Closer Filtering
  29966. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29967. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29968. */
  29969. static readonly FILTER_PCF: number;
  29970. /**
  29971. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29972. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29973. * Contact Hardening
  29974. */
  29975. static readonly FILTER_PCSS: number;
  29976. /**
  29977. * Reserved for PCF and PCSS
  29978. * Highest Quality.
  29979. *
  29980. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29981. *
  29982. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29983. */
  29984. static readonly QUALITY_HIGH: number;
  29985. /**
  29986. * Reserved for PCF and PCSS
  29987. * Good tradeoff for quality/perf cross devices
  29988. *
  29989. * Execute PCF on a 3*3 kernel.
  29990. *
  29991. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29992. */
  29993. static readonly QUALITY_MEDIUM: number;
  29994. /**
  29995. * Reserved for PCF and PCSS
  29996. * The lowest quality but the fastest.
  29997. *
  29998. * Execute PCF on a 1*1 kernel.
  29999. *
  30000. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  30001. */
  30002. static readonly QUALITY_LOW: number;
  30003. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  30004. id: string;
  30005. /** Gets or sets the custom shader name to use */
  30006. customShaderOptions: ICustomShaderOptions;
  30007. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  30008. customAllowRendering: (subMesh: SubMesh) => boolean;
  30009. /**
  30010. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  30011. */
  30012. onBeforeShadowMapRenderObservable: Observable<Effect>;
  30013. /**
  30014. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  30015. */
  30016. onAfterShadowMapRenderObservable: Observable<Effect>;
  30017. /**
  30018. * Observable triggered before a mesh is rendered in the shadow map.
  30019. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  30020. */
  30021. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  30022. /**
  30023. * Observable triggered after a mesh is rendered in the shadow map.
  30024. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  30025. */
  30026. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  30027. protected _bias: number;
  30028. /**
  30029. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30030. */
  30031. get bias(): number;
  30032. /**
  30033. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30034. */
  30035. set bias(bias: number);
  30036. protected _normalBias: number;
  30037. /**
  30038. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30039. */
  30040. get normalBias(): number;
  30041. /**
  30042. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30043. */
  30044. set normalBias(normalBias: number);
  30045. protected _blurBoxOffset: number;
  30046. /**
  30047. * Gets the blur box offset: offset applied during the blur pass.
  30048. * Only useful if useKernelBlur = false
  30049. */
  30050. get blurBoxOffset(): number;
  30051. /**
  30052. * Sets the blur box offset: offset applied during the blur pass.
  30053. * Only useful if useKernelBlur = false
  30054. */
  30055. set blurBoxOffset(value: number);
  30056. protected _blurScale: number;
  30057. /**
  30058. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30059. * 2 means half of the size.
  30060. */
  30061. get blurScale(): number;
  30062. /**
  30063. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30064. * 2 means half of the size.
  30065. */
  30066. set blurScale(value: number);
  30067. protected _blurKernel: number;
  30068. /**
  30069. * Gets the blur kernel: kernel size of the blur pass.
  30070. * Only useful if useKernelBlur = true
  30071. */
  30072. get blurKernel(): number;
  30073. /**
  30074. * Sets the blur kernel: kernel size of the blur pass.
  30075. * Only useful if useKernelBlur = true
  30076. */
  30077. set blurKernel(value: number);
  30078. protected _useKernelBlur: boolean;
  30079. /**
  30080. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30081. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30082. */
  30083. get useKernelBlur(): boolean;
  30084. /**
  30085. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30086. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30087. */
  30088. set useKernelBlur(value: boolean);
  30089. protected _depthScale: number;
  30090. /**
  30091. * Gets the depth scale used in ESM mode.
  30092. */
  30093. get depthScale(): number;
  30094. /**
  30095. * Sets the depth scale used in ESM mode.
  30096. * This can override the scale stored on the light.
  30097. */
  30098. set depthScale(value: number);
  30099. protected _validateFilter(filter: number): number;
  30100. protected _filter: number;
  30101. /**
  30102. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30103. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30104. */
  30105. get filter(): number;
  30106. /**
  30107. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30108. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30109. */
  30110. set filter(value: number);
  30111. /**
  30112. * Gets if the current filter is set to Poisson Sampling.
  30113. */
  30114. get usePoissonSampling(): boolean;
  30115. /**
  30116. * Sets the current filter to Poisson Sampling.
  30117. */
  30118. set usePoissonSampling(value: boolean);
  30119. /**
  30120. * Gets if the current filter is set to ESM.
  30121. */
  30122. get useExponentialShadowMap(): boolean;
  30123. /**
  30124. * Sets the current filter is to ESM.
  30125. */
  30126. set useExponentialShadowMap(value: boolean);
  30127. /**
  30128. * Gets if the current filter is set to filtered ESM.
  30129. */
  30130. get useBlurExponentialShadowMap(): boolean;
  30131. /**
  30132. * Gets if the current filter is set to filtered ESM.
  30133. */
  30134. set useBlurExponentialShadowMap(value: boolean);
  30135. /**
  30136. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30137. * exponential to prevent steep falloff artifacts).
  30138. */
  30139. get useCloseExponentialShadowMap(): boolean;
  30140. /**
  30141. * Sets the current filter to "close ESM" (using the inverse of the
  30142. * exponential to prevent steep falloff artifacts).
  30143. */
  30144. set useCloseExponentialShadowMap(value: boolean);
  30145. /**
  30146. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30147. * exponential to prevent steep falloff artifacts).
  30148. */
  30149. get useBlurCloseExponentialShadowMap(): boolean;
  30150. /**
  30151. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30152. * exponential to prevent steep falloff artifacts).
  30153. */
  30154. set useBlurCloseExponentialShadowMap(value: boolean);
  30155. /**
  30156. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30157. */
  30158. get usePercentageCloserFiltering(): boolean;
  30159. /**
  30160. * Sets the current filter to "PCF" (percentage closer filtering).
  30161. */
  30162. set usePercentageCloserFiltering(value: boolean);
  30163. protected _filteringQuality: number;
  30164. /**
  30165. * Gets the PCF or PCSS Quality.
  30166. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30167. */
  30168. get filteringQuality(): number;
  30169. /**
  30170. * Sets the PCF or PCSS Quality.
  30171. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30172. */
  30173. set filteringQuality(filteringQuality: number);
  30174. /**
  30175. * Gets if the current filter is set to "PCSS" (contact hardening).
  30176. */
  30177. get useContactHardeningShadow(): boolean;
  30178. /**
  30179. * Sets the current filter to "PCSS" (contact hardening).
  30180. */
  30181. set useContactHardeningShadow(value: boolean);
  30182. protected _contactHardeningLightSizeUVRatio: number;
  30183. /**
  30184. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30185. * Using a ratio helps keeping shape stability independently of the map size.
  30186. *
  30187. * It does not account for the light projection as it was having too much
  30188. * instability during the light setup or during light position changes.
  30189. *
  30190. * Only valid if useContactHardeningShadow is true.
  30191. */
  30192. get contactHardeningLightSizeUVRatio(): number;
  30193. /**
  30194. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30195. * Using a ratio helps keeping shape stability independently of the map size.
  30196. *
  30197. * It does not account for the light projection as it was having too much
  30198. * instability during the light setup or during light position changes.
  30199. *
  30200. * Only valid if useContactHardeningShadow is true.
  30201. */
  30202. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30203. protected _darkness: number;
  30204. /** Gets or sets the actual darkness of a shadow */
  30205. get darkness(): number;
  30206. set darkness(value: number);
  30207. /**
  30208. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30209. * 0 means strongest and 1 would means no shadow.
  30210. * @returns the darkness.
  30211. */
  30212. getDarkness(): number;
  30213. /**
  30214. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30215. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30216. * @returns the shadow generator allowing fluent coding.
  30217. */
  30218. setDarkness(darkness: number): ShadowGenerator;
  30219. protected _transparencyShadow: boolean;
  30220. /** Gets or sets the ability to have transparent shadow */
  30221. get transparencyShadow(): boolean;
  30222. set transparencyShadow(value: boolean);
  30223. /**
  30224. * Sets the ability to have transparent shadow (boolean).
  30225. * @param transparent True if transparent else False
  30226. * @returns the shadow generator allowing fluent coding
  30227. */
  30228. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30229. /**
  30230. * Enables or disables shadows with varying strength based on the transparency
  30231. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30232. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30233. * mesh.visibility * alphaTexture.a
  30234. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30235. */
  30236. enableSoftTransparentShadow: boolean;
  30237. protected _shadowMap: Nullable<RenderTargetTexture>;
  30238. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30239. /**
  30240. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30241. * @returns The render target texture if present otherwise, null
  30242. */
  30243. getShadowMap(): Nullable<RenderTargetTexture>;
  30244. /**
  30245. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30246. * @returns The render target texture if the shadow map is present otherwise, null
  30247. */
  30248. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30249. /**
  30250. * Gets the class name of that object
  30251. * @returns "ShadowGenerator"
  30252. */
  30253. getClassName(): string;
  30254. /**
  30255. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30256. * @param mesh Mesh to add
  30257. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30258. * @returns the Shadow Generator itself
  30259. */
  30260. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30261. /**
  30262. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30263. * @param mesh Mesh to remove
  30264. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30265. * @returns the Shadow Generator itself
  30266. */
  30267. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30268. /**
  30269. * Controls the extent to which the shadows fade out at the edge of the frustum
  30270. */
  30271. frustumEdgeFalloff: number;
  30272. protected _light: IShadowLight;
  30273. /**
  30274. * Returns the associated light object.
  30275. * @returns the light generating the shadow
  30276. */
  30277. getLight(): IShadowLight;
  30278. /**
  30279. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30280. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30281. * It might on the other hand introduce peter panning.
  30282. */
  30283. forceBackFacesOnly: boolean;
  30284. protected _scene: Scene;
  30285. protected _lightDirection: Vector3;
  30286. protected _effect: Effect;
  30287. protected _viewMatrix: Matrix;
  30288. protected _projectionMatrix: Matrix;
  30289. protected _transformMatrix: Matrix;
  30290. protected _cachedPosition: Vector3;
  30291. protected _cachedDirection: Vector3;
  30292. protected _cachedDefines: string;
  30293. protected _currentRenderID: number;
  30294. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30295. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30296. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30297. protected _blurPostProcesses: PostProcess[];
  30298. protected _mapSize: number;
  30299. protected _currentFaceIndex: number;
  30300. protected _currentFaceIndexCache: number;
  30301. protected _textureType: number;
  30302. protected _defaultTextureMatrix: Matrix;
  30303. protected _storedUniqueId: Nullable<number>;
  30304. /** @hidden */
  30305. static _SceneComponentInitialization: (scene: Scene) => void;
  30306. /**
  30307. * Gets or sets the size of the texture what stores the shadows
  30308. */
  30309. get mapSize(): number;
  30310. set mapSize(size: number);
  30311. /**
  30312. * Creates a ShadowGenerator object.
  30313. * A ShadowGenerator is the required tool to use the shadows.
  30314. * Each light casting shadows needs to use its own ShadowGenerator.
  30315. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30316. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30317. * @param light The light object generating the shadows.
  30318. * @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.
  30319. */
  30320. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30321. protected _initializeGenerator(): void;
  30322. protected _createTargetRenderTexture(): void;
  30323. protected _initializeShadowMap(): void;
  30324. protected _initializeBlurRTTAndPostProcesses(): void;
  30325. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30326. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30327. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30328. protected _applyFilterValues(): void;
  30329. /**
  30330. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30331. * @param onCompiled Callback triggered at the and of the effects compilation
  30332. * @param options Sets of optional options forcing the compilation with different modes
  30333. */
  30334. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30335. useInstances: boolean;
  30336. }>): void;
  30337. /**
  30338. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30339. * @param options Sets of optional options forcing the compilation with different modes
  30340. * @returns A promise that resolves when the compilation completes
  30341. */
  30342. forceCompilationAsync(options?: Partial<{
  30343. useInstances: boolean;
  30344. }>): Promise<void>;
  30345. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30346. private _prepareShadowDefines;
  30347. /**
  30348. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30349. * @param subMesh The submesh we want to render in the shadow map
  30350. * @param useInstances Defines wether will draw in the map using instances
  30351. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30352. * @returns true if ready otherwise, false
  30353. */
  30354. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30355. /**
  30356. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30357. * @param defines Defines of the material we want to update
  30358. * @param lightIndex Index of the light in the enabled light list of the material
  30359. */
  30360. prepareDefines(defines: any, lightIndex: number): void;
  30361. /**
  30362. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30363. * defined in the generator but impacting the effect).
  30364. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30365. * @param effect The effect we are binfing the information for
  30366. */
  30367. bindShadowLight(lightIndex: string, effect: Effect): void;
  30368. /**
  30369. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30370. * (eq to shadow prjection matrix * light transform matrix)
  30371. * @returns The transform matrix used to create the shadow map
  30372. */
  30373. getTransformMatrix(): Matrix;
  30374. /**
  30375. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30376. * Cube and 2D textures for instance.
  30377. */
  30378. recreateShadowMap(): void;
  30379. protected _disposeBlurPostProcesses(): void;
  30380. protected _disposeRTTandPostProcesses(): void;
  30381. /**
  30382. * Disposes the ShadowGenerator.
  30383. * Returns nothing.
  30384. */
  30385. dispose(): void;
  30386. /**
  30387. * Serializes the shadow generator setup to a json object.
  30388. * @returns The serialized JSON object
  30389. */
  30390. serialize(): any;
  30391. /**
  30392. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30393. * @param parsedShadowGenerator The JSON object to parse
  30394. * @param scene The scene to create the shadow map for
  30395. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30396. * @returns The parsed shadow generator
  30397. */
  30398. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30399. }
  30400. }
  30401. declare module "babylonjs/Materials/shadowDepthWrapper" {
  30402. import { Nullable } from "babylonjs/types";
  30403. import { Scene } from "babylonjs/scene";
  30404. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30405. import { Material } from "babylonjs/Materials/material";
  30406. import { Effect } from "babylonjs/Materials/effect";
  30407. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  30408. /**
  30409. * Options to be used when creating a shadow depth material
  30410. */
  30411. export interface IIOptionShadowDepthMaterial {
  30412. /** Variables in the vertex shader code that need to have their names remapped.
  30413. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30414. * "var_name" should be either: worldPos or vNormalW
  30415. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30416. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30417. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30418. */
  30419. remappedVariables?: string[];
  30420. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30421. standalone?: boolean;
  30422. }
  30423. /**
  30424. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30425. */
  30426. export class ShadowDepthWrapper {
  30427. private _scene;
  30428. private _options?;
  30429. private _baseMaterial;
  30430. private _onEffectCreatedObserver;
  30431. private _subMeshToEffect;
  30432. private _subMeshToDepthEffect;
  30433. private _meshes;
  30434. /** @hidden */
  30435. _matriceNames: any;
  30436. /** Gets the standalone status of the wrapper */
  30437. get standalone(): boolean;
  30438. /** Gets the base material the wrapper is built upon */
  30439. get baseMaterial(): Material;
  30440. /**
  30441. * Instantiate a new shadow depth wrapper.
  30442. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30443. * generate the shadow depth map. For more information, please refer to the documentation:
  30444. * https://doc.babylonjs.com/babylon101/shadows
  30445. * @param baseMaterial Material to wrap
  30446. * @param scene Define the scene the material belongs to
  30447. * @param options Options used to create the wrapper
  30448. */
  30449. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30450. /**
  30451. * Gets the effect to use to generate the depth map
  30452. * @param subMesh subMesh to get the effect for
  30453. * @param shadowGenerator shadow generator to get the effect for
  30454. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30455. */
  30456. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30457. /**
  30458. * Specifies that the submesh is ready to be used for depth rendering
  30459. * @param subMesh submesh to check
  30460. * @param defines the list of defines to take into account when checking the effect
  30461. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30462. * @param useInstances specifies that instances should be used
  30463. * @returns a boolean indicating that the submesh is ready or not
  30464. */
  30465. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30466. /**
  30467. * Disposes the resources
  30468. */
  30469. dispose(): void;
  30470. private _makeEffect;
  30471. }
  30472. }
  30473. declare module "babylonjs/Materials/material" {
  30474. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30475. import { SmartArray } from "babylonjs/Misc/smartArray";
  30476. import { Observable } from "babylonjs/Misc/observable";
  30477. import { Nullable } from "babylonjs/types";
  30478. import { Scene } from "babylonjs/scene";
  30479. import { Matrix } from "babylonjs/Maths/math.vector";
  30480. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30482. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30483. import { Effect } from "babylonjs/Materials/effect";
  30484. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30485. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30486. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30487. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30488. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30489. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30490. import { Mesh } from "babylonjs/Meshes/mesh";
  30491. import { Animation } from "babylonjs/Animations/animation";
  30492. /**
  30493. * Options for compiling materials.
  30494. */
  30495. export interface IMaterialCompilationOptions {
  30496. /**
  30497. * Defines whether clip planes are enabled.
  30498. */
  30499. clipPlane: boolean;
  30500. /**
  30501. * Defines whether instances are enabled.
  30502. */
  30503. useInstances: boolean;
  30504. }
  30505. /**
  30506. * Options passed when calling customShaderNameResolve
  30507. */
  30508. export interface ICustomShaderNameResolveOptions {
  30509. /**
  30510. * 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
  30511. */
  30512. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30513. }
  30514. /**
  30515. * Base class for the main features of a material in Babylon.js
  30516. */
  30517. export class Material implements IAnimatable {
  30518. /**
  30519. * Returns the triangle fill mode
  30520. */
  30521. static readonly TriangleFillMode: number;
  30522. /**
  30523. * Returns the wireframe mode
  30524. */
  30525. static readonly WireFrameFillMode: number;
  30526. /**
  30527. * Returns the point fill mode
  30528. */
  30529. static readonly PointFillMode: number;
  30530. /**
  30531. * Returns the point list draw mode
  30532. */
  30533. static readonly PointListDrawMode: number;
  30534. /**
  30535. * Returns the line list draw mode
  30536. */
  30537. static readonly LineListDrawMode: number;
  30538. /**
  30539. * Returns the line loop draw mode
  30540. */
  30541. static readonly LineLoopDrawMode: number;
  30542. /**
  30543. * Returns the line strip draw mode
  30544. */
  30545. static readonly LineStripDrawMode: number;
  30546. /**
  30547. * Returns the triangle strip draw mode
  30548. */
  30549. static readonly TriangleStripDrawMode: number;
  30550. /**
  30551. * Returns the triangle fan draw mode
  30552. */
  30553. static readonly TriangleFanDrawMode: number;
  30554. /**
  30555. * Stores the clock-wise side orientation
  30556. */
  30557. static readonly ClockWiseSideOrientation: number;
  30558. /**
  30559. * Stores the counter clock-wise side orientation
  30560. */
  30561. static readonly CounterClockWiseSideOrientation: number;
  30562. /**
  30563. * The dirty texture flag value
  30564. */
  30565. static readonly TextureDirtyFlag: number;
  30566. /**
  30567. * The dirty light flag value
  30568. */
  30569. static readonly LightDirtyFlag: number;
  30570. /**
  30571. * The dirty fresnel flag value
  30572. */
  30573. static readonly FresnelDirtyFlag: number;
  30574. /**
  30575. * The dirty attribute flag value
  30576. */
  30577. static readonly AttributesDirtyFlag: number;
  30578. /**
  30579. * The dirty misc flag value
  30580. */
  30581. static readonly MiscDirtyFlag: number;
  30582. /**
  30583. * The dirty prepass flag value
  30584. */
  30585. static readonly PrePassDirtyFlag: number;
  30586. /**
  30587. * The all dirty flag value
  30588. */
  30589. static readonly AllDirtyFlag: number;
  30590. /**
  30591. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30592. */
  30593. static readonly MATERIAL_OPAQUE: number;
  30594. /**
  30595. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30596. */
  30597. static readonly MATERIAL_ALPHATEST: number;
  30598. /**
  30599. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30600. */
  30601. static readonly MATERIAL_ALPHABLEND: number;
  30602. /**
  30603. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30604. * They are also discarded below the alpha cutoff threshold to improve performances.
  30605. */
  30606. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30607. /**
  30608. * The Whiteout method is used to blend normals.
  30609. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30610. */
  30611. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30612. /**
  30613. * The Reoriented Normal Mapping method is used to blend normals.
  30614. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30615. */
  30616. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30617. /**
  30618. * Custom callback helping to override the default shader used in the material.
  30619. */
  30620. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30621. /**
  30622. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30623. */
  30624. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30625. /**
  30626. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30627. * This means that the material can keep using a previous shader while a new one is being compiled.
  30628. * This is mostly used when shader parallel compilation is supported (true by default)
  30629. */
  30630. allowShaderHotSwapping: boolean;
  30631. /**
  30632. * The ID of the material
  30633. */
  30634. id: string;
  30635. /**
  30636. * Gets or sets the unique id of the material
  30637. */
  30638. uniqueId: number;
  30639. /**
  30640. * The name of the material
  30641. */
  30642. name: string;
  30643. /**
  30644. * Gets or sets user defined metadata
  30645. */
  30646. metadata: any;
  30647. /**
  30648. * For internal use only. Please do not use.
  30649. */
  30650. reservedDataStore: any;
  30651. /**
  30652. * Specifies if the ready state should be checked on each call
  30653. */
  30654. checkReadyOnEveryCall: boolean;
  30655. /**
  30656. * Specifies if the ready state should be checked once
  30657. */
  30658. checkReadyOnlyOnce: boolean;
  30659. /**
  30660. * The state of the material
  30661. */
  30662. state: string;
  30663. /**
  30664. * If the material can be rendered to several textures with MRT extension
  30665. */
  30666. get canRenderToMRT(): boolean;
  30667. /**
  30668. * The alpha value of the material
  30669. */
  30670. protected _alpha: number;
  30671. /**
  30672. * List of inspectable custom properties (used by the Inspector)
  30673. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30674. */
  30675. inspectableCustomProperties: IInspectable[];
  30676. /**
  30677. * Sets the alpha value of the material
  30678. */
  30679. set alpha(value: number);
  30680. /**
  30681. * Gets the alpha value of the material
  30682. */
  30683. get alpha(): number;
  30684. /**
  30685. * Specifies if back face culling is enabled
  30686. */
  30687. protected _backFaceCulling: boolean;
  30688. /**
  30689. * Sets the back-face culling state
  30690. */
  30691. set backFaceCulling(value: boolean);
  30692. /**
  30693. * Gets the back-face culling state
  30694. */
  30695. get backFaceCulling(): boolean;
  30696. /**
  30697. * Stores the value for side orientation
  30698. */
  30699. sideOrientation: number;
  30700. /**
  30701. * Callback triggered when the material is compiled
  30702. */
  30703. onCompiled: Nullable<(effect: Effect) => void>;
  30704. /**
  30705. * Callback triggered when an error occurs
  30706. */
  30707. onError: Nullable<(effect: Effect, errors: string) => void>;
  30708. /**
  30709. * Callback triggered to get the render target textures
  30710. */
  30711. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30712. /**
  30713. * Gets a boolean indicating that current material needs to register RTT
  30714. */
  30715. get hasRenderTargetTextures(): boolean;
  30716. /**
  30717. * Specifies if the material should be serialized
  30718. */
  30719. doNotSerialize: boolean;
  30720. /**
  30721. * @hidden
  30722. */
  30723. _storeEffectOnSubMeshes: boolean;
  30724. /**
  30725. * Stores the animations for the material
  30726. */
  30727. animations: Nullable<Array<Animation>>;
  30728. /**
  30729. * An event triggered when the material is disposed
  30730. */
  30731. onDisposeObservable: Observable<Material>;
  30732. /**
  30733. * An observer which watches for dispose events
  30734. */
  30735. private _onDisposeObserver;
  30736. private _onUnBindObservable;
  30737. /**
  30738. * Called during a dispose event
  30739. */
  30740. set onDispose(callback: () => void);
  30741. private _onBindObservable;
  30742. /**
  30743. * An event triggered when the material is bound
  30744. */
  30745. get onBindObservable(): Observable<AbstractMesh>;
  30746. /**
  30747. * An observer which watches for bind events
  30748. */
  30749. private _onBindObserver;
  30750. /**
  30751. * Called during a bind event
  30752. */
  30753. set onBind(callback: (Mesh: AbstractMesh) => void);
  30754. /**
  30755. * An event triggered when the material is unbound
  30756. */
  30757. get onUnBindObservable(): Observable<Material>;
  30758. protected _onEffectCreatedObservable: Nullable<Observable<{
  30759. effect: Effect;
  30760. subMesh: Nullable<SubMesh>;
  30761. }>>;
  30762. /**
  30763. * An event triggered when the effect is (re)created
  30764. */
  30765. get onEffectCreatedObservable(): Observable<{
  30766. effect: Effect;
  30767. subMesh: Nullable<SubMesh>;
  30768. }>;
  30769. /**
  30770. * Stores the value of the alpha mode
  30771. */
  30772. private _alphaMode;
  30773. /**
  30774. * Sets the value of the alpha mode.
  30775. *
  30776. * | Value | Type | Description |
  30777. * | --- | --- | --- |
  30778. * | 0 | ALPHA_DISABLE | |
  30779. * | 1 | ALPHA_ADD | |
  30780. * | 2 | ALPHA_COMBINE | |
  30781. * | 3 | ALPHA_SUBTRACT | |
  30782. * | 4 | ALPHA_MULTIPLY | |
  30783. * | 5 | ALPHA_MAXIMIZED | |
  30784. * | 6 | ALPHA_ONEONE | |
  30785. * | 7 | ALPHA_PREMULTIPLIED | |
  30786. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30787. * | 9 | ALPHA_INTERPOLATE | |
  30788. * | 10 | ALPHA_SCREENMODE | |
  30789. *
  30790. */
  30791. set alphaMode(value: number);
  30792. /**
  30793. * Gets the value of the alpha mode
  30794. */
  30795. get alphaMode(): number;
  30796. /**
  30797. * Stores the state of the need depth pre-pass value
  30798. */
  30799. private _needDepthPrePass;
  30800. /**
  30801. * Sets the need depth pre-pass value
  30802. */
  30803. set needDepthPrePass(value: boolean);
  30804. /**
  30805. * Gets the depth pre-pass value
  30806. */
  30807. get needDepthPrePass(): boolean;
  30808. /**
  30809. * Specifies if depth writing should be disabled
  30810. */
  30811. disableDepthWrite: boolean;
  30812. /**
  30813. * Specifies if color writing should be disabled
  30814. */
  30815. disableColorWrite: boolean;
  30816. /**
  30817. * Specifies if depth writing should be forced
  30818. */
  30819. forceDepthWrite: boolean;
  30820. /**
  30821. * Specifies the depth function that should be used. 0 means the default engine function
  30822. */
  30823. depthFunction: number;
  30824. /**
  30825. * Specifies if there should be a separate pass for culling
  30826. */
  30827. separateCullingPass: boolean;
  30828. /**
  30829. * Stores the state specifing if fog should be enabled
  30830. */
  30831. private _fogEnabled;
  30832. /**
  30833. * Sets the state for enabling fog
  30834. */
  30835. set fogEnabled(value: boolean);
  30836. /**
  30837. * Gets the value of the fog enabled state
  30838. */
  30839. get fogEnabled(): boolean;
  30840. /**
  30841. * Stores the size of points
  30842. */
  30843. pointSize: number;
  30844. /**
  30845. * Stores the z offset value
  30846. */
  30847. zOffset: number;
  30848. get wireframe(): boolean;
  30849. /**
  30850. * Sets the state of wireframe mode
  30851. */
  30852. set wireframe(value: boolean);
  30853. /**
  30854. * Gets the value specifying if point clouds are enabled
  30855. */
  30856. get pointsCloud(): boolean;
  30857. /**
  30858. * Sets the state of point cloud mode
  30859. */
  30860. set pointsCloud(value: boolean);
  30861. /**
  30862. * Gets the material fill mode
  30863. */
  30864. get fillMode(): number;
  30865. /**
  30866. * Sets the material fill mode
  30867. */
  30868. set fillMode(value: number);
  30869. /**
  30870. * @hidden
  30871. * Stores the effects for the material
  30872. */
  30873. _effect: Nullable<Effect>;
  30874. /**
  30875. * Specifies if uniform buffers should be used
  30876. */
  30877. private _useUBO;
  30878. /**
  30879. * Stores a reference to the scene
  30880. */
  30881. private _scene;
  30882. /**
  30883. * Stores the fill mode state
  30884. */
  30885. private _fillMode;
  30886. /**
  30887. * Specifies if the depth write state should be cached
  30888. */
  30889. private _cachedDepthWriteState;
  30890. /**
  30891. * Specifies if the color write state should be cached
  30892. */
  30893. private _cachedColorWriteState;
  30894. /**
  30895. * Specifies if the depth function state should be cached
  30896. */
  30897. private _cachedDepthFunctionState;
  30898. /**
  30899. * Stores the uniform buffer
  30900. */
  30901. protected _uniformBuffer: UniformBuffer;
  30902. /** @hidden */
  30903. _indexInSceneMaterialArray: number;
  30904. /** @hidden */
  30905. meshMap: Nullable<{
  30906. [id: string]: AbstractMesh | undefined;
  30907. }>;
  30908. /**
  30909. * Creates a material instance
  30910. * @param name defines the name of the material
  30911. * @param scene defines the scene to reference
  30912. * @param doNotAdd specifies if the material should be added to the scene
  30913. */
  30914. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30915. /**
  30916. * Returns a string representation of the current material
  30917. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30918. * @returns a string with material information
  30919. */
  30920. toString(fullDetails?: boolean): string;
  30921. /**
  30922. * Gets the class name of the material
  30923. * @returns a string with the class name of the material
  30924. */
  30925. getClassName(): string;
  30926. /**
  30927. * Specifies if updates for the material been locked
  30928. */
  30929. get isFrozen(): boolean;
  30930. /**
  30931. * Locks updates for the material
  30932. */
  30933. freeze(): void;
  30934. /**
  30935. * Unlocks updates for the material
  30936. */
  30937. unfreeze(): void;
  30938. /**
  30939. * Specifies if the material is ready to be used
  30940. * @param mesh defines the mesh to check
  30941. * @param useInstances specifies if instances should be used
  30942. * @returns a boolean indicating if the material is ready to be used
  30943. */
  30944. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30945. /**
  30946. * Specifies that the submesh is ready to be used
  30947. * @param mesh defines the mesh to check
  30948. * @param subMesh defines which submesh to check
  30949. * @param useInstances specifies that instances should be used
  30950. * @returns a boolean indicating that the submesh is ready or not
  30951. */
  30952. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30953. /**
  30954. * Returns the material effect
  30955. * @returns the effect associated with the material
  30956. */
  30957. getEffect(): Nullable<Effect>;
  30958. /**
  30959. * Returns the current scene
  30960. * @returns a Scene
  30961. */
  30962. getScene(): Scene;
  30963. /**
  30964. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30965. */
  30966. protected _forceAlphaTest: boolean;
  30967. /**
  30968. * The transparency mode of the material.
  30969. */
  30970. protected _transparencyMode: Nullable<number>;
  30971. /**
  30972. * Gets the current transparency mode.
  30973. */
  30974. get transparencyMode(): Nullable<number>;
  30975. /**
  30976. * Sets the transparency mode of the material.
  30977. *
  30978. * | Value | Type | Description |
  30979. * | ----- | ----------------------------------- | ----------- |
  30980. * | 0 | OPAQUE | |
  30981. * | 1 | ALPHATEST | |
  30982. * | 2 | ALPHABLEND | |
  30983. * | 3 | ALPHATESTANDBLEND | |
  30984. *
  30985. */
  30986. set transparencyMode(value: Nullable<number>);
  30987. /**
  30988. * Returns true if alpha blending should be disabled.
  30989. */
  30990. protected get _disableAlphaBlending(): boolean;
  30991. /**
  30992. * Specifies whether or not this material should be rendered in alpha blend mode.
  30993. * @returns a boolean specifying if alpha blending is needed
  30994. */
  30995. needAlphaBlending(): boolean;
  30996. /**
  30997. * Specifies if the mesh will require alpha blending
  30998. * @param mesh defines the mesh to check
  30999. * @returns a boolean specifying if alpha blending is needed for the mesh
  31000. */
  31001. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  31002. /**
  31003. * Specifies whether or not this material should be rendered in alpha test mode.
  31004. * @returns a boolean specifying if an alpha test is needed.
  31005. */
  31006. needAlphaTesting(): boolean;
  31007. /**
  31008. * Specifies if material alpha testing should be turned on for the mesh
  31009. * @param mesh defines the mesh to check
  31010. */
  31011. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  31012. /**
  31013. * Gets the texture used for the alpha test
  31014. * @returns the texture to use for alpha testing
  31015. */
  31016. getAlphaTestTexture(): Nullable<BaseTexture>;
  31017. /**
  31018. * Marks the material to indicate that it needs to be re-calculated
  31019. */
  31020. markDirty(): void;
  31021. /** @hidden */
  31022. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  31023. /**
  31024. * Binds the material to the mesh
  31025. * @param world defines the world transformation matrix
  31026. * @param mesh defines the mesh to bind the material to
  31027. */
  31028. bind(world: Matrix, mesh?: Mesh): void;
  31029. /**
  31030. * Binds the submesh to the material
  31031. * @param world defines the world transformation matrix
  31032. * @param mesh defines the mesh containing the submesh
  31033. * @param subMesh defines the submesh to bind the material to
  31034. */
  31035. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31036. /**
  31037. * Binds the world matrix to the material
  31038. * @param world defines the world transformation matrix
  31039. */
  31040. bindOnlyWorldMatrix(world: Matrix): void;
  31041. /**
  31042. * Binds the scene's uniform buffer to the effect.
  31043. * @param effect defines the effect to bind to the scene uniform buffer
  31044. * @param sceneUbo defines the uniform buffer storing scene data
  31045. */
  31046. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  31047. /**
  31048. * Binds the view matrix to the effect
  31049. * @param effect defines the effect to bind the view matrix to
  31050. */
  31051. bindView(effect: Effect): void;
  31052. /**
  31053. * Binds the view projection matrix to the effect
  31054. * @param effect defines the effect to bind the view projection matrix to
  31055. */
  31056. bindViewProjection(effect: Effect): void;
  31057. /**
  31058. * Processes to execute after binding the material to a mesh
  31059. * @param mesh defines the rendered mesh
  31060. */
  31061. protected _afterBind(mesh?: Mesh): void;
  31062. /**
  31063. * Unbinds the material from the mesh
  31064. */
  31065. unbind(): void;
  31066. /**
  31067. * Gets the active textures from the material
  31068. * @returns an array of textures
  31069. */
  31070. getActiveTextures(): BaseTexture[];
  31071. /**
  31072. * Specifies if the material uses a texture
  31073. * @param texture defines the texture to check against the material
  31074. * @returns a boolean specifying if the material uses the texture
  31075. */
  31076. hasTexture(texture: BaseTexture): boolean;
  31077. /**
  31078. * Makes a duplicate of the material, and gives it a new name
  31079. * @param name defines the new name for the duplicated material
  31080. * @returns the cloned material
  31081. */
  31082. clone(name: string): Nullable<Material>;
  31083. /**
  31084. * Gets the meshes bound to the material
  31085. * @returns an array of meshes bound to the material
  31086. */
  31087. getBindedMeshes(): AbstractMesh[];
  31088. /**
  31089. * Force shader compilation
  31090. * @param mesh defines the mesh associated with this material
  31091. * @param onCompiled defines a function to execute once the material is compiled
  31092. * @param options defines the options to configure the compilation
  31093. * @param onError defines a function to execute if the material fails compiling
  31094. */
  31095. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31096. /**
  31097. * Force shader compilation
  31098. * @param mesh defines the mesh that will use this material
  31099. * @param options defines additional options for compiling the shaders
  31100. * @returns a promise that resolves when the compilation completes
  31101. */
  31102. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31103. private static readonly _AllDirtyCallBack;
  31104. private static readonly _ImageProcessingDirtyCallBack;
  31105. private static readonly _TextureDirtyCallBack;
  31106. private static readonly _FresnelDirtyCallBack;
  31107. private static readonly _MiscDirtyCallBack;
  31108. private static readonly _PrePassDirtyCallBack;
  31109. private static readonly _LightsDirtyCallBack;
  31110. private static readonly _AttributeDirtyCallBack;
  31111. private static _FresnelAndMiscDirtyCallBack;
  31112. private static _TextureAndMiscDirtyCallBack;
  31113. private static readonly _DirtyCallbackArray;
  31114. private static readonly _RunDirtyCallBacks;
  31115. /**
  31116. * Marks a define in the material to indicate that it needs to be re-computed
  31117. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31118. */
  31119. markAsDirty(flag: number): void;
  31120. /**
  31121. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31122. * @param func defines a function which checks material defines against the submeshes
  31123. */
  31124. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31125. /**
  31126. * Indicates that the scene should check if the rendering now needs a prepass
  31127. */
  31128. protected _markScenePrePassDirty(): void;
  31129. /**
  31130. * Indicates that we need to re-calculated for all submeshes
  31131. */
  31132. protected _markAllSubMeshesAsAllDirty(): void;
  31133. /**
  31134. * Indicates that image processing needs to be re-calculated for all submeshes
  31135. */
  31136. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31137. /**
  31138. * Indicates that textures need to be re-calculated for all submeshes
  31139. */
  31140. protected _markAllSubMeshesAsTexturesDirty(): void;
  31141. /**
  31142. * Indicates that fresnel needs to be re-calculated for all submeshes
  31143. */
  31144. protected _markAllSubMeshesAsFresnelDirty(): void;
  31145. /**
  31146. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31147. */
  31148. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31149. /**
  31150. * Indicates that lights need to be re-calculated for all submeshes
  31151. */
  31152. protected _markAllSubMeshesAsLightsDirty(): void;
  31153. /**
  31154. * Indicates that attributes need to be re-calculated for all submeshes
  31155. */
  31156. protected _markAllSubMeshesAsAttributesDirty(): void;
  31157. /**
  31158. * Indicates that misc needs to be re-calculated for all submeshes
  31159. */
  31160. protected _markAllSubMeshesAsMiscDirty(): void;
  31161. /**
  31162. * Indicates that prepass needs to be re-calculated for all submeshes
  31163. */
  31164. protected _markAllSubMeshesAsPrePassDirty(): void;
  31165. /**
  31166. * Indicates that textures and misc need to be re-calculated for all submeshes
  31167. */
  31168. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31169. /**
  31170. * Sets the required values to the prepass renderer.
  31171. * @param prePassRenderer defines the prepass renderer to setup.
  31172. * @returns true if the pre pass is needed.
  31173. */
  31174. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31175. /**
  31176. * Disposes the material
  31177. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31178. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31179. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31180. */
  31181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31182. /** @hidden */
  31183. private releaseVertexArrayObject;
  31184. /**
  31185. * Serializes this material
  31186. * @returns the serialized material object
  31187. */
  31188. serialize(): any;
  31189. /**
  31190. * Creates a material from parsed material data
  31191. * @param parsedMaterial defines parsed material data
  31192. * @param scene defines the hosting scene
  31193. * @param rootUrl defines the root URL to use to load textures
  31194. * @returns a new material
  31195. */
  31196. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31197. }
  31198. }
  31199. declare module "babylonjs/Materials/multiMaterial" {
  31200. import { Nullable } from "babylonjs/types";
  31201. import { Scene } from "babylonjs/scene";
  31202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31203. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31204. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31205. import { Material } from "babylonjs/Materials/material";
  31206. /**
  31207. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31208. * separate meshes. This can be use to improve performances.
  31209. * @see https://doc.babylonjs.com/how_to/multi_materials
  31210. */
  31211. export class MultiMaterial extends Material {
  31212. private _subMaterials;
  31213. /**
  31214. * Gets or Sets the list of Materials used within the multi material.
  31215. * They need to be ordered according to the submeshes order in the associated mesh
  31216. */
  31217. get subMaterials(): Nullable<Material>[];
  31218. set subMaterials(value: Nullable<Material>[]);
  31219. /**
  31220. * Function used to align with Node.getChildren()
  31221. * @returns the list of Materials used within the multi material
  31222. */
  31223. getChildren(): Nullable<Material>[];
  31224. /**
  31225. * Instantiates a new Multi Material
  31226. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31227. * separate meshes. This can be use to improve performances.
  31228. * @see https://doc.babylonjs.com/how_to/multi_materials
  31229. * @param name Define the name in the scene
  31230. * @param scene Define the scene the material belongs to
  31231. */
  31232. constructor(name: string, scene: Scene);
  31233. private _hookArray;
  31234. /**
  31235. * Get one of the submaterial by its index in the submaterials array
  31236. * @param index The index to look the sub material at
  31237. * @returns The Material if the index has been defined
  31238. */
  31239. getSubMaterial(index: number): Nullable<Material>;
  31240. /**
  31241. * Get the list of active textures for the whole sub materials list.
  31242. * @returns All the textures that will be used during the rendering
  31243. */
  31244. getActiveTextures(): BaseTexture[];
  31245. /**
  31246. * Specifies if any sub-materials of this multi-material use a given texture.
  31247. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31248. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31249. */
  31250. hasTexture(texture: BaseTexture): boolean;
  31251. /**
  31252. * Gets the current class name of the material e.g. "MultiMaterial"
  31253. * Mainly use in serialization.
  31254. * @returns the class name
  31255. */
  31256. getClassName(): string;
  31257. /**
  31258. * Checks if the material is ready to render the requested sub mesh
  31259. * @param mesh Define the mesh the submesh belongs to
  31260. * @param subMesh Define the sub mesh to look readyness for
  31261. * @param useInstances Define whether or not the material is used with instances
  31262. * @returns true if ready, otherwise false
  31263. */
  31264. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31265. /**
  31266. * Clones the current material and its related sub materials
  31267. * @param name Define the name of the newly cloned material
  31268. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31269. * @returns the cloned material
  31270. */
  31271. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31272. /**
  31273. * Serializes the materials into a JSON representation.
  31274. * @returns the JSON representation
  31275. */
  31276. serialize(): any;
  31277. /**
  31278. * Dispose the material and release its associated resources
  31279. * @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)
  31280. * @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)
  31281. * @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)
  31282. */
  31283. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31284. /**
  31285. * Creates a MultiMaterial from parsed MultiMaterial data.
  31286. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31287. * @param scene defines the hosting scene
  31288. * @returns a new MultiMaterial
  31289. */
  31290. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31291. }
  31292. }
  31293. declare module "babylonjs/Meshes/subMesh" {
  31294. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  31295. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  31296. import { Engine } from "babylonjs/Engines/engine";
  31297. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  31298. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31299. import { Effect } from "babylonjs/Materials/effect";
  31300. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31301. import { Plane } from "babylonjs/Maths/math.plane";
  31302. import { Collider } from "babylonjs/Collisions/collider";
  31303. import { Material } from "babylonjs/Materials/material";
  31304. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31306. import { Mesh } from "babylonjs/Meshes/mesh";
  31307. import { Ray } from "babylonjs/Culling/ray";
  31308. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31309. /**
  31310. * Defines a subdivision inside a mesh
  31311. */
  31312. export class SubMesh implements ICullable {
  31313. /** the material index to use */
  31314. materialIndex: number;
  31315. /** vertex index start */
  31316. verticesStart: number;
  31317. /** vertices count */
  31318. verticesCount: number;
  31319. /** index start */
  31320. indexStart: number;
  31321. /** indices count */
  31322. indexCount: number;
  31323. /** @hidden */
  31324. _materialDefines: Nullable<MaterialDefines>;
  31325. /** @hidden */
  31326. _materialEffect: Nullable<Effect>;
  31327. /** @hidden */
  31328. _effectOverride: Nullable<Effect>;
  31329. /**
  31330. * Gets material defines used by the effect associated to the sub mesh
  31331. */
  31332. get materialDefines(): Nullable<MaterialDefines>;
  31333. /**
  31334. * Sets material defines used by the effect associated to the sub mesh
  31335. */
  31336. set materialDefines(defines: Nullable<MaterialDefines>);
  31337. /**
  31338. * Gets associated effect
  31339. */
  31340. get effect(): Nullable<Effect>;
  31341. /**
  31342. * Sets associated effect (effect used to render this submesh)
  31343. * @param effect defines the effect to associate with
  31344. * @param defines defines the set of defines used to compile this effect
  31345. */
  31346. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31347. /** @hidden */
  31348. _linesIndexCount: number;
  31349. private _mesh;
  31350. private _renderingMesh;
  31351. private _boundingInfo;
  31352. private _linesIndexBuffer;
  31353. /** @hidden */
  31354. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31355. /** @hidden */
  31356. _trianglePlanes: Plane[];
  31357. /** @hidden */
  31358. _lastColliderTransformMatrix: Nullable<Matrix>;
  31359. /** @hidden */
  31360. _renderId: number;
  31361. /** @hidden */
  31362. _alphaIndex: number;
  31363. /** @hidden */
  31364. _distanceToCamera: number;
  31365. /** @hidden */
  31366. _id: number;
  31367. private _currentMaterial;
  31368. /**
  31369. * Add a new submesh to a mesh
  31370. * @param materialIndex defines the material index to use
  31371. * @param verticesStart defines vertex index start
  31372. * @param verticesCount defines vertices count
  31373. * @param indexStart defines index start
  31374. * @param indexCount defines indices count
  31375. * @param mesh defines the parent mesh
  31376. * @param renderingMesh defines an optional rendering mesh
  31377. * @param createBoundingBox defines if bounding box should be created for this submesh
  31378. * @returns the new submesh
  31379. */
  31380. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31381. /**
  31382. * Creates a new submesh
  31383. * @param materialIndex defines the material index to use
  31384. * @param verticesStart defines vertex index start
  31385. * @param verticesCount defines vertices count
  31386. * @param indexStart defines index start
  31387. * @param indexCount defines indices count
  31388. * @param mesh defines the parent mesh
  31389. * @param renderingMesh defines an optional rendering mesh
  31390. * @param createBoundingBox defines if bounding box should be created for this submesh
  31391. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31392. */
  31393. constructor(
  31394. /** the material index to use */
  31395. materialIndex: number,
  31396. /** vertex index start */
  31397. verticesStart: number,
  31398. /** vertices count */
  31399. verticesCount: number,
  31400. /** index start */
  31401. indexStart: number,
  31402. /** indices count */
  31403. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31404. /**
  31405. * Returns true if this submesh covers the entire parent mesh
  31406. * @ignorenaming
  31407. */
  31408. get IsGlobal(): boolean;
  31409. /**
  31410. * Returns the submesh BoudingInfo object
  31411. * @returns current bounding info (or mesh's one if the submesh is global)
  31412. */
  31413. getBoundingInfo(): BoundingInfo;
  31414. /**
  31415. * Sets the submesh BoundingInfo
  31416. * @param boundingInfo defines the new bounding info to use
  31417. * @returns the SubMesh
  31418. */
  31419. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31420. /**
  31421. * Returns the mesh of the current submesh
  31422. * @return the parent mesh
  31423. */
  31424. getMesh(): AbstractMesh;
  31425. /**
  31426. * Returns the rendering mesh of the submesh
  31427. * @returns the rendering mesh (could be different from parent mesh)
  31428. */
  31429. getRenderingMesh(): Mesh;
  31430. /**
  31431. * Returns the replacement mesh of the submesh
  31432. * @returns the replacement mesh (could be different from parent mesh)
  31433. */
  31434. getReplacementMesh(): Nullable<AbstractMesh>;
  31435. /**
  31436. * Returns the effective mesh of the submesh
  31437. * @returns the effective mesh (could be different from parent mesh)
  31438. */
  31439. getEffectiveMesh(): AbstractMesh;
  31440. /**
  31441. * Returns the submesh material
  31442. * @returns null or the current material
  31443. */
  31444. getMaterial(): Nullable<Material>;
  31445. private _IsMultiMaterial;
  31446. /**
  31447. * Sets a new updated BoundingInfo object to the submesh
  31448. * @param data defines an optional position array to use to determine the bounding info
  31449. * @returns the SubMesh
  31450. */
  31451. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31452. /** @hidden */
  31453. _checkCollision(collider: Collider): boolean;
  31454. /**
  31455. * Updates the submesh BoundingInfo
  31456. * @param world defines the world matrix to use to update the bounding info
  31457. * @returns the submesh
  31458. */
  31459. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31460. /**
  31461. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31462. * @param frustumPlanes defines the frustum planes
  31463. * @returns true if the submesh is intersecting with the frustum
  31464. */
  31465. isInFrustum(frustumPlanes: Plane[]): boolean;
  31466. /**
  31467. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31468. * @param frustumPlanes defines the frustum planes
  31469. * @returns true if the submesh is inside the frustum
  31470. */
  31471. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31472. /**
  31473. * Renders the submesh
  31474. * @param enableAlphaMode defines if alpha needs to be used
  31475. * @returns the submesh
  31476. */
  31477. render(enableAlphaMode: boolean): SubMesh;
  31478. /**
  31479. * @hidden
  31480. */
  31481. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31482. /**
  31483. * Checks if the submesh intersects with a ray
  31484. * @param ray defines the ray to test
  31485. * @returns true is the passed ray intersects the submesh bounding box
  31486. */
  31487. canIntersects(ray: Ray): boolean;
  31488. /**
  31489. * Intersects current submesh with a ray
  31490. * @param ray defines the ray to test
  31491. * @param positions defines mesh's positions array
  31492. * @param indices defines mesh's indices array
  31493. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31494. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31495. * @returns intersection info or null if no intersection
  31496. */
  31497. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31498. /** @hidden */
  31499. private _intersectLines;
  31500. /** @hidden */
  31501. private _intersectUnIndexedLines;
  31502. /** @hidden */
  31503. private _intersectTriangles;
  31504. /** @hidden */
  31505. private _intersectUnIndexedTriangles;
  31506. /** @hidden */
  31507. _rebuild(): void;
  31508. /**
  31509. * Creates a new submesh from the passed mesh
  31510. * @param newMesh defines the new hosting mesh
  31511. * @param newRenderingMesh defines an optional rendering mesh
  31512. * @returns the new submesh
  31513. */
  31514. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31515. /**
  31516. * Release associated resources
  31517. */
  31518. dispose(): void;
  31519. /**
  31520. * Gets the class name
  31521. * @returns the string "SubMesh".
  31522. */
  31523. getClassName(): string;
  31524. /**
  31525. * Creates a new submesh from indices data
  31526. * @param materialIndex the index of the main mesh material
  31527. * @param startIndex the index where to start the copy in the mesh indices array
  31528. * @param indexCount the number of indices to copy then from the startIndex
  31529. * @param mesh the main mesh to create the submesh from
  31530. * @param renderingMesh the optional rendering mesh
  31531. * @returns a new submesh
  31532. */
  31533. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31534. }
  31535. }
  31536. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31537. /**
  31538. * Class used to represent data loading progression
  31539. */
  31540. export class SceneLoaderFlags {
  31541. private static _ForceFullSceneLoadingForIncremental;
  31542. private static _ShowLoadingScreen;
  31543. private static _CleanBoneMatrixWeights;
  31544. private static _loggingLevel;
  31545. /**
  31546. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31547. */
  31548. static get ForceFullSceneLoadingForIncremental(): boolean;
  31549. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31550. /**
  31551. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31552. */
  31553. static get ShowLoadingScreen(): boolean;
  31554. static set ShowLoadingScreen(value: boolean);
  31555. /**
  31556. * Defines the current logging level (while loading the scene)
  31557. * @ignorenaming
  31558. */
  31559. static get loggingLevel(): number;
  31560. static set loggingLevel(value: number);
  31561. /**
  31562. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31563. */
  31564. static get CleanBoneMatrixWeights(): boolean;
  31565. static set CleanBoneMatrixWeights(value: boolean);
  31566. }
  31567. }
  31568. declare module "babylonjs/Meshes/geometry" {
  31569. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31570. import { Scene } from "babylonjs/scene";
  31571. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31572. import { Engine } from "babylonjs/Engines/engine";
  31573. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31574. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31575. import { Effect } from "babylonjs/Materials/effect";
  31576. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31577. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31578. import { Mesh } from "babylonjs/Meshes/mesh";
  31579. /**
  31580. * Class used to store geometry data (vertex buffers + index buffer)
  31581. */
  31582. export class Geometry implements IGetSetVerticesData {
  31583. /**
  31584. * Gets or sets the ID of the geometry
  31585. */
  31586. id: string;
  31587. /**
  31588. * Gets or sets the unique ID of the geometry
  31589. */
  31590. uniqueId: number;
  31591. /**
  31592. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31593. */
  31594. delayLoadState: number;
  31595. /**
  31596. * Gets the file containing the data to load when running in delay load state
  31597. */
  31598. delayLoadingFile: Nullable<string>;
  31599. /**
  31600. * Callback called when the geometry is updated
  31601. */
  31602. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31603. private _scene;
  31604. private _engine;
  31605. private _meshes;
  31606. private _totalVertices;
  31607. /** @hidden */
  31608. _indices: IndicesArray;
  31609. /** @hidden */
  31610. _vertexBuffers: {
  31611. [key: string]: VertexBuffer;
  31612. };
  31613. private _isDisposed;
  31614. private _extend;
  31615. private _boundingBias;
  31616. /** @hidden */
  31617. _delayInfo: Array<string>;
  31618. private _indexBuffer;
  31619. private _indexBufferIsUpdatable;
  31620. /** @hidden */
  31621. _boundingInfo: Nullable<BoundingInfo>;
  31622. /** @hidden */
  31623. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31624. /** @hidden */
  31625. _softwareSkinningFrameId: number;
  31626. private _vertexArrayObjects;
  31627. private _updatable;
  31628. /** @hidden */
  31629. _positions: Nullable<Vector3[]>;
  31630. private _positionsCache;
  31631. /**
  31632. * 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
  31633. */
  31634. get boundingBias(): Vector2;
  31635. /**
  31636. * 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
  31637. */
  31638. set boundingBias(value: Vector2);
  31639. /**
  31640. * Static function used to attach a new empty geometry to a mesh
  31641. * @param mesh defines the mesh to attach the geometry to
  31642. * @returns the new Geometry
  31643. */
  31644. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31645. /** Get the list of meshes using this geometry */
  31646. get meshes(): Mesh[];
  31647. /**
  31648. * 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
  31649. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31650. */
  31651. useBoundingInfoFromGeometry: boolean;
  31652. /**
  31653. * Creates a new geometry
  31654. * @param id defines the unique ID
  31655. * @param scene defines the hosting scene
  31656. * @param vertexData defines the VertexData used to get geometry data
  31657. * @param updatable defines if geometry must be updatable (false by default)
  31658. * @param mesh defines the mesh that will be associated with the geometry
  31659. */
  31660. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31661. /**
  31662. * Gets the current extend of the geometry
  31663. */
  31664. get extend(): {
  31665. minimum: Vector3;
  31666. maximum: Vector3;
  31667. };
  31668. /**
  31669. * Gets the hosting scene
  31670. * @returns the hosting Scene
  31671. */
  31672. getScene(): Scene;
  31673. /**
  31674. * Gets the hosting engine
  31675. * @returns the hosting Engine
  31676. */
  31677. getEngine(): Engine;
  31678. /**
  31679. * Defines if the geometry is ready to use
  31680. * @returns true if the geometry is ready to be used
  31681. */
  31682. isReady(): boolean;
  31683. /**
  31684. * Gets a value indicating that the geometry should not be serialized
  31685. */
  31686. get doNotSerialize(): boolean;
  31687. /** @hidden */
  31688. _rebuild(): void;
  31689. /**
  31690. * Affects all geometry data in one call
  31691. * @param vertexData defines the geometry data
  31692. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31693. */
  31694. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31695. /**
  31696. * Set specific vertex data
  31697. * @param kind defines the data kind (Position, normal, etc...)
  31698. * @param data defines the vertex data to use
  31699. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31700. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31701. */
  31702. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31703. /**
  31704. * Removes a specific vertex data
  31705. * @param kind defines the data kind (Position, normal, etc...)
  31706. */
  31707. removeVerticesData(kind: string): void;
  31708. /**
  31709. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31710. * @param buffer defines the vertex buffer to use
  31711. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31712. */
  31713. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31714. /**
  31715. * Update a specific vertex buffer
  31716. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31717. * It will do nothing if the buffer is not updatable
  31718. * @param kind defines the data kind (Position, normal, etc...)
  31719. * @param data defines the data to use
  31720. * @param offset defines the offset in the target buffer where to store the data
  31721. * @param useBytes set to true if the offset is in bytes
  31722. */
  31723. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31724. /**
  31725. * Update a specific vertex buffer
  31726. * This function will create a new buffer if the current one is not updatable
  31727. * @param kind defines the data kind (Position, normal, etc...)
  31728. * @param data defines the data to use
  31729. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31730. */
  31731. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31732. private _updateBoundingInfo;
  31733. /** @hidden */
  31734. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31735. /**
  31736. * Gets total number of vertices
  31737. * @returns the total number of vertices
  31738. */
  31739. getTotalVertices(): number;
  31740. /**
  31741. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31742. * @param kind defines the data kind (Position, normal, etc...)
  31743. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31744. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31745. * @returns a float array containing vertex data
  31746. */
  31747. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31748. /**
  31749. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31750. * @param kind defines the data kind (Position, normal, etc...)
  31751. * @returns true if the vertex buffer with the specified kind is updatable
  31752. */
  31753. isVertexBufferUpdatable(kind: string): boolean;
  31754. /**
  31755. * Gets a specific vertex buffer
  31756. * @param kind defines the data kind (Position, normal, etc...)
  31757. * @returns a VertexBuffer
  31758. */
  31759. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31760. /**
  31761. * Returns all vertex buffers
  31762. * @return an object holding all vertex buffers indexed by kind
  31763. */
  31764. getVertexBuffers(): Nullable<{
  31765. [key: string]: VertexBuffer;
  31766. }>;
  31767. /**
  31768. * Gets a boolean indicating if specific vertex buffer is present
  31769. * @param kind defines the data kind (Position, normal, etc...)
  31770. * @returns true if data is present
  31771. */
  31772. isVerticesDataPresent(kind: string): boolean;
  31773. /**
  31774. * Gets a list of all attached data kinds (Position, normal, etc...)
  31775. * @returns a list of string containing all kinds
  31776. */
  31777. getVerticesDataKinds(): string[];
  31778. /**
  31779. * Update index buffer
  31780. * @param indices defines the indices to store in the index buffer
  31781. * @param offset defines the offset in the target buffer where to store the data
  31782. * @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)
  31783. */
  31784. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31785. /**
  31786. * Creates a new index buffer
  31787. * @param indices defines the indices to store in the index buffer
  31788. * @param totalVertices defines the total number of vertices (could be null)
  31789. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31790. */
  31791. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31792. /**
  31793. * Return the total number of indices
  31794. * @returns the total number of indices
  31795. */
  31796. getTotalIndices(): number;
  31797. /**
  31798. * Gets the index buffer array
  31799. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31800. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31801. * @returns the index buffer array
  31802. */
  31803. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31804. /**
  31805. * Gets the index buffer
  31806. * @return the index buffer
  31807. */
  31808. getIndexBuffer(): Nullable<DataBuffer>;
  31809. /** @hidden */
  31810. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31811. /**
  31812. * Release the associated resources for a specific mesh
  31813. * @param mesh defines the source mesh
  31814. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31815. */
  31816. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31817. /**
  31818. * Apply current geometry to a given mesh
  31819. * @param mesh defines the mesh to apply geometry to
  31820. */
  31821. applyToMesh(mesh: Mesh): void;
  31822. private _updateExtend;
  31823. private _applyToMesh;
  31824. private notifyUpdate;
  31825. /**
  31826. * Load the geometry if it was flagged as delay loaded
  31827. * @param scene defines the hosting scene
  31828. * @param onLoaded defines a callback called when the geometry is loaded
  31829. */
  31830. load(scene: Scene, onLoaded?: () => void): void;
  31831. private _queueLoad;
  31832. /**
  31833. * Invert the geometry to move from a right handed system to a left handed one.
  31834. */
  31835. toLeftHanded(): void;
  31836. /** @hidden */
  31837. _resetPointsArrayCache(): void;
  31838. /** @hidden */
  31839. _generatePointsArray(): boolean;
  31840. /**
  31841. * Gets a value indicating if the geometry is disposed
  31842. * @returns true if the geometry was disposed
  31843. */
  31844. isDisposed(): boolean;
  31845. private _disposeVertexArrayObjects;
  31846. /**
  31847. * Free all associated resources
  31848. */
  31849. dispose(): void;
  31850. /**
  31851. * Clone the current geometry into a new geometry
  31852. * @param id defines the unique ID of the new geometry
  31853. * @returns a new geometry object
  31854. */
  31855. copy(id: string): Geometry;
  31856. /**
  31857. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31858. * @return a JSON representation of the current geometry data (without the vertices data)
  31859. */
  31860. serialize(): any;
  31861. private toNumberArray;
  31862. /**
  31863. * Serialize all vertices data into a JSON oject
  31864. * @returns a JSON representation of the current geometry data
  31865. */
  31866. serializeVerticeData(): any;
  31867. /**
  31868. * Extracts a clone of a mesh geometry
  31869. * @param mesh defines the source mesh
  31870. * @param id defines the unique ID of the new geometry object
  31871. * @returns the new geometry object
  31872. */
  31873. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31874. /**
  31875. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31876. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31877. * Be aware Math.random() could cause collisions, but:
  31878. * "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"
  31879. * @returns a string containing a new GUID
  31880. */
  31881. static RandomId(): string;
  31882. /** @hidden */
  31883. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31884. private static _CleanMatricesWeights;
  31885. /**
  31886. * Create a new geometry from persisted data (Using .babylon file format)
  31887. * @param parsedVertexData defines the persisted data
  31888. * @param scene defines the hosting scene
  31889. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31890. * @returns the new geometry object
  31891. */
  31892. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31893. }
  31894. }
  31895. declare module "babylonjs/Morph/morphTarget" {
  31896. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31897. import { Observable } from "babylonjs/Misc/observable";
  31898. import { Nullable, FloatArray } from "babylonjs/types";
  31899. import { Scene } from "babylonjs/scene";
  31900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31901. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31902. /**
  31903. * Defines a target to use with MorphTargetManager
  31904. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31905. */
  31906. export class MorphTarget implements IAnimatable {
  31907. /** defines the name of the target */
  31908. name: string;
  31909. /**
  31910. * Gets or sets the list of animations
  31911. */
  31912. animations: import("babylonjs/Animations/animation").Animation[];
  31913. private _scene;
  31914. private _positions;
  31915. private _normals;
  31916. private _tangents;
  31917. private _uvs;
  31918. private _influence;
  31919. private _uniqueId;
  31920. /**
  31921. * Observable raised when the influence changes
  31922. */
  31923. onInfluenceChanged: Observable<boolean>;
  31924. /** @hidden */
  31925. _onDataLayoutChanged: Observable<void>;
  31926. /**
  31927. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31928. */
  31929. get influence(): number;
  31930. set influence(influence: number);
  31931. /**
  31932. * Gets or sets the id of the morph Target
  31933. */
  31934. id: string;
  31935. private _animationPropertiesOverride;
  31936. /**
  31937. * Gets or sets the animation properties override
  31938. */
  31939. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31940. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31941. /**
  31942. * Creates a new MorphTarget
  31943. * @param name defines the name of the target
  31944. * @param influence defines the influence to use
  31945. * @param scene defines the scene the morphtarget belongs to
  31946. */
  31947. constructor(
  31948. /** defines the name of the target */
  31949. name: string, influence?: number, scene?: Nullable<Scene>);
  31950. /**
  31951. * Gets the unique ID of this manager
  31952. */
  31953. get uniqueId(): number;
  31954. /**
  31955. * Gets a boolean defining if the target contains position data
  31956. */
  31957. get hasPositions(): boolean;
  31958. /**
  31959. * Gets a boolean defining if the target contains normal data
  31960. */
  31961. get hasNormals(): boolean;
  31962. /**
  31963. * Gets a boolean defining if the target contains tangent data
  31964. */
  31965. get hasTangents(): boolean;
  31966. /**
  31967. * Gets a boolean defining if the target contains texture coordinates data
  31968. */
  31969. get hasUVs(): boolean;
  31970. /**
  31971. * Affects position data to this target
  31972. * @param data defines the position data to use
  31973. */
  31974. setPositions(data: Nullable<FloatArray>): void;
  31975. /**
  31976. * Gets the position data stored in this target
  31977. * @returns a FloatArray containing the position data (or null if not present)
  31978. */
  31979. getPositions(): Nullable<FloatArray>;
  31980. /**
  31981. * Affects normal data to this target
  31982. * @param data defines the normal data to use
  31983. */
  31984. setNormals(data: Nullable<FloatArray>): void;
  31985. /**
  31986. * Gets the normal data stored in this target
  31987. * @returns a FloatArray containing the normal data (or null if not present)
  31988. */
  31989. getNormals(): Nullable<FloatArray>;
  31990. /**
  31991. * Affects tangent data to this target
  31992. * @param data defines the tangent data to use
  31993. */
  31994. setTangents(data: Nullable<FloatArray>): void;
  31995. /**
  31996. * Gets the tangent data stored in this target
  31997. * @returns a FloatArray containing the tangent data (or null if not present)
  31998. */
  31999. getTangents(): Nullable<FloatArray>;
  32000. /**
  32001. * Affects texture coordinates data to this target
  32002. * @param data defines the texture coordinates data to use
  32003. */
  32004. setUVs(data: Nullable<FloatArray>): void;
  32005. /**
  32006. * Gets the texture coordinates data stored in this target
  32007. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32008. */
  32009. getUVs(): Nullable<FloatArray>;
  32010. /**
  32011. * Clone the current target
  32012. * @returns a new MorphTarget
  32013. */
  32014. clone(): MorphTarget;
  32015. /**
  32016. * Serializes the current target into a Serialization object
  32017. * @returns the serialized object
  32018. */
  32019. serialize(): any;
  32020. /**
  32021. * Returns the string "MorphTarget"
  32022. * @returns "MorphTarget"
  32023. */
  32024. getClassName(): string;
  32025. /**
  32026. * Creates a new target from serialized data
  32027. * @param serializationObject defines the serialized data to use
  32028. * @returns a new MorphTarget
  32029. */
  32030. static Parse(serializationObject: any): MorphTarget;
  32031. /**
  32032. * Creates a MorphTarget from mesh data
  32033. * @param mesh defines the source mesh
  32034. * @param name defines the name to use for the new target
  32035. * @param influence defines the influence to attach to the target
  32036. * @returns a new MorphTarget
  32037. */
  32038. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32039. }
  32040. }
  32041. declare module "babylonjs/Morph/morphTargetManager" {
  32042. import { Nullable } from "babylonjs/types";
  32043. import { Scene } from "babylonjs/scene";
  32044. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32045. /**
  32046. * This class is used to deform meshes using morphing between different targets
  32047. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32048. */
  32049. export class MorphTargetManager {
  32050. private _targets;
  32051. private _targetInfluenceChangedObservers;
  32052. private _targetDataLayoutChangedObservers;
  32053. private _activeTargets;
  32054. private _scene;
  32055. private _influences;
  32056. private _supportsNormals;
  32057. private _supportsTangents;
  32058. private _supportsUVs;
  32059. private _vertexCount;
  32060. private _uniqueId;
  32061. private _tempInfluences;
  32062. /**
  32063. * Gets or sets a boolean indicating if normals must be morphed
  32064. */
  32065. enableNormalMorphing: boolean;
  32066. /**
  32067. * Gets or sets a boolean indicating if tangents must be morphed
  32068. */
  32069. enableTangentMorphing: boolean;
  32070. /**
  32071. * Gets or sets a boolean indicating if UV must be morphed
  32072. */
  32073. enableUVMorphing: boolean;
  32074. /**
  32075. * Creates a new MorphTargetManager
  32076. * @param scene defines the current scene
  32077. */
  32078. constructor(scene?: Nullable<Scene>);
  32079. /**
  32080. * Gets the unique ID of this manager
  32081. */
  32082. get uniqueId(): number;
  32083. /**
  32084. * Gets the number of vertices handled by this manager
  32085. */
  32086. get vertexCount(): number;
  32087. /**
  32088. * Gets a boolean indicating if this manager supports morphing of normals
  32089. */
  32090. get supportsNormals(): boolean;
  32091. /**
  32092. * Gets a boolean indicating if this manager supports morphing of tangents
  32093. */
  32094. get supportsTangents(): boolean;
  32095. /**
  32096. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32097. */
  32098. get supportsUVs(): boolean;
  32099. /**
  32100. * Gets the number of targets stored in this manager
  32101. */
  32102. get numTargets(): number;
  32103. /**
  32104. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32105. */
  32106. get numInfluencers(): number;
  32107. /**
  32108. * Gets the list of influences (one per target)
  32109. */
  32110. get influences(): Float32Array;
  32111. /**
  32112. * Gets the active target at specified index. An active target is a target with an influence > 0
  32113. * @param index defines the index to check
  32114. * @returns the requested target
  32115. */
  32116. getActiveTarget(index: number): MorphTarget;
  32117. /**
  32118. * Gets the target at specified index
  32119. * @param index defines the index to check
  32120. * @returns the requested target
  32121. */
  32122. getTarget(index: number): MorphTarget;
  32123. /**
  32124. * Add a new target to this manager
  32125. * @param target defines the target to add
  32126. */
  32127. addTarget(target: MorphTarget): void;
  32128. /**
  32129. * Removes a target from the manager
  32130. * @param target defines the target to remove
  32131. */
  32132. removeTarget(target: MorphTarget): void;
  32133. /**
  32134. * Clone the current manager
  32135. * @returns a new MorphTargetManager
  32136. */
  32137. clone(): MorphTargetManager;
  32138. /**
  32139. * Serializes the current manager into a Serialization object
  32140. * @returns the serialized object
  32141. */
  32142. serialize(): any;
  32143. private _syncActiveTargets;
  32144. /**
  32145. * Syncrhonize the targets with all the meshes using this morph target manager
  32146. */
  32147. synchronize(): void;
  32148. /**
  32149. * Creates a new MorphTargetManager from serialized data
  32150. * @param serializationObject defines the serialized data
  32151. * @param scene defines the hosting scene
  32152. * @returns the new MorphTargetManager
  32153. */
  32154. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32155. }
  32156. }
  32157. declare module "babylonjs/Meshes/meshLODLevel" {
  32158. import { Mesh } from "babylonjs/Meshes/mesh";
  32159. import { Nullable } from "babylonjs/types";
  32160. /**
  32161. * Class used to represent a specific level of detail of a mesh
  32162. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32163. */
  32164. export class MeshLODLevel {
  32165. /** Defines the distance where this level should start being displayed */
  32166. distance: number;
  32167. /** Defines the mesh to use to render this level */
  32168. mesh: Nullable<Mesh>;
  32169. /**
  32170. * Creates a new LOD level
  32171. * @param distance defines the distance where this level should star being displayed
  32172. * @param mesh defines the mesh to use to render this level
  32173. */
  32174. constructor(
  32175. /** Defines the distance where this level should start being displayed */
  32176. distance: number,
  32177. /** Defines the mesh to use to render this level */
  32178. mesh: Nullable<Mesh>);
  32179. }
  32180. }
  32181. declare module "babylonjs/Misc/canvasGenerator" {
  32182. /**
  32183. * Helper class used to generate a canvas to manipulate images
  32184. */
  32185. export class CanvasGenerator {
  32186. /**
  32187. * Create a new canvas (or offscreen canvas depending on the context)
  32188. * @param width defines the expected width
  32189. * @param height defines the expected height
  32190. * @return a new canvas or offscreen canvas
  32191. */
  32192. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32193. }
  32194. }
  32195. declare module "babylonjs/Meshes/groundMesh" {
  32196. import { Scene } from "babylonjs/scene";
  32197. import { Vector3 } from "babylonjs/Maths/math.vector";
  32198. import { Mesh } from "babylonjs/Meshes/mesh";
  32199. /**
  32200. * Mesh representing the gorund
  32201. */
  32202. export class GroundMesh extends Mesh {
  32203. /** If octree should be generated */
  32204. generateOctree: boolean;
  32205. private _heightQuads;
  32206. /** @hidden */
  32207. _subdivisionsX: number;
  32208. /** @hidden */
  32209. _subdivisionsY: number;
  32210. /** @hidden */
  32211. _width: number;
  32212. /** @hidden */
  32213. _height: number;
  32214. /** @hidden */
  32215. _minX: number;
  32216. /** @hidden */
  32217. _maxX: number;
  32218. /** @hidden */
  32219. _minZ: number;
  32220. /** @hidden */
  32221. _maxZ: number;
  32222. constructor(name: string, scene: Scene);
  32223. /**
  32224. * "GroundMesh"
  32225. * @returns "GroundMesh"
  32226. */
  32227. getClassName(): string;
  32228. /**
  32229. * The minimum of x and y subdivisions
  32230. */
  32231. get subdivisions(): number;
  32232. /**
  32233. * X subdivisions
  32234. */
  32235. get subdivisionsX(): number;
  32236. /**
  32237. * Y subdivisions
  32238. */
  32239. get subdivisionsY(): number;
  32240. /**
  32241. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32242. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32243. * @param chunksCount the number of subdivisions for x and y
  32244. * @param octreeBlocksSize (Default: 32)
  32245. */
  32246. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32247. /**
  32248. * Returns a height (y) value in the Worl system :
  32249. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32250. * @param x x coordinate
  32251. * @param z z coordinate
  32252. * @returns the ground y position if (x, z) are outside the ground surface.
  32253. */
  32254. getHeightAtCoordinates(x: number, z: number): number;
  32255. /**
  32256. * Returns a normalized vector (Vector3) orthogonal to the ground
  32257. * at the ground coordinates (x, z) expressed in the World system.
  32258. * @param x x coordinate
  32259. * @param z z coordinate
  32260. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32261. */
  32262. getNormalAtCoordinates(x: number, z: number): Vector3;
  32263. /**
  32264. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32265. * at the ground coordinates (x, z) expressed in the World system.
  32266. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32267. * @param x x coordinate
  32268. * @param z z coordinate
  32269. * @param ref vector to store the result
  32270. * @returns the GroundMesh.
  32271. */
  32272. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32273. /**
  32274. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32275. * if the ground has been updated.
  32276. * This can be used in the render loop.
  32277. * @returns the GroundMesh.
  32278. */
  32279. updateCoordinateHeights(): GroundMesh;
  32280. private _getFacetAt;
  32281. private _initHeightQuads;
  32282. private _computeHeightQuads;
  32283. /**
  32284. * Serializes this ground mesh
  32285. * @param serializationObject object to write serialization to
  32286. */
  32287. serialize(serializationObject: any): void;
  32288. /**
  32289. * Parses a serialized ground mesh
  32290. * @param parsedMesh the serialized mesh
  32291. * @param scene the scene to create the ground mesh in
  32292. * @returns the created ground mesh
  32293. */
  32294. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32295. }
  32296. }
  32297. declare module "babylonjs/Physics/physicsJoint" {
  32298. import { Vector3 } from "babylonjs/Maths/math.vector";
  32299. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32300. /**
  32301. * Interface for Physics-Joint data
  32302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32303. */
  32304. export interface PhysicsJointData {
  32305. /**
  32306. * The main pivot of the joint
  32307. */
  32308. mainPivot?: Vector3;
  32309. /**
  32310. * The connected pivot of the joint
  32311. */
  32312. connectedPivot?: Vector3;
  32313. /**
  32314. * The main axis of the joint
  32315. */
  32316. mainAxis?: Vector3;
  32317. /**
  32318. * The connected axis of the joint
  32319. */
  32320. connectedAxis?: Vector3;
  32321. /**
  32322. * The collision of the joint
  32323. */
  32324. collision?: boolean;
  32325. /**
  32326. * Native Oimo/Cannon/Energy data
  32327. */
  32328. nativeParams?: any;
  32329. }
  32330. /**
  32331. * This is a holder class for the physics joint created by the physics plugin
  32332. * It holds a set of functions to control the underlying joint
  32333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32334. */
  32335. export class PhysicsJoint {
  32336. /**
  32337. * The type of the physics joint
  32338. */
  32339. type: number;
  32340. /**
  32341. * The data for the physics joint
  32342. */
  32343. jointData: PhysicsJointData;
  32344. private _physicsJoint;
  32345. protected _physicsPlugin: IPhysicsEnginePlugin;
  32346. /**
  32347. * Initializes the physics joint
  32348. * @param type The type of the physics joint
  32349. * @param jointData The data for the physics joint
  32350. */
  32351. constructor(
  32352. /**
  32353. * The type of the physics joint
  32354. */
  32355. type: number,
  32356. /**
  32357. * The data for the physics joint
  32358. */
  32359. jointData: PhysicsJointData);
  32360. /**
  32361. * Gets the physics joint
  32362. */
  32363. get physicsJoint(): any;
  32364. /**
  32365. * Sets the physics joint
  32366. */
  32367. set physicsJoint(newJoint: any);
  32368. /**
  32369. * Sets the physics plugin
  32370. */
  32371. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32372. /**
  32373. * Execute a function that is physics-plugin specific.
  32374. * @param {Function} func the function that will be executed.
  32375. * It accepts two parameters: the physics world and the physics joint
  32376. */
  32377. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32378. /**
  32379. * Distance-Joint type
  32380. */
  32381. static DistanceJoint: number;
  32382. /**
  32383. * Hinge-Joint type
  32384. */
  32385. static HingeJoint: number;
  32386. /**
  32387. * Ball-and-Socket joint type
  32388. */
  32389. static BallAndSocketJoint: number;
  32390. /**
  32391. * Wheel-Joint type
  32392. */
  32393. static WheelJoint: number;
  32394. /**
  32395. * Slider-Joint type
  32396. */
  32397. static SliderJoint: number;
  32398. /**
  32399. * Prismatic-Joint type
  32400. */
  32401. static PrismaticJoint: number;
  32402. /**
  32403. * Universal-Joint type
  32404. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32405. */
  32406. static UniversalJoint: number;
  32407. /**
  32408. * Hinge-Joint 2 type
  32409. */
  32410. static Hinge2Joint: number;
  32411. /**
  32412. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32413. */
  32414. static PointToPointJoint: number;
  32415. /**
  32416. * Spring-Joint type
  32417. */
  32418. static SpringJoint: number;
  32419. /**
  32420. * Lock-Joint type
  32421. */
  32422. static LockJoint: number;
  32423. }
  32424. /**
  32425. * A class representing a physics distance joint
  32426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32427. */
  32428. export class DistanceJoint extends PhysicsJoint {
  32429. /**
  32430. *
  32431. * @param jointData The data for the Distance-Joint
  32432. */
  32433. constructor(jointData: DistanceJointData);
  32434. /**
  32435. * Update the predefined distance.
  32436. * @param maxDistance The maximum preferred distance
  32437. * @param minDistance The minimum preferred distance
  32438. */
  32439. updateDistance(maxDistance: number, minDistance?: number): void;
  32440. }
  32441. /**
  32442. * Represents a Motor-Enabled Joint
  32443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32444. */
  32445. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32446. /**
  32447. * Initializes the Motor-Enabled Joint
  32448. * @param type The type of the joint
  32449. * @param jointData The physica joint data for the joint
  32450. */
  32451. constructor(type: number, jointData: PhysicsJointData);
  32452. /**
  32453. * Set the motor values.
  32454. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32455. * @param force the force to apply
  32456. * @param maxForce max force for this motor.
  32457. */
  32458. setMotor(force?: number, maxForce?: number): void;
  32459. /**
  32460. * Set the motor's limits.
  32461. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32462. * @param upperLimit The upper limit of the motor
  32463. * @param lowerLimit The lower limit of the motor
  32464. */
  32465. setLimit(upperLimit: number, lowerLimit?: number): void;
  32466. }
  32467. /**
  32468. * This class represents a single physics Hinge-Joint
  32469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32470. */
  32471. export class HingeJoint extends MotorEnabledJoint {
  32472. /**
  32473. * Initializes the Hinge-Joint
  32474. * @param jointData The joint data for the Hinge-Joint
  32475. */
  32476. constructor(jointData: PhysicsJointData);
  32477. /**
  32478. * Set the motor values.
  32479. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32480. * @param {number} force the force to apply
  32481. * @param {number} maxForce max force for this motor.
  32482. */
  32483. setMotor(force?: number, maxForce?: number): void;
  32484. /**
  32485. * Set the motor's limits.
  32486. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32487. * @param upperLimit The upper limit of the motor
  32488. * @param lowerLimit The lower limit of the motor
  32489. */
  32490. setLimit(upperLimit: number, lowerLimit?: number): void;
  32491. }
  32492. /**
  32493. * This class represents a dual hinge physics joint (same as wheel joint)
  32494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32495. */
  32496. export class Hinge2Joint extends MotorEnabledJoint {
  32497. /**
  32498. * Initializes the Hinge2-Joint
  32499. * @param jointData The joint data for the Hinge2-Joint
  32500. */
  32501. constructor(jointData: PhysicsJointData);
  32502. /**
  32503. * Set the motor values.
  32504. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32505. * @param {number} targetSpeed the speed the motor is to reach
  32506. * @param {number} maxForce max force for this motor.
  32507. * @param {motorIndex} the motor's index, 0 or 1.
  32508. */
  32509. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32510. /**
  32511. * Set the motor limits.
  32512. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32513. * @param {number} upperLimit the upper limit
  32514. * @param {number} lowerLimit lower limit
  32515. * @param {motorIndex} the motor's index, 0 or 1.
  32516. */
  32517. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32518. }
  32519. /**
  32520. * Interface for a motor enabled joint
  32521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32522. */
  32523. export interface IMotorEnabledJoint {
  32524. /**
  32525. * Physics joint
  32526. */
  32527. physicsJoint: any;
  32528. /**
  32529. * Sets the motor of the motor-enabled joint
  32530. * @param force The force of the motor
  32531. * @param maxForce The maximum force of the motor
  32532. * @param motorIndex The index of the motor
  32533. */
  32534. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32535. /**
  32536. * Sets the limit of the motor
  32537. * @param upperLimit The upper limit of the motor
  32538. * @param lowerLimit The lower limit of the motor
  32539. * @param motorIndex The index of the motor
  32540. */
  32541. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32542. }
  32543. /**
  32544. * Joint data for a Distance-Joint
  32545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32546. */
  32547. export interface DistanceJointData extends PhysicsJointData {
  32548. /**
  32549. * Max distance the 2 joint objects can be apart
  32550. */
  32551. maxDistance: number;
  32552. }
  32553. /**
  32554. * Joint data from a spring joint
  32555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32556. */
  32557. export interface SpringJointData extends PhysicsJointData {
  32558. /**
  32559. * Length of the spring
  32560. */
  32561. length: number;
  32562. /**
  32563. * Stiffness of the spring
  32564. */
  32565. stiffness: number;
  32566. /**
  32567. * Damping of the spring
  32568. */
  32569. damping: number;
  32570. /** this callback will be called when applying the force to the impostors. */
  32571. forceApplicationCallback: () => void;
  32572. }
  32573. }
  32574. declare module "babylonjs/Physics/physicsRaycastResult" {
  32575. import { Vector3 } from "babylonjs/Maths/math.vector";
  32576. /**
  32577. * Holds the data for the raycast result
  32578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32579. */
  32580. export class PhysicsRaycastResult {
  32581. private _hasHit;
  32582. private _hitDistance;
  32583. private _hitNormalWorld;
  32584. private _hitPointWorld;
  32585. private _rayFromWorld;
  32586. private _rayToWorld;
  32587. /**
  32588. * Gets if there was a hit
  32589. */
  32590. get hasHit(): boolean;
  32591. /**
  32592. * Gets the distance from the hit
  32593. */
  32594. get hitDistance(): number;
  32595. /**
  32596. * Gets the hit normal/direction in the world
  32597. */
  32598. get hitNormalWorld(): Vector3;
  32599. /**
  32600. * Gets the hit point in the world
  32601. */
  32602. get hitPointWorld(): Vector3;
  32603. /**
  32604. * Gets the ray "start point" of the ray in the world
  32605. */
  32606. get rayFromWorld(): Vector3;
  32607. /**
  32608. * Gets the ray "end point" of the ray in the world
  32609. */
  32610. get rayToWorld(): Vector3;
  32611. /**
  32612. * Sets the hit data (normal & point in world space)
  32613. * @param hitNormalWorld defines the normal in world space
  32614. * @param hitPointWorld defines the point in world space
  32615. */
  32616. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32617. /**
  32618. * Sets the distance from the start point to the hit point
  32619. * @param distance
  32620. */
  32621. setHitDistance(distance: number): void;
  32622. /**
  32623. * Calculates the distance manually
  32624. */
  32625. calculateHitDistance(): void;
  32626. /**
  32627. * Resets all the values to default
  32628. * @param from The from point on world space
  32629. * @param to The to point on world space
  32630. */
  32631. reset(from?: Vector3, to?: Vector3): void;
  32632. }
  32633. /**
  32634. * Interface for the size containing width and height
  32635. */
  32636. interface IXYZ {
  32637. /**
  32638. * X
  32639. */
  32640. x: number;
  32641. /**
  32642. * Y
  32643. */
  32644. y: number;
  32645. /**
  32646. * Z
  32647. */
  32648. z: number;
  32649. }
  32650. }
  32651. declare module "babylonjs/Physics/IPhysicsEngine" {
  32652. import { Nullable } from "babylonjs/types";
  32653. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32655. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32656. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32657. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32658. /**
  32659. * Interface used to describe a physics joint
  32660. */
  32661. export interface PhysicsImpostorJoint {
  32662. /** Defines the main impostor to which the joint is linked */
  32663. mainImpostor: PhysicsImpostor;
  32664. /** Defines the impostor that is connected to the main impostor using this joint */
  32665. connectedImpostor: PhysicsImpostor;
  32666. /** Defines the joint itself */
  32667. joint: PhysicsJoint;
  32668. }
  32669. /** @hidden */
  32670. export interface IPhysicsEnginePlugin {
  32671. world: any;
  32672. name: string;
  32673. setGravity(gravity: Vector3): void;
  32674. setTimeStep(timeStep: number): void;
  32675. getTimeStep(): number;
  32676. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32677. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32678. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32679. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32680. removePhysicsBody(impostor: PhysicsImpostor): void;
  32681. generateJoint(joint: PhysicsImpostorJoint): void;
  32682. removeJoint(joint: PhysicsImpostorJoint): void;
  32683. isSupported(): boolean;
  32684. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32685. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32686. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32687. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32688. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32689. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32690. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32691. getBodyMass(impostor: PhysicsImpostor): number;
  32692. getBodyFriction(impostor: PhysicsImpostor): number;
  32693. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32694. getBodyRestitution(impostor: PhysicsImpostor): number;
  32695. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32696. getBodyPressure?(impostor: PhysicsImpostor): number;
  32697. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32698. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32699. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32700. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32701. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32702. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32703. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32704. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32705. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32706. sleepBody(impostor: PhysicsImpostor): void;
  32707. wakeUpBody(impostor: PhysicsImpostor): void;
  32708. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32709. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32710. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32711. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32712. getRadius(impostor: PhysicsImpostor): number;
  32713. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32714. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32715. dispose(): void;
  32716. }
  32717. /**
  32718. * Interface used to define a physics engine
  32719. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32720. */
  32721. export interface IPhysicsEngine {
  32722. /**
  32723. * Gets the gravity vector used by the simulation
  32724. */
  32725. gravity: Vector3;
  32726. /**
  32727. * Sets the gravity vector used by the simulation
  32728. * @param gravity defines the gravity vector to use
  32729. */
  32730. setGravity(gravity: Vector3): void;
  32731. /**
  32732. * Set the time step of the physics engine.
  32733. * Default is 1/60.
  32734. * To slow it down, enter 1/600 for example.
  32735. * To speed it up, 1/30
  32736. * @param newTimeStep the new timestep to apply to this world.
  32737. */
  32738. setTimeStep(newTimeStep: number): void;
  32739. /**
  32740. * Get the time step of the physics engine.
  32741. * @returns the current time step
  32742. */
  32743. getTimeStep(): number;
  32744. /**
  32745. * Set the sub time step of the physics engine.
  32746. * Default is 0 meaning there is no sub steps
  32747. * To increase physics resolution precision, set a small value (like 1 ms)
  32748. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32749. */
  32750. setSubTimeStep(subTimeStep: number): void;
  32751. /**
  32752. * Get the sub time step of the physics engine.
  32753. * @returns the current sub time step
  32754. */
  32755. getSubTimeStep(): number;
  32756. /**
  32757. * Release all resources
  32758. */
  32759. dispose(): void;
  32760. /**
  32761. * Gets the name of the current physics plugin
  32762. * @returns the name of the plugin
  32763. */
  32764. getPhysicsPluginName(): string;
  32765. /**
  32766. * Adding a new impostor for the impostor tracking.
  32767. * This will be done by the impostor itself.
  32768. * @param impostor the impostor to add
  32769. */
  32770. addImpostor(impostor: PhysicsImpostor): void;
  32771. /**
  32772. * Remove an impostor from the engine.
  32773. * This impostor and its mesh will not longer be updated by the physics engine.
  32774. * @param impostor the impostor to remove
  32775. */
  32776. removeImpostor(impostor: PhysicsImpostor): void;
  32777. /**
  32778. * Add a joint to the physics engine
  32779. * @param mainImpostor defines the main impostor to which the joint is added.
  32780. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32781. * @param joint defines the joint that will connect both impostors.
  32782. */
  32783. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32784. /**
  32785. * Removes a joint from the simulation
  32786. * @param mainImpostor defines the impostor used with the joint
  32787. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32788. * @param joint defines the joint to remove
  32789. */
  32790. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32791. /**
  32792. * Gets the current plugin used to run the simulation
  32793. * @returns current plugin
  32794. */
  32795. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32796. /**
  32797. * Gets the list of physic impostors
  32798. * @returns an array of PhysicsImpostor
  32799. */
  32800. getImpostors(): Array<PhysicsImpostor>;
  32801. /**
  32802. * Gets the impostor for a physics enabled object
  32803. * @param object defines the object impersonated by the impostor
  32804. * @returns the PhysicsImpostor or null if not found
  32805. */
  32806. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32807. /**
  32808. * Gets the impostor for a physics body object
  32809. * @param body defines physics body used by the impostor
  32810. * @returns the PhysicsImpostor or null if not found
  32811. */
  32812. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32813. /**
  32814. * Does a raycast in the physics world
  32815. * @param from when should the ray start?
  32816. * @param to when should the ray end?
  32817. * @returns PhysicsRaycastResult
  32818. */
  32819. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32820. /**
  32821. * Called by the scene. No need to call it.
  32822. * @param delta defines the timespam between frames
  32823. */
  32824. _step(delta: number): void;
  32825. }
  32826. }
  32827. declare module "babylonjs/Physics/physicsImpostor" {
  32828. import { Nullable, IndicesArray } from "babylonjs/types";
  32829. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32830. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32832. import { Scene } from "babylonjs/scene";
  32833. import { Bone } from "babylonjs/Bones/bone";
  32834. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32835. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32836. import { Space } from "babylonjs/Maths/math.axis";
  32837. /**
  32838. * The interface for the physics imposter parameters
  32839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32840. */
  32841. export interface PhysicsImpostorParameters {
  32842. /**
  32843. * The mass of the physics imposter
  32844. */
  32845. mass: number;
  32846. /**
  32847. * The friction of the physics imposter
  32848. */
  32849. friction?: number;
  32850. /**
  32851. * The coefficient of restitution of the physics imposter
  32852. */
  32853. restitution?: number;
  32854. /**
  32855. * The native options of the physics imposter
  32856. */
  32857. nativeOptions?: any;
  32858. /**
  32859. * Specifies if the parent should be ignored
  32860. */
  32861. ignoreParent?: boolean;
  32862. /**
  32863. * Specifies if bi-directional transformations should be disabled
  32864. */
  32865. disableBidirectionalTransformation?: boolean;
  32866. /**
  32867. * The pressure inside the physics imposter, soft object only
  32868. */
  32869. pressure?: number;
  32870. /**
  32871. * The stiffness the physics imposter, soft object only
  32872. */
  32873. stiffness?: number;
  32874. /**
  32875. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32876. */
  32877. velocityIterations?: number;
  32878. /**
  32879. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32880. */
  32881. positionIterations?: number;
  32882. /**
  32883. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32884. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32885. * Add to fix multiple points
  32886. */
  32887. fixedPoints?: number;
  32888. /**
  32889. * The collision margin around a soft object
  32890. */
  32891. margin?: number;
  32892. /**
  32893. * The collision margin around a soft object
  32894. */
  32895. damping?: number;
  32896. /**
  32897. * The path for a rope based on an extrusion
  32898. */
  32899. path?: any;
  32900. /**
  32901. * The shape of an extrusion used for a rope based on an extrusion
  32902. */
  32903. shape?: any;
  32904. }
  32905. /**
  32906. * Interface for a physics-enabled object
  32907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32908. */
  32909. export interface IPhysicsEnabledObject {
  32910. /**
  32911. * The position of the physics-enabled object
  32912. */
  32913. position: Vector3;
  32914. /**
  32915. * The rotation of the physics-enabled object
  32916. */
  32917. rotationQuaternion: Nullable<Quaternion>;
  32918. /**
  32919. * The scale of the physics-enabled object
  32920. */
  32921. scaling: Vector3;
  32922. /**
  32923. * The rotation of the physics-enabled object
  32924. */
  32925. rotation?: Vector3;
  32926. /**
  32927. * The parent of the physics-enabled object
  32928. */
  32929. parent?: any;
  32930. /**
  32931. * The bounding info of the physics-enabled object
  32932. * @returns The bounding info of the physics-enabled object
  32933. */
  32934. getBoundingInfo(): BoundingInfo;
  32935. /**
  32936. * Computes the world matrix
  32937. * @param force Specifies if the world matrix should be computed by force
  32938. * @returns A world matrix
  32939. */
  32940. computeWorldMatrix(force: boolean): Matrix;
  32941. /**
  32942. * Gets the world matrix
  32943. * @returns A world matrix
  32944. */
  32945. getWorldMatrix?(): Matrix;
  32946. /**
  32947. * Gets the child meshes
  32948. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32949. * @returns An array of abstract meshes
  32950. */
  32951. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32952. /**
  32953. * Gets the vertex data
  32954. * @param kind The type of vertex data
  32955. * @returns A nullable array of numbers, or a float32 array
  32956. */
  32957. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32958. /**
  32959. * Gets the indices from the mesh
  32960. * @returns A nullable array of index arrays
  32961. */
  32962. getIndices?(): Nullable<IndicesArray>;
  32963. /**
  32964. * Gets the scene from the mesh
  32965. * @returns the indices array or null
  32966. */
  32967. getScene?(): Scene;
  32968. /**
  32969. * Gets the absolute position from the mesh
  32970. * @returns the absolute position
  32971. */
  32972. getAbsolutePosition(): Vector3;
  32973. /**
  32974. * Gets the absolute pivot point from the mesh
  32975. * @returns the absolute pivot point
  32976. */
  32977. getAbsolutePivotPoint(): Vector3;
  32978. /**
  32979. * Rotates the mesh
  32980. * @param axis The axis of rotation
  32981. * @param amount The amount of rotation
  32982. * @param space The space of the rotation
  32983. * @returns The rotation transform node
  32984. */
  32985. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32986. /**
  32987. * Translates the mesh
  32988. * @param axis The axis of translation
  32989. * @param distance The distance of translation
  32990. * @param space The space of the translation
  32991. * @returns The transform node
  32992. */
  32993. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32994. /**
  32995. * Sets the absolute position of the mesh
  32996. * @param absolutePosition The absolute position of the mesh
  32997. * @returns The transform node
  32998. */
  32999. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33000. /**
  33001. * Gets the class name of the mesh
  33002. * @returns The class name
  33003. */
  33004. getClassName(): string;
  33005. }
  33006. /**
  33007. * Represents a physics imposter
  33008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33009. */
  33010. export class PhysicsImpostor {
  33011. /**
  33012. * The physics-enabled object used as the physics imposter
  33013. */
  33014. object: IPhysicsEnabledObject;
  33015. /**
  33016. * The type of the physics imposter
  33017. */
  33018. type: number;
  33019. private _options;
  33020. private _scene?;
  33021. /**
  33022. * The default object size of the imposter
  33023. */
  33024. static DEFAULT_OBJECT_SIZE: Vector3;
  33025. /**
  33026. * The identity quaternion of the imposter
  33027. */
  33028. static IDENTITY_QUATERNION: Quaternion;
  33029. /** @hidden */
  33030. _pluginData: any;
  33031. private _physicsEngine;
  33032. private _physicsBody;
  33033. private _bodyUpdateRequired;
  33034. private _onBeforePhysicsStepCallbacks;
  33035. private _onAfterPhysicsStepCallbacks;
  33036. /** @hidden */
  33037. _onPhysicsCollideCallbacks: Array<{
  33038. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33039. otherImpostors: Array<PhysicsImpostor>;
  33040. }>;
  33041. private _deltaPosition;
  33042. private _deltaRotation;
  33043. private _deltaRotationConjugated;
  33044. /** @hidden */
  33045. _isFromLine: boolean;
  33046. private _parent;
  33047. private _isDisposed;
  33048. private static _tmpVecs;
  33049. private static _tmpQuat;
  33050. /**
  33051. * Specifies if the physics imposter is disposed
  33052. */
  33053. get isDisposed(): boolean;
  33054. /**
  33055. * Gets the mass of the physics imposter
  33056. */
  33057. get mass(): number;
  33058. set mass(value: number);
  33059. /**
  33060. * Gets the coefficient of friction
  33061. */
  33062. get friction(): number;
  33063. /**
  33064. * Sets the coefficient of friction
  33065. */
  33066. set friction(value: number);
  33067. /**
  33068. * Gets the coefficient of restitution
  33069. */
  33070. get restitution(): number;
  33071. /**
  33072. * Sets the coefficient of restitution
  33073. */
  33074. set restitution(value: number);
  33075. /**
  33076. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33077. */
  33078. get pressure(): number;
  33079. /**
  33080. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33081. */
  33082. set pressure(value: number);
  33083. /**
  33084. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33085. */
  33086. get stiffness(): number;
  33087. /**
  33088. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33089. */
  33090. set stiffness(value: number);
  33091. /**
  33092. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33093. */
  33094. get velocityIterations(): number;
  33095. /**
  33096. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33097. */
  33098. set velocityIterations(value: number);
  33099. /**
  33100. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33101. */
  33102. get positionIterations(): number;
  33103. /**
  33104. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33105. */
  33106. set positionIterations(value: number);
  33107. /**
  33108. * The unique id of the physics imposter
  33109. * set by the physics engine when adding this impostor to the array
  33110. */
  33111. uniqueId: number;
  33112. /**
  33113. * @hidden
  33114. */
  33115. soft: boolean;
  33116. /**
  33117. * @hidden
  33118. */
  33119. segments: number;
  33120. private _joints;
  33121. /**
  33122. * Initializes the physics imposter
  33123. * @param object The physics-enabled object used as the physics imposter
  33124. * @param type The type of the physics imposter
  33125. * @param _options The options for the physics imposter
  33126. * @param _scene The Babylon scene
  33127. */
  33128. constructor(
  33129. /**
  33130. * The physics-enabled object used as the physics imposter
  33131. */
  33132. object: IPhysicsEnabledObject,
  33133. /**
  33134. * The type of the physics imposter
  33135. */
  33136. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33137. /**
  33138. * This function will completly initialize this impostor.
  33139. * It will create a new body - but only if this mesh has no parent.
  33140. * If it has, this impostor will not be used other than to define the impostor
  33141. * of the child mesh.
  33142. * @hidden
  33143. */
  33144. _init(): void;
  33145. private _getPhysicsParent;
  33146. /**
  33147. * Should a new body be generated.
  33148. * @returns boolean specifying if body initialization is required
  33149. */
  33150. isBodyInitRequired(): boolean;
  33151. /**
  33152. * Sets the updated scaling
  33153. * @param updated Specifies if the scaling is updated
  33154. */
  33155. setScalingUpdated(): void;
  33156. /**
  33157. * Force a regeneration of this or the parent's impostor's body.
  33158. * Use under cautious - This will remove all joints already implemented.
  33159. */
  33160. forceUpdate(): void;
  33161. /**
  33162. * Gets the body that holds this impostor. Either its own, or its parent.
  33163. */
  33164. get physicsBody(): any;
  33165. /**
  33166. * Get the parent of the physics imposter
  33167. * @returns Physics imposter or null
  33168. */
  33169. get parent(): Nullable<PhysicsImpostor>;
  33170. /**
  33171. * Sets the parent of the physics imposter
  33172. */
  33173. set parent(value: Nullable<PhysicsImpostor>);
  33174. /**
  33175. * Set the physics body. Used mainly by the physics engine/plugin
  33176. */
  33177. set physicsBody(physicsBody: any);
  33178. /**
  33179. * Resets the update flags
  33180. */
  33181. resetUpdateFlags(): void;
  33182. /**
  33183. * Gets the object extend size
  33184. * @returns the object extend size
  33185. */
  33186. getObjectExtendSize(): Vector3;
  33187. /**
  33188. * Gets the object center
  33189. * @returns The object center
  33190. */
  33191. getObjectCenter(): Vector3;
  33192. /**
  33193. * Get a specific parameter from the options parameters
  33194. * @param paramName The object parameter name
  33195. * @returns The object parameter
  33196. */
  33197. getParam(paramName: string): any;
  33198. /**
  33199. * Sets a specific parameter in the options given to the physics plugin
  33200. * @param paramName The parameter name
  33201. * @param value The value of the parameter
  33202. */
  33203. setParam(paramName: string, value: number): void;
  33204. /**
  33205. * Specifically change the body's mass option. Won't recreate the physics body object
  33206. * @param mass The mass of the physics imposter
  33207. */
  33208. setMass(mass: number): void;
  33209. /**
  33210. * Gets the linear velocity
  33211. * @returns linear velocity or null
  33212. */
  33213. getLinearVelocity(): Nullable<Vector3>;
  33214. /**
  33215. * Sets the linear velocity
  33216. * @param velocity linear velocity or null
  33217. */
  33218. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33219. /**
  33220. * Gets the angular velocity
  33221. * @returns angular velocity or null
  33222. */
  33223. getAngularVelocity(): Nullable<Vector3>;
  33224. /**
  33225. * Sets the angular velocity
  33226. * @param velocity The velocity or null
  33227. */
  33228. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33229. /**
  33230. * Execute a function with the physics plugin native code
  33231. * Provide a function the will have two variables - the world object and the physics body object
  33232. * @param func The function to execute with the physics plugin native code
  33233. */
  33234. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33235. /**
  33236. * Register a function that will be executed before the physics world is stepping forward
  33237. * @param func The function to execute before the physics world is stepped forward
  33238. */
  33239. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33240. /**
  33241. * Unregister a function that will be executed before the physics world is stepping forward
  33242. * @param func The function to execute before the physics world is stepped forward
  33243. */
  33244. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33245. /**
  33246. * Register a function that will be executed after the physics step
  33247. * @param func The function to execute after physics step
  33248. */
  33249. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33250. /**
  33251. * Unregisters a function that will be executed after the physics step
  33252. * @param func The function to execute after physics step
  33253. */
  33254. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33255. /**
  33256. * register a function that will be executed when this impostor collides against a different body
  33257. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33258. * @param func Callback that is executed on collision
  33259. */
  33260. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33261. /**
  33262. * Unregisters the physics imposter on contact
  33263. * @param collideAgainst The physics object to collide against
  33264. * @param func Callback to execute on collision
  33265. */
  33266. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33267. private _tmpQuat;
  33268. private _tmpQuat2;
  33269. /**
  33270. * Get the parent rotation
  33271. * @returns The parent rotation
  33272. */
  33273. getParentsRotation(): Quaternion;
  33274. /**
  33275. * this function is executed by the physics engine.
  33276. */
  33277. beforeStep: () => void;
  33278. /**
  33279. * this function is executed by the physics engine
  33280. */
  33281. afterStep: () => void;
  33282. /**
  33283. * Legacy collision detection event support
  33284. */
  33285. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33286. /**
  33287. * event and body object due to cannon's event-based architecture.
  33288. */
  33289. onCollide: (e: {
  33290. body: any;
  33291. point: Nullable<Vector3>;
  33292. }) => void;
  33293. /**
  33294. * Apply a force
  33295. * @param force The force to apply
  33296. * @param contactPoint The contact point for the force
  33297. * @returns The physics imposter
  33298. */
  33299. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33300. /**
  33301. * Apply an impulse
  33302. * @param force The impulse force
  33303. * @param contactPoint The contact point for the impulse force
  33304. * @returns The physics imposter
  33305. */
  33306. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33307. /**
  33308. * A help function to create a joint
  33309. * @param otherImpostor A physics imposter used to create a joint
  33310. * @param jointType The type of joint
  33311. * @param jointData The data for the joint
  33312. * @returns The physics imposter
  33313. */
  33314. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33315. /**
  33316. * Add a joint to this impostor with a different impostor
  33317. * @param otherImpostor A physics imposter used to add a joint
  33318. * @param joint The joint to add
  33319. * @returns The physics imposter
  33320. */
  33321. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33322. /**
  33323. * Add an anchor to a cloth impostor
  33324. * @param otherImpostor rigid impostor to anchor to
  33325. * @param width ratio across width from 0 to 1
  33326. * @param height ratio up height from 0 to 1
  33327. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33328. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33329. * @returns impostor the soft imposter
  33330. */
  33331. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33332. /**
  33333. * Add a hook to a rope impostor
  33334. * @param otherImpostor rigid impostor to anchor to
  33335. * @param length ratio across rope from 0 to 1
  33336. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33337. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33338. * @returns impostor the rope imposter
  33339. */
  33340. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33341. /**
  33342. * Will keep this body still, in a sleep mode.
  33343. * @returns the physics imposter
  33344. */
  33345. sleep(): PhysicsImpostor;
  33346. /**
  33347. * Wake the body up.
  33348. * @returns The physics imposter
  33349. */
  33350. wakeUp(): PhysicsImpostor;
  33351. /**
  33352. * Clones the physics imposter
  33353. * @param newObject The physics imposter clones to this physics-enabled object
  33354. * @returns A nullable physics imposter
  33355. */
  33356. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33357. /**
  33358. * Disposes the physics imposter
  33359. */
  33360. dispose(): void;
  33361. /**
  33362. * Sets the delta position
  33363. * @param position The delta position amount
  33364. */
  33365. setDeltaPosition(position: Vector3): void;
  33366. /**
  33367. * Sets the delta rotation
  33368. * @param rotation The delta rotation amount
  33369. */
  33370. setDeltaRotation(rotation: Quaternion): void;
  33371. /**
  33372. * Gets the box size of the physics imposter and stores the result in the input parameter
  33373. * @param result Stores the box size
  33374. * @returns The physics imposter
  33375. */
  33376. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33377. /**
  33378. * Gets the radius of the physics imposter
  33379. * @returns Radius of the physics imposter
  33380. */
  33381. getRadius(): number;
  33382. /**
  33383. * Sync a bone with this impostor
  33384. * @param bone The bone to sync to the impostor.
  33385. * @param boneMesh The mesh that the bone is influencing.
  33386. * @param jointPivot The pivot of the joint / bone in local space.
  33387. * @param distToJoint Optional distance from the impostor to the joint.
  33388. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33389. */
  33390. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33391. /**
  33392. * Sync impostor to a bone
  33393. * @param bone The bone that the impostor will be synced to.
  33394. * @param boneMesh The mesh that the bone is influencing.
  33395. * @param jointPivot The pivot of the joint / bone in local space.
  33396. * @param distToJoint Optional distance from the impostor to the joint.
  33397. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33398. * @param boneAxis Optional vector3 axis the bone is aligned with
  33399. */
  33400. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33401. /**
  33402. * No-Imposter type
  33403. */
  33404. static NoImpostor: number;
  33405. /**
  33406. * Sphere-Imposter type
  33407. */
  33408. static SphereImpostor: number;
  33409. /**
  33410. * Box-Imposter type
  33411. */
  33412. static BoxImpostor: number;
  33413. /**
  33414. * Plane-Imposter type
  33415. */
  33416. static PlaneImpostor: number;
  33417. /**
  33418. * Mesh-imposter type
  33419. */
  33420. static MeshImpostor: number;
  33421. /**
  33422. * Capsule-Impostor type (Ammo.js plugin only)
  33423. */
  33424. static CapsuleImpostor: number;
  33425. /**
  33426. * Cylinder-Imposter type
  33427. */
  33428. static CylinderImpostor: number;
  33429. /**
  33430. * Particle-Imposter type
  33431. */
  33432. static ParticleImpostor: number;
  33433. /**
  33434. * Heightmap-Imposter type
  33435. */
  33436. static HeightmapImpostor: number;
  33437. /**
  33438. * ConvexHull-Impostor type (Ammo.js plugin only)
  33439. */
  33440. static ConvexHullImpostor: number;
  33441. /**
  33442. * Custom-Imposter type (Ammo.js plugin only)
  33443. */
  33444. static CustomImpostor: number;
  33445. /**
  33446. * Rope-Imposter type
  33447. */
  33448. static RopeImpostor: number;
  33449. /**
  33450. * Cloth-Imposter type
  33451. */
  33452. static ClothImpostor: number;
  33453. /**
  33454. * Softbody-Imposter type
  33455. */
  33456. static SoftbodyImpostor: number;
  33457. }
  33458. }
  33459. declare module "babylonjs/Meshes/mesh" {
  33460. import { Observable } from "babylonjs/Misc/observable";
  33461. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33462. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33463. import { Camera } from "babylonjs/Cameras/camera";
  33464. import { Scene } from "babylonjs/scene";
  33465. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33466. import { Color4 } from "babylonjs/Maths/math.color";
  33467. import { Engine } from "babylonjs/Engines/engine";
  33468. import { Node } from "babylonjs/node";
  33469. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33470. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33471. import { Buffer } from "babylonjs/Meshes/buffer";
  33472. import { Geometry } from "babylonjs/Meshes/geometry";
  33473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33475. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33476. import { Effect } from "babylonjs/Materials/effect";
  33477. import { Material } from "babylonjs/Materials/material";
  33478. import { Skeleton } from "babylonjs/Bones/skeleton";
  33479. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33480. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33481. import { Path3D } from "babylonjs/Maths/math.path";
  33482. import { Plane } from "babylonjs/Maths/math.plane";
  33483. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33484. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33485. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33486. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33487. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33488. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33489. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33490. /**
  33491. * @hidden
  33492. **/
  33493. export class _CreationDataStorage {
  33494. closePath?: boolean;
  33495. closeArray?: boolean;
  33496. idx: number[];
  33497. dashSize: number;
  33498. gapSize: number;
  33499. path3D: Path3D;
  33500. pathArray: Vector3[][];
  33501. arc: number;
  33502. radius: number;
  33503. cap: number;
  33504. tessellation: number;
  33505. }
  33506. /**
  33507. * @hidden
  33508. **/
  33509. class _InstanceDataStorage {
  33510. visibleInstances: any;
  33511. batchCache: _InstancesBatch;
  33512. instancesBufferSize: number;
  33513. instancesBuffer: Nullable<Buffer>;
  33514. instancesData: Float32Array;
  33515. overridenInstanceCount: number;
  33516. isFrozen: boolean;
  33517. previousBatch: Nullable<_InstancesBatch>;
  33518. hardwareInstancedRendering: boolean;
  33519. sideOrientation: number;
  33520. manualUpdate: boolean;
  33521. previousRenderId: number;
  33522. }
  33523. /**
  33524. * @hidden
  33525. **/
  33526. export class _InstancesBatch {
  33527. mustReturn: boolean;
  33528. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33529. renderSelf: boolean[];
  33530. hardwareInstancedRendering: boolean[];
  33531. }
  33532. /**
  33533. * @hidden
  33534. **/
  33535. class _ThinInstanceDataStorage {
  33536. instancesCount: number;
  33537. matrixBuffer: Nullable<Buffer>;
  33538. matrixBufferSize: number;
  33539. matrixData: Nullable<Float32Array>;
  33540. boundingVectors: Array<Vector3>;
  33541. worldMatrices: Nullable<Matrix[]>;
  33542. }
  33543. /**
  33544. * Class used to represent renderable models
  33545. */
  33546. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33547. /**
  33548. * Mesh side orientation : usually the external or front surface
  33549. */
  33550. static readonly FRONTSIDE: number;
  33551. /**
  33552. * Mesh side orientation : usually the internal or back surface
  33553. */
  33554. static readonly BACKSIDE: number;
  33555. /**
  33556. * Mesh side orientation : both internal and external or front and back surfaces
  33557. */
  33558. static readonly DOUBLESIDE: number;
  33559. /**
  33560. * Mesh side orientation : by default, `FRONTSIDE`
  33561. */
  33562. static readonly DEFAULTSIDE: number;
  33563. /**
  33564. * Mesh cap setting : no cap
  33565. */
  33566. static readonly NO_CAP: number;
  33567. /**
  33568. * Mesh cap setting : one cap at the beginning of the mesh
  33569. */
  33570. static readonly CAP_START: number;
  33571. /**
  33572. * Mesh cap setting : one cap at the end of the mesh
  33573. */
  33574. static readonly CAP_END: number;
  33575. /**
  33576. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33577. */
  33578. static readonly CAP_ALL: number;
  33579. /**
  33580. * Mesh pattern setting : no flip or rotate
  33581. */
  33582. static readonly NO_FLIP: number;
  33583. /**
  33584. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33585. */
  33586. static readonly FLIP_TILE: number;
  33587. /**
  33588. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33589. */
  33590. static readonly ROTATE_TILE: number;
  33591. /**
  33592. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33593. */
  33594. static readonly FLIP_ROW: number;
  33595. /**
  33596. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33597. */
  33598. static readonly ROTATE_ROW: number;
  33599. /**
  33600. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33601. */
  33602. static readonly FLIP_N_ROTATE_TILE: number;
  33603. /**
  33604. * Mesh pattern setting : rotate pattern and rotate
  33605. */
  33606. static readonly FLIP_N_ROTATE_ROW: number;
  33607. /**
  33608. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33609. */
  33610. static readonly CENTER: number;
  33611. /**
  33612. * Mesh tile positioning : part tiles on left
  33613. */
  33614. static readonly LEFT: number;
  33615. /**
  33616. * Mesh tile positioning : part tiles on right
  33617. */
  33618. static readonly RIGHT: number;
  33619. /**
  33620. * Mesh tile positioning : part tiles on top
  33621. */
  33622. static readonly TOP: number;
  33623. /**
  33624. * Mesh tile positioning : part tiles on bottom
  33625. */
  33626. static readonly BOTTOM: number;
  33627. /**
  33628. * Gets the default side orientation.
  33629. * @param orientation the orientation to value to attempt to get
  33630. * @returns the default orientation
  33631. * @hidden
  33632. */
  33633. static _GetDefaultSideOrientation(orientation?: number): number;
  33634. private _internalMeshDataInfo;
  33635. get computeBonesUsingShaders(): boolean;
  33636. set computeBonesUsingShaders(value: boolean);
  33637. /**
  33638. * An event triggered before rendering the mesh
  33639. */
  33640. get onBeforeRenderObservable(): Observable<Mesh>;
  33641. /**
  33642. * An event triggered before binding the mesh
  33643. */
  33644. get onBeforeBindObservable(): Observable<Mesh>;
  33645. /**
  33646. * An event triggered after rendering the mesh
  33647. */
  33648. get onAfterRenderObservable(): Observable<Mesh>;
  33649. /**
  33650. * An event triggered before drawing the mesh
  33651. */
  33652. get onBeforeDrawObservable(): Observable<Mesh>;
  33653. private _onBeforeDrawObserver;
  33654. /**
  33655. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33656. */
  33657. set onBeforeDraw(callback: () => void);
  33658. get hasInstances(): boolean;
  33659. get hasThinInstances(): boolean;
  33660. /**
  33661. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33662. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33663. */
  33664. delayLoadState: number;
  33665. /**
  33666. * Gets the list of instances created from this mesh
  33667. * it is not supposed to be modified manually.
  33668. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33669. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33670. */
  33671. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33672. /**
  33673. * Gets the file containing delay loading data for this mesh
  33674. */
  33675. delayLoadingFile: string;
  33676. /** @hidden */
  33677. _binaryInfo: any;
  33678. /**
  33679. * User defined function used to change how LOD level selection is done
  33680. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33681. */
  33682. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33683. /**
  33684. * Gets or sets the morph target manager
  33685. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33686. */
  33687. get morphTargetManager(): Nullable<MorphTargetManager>;
  33688. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33689. /** @hidden */
  33690. _creationDataStorage: Nullable<_CreationDataStorage>;
  33691. /** @hidden */
  33692. _geometry: Nullable<Geometry>;
  33693. /** @hidden */
  33694. _delayInfo: Array<string>;
  33695. /** @hidden */
  33696. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33697. /** @hidden */
  33698. _instanceDataStorage: _InstanceDataStorage;
  33699. /** @hidden */
  33700. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33701. private _effectiveMaterial;
  33702. /** @hidden */
  33703. _shouldGenerateFlatShading: boolean;
  33704. /** @hidden */
  33705. _originalBuilderSideOrientation: number;
  33706. /**
  33707. * Use this property to change the original side orientation defined at construction time
  33708. */
  33709. overrideMaterialSideOrientation: Nullable<number>;
  33710. /**
  33711. * Gets the source mesh (the one used to clone this one from)
  33712. */
  33713. get source(): Nullable<Mesh>;
  33714. /**
  33715. * Gets the list of clones of this mesh
  33716. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33717. * Note that useClonedMeshMap=true is the default setting
  33718. */
  33719. get cloneMeshMap(): Nullable<{
  33720. [id: string]: Mesh | undefined;
  33721. }>;
  33722. /**
  33723. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33724. */
  33725. get isUnIndexed(): boolean;
  33726. set isUnIndexed(value: boolean);
  33727. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33728. get worldMatrixInstancedBuffer(): Float32Array;
  33729. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33730. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33731. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33732. /**
  33733. * @constructor
  33734. * @param name The value used by scene.getMeshByName() to do a lookup.
  33735. * @param scene The scene to add this mesh to.
  33736. * @param parent The parent of this mesh, if it has one
  33737. * @param source An optional Mesh from which geometry is shared, cloned.
  33738. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33739. * When false, achieved by calling a clone(), also passing False.
  33740. * This will make creation of children, recursive.
  33741. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33742. */
  33743. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33744. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33745. doNotInstantiate: boolean;
  33746. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33747. /**
  33748. * Gets the class name
  33749. * @returns the string "Mesh".
  33750. */
  33751. getClassName(): string;
  33752. /** @hidden */
  33753. get _isMesh(): boolean;
  33754. /**
  33755. * Returns a description of this mesh
  33756. * @param fullDetails define if full details about this mesh must be used
  33757. * @returns a descriptive string representing this mesh
  33758. */
  33759. toString(fullDetails?: boolean): string;
  33760. /** @hidden */
  33761. _unBindEffect(): void;
  33762. /**
  33763. * Gets a boolean indicating if this mesh has LOD
  33764. */
  33765. get hasLODLevels(): boolean;
  33766. /**
  33767. * Gets the list of MeshLODLevel associated with the current mesh
  33768. * @returns an array of MeshLODLevel
  33769. */
  33770. getLODLevels(): MeshLODLevel[];
  33771. private _sortLODLevels;
  33772. /**
  33773. * Add a mesh as LOD level triggered at the given distance.
  33774. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33775. * @param distance The distance from the center of the object to show this level
  33776. * @param mesh The mesh to be added as LOD level (can be null)
  33777. * @return This mesh (for chaining)
  33778. */
  33779. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33780. /**
  33781. * Returns the LOD level mesh at the passed distance or null if not found.
  33782. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33783. * @param distance The distance from the center of the object to show this level
  33784. * @returns a Mesh or `null`
  33785. */
  33786. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33787. /**
  33788. * Remove a mesh from the LOD array
  33789. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33790. * @param mesh defines the mesh to be removed
  33791. * @return This mesh (for chaining)
  33792. */
  33793. removeLODLevel(mesh: Mesh): Mesh;
  33794. /**
  33795. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33796. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33797. * @param camera defines the camera to use to compute distance
  33798. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33799. * @return This mesh (for chaining)
  33800. */
  33801. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33802. /**
  33803. * Gets the mesh internal Geometry object
  33804. */
  33805. get geometry(): Nullable<Geometry>;
  33806. /**
  33807. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33808. * @returns the total number of vertices
  33809. */
  33810. getTotalVertices(): number;
  33811. /**
  33812. * Returns the content of an associated vertex buffer
  33813. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33814. * - VertexBuffer.PositionKind
  33815. * - VertexBuffer.UVKind
  33816. * - VertexBuffer.UV2Kind
  33817. * - VertexBuffer.UV3Kind
  33818. * - VertexBuffer.UV4Kind
  33819. * - VertexBuffer.UV5Kind
  33820. * - VertexBuffer.UV6Kind
  33821. * - VertexBuffer.ColorKind
  33822. * - VertexBuffer.MatricesIndicesKind
  33823. * - VertexBuffer.MatricesIndicesExtraKind
  33824. * - VertexBuffer.MatricesWeightsKind
  33825. * - VertexBuffer.MatricesWeightsExtraKind
  33826. * @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
  33827. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33828. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33829. */
  33830. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33831. /**
  33832. * Returns the mesh VertexBuffer object from the requested `kind`
  33833. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33834. * - VertexBuffer.PositionKind
  33835. * - VertexBuffer.NormalKind
  33836. * - VertexBuffer.UVKind
  33837. * - VertexBuffer.UV2Kind
  33838. * - VertexBuffer.UV3Kind
  33839. * - VertexBuffer.UV4Kind
  33840. * - VertexBuffer.UV5Kind
  33841. * - VertexBuffer.UV6Kind
  33842. * - VertexBuffer.ColorKind
  33843. * - VertexBuffer.MatricesIndicesKind
  33844. * - VertexBuffer.MatricesIndicesExtraKind
  33845. * - VertexBuffer.MatricesWeightsKind
  33846. * - VertexBuffer.MatricesWeightsExtraKind
  33847. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33848. */
  33849. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33850. /**
  33851. * Tests if a specific vertex buffer is associated with this mesh
  33852. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33853. * - VertexBuffer.PositionKind
  33854. * - VertexBuffer.NormalKind
  33855. * - VertexBuffer.UVKind
  33856. * - VertexBuffer.UV2Kind
  33857. * - VertexBuffer.UV3Kind
  33858. * - VertexBuffer.UV4Kind
  33859. * - VertexBuffer.UV5Kind
  33860. * - VertexBuffer.UV6Kind
  33861. * - VertexBuffer.ColorKind
  33862. * - VertexBuffer.MatricesIndicesKind
  33863. * - VertexBuffer.MatricesIndicesExtraKind
  33864. * - VertexBuffer.MatricesWeightsKind
  33865. * - VertexBuffer.MatricesWeightsExtraKind
  33866. * @returns a boolean
  33867. */
  33868. isVerticesDataPresent(kind: string): boolean;
  33869. /**
  33870. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33871. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33872. * - VertexBuffer.PositionKind
  33873. * - VertexBuffer.UVKind
  33874. * - VertexBuffer.UV2Kind
  33875. * - VertexBuffer.UV3Kind
  33876. * - VertexBuffer.UV4Kind
  33877. * - VertexBuffer.UV5Kind
  33878. * - VertexBuffer.UV6Kind
  33879. * - VertexBuffer.ColorKind
  33880. * - VertexBuffer.MatricesIndicesKind
  33881. * - VertexBuffer.MatricesIndicesExtraKind
  33882. * - VertexBuffer.MatricesWeightsKind
  33883. * - VertexBuffer.MatricesWeightsExtraKind
  33884. * @returns a boolean
  33885. */
  33886. isVertexBufferUpdatable(kind: string): boolean;
  33887. /**
  33888. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33889. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33890. * - VertexBuffer.PositionKind
  33891. * - VertexBuffer.NormalKind
  33892. * - VertexBuffer.UVKind
  33893. * - VertexBuffer.UV2Kind
  33894. * - VertexBuffer.UV3Kind
  33895. * - VertexBuffer.UV4Kind
  33896. * - VertexBuffer.UV5Kind
  33897. * - VertexBuffer.UV6Kind
  33898. * - VertexBuffer.ColorKind
  33899. * - VertexBuffer.MatricesIndicesKind
  33900. * - VertexBuffer.MatricesIndicesExtraKind
  33901. * - VertexBuffer.MatricesWeightsKind
  33902. * - VertexBuffer.MatricesWeightsExtraKind
  33903. * @returns an array of strings
  33904. */
  33905. getVerticesDataKinds(): string[];
  33906. /**
  33907. * Returns a positive integer : the total number of indices in this mesh geometry.
  33908. * @returns the numner of indices or zero if the mesh has no geometry.
  33909. */
  33910. getTotalIndices(): number;
  33911. /**
  33912. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33913. * @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.
  33914. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33915. * @returns the indices array or an empty array if the mesh has no geometry
  33916. */
  33917. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33918. get isBlocked(): boolean;
  33919. /**
  33920. * Determine if the current mesh is ready to be rendered
  33921. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33922. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33923. * @returns true if all associated assets are ready (material, textures, shaders)
  33924. */
  33925. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33926. /**
  33927. * 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.
  33928. */
  33929. get areNormalsFrozen(): boolean;
  33930. /**
  33931. * 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.
  33932. * @returns the current mesh
  33933. */
  33934. freezeNormals(): Mesh;
  33935. /**
  33936. * 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
  33937. * @returns the current mesh
  33938. */
  33939. unfreezeNormals(): Mesh;
  33940. /**
  33941. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33942. */
  33943. set overridenInstanceCount(count: number);
  33944. /** @hidden */
  33945. _preActivate(): Mesh;
  33946. /** @hidden */
  33947. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33948. /** @hidden */
  33949. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33950. protected _afterComputeWorldMatrix(): void;
  33951. /** @hidden */
  33952. _postActivate(): void;
  33953. /**
  33954. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33955. * This means the mesh underlying bounding box and sphere are recomputed.
  33956. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33957. * @returns the current mesh
  33958. */
  33959. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33960. /** @hidden */
  33961. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33962. /**
  33963. * This function will subdivide the mesh into multiple submeshes
  33964. * @param count defines the expected number of submeshes
  33965. */
  33966. subdivide(count: number): void;
  33967. /**
  33968. * Copy a FloatArray into a specific associated vertex buffer
  33969. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33970. * - VertexBuffer.PositionKind
  33971. * - VertexBuffer.UVKind
  33972. * - VertexBuffer.UV2Kind
  33973. * - VertexBuffer.UV3Kind
  33974. * - VertexBuffer.UV4Kind
  33975. * - VertexBuffer.UV5Kind
  33976. * - VertexBuffer.UV6Kind
  33977. * - VertexBuffer.ColorKind
  33978. * - VertexBuffer.MatricesIndicesKind
  33979. * - VertexBuffer.MatricesIndicesExtraKind
  33980. * - VertexBuffer.MatricesWeightsKind
  33981. * - VertexBuffer.MatricesWeightsExtraKind
  33982. * @param data defines the data source
  33983. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33984. * @param stride defines the data stride size (can be null)
  33985. * @returns the current mesh
  33986. */
  33987. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33988. /**
  33989. * Delete a vertex buffer associated with this mesh
  33990. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33991. * - VertexBuffer.PositionKind
  33992. * - VertexBuffer.UVKind
  33993. * - VertexBuffer.UV2Kind
  33994. * - VertexBuffer.UV3Kind
  33995. * - VertexBuffer.UV4Kind
  33996. * - VertexBuffer.UV5Kind
  33997. * - VertexBuffer.UV6Kind
  33998. * - VertexBuffer.ColorKind
  33999. * - VertexBuffer.MatricesIndicesKind
  34000. * - VertexBuffer.MatricesIndicesExtraKind
  34001. * - VertexBuffer.MatricesWeightsKind
  34002. * - VertexBuffer.MatricesWeightsExtraKind
  34003. */
  34004. removeVerticesData(kind: string): void;
  34005. /**
  34006. * Flags an associated vertex buffer as updatable
  34007. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34008. * - VertexBuffer.PositionKind
  34009. * - VertexBuffer.UVKind
  34010. * - VertexBuffer.UV2Kind
  34011. * - VertexBuffer.UV3Kind
  34012. * - VertexBuffer.UV4Kind
  34013. * - VertexBuffer.UV5Kind
  34014. * - VertexBuffer.UV6Kind
  34015. * - VertexBuffer.ColorKind
  34016. * - VertexBuffer.MatricesIndicesKind
  34017. * - VertexBuffer.MatricesIndicesExtraKind
  34018. * - VertexBuffer.MatricesWeightsKind
  34019. * - VertexBuffer.MatricesWeightsExtraKind
  34020. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34021. */
  34022. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34023. /**
  34024. * Sets the mesh global Vertex Buffer
  34025. * @param buffer defines the buffer to use
  34026. * @returns the current mesh
  34027. */
  34028. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34029. /**
  34030. * Update a specific associated vertex buffer
  34031. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34032. * - VertexBuffer.PositionKind
  34033. * - VertexBuffer.UVKind
  34034. * - VertexBuffer.UV2Kind
  34035. * - VertexBuffer.UV3Kind
  34036. * - VertexBuffer.UV4Kind
  34037. * - VertexBuffer.UV5Kind
  34038. * - VertexBuffer.UV6Kind
  34039. * - VertexBuffer.ColorKind
  34040. * - VertexBuffer.MatricesIndicesKind
  34041. * - VertexBuffer.MatricesIndicesExtraKind
  34042. * - VertexBuffer.MatricesWeightsKind
  34043. * - VertexBuffer.MatricesWeightsExtraKind
  34044. * @param data defines the data source
  34045. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34046. * @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)
  34047. * @returns the current mesh
  34048. */
  34049. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34050. /**
  34051. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34052. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34053. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34054. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34055. * @returns the current mesh
  34056. */
  34057. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34058. /**
  34059. * Creates a un-shared specific occurence of the geometry for the mesh.
  34060. * @returns the current mesh
  34061. */
  34062. makeGeometryUnique(): Mesh;
  34063. /**
  34064. * Set the index buffer of this mesh
  34065. * @param indices defines the source data
  34066. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34067. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34068. * @returns the current mesh
  34069. */
  34070. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34071. /**
  34072. * Update the current index buffer
  34073. * @param indices defines the source data
  34074. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34075. * @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)
  34076. * @returns the current mesh
  34077. */
  34078. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34079. /**
  34080. * Invert the geometry to move from a right handed system to a left handed one.
  34081. * @returns the current mesh
  34082. */
  34083. toLeftHanded(): Mesh;
  34084. /** @hidden */
  34085. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34086. /** @hidden */
  34087. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34088. /**
  34089. * Registers for this mesh a javascript function called just before the rendering process
  34090. * @param func defines the function to call before rendering this mesh
  34091. * @returns the current mesh
  34092. */
  34093. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34094. /**
  34095. * Disposes a previously registered javascript function called before the rendering
  34096. * @param func defines the function to remove
  34097. * @returns the current mesh
  34098. */
  34099. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34100. /**
  34101. * Registers for this mesh a javascript function called just after the rendering is complete
  34102. * @param func defines the function to call after rendering this mesh
  34103. * @returns the current mesh
  34104. */
  34105. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34106. /**
  34107. * Disposes a previously registered javascript function called after the rendering.
  34108. * @param func defines the function to remove
  34109. * @returns the current mesh
  34110. */
  34111. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34112. /** @hidden */
  34113. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34114. /** @hidden */
  34115. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34116. /** @hidden */
  34117. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34118. /** @hidden */
  34119. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34120. /** @hidden */
  34121. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34122. /** @hidden */
  34123. _rebuild(): void;
  34124. /** @hidden */
  34125. _freeze(): void;
  34126. /** @hidden */
  34127. _unFreeze(): void;
  34128. /**
  34129. * 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
  34130. * @param subMesh defines the subMesh to render
  34131. * @param enableAlphaMode defines if alpha mode can be changed
  34132. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34133. * @returns the current mesh
  34134. */
  34135. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34136. private _onBeforeDraw;
  34137. /**
  34138. * Renormalize the mesh and patch it up if there are no weights
  34139. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34140. * However in the case of zero weights then we set just a single influence to 1.
  34141. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34142. */
  34143. cleanMatrixWeights(): void;
  34144. private normalizeSkinFourWeights;
  34145. private normalizeSkinWeightsAndExtra;
  34146. /**
  34147. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34148. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34149. * the user know there was an issue with importing the mesh
  34150. * @returns a validation object with skinned, valid and report string
  34151. */
  34152. validateSkinning(): {
  34153. skinned: boolean;
  34154. valid: boolean;
  34155. report: string;
  34156. };
  34157. /** @hidden */
  34158. _checkDelayState(): Mesh;
  34159. private _queueLoad;
  34160. /**
  34161. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34162. * A mesh is in the frustum if its bounding box intersects the frustum
  34163. * @param frustumPlanes defines the frustum to test
  34164. * @returns true if the mesh is in the frustum planes
  34165. */
  34166. isInFrustum(frustumPlanes: Plane[]): boolean;
  34167. /**
  34168. * Sets the mesh material by the material or multiMaterial `id` property
  34169. * @param id is a string identifying the material or the multiMaterial
  34170. * @returns the current mesh
  34171. */
  34172. setMaterialByID(id: string): Mesh;
  34173. /**
  34174. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34175. * @returns an array of IAnimatable
  34176. */
  34177. getAnimatables(): IAnimatable[];
  34178. /**
  34179. * Modifies the mesh geometry according to the passed transformation matrix.
  34180. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34181. * The mesh normals are modified using the same transformation.
  34182. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34183. * @param transform defines the transform matrix to use
  34184. * @see https://doc.babylonjs.com/resources/baking_transformations
  34185. * @returns the current mesh
  34186. */
  34187. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34188. /**
  34189. * Modifies the mesh geometry according to its own current World Matrix.
  34190. * The mesh World Matrix is then reset.
  34191. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34192. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34193. * @see https://doc.babylonjs.com/resources/baking_transformations
  34194. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34195. * @returns the current mesh
  34196. */
  34197. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34198. /** @hidden */
  34199. get _positions(): Nullable<Vector3[]>;
  34200. /** @hidden */
  34201. _resetPointsArrayCache(): Mesh;
  34202. /** @hidden */
  34203. _generatePointsArray(): boolean;
  34204. /**
  34205. * Returns a new Mesh object generated from the current mesh properties.
  34206. * This method must not get confused with createInstance()
  34207. * @param name is a string, the name given to the new mesh
  34208. * @param newParent can be any Node object (default `null`)
  34209. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34210. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34211. * @returns a new mesh
  34212. */
  34213. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34214. /**
  34215. * Releases resources associated with this mesh.
  34216. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34217. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34218. */
  34219. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34220. /** @hidden */
  34221. _disposeInstanceSpecificData(): void;
  34222. /** @hidden */
  34223. _disposeThinInstanceSpecificData(): void;
  34224. /**
  34225. * Modifies the mesh geometry according to a displacement map.
  34226. * 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.
  34227. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34228. * @param url is a string, the URL from the image file is to be downloaded.
  34229. * @param minHeight is the lower limit of the displacement.
  34230. * @param maxHeight is the upper limit of the displacement.
  34231. * @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.
  34232. * @param uvOffset is an optional vector2 used to offset UV.
  34233. * @param uvScale is an optional vector2 used to scale UV.
  34234. * @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.
  34235. * @returns the Mesh.
  34236. */
  34237. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34238. /**
  34239. * Modifies the mesh geometry according to a displacementMap buffer.
  34240. * 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.
  34241. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34242. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34243. * @param heightMapWidth is the width of the buffer image.
  34244. * @param heightMapHeight is the height of the buffer image.
  34245. * @param minHeight is the lower limit of the displacement.
  34246. * @param maxHeight is the upper limit of the displacement.
  34247. * @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.
  34248. * @param uvOffset is an optional vector2 used to offset UV.
  34249. * @param uvScale is an optional vector2 used to scale UV.
  34250. * @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.
  34251. * @returns the Mesh.
  34252. */
  34253. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34254. /**
  34255. * Modify the mesh to get a flat shading rendering.
  34256. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34257. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34258. * @returns current mesh
  34259. */
  34260. convertToFlatShadedMesh(): Mesh;
  34261. /**
  34262. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34263. * In other words, more vertices, no more indices and a single bigger VBO.
  34264. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34265. * @returns current mesh
  34266. */
  34267. convertToUnIndexedMesh(): Mesh;
  34268. /**
  34269. * Inverses facet orientations.
  34270. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34271. * @param flipNormals will also inverts the normals
  34272. * @returns current mesh
  34273. */
  34274. flipFaces(flipNormals?: boolean): Mesh;
  34275. /**
  34276. * Increase the number of facets and hence vertices in a mesh
  34277. * Vertex normals are interpolated from existing vertex normals
  34278. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34279. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34280. */
  34281. increaseVertices(numberPerEdge: number): void;
  34282. /**
  34283. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34284. * This will undo any application of covertToFlatShadedMesh
  34285. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34286. */
  34287. forceSharedVertices(): void;
  34288. /** @hidden */
  34289. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34290. /** @hidden */
  34291. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34292. /**
  34293. * Creates a new InstancedMesh object from the mesh model.
  34294. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34295. * @param name defines the name of the new instance
  34296. * @returns a new InstancedMesh
  34297. */
  34298. createInstance(name: string): InstancedMesh;
  34299. /**
  34300. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34301. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34302. * @returns the current mesh
  34303. */
  34304. synchronizeInstances(): Mesh;
  34305. /**
  34306. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34307. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34308. * This should be used together with the simplification to avoid disappearing triangles.
  34309. * @param successCallback an optional success callback to be called after the optimization finished.
  34310. * @returns the current mesh
  34311. */
  34312. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34313. /**
  34314. * Serialize current mesh
  34315. * @param serializationObject defines the object which will receive the serialization data
  34316. */
  34317. serialize(serializationObject: any): void;
  34318. /** @hidden */
  34319. _syncGeometryWithMorphTargetManager(): void;
  34320. /** @hidden */
  34321. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34322. /**
  34323. * Returns a new Mesh object parsed from the source provided.
  34324. * @param parsedMesh is the source
  34325. * @param scene defines the hosting scene
  34326. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34327. * @returns a new Mesh
  34328. */
  34329. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34330. /**
  34331. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34332. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34333. * @param name defines the name of the mesh to create
  34334. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34335. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34336. * @param closePath creates a seam between the first and the last points of each path of the path array
  34337. * @param offset is taken in account only if the `pathArray` is containing a single path
  34338. * @param scene defines the hosting scene
  34339. * @param updatable defines if the mesh must be flagged as updatable
  34340. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34341. * @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)
  34342. * @returns a new Mesh
  34343. */
  34344. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34345. /**
  34346. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34347. * @param name defines the name of the mesh to create
  34348. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34349. * @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
  34350. * @param scene defines the hosting scene
  34351. * @param updatable defines if the mesh must be flagged as updatable
  34352. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34353. * @returns a new Mesh
  34354. */
  34355. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34356. /**
  34357. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34358. * @param name defines the name of the mesh to create
  34359. * @param size sets the size (float) of each box side (default 1)
  34360. * @param scene defines the hosting scene
  34361. * @param updatable defines if the mesh must be flagged as updatable
  34362. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34363. * @returns a new Mesh
  34364. */
  34365. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34366. /**
  34367. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34368. * @param name defines the name of the mesh to create
  34369. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34370. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34371. * @param scene defines the hosting scene
  34372. * @param updatable defines if the mesh must be flagged as updatable
  34373. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34374. * @returns a new Mesh
  34375. */
  34376. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34377. /**
  34378. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34379. * @param name defines the name of the mesh to create
  34380. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34381. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34382. * @param scene defines the hosting scene
  34383. * @returns a new Mesh
  34384. */
  34385. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34386. /**
  34387. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34388. * @param name defines the name of the mesh to create
  34389. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34390. * @param diameterTop set the top cap diameter (floats, default 1)
  34391. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34392. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34393. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34394. * @param scene defines the hosting scene
  34395. * @param updatable defines if the mesh must be flagged as updatable
  34396. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34397. * @returns a new Mesh
  34398. */
  34399. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34400. /**
  34401. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34402. * @param name defines the name of the mesh to create
  34403. * @param diameter sets the diameter size (float) of the torus (default 1)
  34404. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34405. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34406. * @param scene defines the hosting scene
  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. * @returns a new Mesh
  34410. */
  34411. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34412. /**
  34413. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34414. * @param name defines the name of the mesh to create
  34415. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34416. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34417. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34418. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34419. * @param p the number of windings on X axis (positive integers, default 2)
  34420. * @param q the number of windings on Y axis (positive integers, default 3)
  34421. * @param scene defines the hosting scene
  34422. * @param updatable defines if the mesh must be flagged as updatable
  34423. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34424. * @returns a new Mesh
  34425. */
  34426. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34427. /**
  34428. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34429. * @param name defines the name of the mesh to create
  34430. * @param points is an array successive Vector3
  34431. * @param scene defines the hosting scene
  34432. * @param updatable defines if the mesh must be flagged as updatable
  34433. * @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).
  34434. * @returns a new Mesh
  34435. */
  34436. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34437. /**
  34438. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34439. * @param name defines the name of the mesh to create
  34440. * @param points is an array successive Vector3
  34441. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34442. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34443. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34444. * @param scene defines the hosting scene
  34445. * @param updatable defines if the mesh must be flagged as updatable
  34446. * @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)
  34447. * @returns a new Mesh
  34448. */
  34449. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34450. /**
  34451. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34452. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34453. * 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.
  34454. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34455. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34456. * Remember you can only change the shape positions, not their number when updating a polygon.
  34457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34458. * @param name defines the name of the mesh to create
  34459. * @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
  34460. * @param scene defines the hosting scene
  34461. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34462. * @param updatable defines if the mesh must be flagged as updatable
  34463. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34464. * @param earcutInjection can be used to inject your own earcut reference
  34465. * @returns a new Mesh
  34466. */
  34467. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34468. /**
  34469. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34471. * @param name defines the name of the mesh to create
  34472. * @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
  34473. * @param depth defines the height of extrusion
  34474. * @param scene defines the hosting scene
  34475. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34476. * @param updatable defines if the mesh must be flagged as updatable
  34477. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34478. * @param earcutInjection can be used to inject your own earcut reference
  34479. * @returns a new Mesh
  34480. */
  34481. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34482. /**
  34483. * Creates an extruded shape mesh.
  34484. * 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
  34485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34487. * @param name defines the name of the mesh to create
  34488. * @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
  34489. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34490. * @param scale is the value to scale the shape
  34491. * @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
  34492. * @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
  34493. * @param scene defines the hosting scene
  34494. * @param updatable defines if the mesh must be flagged as updatable
  34495. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34496. * @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)
  34497. * @returns a new Mesh
  34498. */
  34499. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34500. /**
  34501. * Creates an custom extruded shape mesh.
  34502. * The custom extrusion is a parametric shape.
  34503. * It has no predefined shape. Its final shape will depend on the input parameters.
  34504. * Please consider using the same method from the MeshBuilder class instead
  34505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34506. * @param name defines the name of the mesh to create
  34507. * @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
  34508. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34509. * @param scaleFunction is a custom Javascript function called on each path point
  34510. * @param rotationFunction is a custom Javascript function called on each path point
  34511. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34512. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34513. * @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
  34514. * @param scene defines the hosting scene
  34515. * @param updatable defines if the mesh must be flagged as updatable
  34516. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34517. * @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)
  34518. * @returns a new Mesh
  34519. */
  34520. 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;
  34521. /**
  34522. * Creates lathe mesh.
  34523. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34524. * Please consider using the same method from the MeshBuilder class instead
  34525. * @param name defines the name of the mesh to create
  34526. * @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
  34527. * @param radius is the radius value of the lathe
  34528. * @param tessellation is the side number of the lathe.
  34529. * @param scene defines the hosting scene
  34530. * @param updatable defines if the mesh must be flagged as updatable
  34531. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34532. * @returns a new Mesh
  34533. */
  34534. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34535. /**
  34536. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34537. * @param name defines the name of the mesh to create
  34538. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34539. * @param scene defines the hosting scene
  34540. * @param updatable defines if the mesh must be flagged as updatable
  34541. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34542. * @returns a new Mesh
  34543. */
  34544. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34545. /**
  34546. * Creates a ground mesh.
  34547. * Please consider using the same method from the MeshBuilder class instead
  34548. * @param name defines the name of the mesh to create
  34549. * @param width set the width of the ground
  34550. * @param height set the height of the ground
  34551. * @param subdivisions sets the number of subdivisions per side
  34552. * @param scene defines the hosting scene
  34553. * @param updatable defines if the mesh must be flagged as updatable
  34554. * @returns a new Mesh
  34555. */
  34556. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34557. /**
  34558. * Creates a tiled ground mesh.
  34559. * Please consider using the same method from the MeshBuilder class instead
  34560. * @param name defines the name of the mesh to create
  34561. * @param xmin set the ground minimum X coordinate
  34562. * @param zmin set the ground minimum Y coordinate
  34563. * @param xmax set the ground maximum X coordinate
  34564. * @param zmax set the ground maximum Z coordinate
  34565. * @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
  34566. * @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
  34567. * @param scene defines the hosting scene
  34568. * @param updatable defines if the mesh must be flagged as updatable
  34569. * @returns a new Mesh
  34570. */
  34571. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34572. w: number;
  34573. h: number;
  34574. }, precision: {
  34575. w: number;
  34576. h: number;
  34577. }, scene: Scene, updatable?: boolean): Mesh;
  34578. /**
  34579. * Creates a ground mesh from a height map.
  34580. * Please consider using the same method from the MeshBuilder class instead
  34581. * @see https://doc.babylonjs.com/babylon101/height_map
  34582. * @param name defines the name of the mesh to create
  34583. * @param url sets the URL of the height map image resource
  34584. * @param width set the ground width size
  34585. * @param height set the ground height size
  34586. * @param subdivisions sets the number of subdivision per side
  34587. * @param minHeight is the minimum altitude on the ground
  34588. * @param maxHeight is the maximum altitude on the ground
  34589. * @param scene defines the hosting scene
  34590. * @param updatable defines if the mesh must be flagged as updatable
  34591. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34592. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34593. * @returns a new Mesh
  34594. */
  34595. 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;
  34596. /**
  34597. * Creates a tube mesh.
  34598. * The tube is a parametric shape.
  34599. * It has no predefined shape. Its final shape will depend on the input parameters.
  34600. * Please consider using the same method from the MeshBuilder class instead
  34601. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34602. * @param name defines the name of the mesh to create
  34603. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34604. * @param radius sets the tube radius size
  34605. * @param tessellation is the number of sides on the tubular surface
  34606. * @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
  34607. * @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
  34608. * @param scene defines the hosting scene
  34609. * @param updatable defines if the mesh must be flagged as updatable
  34610. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34611. * @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)
  34612. * @returns a new Mesh
  34613. */
  34614. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34615. (i: number, distance: number): number;
  34616. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34617. /**
  34618. * Creates a polyhedron mesh.
  34619. * Please consider using the same method from the MeshBuilder class instead.
  34620. * * 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
  34621. * * The parameter `size` (positive float, default 1) sets the polygon size
  34622. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34623. * * 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`
  34624. * * 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
  34625. * * 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)`)
  34626. * * 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
  34627. * * 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
  34628. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34631. * @param name defines the name of the mesh to create
  34632. * @param options defines the options used to create the mesh
  34633. * @param scene defines the hosting scene
  34634. * @returns a new Mesh
  34635. */
  34636. static CreatePolyhedron(name: string, options: {
  34637. type?: number;
  34638. size?: number;
  34639. sizeX?: number;
  34640. sizeY?: number;
  34641. sizeZ?: number;
  34642. custom?: any;
  34643. faceUV?: Vector4[];
  34644. faceColors?: Color4[];
  34645. updatable?: boolean;
  34646. sideOrientation?: number;
  34647. }, scene: Scene): Mesh;
  34648. /**
  34649. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34650. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34651. * * 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`)
  34652. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34653. * * 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
  34654. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34657. * @param name defines the name of the mesh
  34658. * @param options defines the options used to create the mesh
  34659. * @param scene defines the hosting scene
  34660. * @returns a new Mesh
  34661. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34662. */
  34663. static CreateIcoSphere(name: string, options: {
  34664. radius?: number;
  34665. flat?: boolean;
  34666. subdivisions?: number;
  34667. sideOrientation?: number;
  34668. updatable?: boolean;
  34669. }, scene: Scene): Mesh;
  34670. /**
  34671. * Creates a decal mesh.
  34672. * Please consider using the same method from the MeshBuilder class instead.
  34673. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34674. * @param name defines the name of the mesh
  34675. * @param sourceMesh defines the mesh receiving the decal
  34676. * @param position sets the position of the decal in world coordinates
  34677. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34678. * @param size sets the decal scaling
  34679. * @param angle sets the angle to rotate the decal
  34680. * @returns a new Mesh
  34681. */
  34682. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34683. /** Creates a Capsule Mesh
  34684. * @param name defines the name of the mesh.
  34685. * @param options the constructors options used to shape the mesh.
  34686. * @param scene defines the scene the mesh is scoped to.
  34687. * @returns the capsule mesh
  34688. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34689. */
  34690. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34691. /**
  34692. * Prepare internal position array for software CPU skinning
  34693. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34694. */
  34695. setPositionsForCPUSkinning(): Float32Array;
  34696. /**
  34697. * Prepare internal normal array for software CPU skinning
  34698. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34699. */
  34700. setNormalsForCPUSkinning(): Float32Array;
  34701. /**
  34702. * Updates the vertex buffer by applying transformation from the bones
  34703. * @param skeleton defines the skeleton to apply to current mesh
  34704. * @returns the current mesh
  34705. */
  34706. applySkeleton(skeleton: Skeleton): Mesh;
  34707. /**
  34708. * 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
  34709. * @param meshes defines the list of meshes to scan
  34710. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34711. */
  34712. static MinMax(meshes: AbstractMesh[]): {
  34713. min: Vector3;
  34714. max: Vector3;
  34715. };
  34716. /**
  34717. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34718. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34719. * @returns a vector3
  34720. */
  34721. static Center(meshesOrMinMaxVector: {
  34722. min: Vector3;
  34723. max: Vector3;
  34724. } | AbstractMesh[]): Vector3;
  34725. /**
  34726. * Merge the array of meshes into a single mesh for performance reasons.
  34727. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34728. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34729. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34730. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34731. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34732. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34733. * @returns a new mesh
  34734. */
  34735. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34736. /** @hidden */
  34737. addInstance(instance: InstancedMesh): void;
  34738. /** @hidden */
  34739. removeInstance(instance: InstancedMesh): void;
  34740. }
  34741. }
  34742. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  34743. import { Vector3 } from "babylonjs/Maths/math.vector";
  34744. import { Mesh } from "babylonjs/Meshes/mesh";
  34745. /**
  34746. * The options Interface for creating a Capsule Mesh
  34747. */
  34748. export interface ICreateCapsuleOptions {
  34749. /** The Orientation of the capsule. Default : Vector3.Up() */
  34750. orientation?: Vector3;
  34751. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34752. subdivisions: number;
  34753. /** Number of cylindrical segments on the capsule. */
  34754. tessellation: number;
  34755. /** Height or Length of the capsule. */
  34756. height: number;
  34757. /** Radius of the capsule. */
  34758. radius: number;
  34759. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34760. capSubdivisions: number;
  34761. /** Overwrite for the top radius. */
  34762. radiusTop?: number;
  34763. /** Overwrite for the bottom radius. */
  34764. radiusBottom?: number;
  34765. /** Overwrite for the top capSubdivisions. */
  34766. topCapSubdivisions?: number;
  34767. /** Overwrite for the bottom capSubdivisions. */
  34768. bottomCapSubdivisions?: number;
  34769. }
  34770. /**
  34771. * Class containing static functions to help procedurally build meshes
  34772. */
  34773. export class CapsuleBuilder {
  34774. /**
  34775. * Creates a capsule or a pill mesh
  34776. * @param name defines the name of the mesh
  34777. * @param options The constructors options.
  34778. * @param scene The scene the mesh is scoped to.
  34779. * @returns Capsule Mesh
  34780. */
  34781. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34782. }
  34783. }
  34784. declare module "babylonjs/Meshes/mesh.vertexData" {
  34785. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34786. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34787. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34788. import { Geometry } from "babylonjs/Meshes/geometry";
  34789. import { Mesh } from "babylonjs/Meshes/mesh";
  34790. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34791. /**
  34792. * Define an interface for all classes that will get and set the data on vertices
  34793. */
  34794. export interface IGetSetVerticesData {
  34795. /**
  34796. * Gets a boolean indicating if specific vertex data is present
  34797. * @param kind defines the vertex data kind to use
  34798. * @returns true is data kind is present
  34799. */
  34800. isVerticesDataPresent(kind: string): boolean;
  34801. /**
  34802. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34803. * @param kind defines the data kind (Position, normal, etc...)
  34804. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34805. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34806. * @returns a float array containing vertex data
  34807. */
  34808. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34809. /**
  34810. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34811. * @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.
  34812. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34813. * @returns the indices array or an empty array if the mesh has no geometry
  34814. */
  34815. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34816. /**
  34817. * Set specific vertex data
  34818. * @param kind defines the data kind (Position, normal, etc...)
  34819. * @param data defines the vertex data to use
  34820. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34821. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34822. */
  34823. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34824. /**
  34825. * Update a specific associated vertex buffer
  34826. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34827. * - VertexBuffer.PositionKind
  34828. * - VertexBuffer.UVKind
  34829. * - VertexBuffer.UV2Kind
  34830. * - VertexBuffer.UV3Kind
  34831. * - VertexBuffer.UV4Kind
  34832. * - VertexBuffer.UV5Kind
  34833. * - VertexBuffer.UV6Kind
  34834. * - VertexBuffer.ColorKind
  34835. * - VertexBuffer.MatricesIndicesKind
  34836. * - VertexBuffer.MatricesIndicesExtraKind
  34837. * - VertexBuffer.MatricesWeightsKind
  34838. * - VertexBuffer.MatricesWeightsExtraKind
  34839. * @param data defines the data source
  34840. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34841. * @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)
  34842. */
  34843. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34844. /**
  34845. * Creates a new index buffer
  34846. * @param indices defines the indices to store in the index buffer
  34847. * @param totalVertices defines the total number of vertices (could be null)
  34848. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34849. */
  34850. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34851. }
  34852. /**
  34853. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34854. */
  34855. export class VertexData {
  34856. /**
  34857. * Mesh side orientation : usually the external or front surface
  34858. */
  34859. static readonly FRONTSIDE: number;
  34860. /**
  34861. * Mesh side orientation : usually the internal or back surface
  34862. */
  34863. static readonly BACKSIDE: number;
  34864. /**
  34865. * Mesh side orientation : both internal and external or front and back surfaces
  34866. */
  34867. static readonly DOUBLESIDE: number;
  34868. /**
  34869. * Mesh side orientation : by default, `FRONTSIDE`
  34870. */
  34871. static readonly DEFAULTSIDE: number;
  34872. /**
  34873. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34874. */
  34875. positions: Nullable<FloatArray>;
  34876. /**
  34877. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34878. */
  34879. normals: Nullable<FloatArray>;
  34880. /**
  34881. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34882. */
  34883. tangents: Nullable<FloatArray>;
  34884. /**
  34885. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34886. */
  34887. uvs: Nullable<FloatArray>;
  34888. /**
  34889. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34890. */
  34891. uvs2: Nullable<FloatArray>;
  34892. /**
  34893. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34894. */
  34895. uvs3: Nullable<FloatArray>;
  34896. /**
  34897. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34898. */
  34899. uvs4: Nullable<FloatArray>;
  34900. /**
  34901. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34902. */
  34903. uvs5: Nullable<FloatArray>;
  34904. /**
  34905. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34906. */
  34907. uvs6: Nullable<FloatArray>;
  34908. /**
  34909. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34910. */
  34911. colors: Nullable<FloatArray>;
  34912. /**
  34913. * 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).
  34914. */
  34915. matricesIndices: Nullable<FloatArray>;
  34916. /**
  34917. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34918. */
  34919. matricesWeights: Nullable<FloatArray>;
  34920. /**
  34921. * An array extending the number of possible indices
  34922. */
  34923. matricesIndicesExtra: Nullable<FloatArray>;
  34924. /**
  34925. * An array extending the number of possible weights when the number of indices is extended
  34926. */
  34927. matricesWeightsExtra: Nullable<FloatArray>;
  34928. /**
  34929. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34930. */
  34931. indices: Nullable<IndicesArray>;
  34932. /**
  34933. * Uses the passed data array to set the set the values for the specified kind of data
  34934. * @param data a linear array of floating numbers
  34935. * @param kind the type of data that is being set, eg positions, colors etc
  34936. */
  34937. set(data: FloatArray, kind: string): void;
  34938. /**
  34939. * Associates the vertexData to the passed Mesh.
  34940. * Sets it as updatable or not (default `false`)
  34941. * @param mesh the mesh the vertexData is applied to
  34942. * @param updatable when used and having the value true allows new data to update the vertexData
  34943. * @returns the VertexData
  34944. */
  34945. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34946. /**
  34947. * Associates the vertexData to the passed Geometry.
  34948. * Sets it as updatable or not (default `false`)
  34949. * @param geometry the geometry the vertexData is applied to
  34950. * @param updatable when used and having the value true allows new data to update the vertexData
  34951. * @returns VertexData
  34952. */
  34953. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34954. /**
  34955. * Updates the associated mesh
  34956. * @param mesh the mesh to be updated
  34957. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34958. * @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
  34959. * @returns VertexData
  34960. */
  34961. updateMesh(mesh: Mesh): VertexData;
  34962. /**
  34963. * Updates the associated geometry
  34964. * @param geometry the geometry to be updated
  34965. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34966. * @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
  34967. * @returns VertexData.
  34968. */
  34969. updateGeometry(geometry: Geometry): VertexData;
  34970. private _applyTo;
  34971. private _update;
  34972. /**
  34973. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34974. * @param matrix the transforming matrix
  34975. * @returns the VertexData
  34976. */
  34977. transform(matrix: Matrix): VertexData;
  34978. /**
  34979. * Merges the passed VertexData into the current one
  34980. * @param other the VertexData to be merged into the current one
  34981. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34982. * @returns the modified VertexData
  34983. */
  34984. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34985. private _mergeElement;
  34986. private _validate;
  34987. /**
  34988. * Serializes the VertexData
  34989. * @returns a serialized object
  34990. */
  34991. serialize(): any;
  34992. /**
  34993. * Extracts the vertexData from a mesh
  34994. * @param mesh the mesh from which to extract the VertexData
  34995. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34996. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34997. * @returns the object VertexData associated to the passed mesh
  34998. */
  34999. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35000. /**
  35001. * Extracts the vertexData from the geometry
  35002. * @param geometry the geometry from which to extract the VertexData
  35003. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  35004. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  35005. * @returns the object VertexData associated to the passed mesh
  35006. */
  35007. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  35008. private static _ExtractFrom;
  35009. /**
  35010. * Creates the VertexData for a Ribbon
  35011. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  35012. * * pathArray array of paths, each of which an array of successive Vector3
  35013. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  35014. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  35015. * * 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
  35016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35017. * * 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)
  35018. * * 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)
  35019. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  35020. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  35021. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  35022. * @returns the VertexData of the ribbon
  35023. */
  35024. static CreateRibbon(options: {
  35025. pathArray: Vector3[][];
  35026. closeArray?: boolean;
  35027. closePath?: boolean;
  35028. offset?: number;
  35029. sideOrientation?: number;
  35030. frontUVs?: Vector4;
  35031. backUVs?: Vector4;
  35032. invertUV?: boolean;
  35033. uvs?: Vector2[];
  35034. colors?: Color4[];
  35035. }): VertexData;
  35036. /**
  35037. * Creates the VertexData for a box
  35038. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35039. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35040. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35041. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35042. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35043. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35044. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35046. * * 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)
  35047. * * 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)
  35048. * @returns the VertexData of the box
  35049. */
  35050. static CreateBox(options: {
  35051. size?: number;
  35052. width?: number;
  35053. height?: number;
  35054. depth?: number;
  35055. faceUV?: Vector4[];
  35056. faceColors?: Color4[];
  35057. sideOrientation?: number;
  35058. frontUVs?: Vector4;
  35059. backUVs?: Vector4;
  35060. }): VertexData;
  35061. /**
  35062. * Creates the VertexData for a tiled box
  35063. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35064. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35065. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35066. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35068. * @returns the VertexData of the box
  35069. */
  35070. static CreateTiledBox(options: {
  35071. pattern?: number;
  35072. width?: number;
  35073. height?: number;
  35074. depth?: number;
  35075. tileSize?: number;
  35076. tileWidth?: number;
  35077. tileHeight?: number;
  35078. alignHorizontal?: number;
  35079. alignVertical?: number;
  35080. faceUV?: Vector4[];
  35081. faceColors?: Color4[];
  35082. sideOrientation?: number;
  35083. }): VertexData;
  35084. /**
  35085. * Creates the VertexData for a tiled plane
  35086. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35087. * * pattern a limited pattern arrangement depending on the number
  35088. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35089. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35090. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35091. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35092. * * 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)
  35093. * * 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)
  35094. * @returns the VertexData of the tiled plane
  35095. */
  35096. static CreateTiledPlane(options: {
  35097. pattern?: number;
  35098. tileSize?: number;
  35099. tileWidth?: number;
  35100. tileHeight?: number;
  35101. size?: number;
  35102. width?: number;
  35103. height?: number;
  35104. alignHorizontal?: number;
  35105. alignVertical?: number;
  35106. sideOrientation?: number;
  35107. frontUVs?: Vector4;
  35108. backUVs?: Vector4;
  35109. }): VertexData;
  35110. /**
  35111. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35112. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35113. * * segments sets the number of horizontal strips optional, default 32
  35114. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35115. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35116. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35117. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35118. * * 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
  35119. * * 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
  35120. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35121. * * 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)
  35122. * * 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)
  35123. * @returns the VertexData of the ellipsoid
  35124. */
  35125. static CreateSphere(options: {
  35126. segments?: number;
  35127. diameter?: number;
  35128. diameterX?: number;
  35129. diameterY?: number;
  35130. diameterZ?: number;
  35131. arc?: number;
  35132. slice?: number;
  35133. sideOrientation?: number;
  35134. frontUVs?: Vector4;
  35135. backUVs?: Vector4;
  35136. }): VertexData;
  35137. /**
  35138. * Creates the VertexData for a cylinder, cone or prism
  35139. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35140. * * height sets the height (y direction) of the cylinder, optional, default 2
  35141. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35142. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35143. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35144. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35145. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35146. * * 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
  35147. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35148. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35149. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35150. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35151. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35152. * * 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)
  35153. * * 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)
  35154. * @returns the VertexData of the cylinder, cone or prism
  35155. */
  35156. static CreateCylinder(options: {
  35157. height?: number;
  35158. diameterTop?: number;
  35159. diameterBottom?: number;
  35160. diameter?: number;
  35161. tessellation?: number;
  35162. subdivisions?: number;
  35163. arc?: number;
  35164. faceColors?: Color4[];
  35165. faceUV?: Vector4[];
  35166. hasRings?: boolean;
  35167. enclose?: boolean;
  35168. sideOrientation?: number;
  35169. frontUVs?: Vector4;
  35170. backUVs?: Vector4;
  35171. }): VertexData;
  35172. /**
  35173. * Creates the VertexData for a torus
  35174. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35175. * * diameter the diameter of the torus, optional default 1
  35176. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35177. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35178. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35179. * * 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)
  35180. * * 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)
  35181. * @returns the VertexData of the torus
  35182. */
  35183. static CreateTorus(options: {
  35184. diameter?: number;
  35185. thickness?: number;
  35186. tessellation?: number;
  35187. sideOrientation?: number;
  35188. frontUVs?: Vector4;
  35189. backUVs?: Vector4;
  35190. }): VertexData;
  35191. /**
  35192. * Creates the VertexData of the LineSystem
  35193. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35194. * - lines an array of lines, each line being an array of successive Vector3
  35195. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35196. * @returns the VertexData of the LineSystem
  35197. */
  35198. static CreateLineSystem(options: {
  35199. lines: Vector3[][];
  35200. colors?: Nullable<Color4[][]>;
  35201. }): VertexData;
  35202. /**
  35203. * Create the VertexData for a DashedLines
  35204. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35205. * - points an array successive Vector3
  35206. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35207. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35208. * - dashNb the intended total number of dashes, optional, default 200
  35209. * @returns the VertexData for the DashedLines
  35210. */
  35211. static CreateDashedLines(options: {
  35212. points: Vector3[];
  35213. dashSize?: number;
  35214. gapSize?: number;
  35215. dashNb?: number;
  35216. }): VertexData;
  35217. /**
  35218. * Creates the VertexData for a Ground
  35219. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35220. * - width the width (x direction) of the ground, optional, default 1
  35221. * - height the height (z direction) of the ground, optional, default 1
  35222. * - subdivisions the number of subdivisions per side, optional, default 1
  35223. * @returns the VertexData of the Ground
  35224. */
  35225. static CreateGround(options: {
  35226. width?: number;
  35227. height?: number;
  35228. subdivisions?: number;
  35229. subdivisionsX?: number;
  35230. subdivisionsY?: number;
  35231. }): VertexData;
  35232. /**
  35233. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35234. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35235. * * xmin the ground minimum X coordinate, optional, default -1
  35236. * * zmin the ground minimum Z coordinate, optional, default -1
  35237. * * xmax the ground maximum X coordinate, optional, default 1
  35238. * * zmax the ground maximum Z coordinate, optional, default 1
  35239. * * 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}
  35240. * * 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}
  35241. * @returns the VertexData of the TiledGround
  35242. */
  35243. static CreateTiledGround(options: {
  35244. xmin: number;
  35245. zmin: number;
  35246. xmax: number;
  35247. zmax: number;
  35248. subdivisions?: {
  35249. w: number;
  35250. h: number;
  35251. };
  35252. precision?: {
  35253. w: number;
  35254. h: number;
  35255. };
  35256. }): VertexData;
  35257. /**
  35258. * Creates the VertexData of the Ground designed from a heightmap
  35259. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35260. * * width the width (x direction) of the ground
  35261. * * height the height (z direction) of the ground
  35262. * * subdivisions the number of subdivisions per side
  35263. * * minHeight the minimum altitude on the ground, optional, default 0
  35264. * * maxHeight the maximum altitude on the ground, optional default 1
  35265. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35266. * * buffer the array holding the image color data
  35267. * * bufferWidth the width of image
  35268. * * bufferHeight the height of image
  35269. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35270. * @returns the VertexData of the Ground designed from a heightmap
  35271. */
  35272. static CreateGroundFromHeightMap(options: {
  35273. width: number;
  35274. height: number;
  35275. subdivisions: number;
  35276. minHeight: number;
  35277. maxHeight: number;
  35278. colorFilter: Color3;
  35279. buffer: Uint8Array;
  35280. bufferWidth: number;
  35281. bufferHeight: number;
  35282. alphaFilter: number;
  35283. }): VertexData;
  35284. /**
  35285. * Creates the VertexData for a Plane
  35286. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35287. * * size sets the width and height of the plane to the value of size, optional default 1
  35288. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35289. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35291. * * 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)
  35292. * * 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)
  35293. * @returns the VertexData of the box
  35294. */
  35295. static CreatePlane(options: {
  35296. size?: number;
  35297. width?: number;
  35298. height?: number;
  35299. sideOrientation?: number;
  35300. frontUVs?: Vector4;
  35301. backUVs?: Vector4;
  35302. }): VertexData;
  35303. /**
  35304. * Creates the VertexData of the Disc or regular Polygon
  35305. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35306. * * radius the radius of the disc, optional default 0.5
  35307. * * tessellation the number of polygon sides, optional, default 64
  35308. * * 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
  35309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35310. * * 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)
  35311. * * 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)
  35312. * @returns the VertexData of the box
  35313. */
  35314. static CreateDisc(options: {
  35315. radius?: number;
  35316. tessellation?: number;
  35317. arc?: number;
  35318. sideOrientation?: number;
  35319. frontUVs?: Vector4;
  35320. backUVs?: Vector4;
  35321. }): VertexData;
  35322. /**
  35323. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35324. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35325. * @param polygon a mesh built from polygonTriangulation.build()
  35326. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35327. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35328. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35329. * @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)
  35330. * @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)
  35331. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35332. * @returns the VertexData of the Polygon
  35333. */
  35334. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35335. /**
  35336. * Creates the VertexData of the IcoSphere
  35337. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35338. * * radius the radius of the IcoSphere, optional default 1
  35339. * * radiusX allows stretching in the x direction, optional, default radius
  35340. * * radiusY allows stretching in the y direction, optional, default radius
  35341. * * radiusZ allows stretching in the z direction, optional, default radius
  35342. * * flat when true creates a flat shaded mesh, optional, default true
  35343. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35345. * * 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)
  35346. * * 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)
  35347. * @returns the VertexData of the IcoSphere
  35348. */
  35349. static CreateIcoSphere(options: {
  35350. radius?: number;
  35351. radiusX?: number;
  35352. radiusY?: number;
  35353. radiusZ?: number;
  35354. flat?: boolean;
  35355. subdivisions?: number;
  35356. sideOrientation?: number;
  35357. frontUVs?: Vector4;
  35358. backUVs?: Vector4;
  35359. }): VertexData;
  35360. /**
  35361. * Creates the VertexData for a Polyhedron
  35362. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35363. * * type provided types are:
  35364. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35365. * * 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)
  35366. * * size the size of the IcoSphere, optional default 1
  35367. * * sizeX allows stretching in the x direction, optional, default size
  35368. * * sizeY allows stretching in the y direction, optional, default size
  35369. * * sizeZ allows stretching in the z direction, optional, default size
  35370. * * 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
  35371. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35372. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35373. * * flat when true creates a flat shaded mesh, optional, default true
  35374. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35375. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35376. * * 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)
  35377. * * 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)
  35378. * @returns the VertexData of the Polyhedron
  35379. */
  35380. static CreatePolyhedron(options: {
  35381. type?: number;
  35382. size?: number;
  35383. sizeX?: number;
  35384. sizeY?: number;
  35385. sizeZ?: number;
  35386. custom?: any;
  35387. faceUV?: Vector4[];
  35388. faceColors?: Color4[];
  35389. flat?: boolean;
  35390. sideOrientation?: number;
  35391. frontUVs?: Vector4;
  35392. backUVs?: Vector4;
  35393. }): VertexData;
  35394. /**
  35395. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35396. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35397. * @returns the VertexData of the Capsule
  35398. */
  35399. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35400. /**
  35401. * Creates the VertexData for a TorusKnot
  35402. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35403. * * radius the radius of the torus knot, optional, default 2
  35404. * * tube the thickness of the tube, optional, default 0.5
  35405. * * radialSegments the number of sides on each tube segments, optional, default 32
  35406. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35407. * * p the number of windings around the z axis, optional, default 2
  35408. * * q the number of windings around the x axis, optional, default 3
  35409. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35410. * * 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)
  35411. * * 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)
  35412. * @returns the VertexData of the Torus Knot
  35413. */
  35414. static CreateTorusKnot(options: {
  35415. radius?: number;
  35416. tube?: number;
  35417. radialSegments?: number;
  35418. tubularSegments?: number;
  35419. p?: number;
  35420. q?: number;
  35421. sideOrientation?: number;
  35422. frontUVs?: Vector4;
  35423. backUVs?: Vector4;
  35424. }): VertexData;
  35425. /**
  35426. * Compute normals for given positions and indices
  35427. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35428. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35429. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35430. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35431. * * facetNormals : optional array of facet normals (vector3)
  35432. * * facetPositions : optional array of facet positions (vector3)
  35433. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35434. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35435. * * bInfo : optional bounding info, required for facetPartitioning computation
  35436. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35437. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  35438. * * useRightHandedSystem: optional boolean to for right handed system computation
  35439. * * depthSort : optional boolean to enable the facet depth sort computation
  35440. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35441. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35442. */
  35443. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35444. facetNormals?: any;
  35445. facetPositions?: any;
  35446. facetPartitioning?: any;
  35447. ratio?: number;
  35448. bInfo?: any;
  35449. bbSize?: Vector3;
  35450. subDiv?: any;
  35451. useRightHandedSystem?: boolean;
  35452. depthSort?: boolean;
  35453. distanceTo?: Vector3;
  35454. depthSortedFacets?: any;
  35455. }): void;
  35456. /** @hidden */
  35457. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35458. /**
  35459. * Applies VertexData created from the imported parameters to the geometry
  35460. * @param parsedVertexData the parsed data from an imported file
  35461. * @param geometry the geometry to apply the VertexData to
  35462. */
  35463. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35464. }
  35465. }
  35466. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35467. import { Nullable } from "babylonjs/types";
  35468. import { Scene } from "babylonjs/scene";
  35469. import { Vector4 } from "babylonjs/Maths/math.vector";
  35470. import { Mesh } from "babylonjs/Meshes/mesh";
  35471. /**
  35472. * Class containing static functions to help procedurally build meshes
  35473. */
  35474. export class DiscBuilder {
  35475. /**
  35476. * Creates a plane polygonal mesh. By default, this is a disc
  35477. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35478. * * 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
  35479. * * 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
  35480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35483. * @param name defines the name of the mesh
  35484. * @param options defines the options used to create the mesh
  35485. * @param scene defines the hosting scene
  35486. * @returns the plane polygonal mesh
  35487. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35488. */
  35489. static CreateDisc(name: string, options: {
  35490. radius?: number;
  35491. tessellation?: number;
  35492. arc?: number;
  35493. updatable?: boolean;
  35494. sideOrientation?: number;
  35495. frontUVs?: Vector4;
  35496. backUVs?: Vector4;
  35497. }, scene?: Nullable<Scene>): Mesh;
  35498. }
  35499. }
  35500. declare module "babylonjs/Particles/solidParticleSystem" {
  35501. import { Nullable } from "babylonjs/types";
  35502. import { Mesh } from "babylonjs/Meshes/mesh";
  35503. import { Scene, IDisposable } from "babylonjs/scene";
  35504. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35505. import { Material } from "babylonjs/Materials/material";
  35506. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35507. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35508. /**
  35509. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35510. *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.
  35511. * The SPS is also a particle system. It provides some methods to manage the particles.
  35512. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35513. *
  35514. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35515. */
  35516. export class SolidParticleSystem implements IDisposable {
  35517. /**
  35518. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35519. * Example : var p = SPS.particles[i];
  35520. */
  35521. particles: SolidParticle[];
  35522. /**
  35523. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35524. */
  35525. nbParticles: number;
  35526. /**
  35527. * If the particles must ever face the camera (default false). Useful for planar particles.
  35528. */
  35529. billboard: boolean;
  35530. /**
  35531. * Recompute normals when adding a shape
  35532. */
  35533. recomputeNormals: boolean;
  35534. /**
  35535. * This a counter ofr your own usage. It's not set by any SPS functions.
  35536. */
  35537. counter: number;
  35538. /**
  35539. * The SPS name. This name is also given to the underlying mesh.
  35540. */
  35541. name: string;
  35542. /**
  35543. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35544. */
  35545. mesh: Mesh;
  35546. /**
  35547. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35548. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35549. */
  35550. vars: any;
  35551. /**
  35552. * This array is populated when the SPS is set as 'pickable'.
  35553. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35554. * Each element of this array is an object `{idx: int, faceId: int}`.
  35555. * `idx` is the picked particle index in the `SPS.particles` array
  35556. * `faceId` is the picked face index counted within this particle.
  35557. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35558. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35559. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35560. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35561. */
  35562. pickedParticles: {
  35563. idx: number;
  35564. faceId: number;
  35565. }[];
  35566. /**
  35567. * This array is populated when the SPS is set as 'pickable'
  35568. * Each key of this array is a submesh index.
  35569. * Each element of this array is a second array defined like this :
  35570. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35571. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35572. * `idx` is the picked particle index in the `SPS.particles` array
  35573. * `faceId` is the picked face index counted within this particle.
  35574. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35575. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35576. */
  35577. pickedBySubMesh: {
  35578. idx: number;
  35579. faceId: number;
  35580. }[][];
  35581. /**
  35582. * This array is populated when `enableDepthSort` is set to true.
  35583. * Each element of this array is an instance of the class DepthSortedParticle.
  35584. */
  35585. depthSortedParticles: DepthSortedParticle[];
  35586. /**
  35587. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35588. * @hidden
  35589. */
  35590. _bSphereOnly: boolean;
  35591. /**
  35592. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35593. * @hidden
  35594. */
  35595. _bSphereRadiusFactor: number;
  35596. private _scene;
  35597. private _positions;
  35598. private _indices;
  35599. private _normals;
  35600. private _colors;
  35601. private _uvs;
  35602. private _indices32;
  35603. private _positions32;
  35604. private _normals32;
  35605. private _fixedNormal32;
  35606. private _colors32;
  35607. private _uvs32;
  35608. private _index;
  35609. private _updatable;
  35610. private _pickable;
  35611. private _isVisibilityBoxLocked;
  35612. private _alwaysVisible;
  35613. private _depthSort;
  35614. private _expandable;
  35615. private _shapeCounter;
  35616. private _copy;
  35617. private _color;
  35618. private _computeParticleColor;
  35619. private _computeParticleTexture;
  35620. private _computeParticleRotation;
  35621. private _computeParticleVertex;
  35622. private _computeBoundingBox;
  35623. private _depthSortParticles;
  35624. private _camera;
  35625. private _mustUnrotateFixedNormals;
  35626. private _particlesIntersect;
  35627. private _needs32Bits;
  35628. private _isNotBuilt;
  35629. private _lastParticleId;
  35630. private _idxOfId;
  35631. private _multimaterialEnabled;
  35632. private _useModelMaterial;
  35633. private _indicesByMaterial;
  35634. private _materialIndexes;
  35635. private _depthSortFunction;
  35636. private _materialSortFunction;
  35637. private _materials;
  35638. private _multimaterial;
  35639. private _materialIndexesById;
  35640. private _defaultMaterial;
  35641. private _autoUpdateSubMeshes;
  35642. private _tmpVertex;
  35643. /**
  35644. * Creates a SPS (Solid Particle System) object.
  35645. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35646. * @param scene (Scene) is the scene in which the SPS is added.
  35647. * @param options defines the options of the sps e.g.
  35648. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35649. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35650. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35651. * * 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.
  35652. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35653. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35654. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35655. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35656. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35657. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35658. */
  35659. constructor(name: string, scene: Scene, options?: {
  35660. updatable?: boolean;
  35661. isPickable?: boolean;
  35662. enableDepthSort?: boolean;
  35663. particleIntersection?: boolean;
  35664. boundingSphereOnly?: boolean;
  35665. bSphereRadiusFactor?: number;
  35666. expandable?: boolean;
  35667. useModelMaterial?: boolean;
  35668. enableMultiMaterial?: boolean;
  35669. });
  35670. /**
  35671. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35672. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35673. * @returns the created mesh
  35674. */
  35675. buildMesh(): Mesh;
  35676. /**
  35677. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35678. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35679. * Thus the particles generated from `digest()` have their property `position` set yet.
  35680. * @param mesh ( Mesh ) is the mesh to be digested
  35681. * @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
  35682. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35683. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35684. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35685. * @returns the current SPS
  35686. */
  35687. digest(mesh: Mesh, options?: {
  35688. facetNb?: number;
  35689. number?: number;
  35690. delta?: number;
  35691. storage?: [];
  35692. }): SolidParticleSystem;
  35693. /**
  35694. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35695. * @hidden
  35696. */
  35697. private _unrotateFixedNormals;
  35698. /**
  35699. * Resets the temporary working copy particle
  35700. * @hidden
  35701. */
  35702. private _resetCopy;
  35703. /**
  35704. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35705. * @param p the current index in the positions array to be updated
  35706. * @param ind the current index in the indices array
  35707. * @param shape a Vector3 array, the shape geometry
  35708. * @param positions the positions array to be updated
  35709. * @param meshInd the shape indices array
  35710. * @param indices the indices array to be updated
  35711. * @param meshUV the shape uv array
  35712. * @param uvs the uv array to be updated
  35713. * @param meshCol the shape color array
  35714. * @param colors the color array to be updated
  35715. * @param meshNor the shape normals array
  35716. * @param normals the normals array to be updated
  35717. * @param idx the particle index
  35718. * @param idxInShape the particle index in its shape
  35719. * @param options the addShape() method passed options
  35720. * @model the particle model
  35721. * @hidden
  35722. */
  35723. private _meshBuilder;
  35724. /**
  35725. * Returns a shape Vector3 array from positions float array
  35726. * @param positions float array
  35727. * @returns a vector3 array
  35728. * @hidden
  35729. */
  35730. private _posToShape;
  35731. /**
  35732. * Returns a shapeUV array from a float uvs (array deep copy)
  35733. * @param uvs as a float array
  35734. * @returns a shapeUV array
  35735. * @hidden
  35736. */
  35737. private _uvsToShapeUV;
  35738. /**
  35739. * Adds a new particle object in the particles array
  35740. * @param idx particle index in particles array
  35741. * @param id particle id
  35742. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35743. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35744. * @param model particle ModelShape object
  35745. * @param shapeId model shape identifier
  35746. * @param idxInShape index of the particle in the current model
  35747. * @param bInfo model bounding info object
  35748. * @param storage target storage array, if any
  35749. * @hidden
  35750. */
  35751. private _addParticle;
  35752. /**
  35753. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35754. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35755. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35756. * @param nb (positive integer) the number of particles to be created from this model
  35757. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35758. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35759. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35760. * @returns the number of shapes in the system
  35761. */
  35762. addShape(mesh: Mesh, nb: number, options?: {
  35763. positionFunction?: any;
  35764. vertexFunction?: any;
  35765. storage?: [];
  35766. }): number;
  35767. /**
  35768. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35769. * @hidden
  35770. */
  35771. private _rebuildParticle;
  35772. /**
  35773. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35774. * @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.
  35775. * @returns the SPS.
  35776. */
  35777. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35778. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35779. * Returns an array with the removed particles.
  35780. * 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.
  35781. * The SPS can't be empty so at least one particle needs to remain in place.
  35782. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35783. * @param start index of the first particle to remove
  35784. * @param end index of the last particle to remove (included)
  35785. * @returns an array populated with the removed particles
  35786. */
  35787. removeParticles(start: number, end: number): SolidParticle[];
  35788. /**
  35789. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35790. * @param solidParticleArray an array populated with Solid Particles objects
  35791. * @returns the SPS
  35792. */
  35793. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35794. /**
  35795. * Creates a new particle and modifies the SPS mesh geometry :
  35796. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35797. * - calls _addParticle() to populate the particle array
  35798. * factorized code from addShape() and insertParticlesFromArray()
  35799. * @param idx particle index in the particles array
  35800. * @param i particle index in its shape
  35801. * @param modelShape particle ModelShape object
  35802. * @param shape shape vertex array
  35803. * @param meshInd shape indices array
  35804. * @param meshUV shape uv array
  35805. * @param meshCol shape color array
  35806. * @param meshNor shape normals array
  35807. * @param bbInfo shape bounding info
  35808. * @param storage target particle storage
  35809. * @options addShape() passed options
  35810. * @hidden
  35811. */
  35812. private _insertNewParticle;
  35813. /**
  35814. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35815. * This method calls `updateParticle()` for each particle of the SPS.
  35816. * For an animated SPS, it is usually called within the render loop.
  35817. * 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.
  35818. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35819. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35820. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35821. * @returns the SPS.
  35822. */
  35823. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35824. /**
  35825. * Disposes the SPS.
  35826. */
  35827. dispose(): void;
  35828. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35829. * idx is the particle index in the SPS
  35830. * faceId is the picked face index counted within this particle.
  35831. * Returns null if the pickInfo can't identify a picked particle.
  35832. * @param pickingInfo (PickingInfo object)
  35833. * @returns {idx: number, faceId: number} or null
  35834. */
  35835. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35836. idx: number;
  35837. faceId: number;
  35838. }>;
  35839. /**
  35840. * Returns a SolidParticle object from its identifier : particle.id
  35841. * @param id (integer) the particle Id
  35842. * @returns the searched particle or null if not found in the SPS.
  35843. */
  35844. getParticleById(id: number): Nullable<SolidParticle>;
  35845. /**
  35846. * Returns a new array populated with the particles having the passed shapeId.
  35847. * @param shapeId (integer) the shape identifier
  35848. * @returns a new solid particle array
  35849. */
  35850. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35851. /**
  35852. * Populates the passed array "ref" with the particles having the passed shapeId.
  35853. * @param shapeId the shape identifier
  35854. * @returns the SPS
  35855. * @param ref
  35856. */
  35857. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35858. /**
  35859. * Computes the required SubMeshes according the materials assigned to the particles.
  35860. * @returns the solid particle system.
  35861. * Does nothing if called before the SPS mesh is built.
  35862. */
  35863. computeSubMeshes(): SolidParticleSystem;
  35864. /**
  35865. * Sorts the solid particles by material when MultiMaterial is enabled.
  35866. * Updates the indices32 array.
  35867. * Updates the indicesByMaterial array.
  35868. * Updates the mesh indices array.
  35869. * @returns the SPS
  35870. * @hidden
  35871. */
  35872. private _sortParticlesByMaterial;
  35873. /**
  35874. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35875. * @hidden
  35876. */
  35877. private _setMaterialIndexesById;
  35878. /**
  35879. * Returns an array with unique values of Materials from the passed array
  35880. * @param array the material array to be checked and filtered
  35881. * @hidden
  35882. */
  35883. private _filterUniqueMaterialId;
  35884. /**
  35885. * Sets a new Standard Material as _defaultMaterial if not already set.
  35886. * @hidden
  35887. */
  35888. private _setDefaultMaterial;
  35889. /**
  35890. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35891. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35892. * @returns the SPS.
  35893. */
  35894. refreshVisibleSize(): SolidParticleSystem;
  35895. /**
  35896. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35897. * @param size the size (float) of the visibility box
  35898. * note : this doesn't lock the SPS mesh bounding box.
  35899. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35900. */
  35901. setVisibilityBox(size: number): void;
  35902. /**
  35903. * Gets whether the SPS as always visible or not
  35904. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35905. */
  35906. get isAlwaysVisible(): boolean;
  35907. /**
  35908. * Sets the SPS as always visible or not
  35909. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35910. */
  35911. set isAlwaysVisible(val: boolean);
  35912. /**
  35913. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35914. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35915. */
  35916. set isVisibilityBoxLocked(val: boolean);
  35917. /**
  35918. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35919. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35920. */
  35921. get isVisibilityBoxLocked(): boolean;
  35922. /**
  35923. * Tells to `setParticles()` to compute the particle rotations or not.
  35924. * Default value : true. The SPS is faster when it's set to false.
  35925. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35926. */
  35927. set computeParticleRotation(val: boolean);
  35928. /**
  35929. * Tells to `setParticles()` to compute the particle colors or not.
  35930. * Default value : true. The SPS is faster when it's set to false.
  35931. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35932. */
  35933. set computeParticleColor(val: boolean);
  35934. set computeParticleTexture(val: boolean);
  35935. /**
  35936. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35937. * Default value : false. The SPS is faster when it's set to false.
  35938. * Note : the particle custom vertex positions aren't stored values.
  35939. */
  35940. set computeParticleVertex(val: boolean);
  35941. /**
  35942. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35943. */
  35944. set computeBoundingBox(val: boolean);
  35945. /**
  35946. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35947. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35948. * Default : `true`
  35949. */
  35950. set depthSortParticles(val: boolean);
  35951. /**
  35952. * Gets if `setParticles()` computes the particle rotations or not.
  35953. * Default value : true. The SPS is faster when it's set to false.
  35954. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35955. */
  35956. get computeParticleRotation(): boolean;
  35957. /**
  35958. * Gets if `setParticles()` computes the particle colors or not.
  35959. * Default value : true. The SPS is faster when it's set to false.
  35960. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35961. */
  35962. get computeParticleColor(): boolean;
  35963. /**
  35964. * Gets if `setParticles()` computes the particle textures or not.
  35965. * Default value : true. The SPS is faster when it's set to false.
  35966. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35967. */
  35968. get computeParticleTexture(): boolean;
  35969. /**
  35970. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35971. * Default value : false. The SPS is faster when it's set to false.
  35972. * Note : the particle custom vertex positions aren't stored values.
  35973. */
  35974. get computeParticleVertex(): boolean;
  35975. /**
  35976. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35977. */
  35978. get computeBoundingBox(): boolean;
  35979. /**
  35980. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35981. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35982. * Default : `true`
  35983. */
  35984. get depthSortParticles(): boolean;
  35985. /**
  35986. * Gets if the SPS is created as expandable at construction time.
  35987. * Default : `false`
  35988. */
  35989. get expandable(): boolean;
  35990. /**
  35991. * Gets if the SPS supports the Multi Materials
  35992. */
  35993. get multimaterialEnabled(): boolean;
  35994. /**
  35995. * Gets if the SPS uses the model materials for its own multimaterial.
  35996. */
  35997. get useModelMaterial(): boolean;
  35998. /**
  35999. * The SPS used material array.
  36000. */
  36001. get materials(): Material[];
  36002. /**
  36003. * Sets the SPS MultiMaterial from the passed materials.
  36004. * Note : the passed array is internally copied and not used then by reference.
  36005. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36006. */
  36007. setMultiMaterial(materials: Material[]): void;
  36008. /**
  36009. * The SPS computed multimaterial object
  36010. */
  36011. get multimaterial(): MultiMaterial;
  36012. set multimaterial(mm: MultiMaterial);
  36013. /**
  36014. * If the subMeshes must be updated on the next call to setParticles()
  36015. */
  36016. get autoUpdateSubMeshes(): boolean;
  36017. set autoUpdateSubMeshes(val: boolean);
  36018. /**
  36019. * This function does nothing. It may be overwritten to set all the particle first values.
  36020. * The SPS doesn't call this function, you may have to call it by your own.
  36021. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36022. */
  36023. initParticles(): void;
  36024. /**
  36025. * This function does nothing. It may be overwritten to recycle a particle.
  36026. * The SPS doesn't call this function, you may have to call it by your own.
  36027. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36028. * @param particle The particle to recycle
  36029. * @returns the recycled particle
  36030. */
  36031. recycleParticle(particle: SolidParticle): SolidParticle;
  36032. /**
  36033. * Updates a particle : this function should be overwritten by the user.
  36034. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36035. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36036. * @example : just set a particle position or velocity and recycle conditions
  36037. * @param particle The particle to update
  36038. * @returns the updated particle
  36039. */
  36040. updateParticle(particle: SolidParticle): SolidParticle;
  36041. /**
  36042. * Updates a vertex of a particle : it can be overwritten by the user.
  36043. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36044. * @param particle the current particle
  36045. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36046. * @param pt the index of the current vertex in the particle shape
  36047. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36048. * @example : just set a vertex particle position or color
  36049. * @returns the sps
  36050. */
  36051. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36052. /**
  36053. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36054. * This does nothing and may be overwritten by the user.
  36055. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36056. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36057. * @param update the boolean update value actually passed to setParticles()
  36058. */
  36059. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36060. /**
  36061. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36062. * This will be passed three parameters.
  36063. * This does nothing and may be overwritten by the user.
  36064. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36065. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36066. * @param update the boolean update value actually passed to setParticles()
  36067. */
  36068. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36069. }
  36070. }
  36071. declare module "babylonjs/Particles/solidParticle" {
  36072. import { Nullable } from "babylonjs/types";
  36073. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36074. import { Color4 } from "babylonjs/Maths/math.color";
  36075. import { Mesh } from "babylonjs/Meshes/mesh";
  36076. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36077. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36078. import { Plane } from "babylonjs/Maths/math.plane";
  36079. import { Material } from "babylonjs/Materials/material";
  36080. /**
  36081. * Represents one particle of a solid particle system.
  36082. */
  36083. export class SolidParticle {
  36084. /**
  36085. * particle global index
  36086. */
  36087. idx: number;
  36088. /**
  36089. * particle identifier
  36090. */
  36091. id: number;
  36092. /**
  36093. * The color of the particle
  36094. */
  36095. color: Nullable<Color4>;
  36096. /**
  36097. * The world space position of the particle.
  36098. */
  36099. position: Vector3;
  36100. /**
  36101. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36102. */
  36103. rotation: Vector3;
  36104. /**
  36105. * The world space rotation quaternion of the particle.
  36106. */
  36107. rotationQuaternion: Nullable<Quaternion>;
  36108. /**
  36109. * The scaling of the particle.
  36110. */
  36111. scaling: Vector3;
  36112. /**
  36113. * The uvs of the particle.
  36114. */
  36115. uvs: Vector4;
  36116. /**
  36117. * The current speed of the particle.
  36118. */
  36119. velocity: Vector3;
  36120. /**
  36121. * The pivot point in the particle local space.
  36122. */
  36123. pivot: Vector3;
  36124. /**
  36125. * Must the particle be translated from its pivot point in its local space ?
  36126. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36127. * Default : false
  36128. */
  36129. translateFromPivot: boolean;
  36130. /**
  36131. * Is the particle active or not ?
  36132. */
  36133. alive: boolean;
  36134. /**
  36135. * Is the particle visible or not ?
  36136. */
  36137. isVisible: boolean;
  36138. /**
  36139. * Index of this particle in the global "positions" array (Internal use)
  36140. * @hidden
  36141. */
  36142. _pos: number;
  36143. /**
  36144. * @hidden Index of this particle in the global "indices" array (Internal use)
  36145. */
  36146. _ind: number;
  36147. /**
  36148. * @hidden ModelShape of this particle (Internal use)
  36149. */
  36150. _model: ModelShape;
  36151. /**
  36152. * ModelShape id of this particle
  36153. */
  36154. shapeId: number;
  36155. /**
  36156. * Index of the particle in its shape id
  36157. */
  36158. idxInShape: number;
  36159. /**
  36160. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36161. */
  36162. _modelBoundingInfo: BoundingInfo;
  36163. /**
  36164. * @hidden Particle BoundingInfo object (Internal use)
  36165. */
  36166. _boundingInfo: BoundingInfo;
  36167. /**
  36168. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36169. */
  36170. _sps: SolidParticleSystem;
  36171. /**
  36172. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36173. */
  36174. _stillInvisible: boolean;
  36175. /**
  36176. * @hidden Last computed particle rotation matrix
  36177. */
  36178. _rotationMatrix: number[];
  36179. /**
  36180. * Parent particle Id, if any.
  36181. * Default null.
  36182. */
  36183. parentId: Nullable<number>;
  36184. /**
  36185. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36186. */
  36187. materialIndex: Nullable<number>;
  36188. /**
  36189. * Custom object or properties.
  36190. */
  36191. props: Nullable<any>;
  36192. /**
  36193. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36194. * The possible values are :
  36195. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36196. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36197. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36198. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36199. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36200. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36201. * */
  36202. cullingStrategy: number;
  36203. /**
  36204. * @hidden Internal global position in the SPS.
  36205. */
  36206. _globalPosition: Vector3;
  36207. /**
  36208. * Creates a Solid Particle object.
  36209. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36210. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36211. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36212. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36213. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36214. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36215. * @param shapeId (integer) is the model shape identifier in the SPS.
  36216. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36217. * @param sps defines the sps it is associated to
  36218. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36219. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36220. */
  36221. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36222. /**
  36223. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36224. * @param target the particle target
  36225. * @returns the current particle
  36226. */
  36227. copyToRef(target: SolidParticle): SolidParticle;
  36228. /**
  36229. * Legacy support, changed scale to scaling
  36230. */
  36231. get scale(): Vector3;
  36232. /**
  36233. * Legacy support, changed scale to scaling
  36234. */
  36235. set scale(scale: Vector3);
  36236. /**
  36237. * Legacy support, changed quaternion to rotationQuaternion
  36238. */
  36239. get quaternion(): Nullable<Quaternion>;
  36240. /**
  36241. * Legacy support, changed quaternion to rotationQuaternion
  36242. */
  36243. set quaternion(q: Nullable<Quaternion>);
  36244. /**
  36245. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36246. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36247. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36248. * @returns true if it intersects
  36249. */
  36250. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36251. /**
  36252. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36253. * A particle is in the frustum if its bounding box intersects the frustum
  36254. * @param frustumPlanes defines the frustum to test
  36255. * @returns true if the particle is in the frustum planes
  36256. */
  36257. isInFrustum(frustumPlanes: Plane[]): boolean;
  36258. /**
  36259. * get the rotation matrix of the particle
  36260. * @hidden
  36261. */
  36262. getRotationMatrix(m: Matrix): void;
  36263. }
  36264. /**
  36265. * Represents the shape of the model used by one particle of a solid particle system.
  36266. * SPS internal tool, don't use it manually.
  36267. */
  36268. export class ModelShape {
  36269. /**
  36270. * The shape id
  36271. * @hidden
  36272. */
  36273. shapeID: number;
  36274. /**
  36275. * flat array of model positions (internal use)
  36276. * @hidden
  36277. */
  36278. _shape: Vector3[];
  36279. /**
  36280. * flat array of model UVs (internal use)
  36281. * @hidden
  36282. */
  36283. _shapeUV: number[];
  36284. /**
  36285. * color array of the model
  36286. * @hidden
  36287. */
  36288. _shapeColors: number[];
  36289. /**
  36290. * indices array of the model
  36291. * @hidden
  36292. */
  36293. _indices: number[];
  36294. /**
  36295. * normals array of the model
  36296. * @hidden
  36297. */
  36298. _normals: number[];
  36299. /**
  36300. * length of the shape in the model indices array (internal use)
  36301. * @hidden
  36302. */
  36303. _indicesLength: number;
  36304. /**
  36305. * Custom position function (internal use)
  36306. * @hidden
  36307. */
  36308. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36309. /**
  36310. * Custom vertex function (internal use)
  36311. * @hidden
  36312. */
  36313. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36314. /**
  36315. * Model material (internal use)
  36316. * @hidden
  36317. */
  36318. _material: Nullable<Material>;
  36319. /**
  36320. * 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.
  36321. * SPS internal tool, don't use it manually.
  36322. * @hidden
  36323. */
  36324. 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>);
  36325. }
  36326. /**
  36327. * Represents a Depth Sorted Particle in the solid particle system.
  36328. * @hidden
  36329. */
  36330. export class DepthSortedParticle {
  36331. /**
  36332. * Particle index
  36333. */
  36334. idx: number;
  36335. /**
  36336. * Index of the particle in the "indices" array
  36337. */
  36338. ind: number;
  36339. /**
  36340. * Length of the particle shape in the "indices" array
  36341. */
  36342. indicesLength: number;
  36343. /**
  36344. * Squared distance from the particle to the camera
  36345. */
  36346. sqDistance: number;
  36347. /**
  36348. * Material index when used with MultiMaterials
  36349. */
  36350. materialIndex: number;
  36351. /**
  36352. * Creates a new sorted particle
  36353. * @param materialIndex
  36354. */
  36355. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36356. }
  36357. /**
  36358. * Represents a solid particle vertex
  36359. */
  36360. export class SolidParticleVertex {
  36361. /**
  36362. * Vertex position
  36363. */
  36364. position: Vector3;
  36365. /**
  36366. * Vertex color
  36367. */
  36368. color: Color4;
  36369. /**
  36370. * Vertex UV
  36371. */
  36372. uv: Vector2;
  36373. /**
  36374. * Creates a new solid particle vertex
  36375. */
  36376. constructor();
  36377. /** Vertex x coordinate */
  36378. get x(): number;
  36379. set x(val: number);
  36380. /** Vertex y coordinate */
  36381. get y(): number;
  36382. set y(val: number);
  36383. /** Vertex z coordinate */
  36384. get z(): number;
  36385. set z(val: number);
  36386. }
  36387. }
  36388. declare module "babylonjs/Collisions/meshCollisionData" {
  36389. import { Collider } from "babylonjs/Collisions/collider";
  36390. import { Vector3 } from "babylonjs/Maths/math.vector";
  36391. import { Nullable } from "babylonjs/types";
  36392. import { Observer } from "babylonjs/Misc/observable";
  36393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36394. /**
  36395. * @hidden
  36396. */
  36397. export class _MeshCollisionData {
  36398. _checkCollisions: boolean;
  36399. _collisionMask: number;
  36400. _collisionGroup: number;
  36401. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36402. _collider: Nullable<Collider>;
  36403. _oldPositionForCollisions: Vector3;
  36404. _diffPositionForCollisions: Vector3;
  36405. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36406. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36407. _collisionResponse: boolean;
  36408. }
  36409. }
  36410. declare module "babylonjs/Meshes/abstractMesh" {
  36411. import { Observable } from "babylonjs/Misc/observable";
  36412. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36413. import { Camera } from "babylonjs/Cameras/camera";
  36414. import { Scene, IDisposable } from "babylonjs/scene";
  36415. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36416. import { Node } from "babylonjs/node";
  36417. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36418. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36420. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36421. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36422. import { Material } from "babylonjs/Materials/material";
  36423. import { Light } from "babylonjs/Lights/light";
  36424. import { Skeleton } from "babylonjs/Bones/skeleton";
  36425. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36426. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36427. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36428. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36429. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36430. import { Plane } from "babylonjs/Maths/math.plane";
  36431. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36432. import { Ray } from "babylonjs/Culling/ray";
  36433. import { Collider } from "babylonjs/Collisions/collider";
  36434. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36435. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36436. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  36437. /** @hidden */
  36438. class _FacetDataStorage {
  36439. facetPositions: Vector3[];
  36440. facetNormals: Vector3[];
  36441. facetPartitioning: number[][];
  36442. facetNb: number;
  36443. partitioningSubdivisions: number;
  36444. partitioningBBoxRatio: number;
  36445. facetDataEnabled: boolean;
  36446. facetParameters: any;
  36447. bbSize: Vector3;
  36448. subDiv: {
  36449. max: number;
  36450. X: number;
  36451. Y: number;
  36452. Z: number;
  36453. };
  36454. facetDepthSort: boolean;
  36455. facetDepthSortEnabled: boolean;
  36456. depthSortedIndices: IndicesArray;
  36457. depthSortedFacets: {
  36458. ind: number;
  36459. sqDistance: number;
  36460. }[];
  36461. facetDepthSortFunction: (f1: {
  36462. ind: number;
  36463. sqDistance: number;
  36464. }, f2: {
  36465. ind: number;
  36466. sqDistance: number;
  36467. }) => number;
  36468. facetDepthSortFrom: Vector3;
  36469. facetDepthSortOrigin: Vector3;
  36470. invertedMatrix: Matrix;
  36471. }
  36472. /**
  36473. * @hidden
  36474. **/
  36475. class _InternalAbstractMeshDataInfo {
  36476. _hasVertexAlpha: boolean;
  36477. _useVertexColors: boolean;
  36478. _numBoneInfluencers: number;
  36479. _applyFog: boolean;
  36480. _receiveShadows: boolean;
  36481. _facetData: _FacetDataStorage;
  36482. _visibility: number;
  36483. _skeleton: Nullable<Skeleton>;
  36484. _layerMask: number;
  36485. _computeBonesUsingShaders: boolean;
  36486. _isActive: boolean;
  36487. _onlyForInstances: boolean;
  36488. _isActiveIntermediate: boolean;
  36489. _onlyForInstancesIntermediate: boolean;
  36490. _actAsRegularMesh: boolean;
  36491. _currentLOD: Nullable<AbstractMesh>;
  36492. _currentLODIsUpToDate: boolean;
  36493. }
  36494. /**
  36495. * Class used to store all common mesh properties
  36496. */
  36497. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36498. /** No occlusion */
  36499. static OCCLUSION_TYPE_NONE: number;
  36500. /** Occlusion set to optimisitic */
  36501. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36502. /** Occlusion set to strict */
  36503. static OCCLUSION_TYPE_STRICT: number;
  36504. /** Use an accurante occlusion algorithm */
  36505. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36506. /** Use a conservative occlusion algorithm */
  36507. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36508. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36509. * Test order :
  36510. * Is the bounding sphere outside the frustum ?
  36511. * If not, are the bounding box vertices outside the frustum ?
  36512. * It not, then the cullable object is in the frustum.
  36513. */
  36514. static readonly CULLINGSTRATEGY_STANDARD: number;
  36515. /** Culling strategy : Bounding Sphere Only.
  36516. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36517. * It's also less accurate than the standard because some not visible objects can still be selected.
  36518. * Test : is the bounding sphere outside the frustum ?
  36519. * If not, then the cullable object is in the frustum.
  36520. */
  36521. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36522. /** Culling strategy : Optimistic Inclusion.
  36523. * This in an inclusion test first, then the standard exclusion test.
  36524. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36525. * 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.
  36526. * Anyway, it's as accurate as the standard strategy.
  36527. * Test :
  36528. * Is the cullable object bounding sphere center in the frustum ?
  36529. * If not, apply the default culling strategy.
  36530. */
  36531. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36532. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36533. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36534. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36535. * 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.
  36536. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36537. * Test :
  36538. * Is the cullable object bounding sphere center in the frustum ?
  36539. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36540. */
  36541. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36542. /**
  36543. * No billboard
  36544. */
  36545. static get BILLBOARDMODE_NONE(): number;
  36546. /** Billboard on X axis */
  36547. static get BILLBOARDMODE_X(): number;
  36548. /** Billboard on Y axis */
  36549. static get BILLBOARDMODE_Y(): number;
  36550. /** Billboard on Z axis */
  36551. static get BILLBOARDMODE_Z(): number;
  36552. /** Billboard on all axes */
  36553. static get BILLBOARDMODE_ALL(): number;
  36554. /** Billboard on using position instead of orientation */
  36555. static get BILLBOARDMODE_USE_POSITION(): number;
  36556. /** @hidden */
  36557. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36558. /**
  36559. * The culling strategy to use to check whether the mesh must be rendered or not.
  36560. * This value can be changed at any time and will be used on the next render mesh selection.
  36561. * The possible values are :
  36562. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36563. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36564. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36565. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36566. * Please read each static variable documentation to get details about the culling process.
  36567. * */
  36568. cullingStrategy: number;
  36569. /**
  36570. * Gets the number of facets in the mesh
  36571. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36572. */
  36573. get facetNb(): number;
  36574. /**
  36575. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36576. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36577. */
  36578. get partitioningSubdivisions(): number;
  36579. set partitioningSubdivisions(nb: number);
  36580. /**
  36581. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36582. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36583. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36584. */
  36585. get partitioningBBoxRatio(): number;
  36586. set partitioningBBoxRatio(ratio: number);
  36587. /**
  36588. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36589. * Works only for updatable meshes.
  36590. * Doesn't work with multi-materials
  36591. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36592. */
  36593. get mustDepthSortFacets(): boolean;
  36594. set mustDepthSortFacets(sort: boolean);
  36595. /**
  36596. * The location (Vector3) where the facet depth sort must be computed from.
  36597. * By default, the active camera position.
  36598. * Used only when facet depth sort is enabled
  36599. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36600. */
  36601. get facetDepthSortFrom(): Vector3;
  36602. set facetDepthSortFrom(location: Vector3);
  36603. /**
  36604. * gets a boolean indicating if facetData is enabled
  36605. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36606. */
  36607. get isFacetDataEnabled(): boolean;
  36608. /** @hidden */
  36609. _updateNonUniformScalingState(value: boolean): boolean;
  36610. /**
  36611. * An event triggered when this mesh collides with another one
  36612. */
  36613. onCollideObservable: Observable<AbstractMesh>;
  36614. /** Set a function to call when this mesh collides with another one */
  36615. set onCollide(callback: () => void);
  36616. /**
  36617. * An event triggered when the collision's position changes
  36618. */
  36619. onCollisionPositionChangeObservable: Observable<Vector3>;
  36620. /** Set a function to call when the collision's position changes */
  36621. set onCollisionPositionChange(callback: () => void);
  36622. /**
  36623. * An event triggered when material is changed
  36624. */
  36625. onMaterialChangedObservable: Observable<AbstractMesh>;
  36626. /**
  36627. * Gets or sets the orientation for POV movement & rotation
  36628. */
  36629. definedFacingForward: boolean;
  36630. /** @hidden */
  36631. _occlusionQuery: Nullable<WebGLQuery>;
  36632. /** @hidden */
  36633. _renderingGroup: Nullable<RenderingGroup>;
  36634. /**
  36635. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36636. */
  36637. get visibility(): number;
  36638. /**
  36639. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36640. */
  36641. set visibility(value: number);
  36642. /** Gets or sets the alpha index used to sort transparent meshes
  36643. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36644. */
  36645. alphaIndex: number;
  36646. /**
  36647. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36648. */
  36649. isVisible: boolean;
  36650. /**
  36651. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36652. */
  36653. isPickable: boolean;
  36654. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36655. showSubMeshesBoundingBox: boolean;
  36656. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36657. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36658. */
  36659. isBlocker: boolean;
  36660. /**
  36661. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36662. */
  36663. enablePointerMoveEvents: boolean;
  36664. private _renderingGroupId;
  36665. /**
  36666. * Specifies the rendering group id for this mesh (0 by default)
  36667. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36668. */
  36669. get renderingGroupId(): number;
  36670. set renderingGroupId(value: number);
  36671. private _material;
  36672. /** Gets or sets current material */
  36673. get material(): Nullable<Material>;
  36674. set material(value: Nullable<Material>);
  36675. /**
  36676. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36677. * @see https://doc.babylonjs.com/babylon101/shadows
  36678. */
  36679. get receiveShadows(): boolean;
  36680. set receiveShadows(value: boolean);
  36681. /** Defines color to use when rendering outline */
  36682. outlineColor: Color3;
  36683. /** Define width to use when rendering outline */
  36684. outlineWidth: number;
  36685. /** Defines color to use when rendering overlay */
  36686. overlayColor: Color3;
  36687. /** Defines alpha to use when rendering overlay */
  36688. overlayAlpha: number;
  36689. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36690. get hasVertexAlpha(): boolean;
  36691. set hasVertexAlpha(value: boolean);
  36692. /** 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) */
  36693. get useVertexColors(): boolean;
  36694. set useVertexColors(value: boolean);
  36695. /**
  36696. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36697. */
  36698. get computeBonesUsingShaders(): boolean;
  36699. set computeBonesUsingShaders(value: boolean);
  36700. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36701. get numBoneInfluencers(): number;
  36702. set numBoneInfluencers(value: number);
  36703. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36704. get applyFog(): boolean;
  36705. set applyFog(value: boolean);
  36706. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36707. useOctreeForRenderingSelection: boolean;
  36708. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36709. useOctreeForPicking: boolean;
  36710. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36711. useOctreeForCollisions: boolean;
  36712. /**
  36713. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36714. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36715. */
  36716. get layerMask(): number;
  36717. set layerMask(value: number);
  36718. /**
  36719. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36720. */
  36721. alwaysSelectAsActiveMesh: boolean;
  36722. /**
  36723. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36724. */
  36725. doNotSyncBoundingInfo: boolean;
  36726. /**
  36727. * Gets or sets the current action manager
  36728. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36729. */
  36730. actionManager: Nullable<AbstractActionManager>;
  36731. private _meshCollisionData;
  36732. /**
  36733. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36734. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36735. */
  36736. ellipsoid: Vector3;
  36737. /**
  36738. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36739. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36740. */
  36741. ellipsoidOffset: Vector3;
  36742. /**
  36743. * Gets or sets a collision mask used to mask collisions (default is -1).
  36744. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36745. */
  36746. get collisionMask(): number;
  36747. set collisionMask(mask: number);
  36748. /**
  36749. * Gets or sets a collision response flag (default is true).
  36750. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36751. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36752. * to respond to the collision.
  36753. */
  36754. get collisionResponse(): boolean;
  36755. set collisionResponse(response: boolean);
  36756. /**
  36757. * Gets or sets the current collision group mask (-1 by default).
  36758. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36759. */
  36760. get collisionGroup(): number;
  36761. set collisionGroup(mask: number);
  36762. /**
  36763. * Gets or sets current surrounding meshes (null by default).
  36764. *
  36765. * By default collision detection is tested against every mesh in the scene.
  36766. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36767. * meshes will be tested for the collision.
  36768. *
  36769. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36770. */
  36771. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36772. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36773. /**
  36774. * Defines edge width used when edgesRenderer is enabled
  36775. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36776. */
  36777. edgesWidth: number;
  36778. /**
  36779. * Defines edge color used when edgesRenderer is enabled
  36780. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36781. */
  36782. edgesColor: Color4;
  36783. /** @hidden */
  36784. _edgesRenderer: Nullable<IEdgesRenderer>;
  36785. /** @hidden */
  36786. _masterMesh: Nullable<AbstractMesh>;
  36787. /** @hidden */
  36788. _boundingInfo: Nullable<BoundingInfo>;
  36789. /** @hidden */
  36790. _renderId: number;
  36791. /**
  36792. * Gets or sets the list of subMeshes
  36793. * @see https://doc.babylonjs.com/how_to/multi_materials
  36794. */
  36795. subMeshes: SubMesh[];
  36796. /** @hidden */
  36797. _intersectionsInProgress: AbstractMesh[];
  36798. /** @hidden */
  36799. _unIndexed: boolean;
  36800. /** @hidden */
  36801. _lightSources: Light[];
  36802. /** Gets the list of lights affecting that mesh */
  36803. get lightSources(): Light[];
  36804. /** @hidden */
  36805. get _positions(): Nullable<Vector3[]>;
  36806. /** @hidden */
  36807. _waitingData: {
  36808. lods: Nullable<any>;
  36809. actions: Nullable<any>;
  36810. freezeWorldMatrix: Nullable<boolean>;
  36811. };
  36812. /** @hidden */
  36813. _bonesTransformMatrices: Nullable<Float32Array>;
  36814. /** @hidden */
  36815. _transformMatrixTexture: Nullable<RawTexture>;
  36816. /**
  36817. * Gets or sets a skeleton to apply skining transformations
  36818. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36819. */
  36820. set skeleton(value: Nullable<Skeleton>);
  36821. get skeleton(): Nullable<Skeleton>;
  36822. /**
  36823. * An event triggered when the mesh is rebuilt.
  36824. */
  36825. onRebuildObservable: Observable<AbstractMesh>;
  36826. /**
  36827. * Creates a new AbstractMesh
  36828. * @param name defines the name of the mesh
  36829. * @param scene defines the hosting scene
  36830. */
  36831. constructor(name: string, scene?: Nullable<Scene>);
  36832. /**
  36833. * Returns the string "AbstractMesh"
  36834. * @returns "AbstractMesh"
  36835. */
  36836. getClassName(): string;
  36837. /**
  36838. * Gets a string representation of the current mesh
  36839. * @param fullDetails defines a boolean indicating if full details must be included
  36840. * @returns a string representation of the current mesh
  36841. */
  36842. toString(fullDetails?: boolean): string;
  36843. /**
  36844. * @hidden
  36845. */
  36846. protected _getEffectiveParent(): Nullable<Node>;
  36847. /** @hidden */
  36848. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36849. /** @hidden */
  36850. _rebuild(): void;
  36851. /** @hidden */
  36852. _resyncLightSources(): void;
  36853. /** @hidden */
  36854. _resyncLightSource(light: Light): void;
  36855. /** @hidden */
  36856. _unBindEffect(): void;
  36857. /** @hidden */
  36858. _removeLightSource(light: Light, dispose: boolean): void;
  36859. private _markSubMeshesAsDirty;
  36860. /** @hidden */
  36861. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36862. /** @hidden */
  36863. _markSubMeshesAsAttributesDirty(): void;
  36864. /** @hidden */
  36865. _markSubMeshesAsMiscDirty(): void;
  36866. /**
  36867. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36868. */
  36869. get scaling(): Vector3;
  36870. set scaling(newScaling: Vector3);
  36871. /**
  36872. * Returns true if the mesh is blocked. Implemented by child classes
  36873. */
  36874. get isBlocked(): boolean;
  36875. /**
  36876. * Returns the mesh itself by default. Implemented by child classes
  36877. * @param camera defines the camera to use to pick the right LOD level
  36878. * @returns the currentAbstractMesh
  36879. */
  36880. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36881. /**
  36882. * Returns 0 by default. Implemented by child classes
  36883. * @returns an integer
  36884. */
  36885. getTotalVertices(): number;
  36886. /**
  36887. * Returns a positive integer : the total number of indices in this mesh geometry.
  36888. * @returns the numner of indices or zero if the mesh has no geometry.
  36889. */
  36890. getTotalIndices(): number;
  36891. /**
  36892. * Returns null by default. Implemented by child classes
  36893. * @returns null
  36894. */
  36895. getIndices(): Nullable<IndicesArray>;
  36896. /**
  36897. * Returns the array of the requested vertex data kind. Implemented by child classes
  36898. * @param kind defines the vertex data kind to use
  36899. * @returns null
  36900. */
  36901. getVerticesData(kind: string): Nullable<FloatArray>;
  36902. /**
  36903. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36904. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36905. * Note that a new underlying VertexBuffer object is created each call.
  36906. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36907. * @param kind defines vertex data kind:
  36908. * * VertexBuffer.PositionKind
  36909. * * VertexBuffer.UVKind
  36910. * * VertexBuffer.UV2Kind
  36911. * * VertexBuffer.UV3Kind
  36912. * * VertexBuffer.UV4Kind
  36913. * * VertexBuffer.UV5Kind
  36914. * * VertexBuffer.UV6Kind
  36915. * * VertexBuffer.ColorKind
  36916. * * VertexBuffer.MatricesIndicesKind
  36917. * * VertexBuffer.MatricesIndicesExtraKind
  36918. * * VertexBuffer.MatricesWeightsKind
  36919. * * VertexBuffer.MatricesWeightsExtraKind
  36920. * @param data defines the data source
  36921. * @param updatable defines if the data must be flagged as updatable (or static)
  36922. * @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
  36923. * @returns the current mesh
  36924. */
  36925. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36926. /**
  36927. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36928. * If the mesh has no geometry, it is simply returned as it is.
  36929. * @param kind defines vertex data kind:
  36930. * * VertexBuffer.PositionKind
  36931. * * VertexBuffer.UVKind
  36932. * * VertexBuffer.UV2Kind
  36933. * * VertexBuffer.UV3Kind
  36934. * * VertexBuffer.UV4Kind
  36935. * * VertexBuffer.UV5Kind
  36936. * * VertexBuffer.UV6Kind
  36937. * * VertexBuffer.ColorKind
  36938. * * VertexBuffer.MatricesIndicesKind
  36939. * * VertexBuffer.MatricesIndicesExtraKind
  36940. * * VertexBuffer.MatricesWeightsKind
  36941. * * VertexBuffer.MatricesWeightsExtraKind
  36942. * @param data defines the data source
  36943. * @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
  36944. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36945. * @returns the current mesh
  36946. */
  36947. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36948. /**
  36949. * Sets the mesh indices,
  36950. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36951. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36952. * @param totalVertices Defines the total number of vertices
  36953. * @returns the current mesh
  36954. */
  36955. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36956. /**
  36957. * Gets a boolean indicating if specific vertex data is present
  36958. * @param kind defines the vertex data kind to use
  36959. * @returns true is data kind is present
  36960. */
  36961. isVerticesDataPresent(kind: string): boolean;
  36962. /**
  36963. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36964. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36965. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36966. * @returns a BoundingInfo
  36967. */
  36968. getBoundingInfo(): BoundingInfo;
  36969. /**
  36970. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36971. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36972. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36973. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36974. * @returns the current mesh
  36975. */
  36976. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36977. /**
  36978. * Overwrite the current bounding info
  36979. * @param boundingInfo defines the new bounding info
  36980. * @returns the current mesh
  36981. */
  36982. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36983. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36984. get useBones(): boolean;
  36985. /** @hidden */
  36986. _preActivate(): void;
  36987. /** @hidden */
  36988. _preActivateForIntermediateRendering(renderId: number): void;
  36989. /** @hidden */
  36990. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36991. /** @hidden */
  36992. _postActivate(): void;
  36993. /** @hidden */
  36994. _freeze(): void;
  36995. /** @hidden */
  36996. _unFreeze(): void;
  36997. /**
  36998. * Gets the current world matrix
  36999. * @returns a Matrix
  37000. */
  37001. getWorldMatrix(): Matrix;
  37002. /** @hidden */
  37003. _getWorldMatrixDeterminant(): number;
  37004. /**
  37005. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37006. */
  37007. get isAnInstance(): boolean;
  37008. /**
  37009. * Gets a boolean indicating if this mesh has instances
  37010. */
  37011. get hasInstances(): boolean;
  37012. /**
  37013. * Gets a boolean indicating if this mesh has thin instances
  37014. */
  37015. get hasThinInstances(): boolean;
  37016. /**
  37017. * Perform relative position change from the point of view of behind the front of the mesh.
  37018. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37019. * Supports definition of mesh facing forward or backward
  37020. * @param amountRight defines the distance on the right axis
  37021. * @param amountUp defines the distance on the up axis
  37022. * @param amountForward defines the distance on the forward axis
  37023. * @returns the current mesh
  37024. */
  37025. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37026. /**
  37027. * Calculate relative position change from the point of view of behind the front of the mesh.
  37028. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37029. * Supports definition of mesh facing forward or backward
  37030. * @param amountRight defines the distance on the right axis
  37031. * @param amountUp defines the distance on the up axis
  37032. * @param amountForward defines the distance on the forward axis
  37033. * @returns the new displacement vector
  37034. */
  37035. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37036. /**
  37037. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37038. * Supports definition of mesh facing forward or backward
  37039. * @param flipBack defines the flip
  37040. * @param twirlClockwise defines the twirl
  37041. * @param tiltRight defines the tilt
  37042. * @returns the current mesh
  37043. */
  37044. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37045. /**
  37046. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37047. * Supports definition of mesh facing forward or backward.
  37048. * @param flipBack defines the flip
  37049. * @param twirlClockwise defines the twirl
  37050. * @param tiltRight defines the tilt
  37051. * @returns the new rotation vector
  37052. */
  37053. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37054. /**
  37055. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37056. * This means the mesh underlying bounding box and sphere are recomputed.
  37057. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37058. * @returns the current mesh
  37059. */
  37060. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37061. /** @hidden */
  37062. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37063. /** @hidden */
  37064. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37065. /** @hidden */
  37066. _updateBoundingInfo(): AbstractMesh;
  37067. /** @hidden */
  37068. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37069. /** @hidden */
  37070. protected _afterComputeWorldMatrix(): void;
  37071. /** @hidden */
  37072. get _effectiveMesh(): AbstractMesh;
  37073. /**
  37074. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37075. * A mesh is in the frustum if its bounding box intersects the frustum
  37076. * @param frustumPlanes defines the frustum to test
  37077. * @returns true if the mesh is in the frustum planes
  37078. */
  37079. isInFrustum(frustumPlanes: Plane[]): boolean;
  37080. /**
  37081. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37082. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37083. * @param frustumPlanes defines the frustum to test
  37084. * @returns true if the mesh is completely in the frustum planes
  37085. */
  37086. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37087. /**
  37088. * True if the mesh intersects another mesh or a SolidParticle object
  37089. * @param mesh defines a target mesh or SolidParticle to test
  37090. * @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)
  37091. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37092. * @returns true if there is an intersection
  37093. */
  37094. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37095. /**
  37096. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37097. * @param point defines the point to test
  37098. * @returns true if there is an intersection
  37099. */
  37100. intersectsPoint(point: Vector3): boolean;
  37101. /**
  37102. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37103. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37104. */
  37105. get checkCollisions(): boolean;
  37106. set checkCollisions(collisionEnabled: boolean);
  37107. /**
  37108. * Gets Collider object used to compute collisions (not physics)
  37109. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37110. */
  37111. get collider(): Nullable<Collider>;
  37112. /**
  37113. * Move the mesh using collision engine
  37114. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37115. * @param displacement defines the requested displacement vector
  37116. * @returns the current mesh
  37117. */
  37118. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37119. private _onCollisionPositionChange;
  37120. /** @hidden */
  37121. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37122. /** @hidden */
  37123. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37124. /** @hidden */
  37125. _checkCollision(collider: Collider): AbstractMesh;
  37126. /** @hidden */
  37127. _generatePointsArray(): boolean;
  37128. /**
  37129. * Checks if the passed Ray intersects with the mesh
  37130. * @param ray defines the ray to use
  37131. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37132. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37133. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37134. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37135. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37136. * @returns the picking info
  37137. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37138. */
  37139. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37140. /**
  37141. * Clones the current mesh
  37142. * @param name defines the mesh name
  37143. * @param newParent defines the new mesh parent
  37144. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37145. * @returns the new mesh
  37146. */
  37147. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37148. /**
  37149. * Disposes all the submeshes of the current meshnp
  37150. * @returns the current mesh
  37151. */
  37152. releaseSubMeshes(): AbstractMesh;
  37153. /**
  37154. * Releases resources associated with this abstract mesh.
  37155. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37156. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37157. */
  37158. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37159. /**
  37160. * Adds the passed mesh as a child to the current mesh
  37161. * @param mesh defines the child mesh
  37162. * @returns the current mesh
  37163. */
  37164. addChild(mesh: AbstractMesh): AbstractMesh;
  37165. /**
  37166. * Removes the passed mesh from the current mesh children list
  37167. * @param mesh defines the child mesh
  37168. * @returns the current mesh
  37169. */
  37170. removeChild(mesh: AbstractMesh): AbstractMesh;
  37171. /** @hidden */
  37172. private _initFacetData;
  37173. /**
  37174. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37175. * This method can be called within the render loop.
  37176. * 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
  37177. * @returns the current mesh
  37178. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37179. */
  37180. updateFacetData(): AbstractMesh;
  37181. /**
  37182. * Returns the facetLocalNormals array.
  37183. * The normals are expressed in the mesh local spac
  37184. * @returns an array of Vector3
  37185. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37186. */
  37187. getFacetLocalNormals(): Vector3[];
  37188. /**
  37189. * Returns the facetLocalPositions array.
  37190. * The facet positions are expressed in the mesh local space
  37191. * @returns an array of Vector3
  37192. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37193. */
  37194. getFacetLocalPositions(): Vector3[];
  37195. /**
  37196. * Returns the facetLocalPartioning array
  37197. * @returns an array of array of numbers
  37198. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37199. */
  37200. getFacetLocalPartitioning(): number[][];
  37201. /**
  37202. * Returns the i-th facet position in the world system.
  37203. * This method allocates a new Vector3 per call
  37204. * @param i defines the facet index
  37205. * @returns a new Vector3
  37206. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37207. */
  37208. getFacetPosition(i: number): Vector3;
  37209. /**
  37210. * Sets the reference Vector3 with the i-th facet position in the world system
  37211. * @param i defines the facet index
  37212. * @param ref defines the target vector
  37213. * @returns the current mesh
  37214. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37215. */
  37216. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37217. /**
  37218. * Returns the i-th facet normal in the world system.
  37219. * This method allocates a new Vector3 per call
  37220. * @param i defines the facet index
  37221. * @returns a new Vector3
  37222. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37223. */
  37224. getFacetNormal(i: number): Vector3;
  37225. /**
  37226. * Sets the reference Vector3 with the i-th facet normal in the world system
  37227. * @param i defines the facet index
  37228. * @param ref defines the target vector
  37229. * @returns the current mesh
  37230. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37231. */
  37232. getFacetNormalToRef(i: number, ref: Vector3): this;
  37233. /**
  37234. * 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)
  37235. * @param x defines x coordinate
  37236. * @param y defines y coordinate
  37237. * @param z defines z coordinate
  37238. * @returns the array of facet indexes
  37239. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37240. */
  37241. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37242. /**
  37243. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37244. * @param projected sets as the (x,y,z) world projection on the facet
  37245. * @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
  37246. * @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
  37247. * @param x defines x coordinate
  37248. * @param y defines y coordinate
  37249. * @param z defines z coordinate
  37250. * @returns the face index if found (or null instead)
  37251. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37252. */
  37253. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37254. /**
  37255. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37256. * @param projected sets as the (x,y,z) local projection on the facet
  37257. * @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
  37258. * @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
  37259. * @param x defines x coordinate
  37260. * @param y defines y coordinate
  37261. * @param z defines z coordinate
  37262. * @returns the face index if found (or null instead)
  37263. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37264. */
  37265. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37266. /**
  37267. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37268. * @returns the parameters
  37269. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37270. */
  37271. getFacetDataParameters(): any;
  37272. /**
  37273. * Disables the feature FacetData and frees the related memory
  37274. * @returns the current mesh
  37275. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37276. */
  37277. disableFacetData(): AbstractMesh;
  37278. /**
  37279. * Updates the AbstractMesh indices array
  37280. * @param indices defines the data source
  37281. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37282. * @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)
  37283. * @returns the current mesh
  37284. */
  37285. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37286. /**
  37287. * Creates new normals data for the mesh
  37288. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37289. * @returns the current mesh
  37290. */
  37291. createNormals(updatable: boolean): AbstractMesh;
  37292. /**
  37293. * Align the mesh with a normal
  37294. * @param normal defines the normal to use
  37295. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37296. * @returns the current mesh
  37297. */
  37298. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37299. /** @hidden */
  37300. _checkOcclusionQuery(): boolean;
  37301. /**
  37302. * Disables the mesh edge rendering mode
  37303. * @returns the currentAbstractMesh
  37304. */
  37305. disableEdgesRendering(): AbstractMesh;
  37306. /**
  37307. * Enables the edge rendering mode on the mesh.
  37308. * This mode makes the mesh edges visible
  37309. * @param epsilon defines the maximal distance between two angles to detect a face
  37310. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37311. * @param options options to the edge renderer
  37312. * @returns the currentAbstractMesh
  37313. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37314. */
  37315. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37316. /**
  37317. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37318. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37319. */
  37320. getConnectedParticleSystems(): IParticleSystem[];
  37321. }
  37322. }
  37323. declare module "babylonjs/Actions/actionEvent" {
  37324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37325. import { Nullable } from "babylonjs/types";
  37326. import { Sprite } from "babylonjs/Sprites/sprite";
  37327. import { Scene } from "babylonjs/scene";
  37328. import { Vector2 } from "babylonjs/Maths/math.vector";
  37329. /**
  37330. * Interface used to define ActionEvent
  37331. */
  37332. export interface IActionEvent {
  37333. /** The mesh or sprite that triggered the action */
  37334. source: any;
  37335. /** The X mouse cursor position at the time of the event */
  37336. pointerX: number;
  37337. /** The Y mouse cursor position at the time of the event */
  37338. pointerY: number;
  37339. /** The mesh that is currently pointed at (can be null) */
  37340. meshUnderPointer: Nullable<AbstractMesh>;
  37341. /** the original (browser) event that triggered the ActionEvent */
  37342. sourceEvent?: any;
  37343. /** additional data for the event */
  37344. additionalData?: any;
  37345. }
  37346. /**
  37347. * ActionEvent is the event being sent when an action is triggered.
  37348. */
  37349. export class ActionEvent implements IActionEvent {
  37350. /** The mesh or sprite that triggered the action */
  37351. source: any;
  37352. /** The X mouse cursor position at the time of the event */
  37353. pointerX: number;
  37354. /** The Y mouse cursor position at the time of the event */
  37355. pointerY: number;
  37356. /** The mesh that is currently pointed at (can be null) */
  37357. meshUnderPointer: Nullable<AbstractMesh>;
  37358. /** the original (browser) event that triggered the ActionEvent */
  37359. sourceEvent?: any;
  37360. /** additional data for the event */
  37361. additionalData?: any;
  37362. /**
  37363. * Creates a new ActionEvent
  37364. * @param source The mesh or sprite that triggered the action
  37365. * @param pointerX The X mouse cursor position at the time of the event
  37366. * @param pointerY The Y mouse cursor position at the time of the event
  37367. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37368. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37369. * @param additionalData additional data for the event
  37370. */
  37371. constructor(
  37372. /** The mesh or sprite that triggered the action */
  37373. source: any,
  37374. /** The X mouse cursor position at the time of the event */
  37375. pointerX: number,
  37376. /** The Y mouse cursor position at the time of the event */
  37377. pointerY: number,
  37378. /** The mesh that is currently pointed at (can be null) */
  37379. meshUnderPointer: Nullable<AbstractMesh>,
  37380. /** the original (browser) event that triggered the ActionEvent */
  37381. sourceEvent?: any,
  37382. /** additional data for the event */
  37383. additionalData?: any);
  37384. /**
  37385. * Helper function to auto-create an ActionEvent from a source mesh.
  37386. * @param source The source mesh that triggered the event
  37387. * @param evt The original (browser) event
  37388. * @param additionalData additional data for the event
  37389. * @returns the new ActionEvent
  37390. */
  37391. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37392. /**
  37393. * Helper function to auto-create an ActionEvent from a source sprite
  37394. * @param source The source sprite that triggered the event
  37395. * @param scene Scene associated with the sprite
  37396. * @param evt The original (browser) event
  37397. * @param additionalData additional data for the event
  37398. * @returns the new ActionEvent
  37399. */
  37400. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37401. /**
  37402. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37403. * @param scene the scene where the event occurred
  37404. * @param evt The original (browser) event
  37405. * @returns the new ActionEvent
  37406. */
  37407. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37408. /**
  37409. * Helper function to auto-create an ActionEvent from a primitive
  37410. * @param prim defines the target primitive
  37411. * @param pointerPos defines the pointer position
  37412. * @param evt The original (browser) event
  37413. * @param additionalData additional data for the event
  37414. * @returns the new ActionEvent
  37415. */
  37416. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37417. }
  37418. }
  37419. declare module "babylonjs/Actions/abstractActionManager" {
  37420. import { IDisposable } from "babylonjs/scene";
  37421. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37422. import { IAction } from "babylonjs/Actions/action";
  37423. import { Nullable } from "babylonjs/types";
  37424. /**
  37425. * Abstract class used to decouple action Manager from scene and meshes.
  37426. * Do not instantiate.
  37427. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37428. */
  37429. export abstract class AbstractActionManager implements IDisposable {
  37430. /** Gets the list of active triggers */
  37431. static Triggers: {
  37432. [key: string]: number;
  37433. };
  37434. /** Gets the cursor to use when hovering items */
  37435. hoverCursor: string;
  37436. /** Gets the list of actions */
  37437. actions: IAction[];
  37438. /**
  37439. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37440. */
  37441. isRecursive: boolean;
  37442. /**
  37443. * Releases all associated resources
  37444. */
  37445. abstract dispose(): void;
  37446. /**
  37447. * Does this action manager has pointer triggers
  37448. */
  37449. abstract get hasPointerTriggers(): boolean;
  37450. /**
  37451. * Does this action manager has pick triggers
  37452. */
  37453. abstract get hasPickTriggers(): boolean;
  37454. /**
  37455. * Process a specific trigger
  37456. * @param trigger defines the trigger to process
  37457. * @param evt defines the event details to be processed
  37458. */
  37459. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37460. /**
  37461. * Does this action manager handles actions of any of the given triggers
  37462. * @param triggers defines the triggers to be tested
  37463. * @return a boolean indicating whether one (or more) of the triggers is handled
  37464. */
  37465. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37466. /**
  37467. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37468. * speed.
  37469. * @param triggerA defines the trigger to be tested
  37470. * @param triggerB defines the trigger to be tested
  37471. * @return a boolean indicating whether one (or more) of the triggers is handled
  37472. */
  37473. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37474. /**
  37475. * Does this action manager handles actions of a given trigger
  37476. * @param trigger defines the trigger to be tested
  37477. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37478. * @return whether the trigger is handled
  37479. */
  37480. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37481. /**
  37482. * Serialize this manager to a JSON object
  37483. * @param name defines the property name to store this manager
  37484. * @returns a JSON representation of this manager
  37485. */
  37486. abstract serialize(name: string): any;
  37487. /**
  37488. * Registers an action to this action manager
  37489. * @param action defines the action to be registered
  37490. * @return the action amended (prepared) after registration
  37491. */
  37492. abstract registerAction(action: IAction): Nullable<IAction>;
  37493. /**
  37494. * Unregisters an action to this action manager
  37495. * @param action defines the action to be unregistered
  37496. * @return a boolean indicating whether the action has been unregistered
  37497. */
  37498. abstract unregisterAction(action: IAction): Boolean;
  37499. /**
  37500. * Does exist one action manager with at least one trigger
  37501. **/
  37502. static get HasTriggers(): boolean;
  37503. /**
  37504. * Does exist one action manager with at least one pick trigger
  37505. **/
  37506. static get HasPickTriggers(): boolean;
  37507. /**
  37508. * Does exist one action manager that handles actions of a given trigger
  37509. * @param trigger defines the trigger to be tested
  37510. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37511. **/
  37512. static HasSpecificTrigger(trigger: number): boolean;
  37513. }
  37514. }
  37515. declare module "babylonjs/node" {
  37516. import { Scene } from "babylonjs/scene";
  37517. import { Nullable } from "babylonjs/types";
  37518. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37519. import { Engine } from "babylonjs/Engines/engine";
  37520. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37521. import { Observable } from "babylonjs/Misc/observable";
  37522. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37523. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37524. import { Animatable } from "babylonjs/Animations/animatable";
  37525. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37526. import { Animation } from "babylonjs/Animations/animation";
  37527. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37529. /**
  37530. * Defines how a node can be built from a string name.
  37531. */
  37532. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37533. /**
  37534. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37535. */
  37536. export class Node implements IBehaviorAware<Node> {
  37537. /** @hidden */
  37538. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37539. private static _NodeConstructors;
  37540. /**
  37541. * Add a new node constructor
  37542. * @param type defines the type name of the node to construct
  37543. * @param constructorFunc defines the constructor function
  37544. */
  37545. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37546. /**
  37547. * Returns a node constructor based on type name
  37548. * @param type defines the type name
  37549. * @param name defines the new node name
  37550. * @param scene defines the hosting scene
  37551. * @param options defines optional options to transmit to constructors
  37552. * @returns the new constructor or null
  37553. */
  37554. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37555. /**
  37556. * Gets or sets the name of the node
  37557. */
  37558. name: string;
  37559. /**
  37560. * Gets or sets the id of the node
  37561. */
  37562. id: string;
  37563. /**
  37564. * Gets or sets the unique id of the node
  37565. */
  37566. uniqueId: number;
  37567. /**
  37568. * Gets or sets a string used to store user defined state for the node
  37569. */
  37570. state: string;
  37571. /**
  37572. * Gets or sets an object used to store user defined information for the node
  37573. */
  37574. metadata: any;
  37575. /**
  37576. * For internal use only. Please do not use.
  37577. */
  37578. reservedDataStore: any;
  37579. /**
  37580. * List of inspectable custom properties (used by the Inspector)
  37581. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37582. */
  37583. inspectableCustomProperties: IInspectable[];
  37584. private _doNotSerialize;
  37585. /**
  37586. * Gets or sets a boolean used to define if the node must be serialized
  37587. */
  37588. get doNotSerialize(): boolean;
  37589. set doNotSerialize(value: boolean);
  37590. /** @hidden */
  37591. _isDisposed: boolean;
  37592. /**
  37593. * Gets a list of Animations associated with the node
  37594. */
  37595. animations: import("babylonjs/Animations/animation").Animation[];
  37596. protected _ranges: {
  37597. [name: string]: Nullable<AnimationRange>;
  37598. };
  37599. /**
  37600. * Callback raised when the node is ready to be used
  37601. */
  37602. onReady: Nullable<(node: Node) => void>;
  37603. private _isEnabled;
  37604. private _isParentEnabled;
  37605. private _isReady;
  37606. /** @hidden */
  37607. _currentRenderId: number;
  37608. private _parentUpdateId;
  37609. /** @hidden */
  37610. _childUpdateId: number;
  37611. /** @hidden */
  37612. _waitingParentId: Nullable<string>;
  37613. /** @hidden */
  37614. _scene: Scene;
  37615. /** @hidden */
  37616. _cache: any;
  37617. private _parentNode;
  37618. private _children;
  37619. /** @hidden */
  37620. _worldMatrix: Matrix;
  37621. /** @hidden */
  37622. _worldMatrixDeterminant: number;
  37623. /** @hidden */
  37624. _worldMatrixDeterminantIsDirty: boolean;
  37625. /** @hidden */
  37626. private _sceneRootNodesIndex;
  37627. /**
  37628. * Gets a boolean indicating if the node has been disposed
  37629. * @returns true if the node was disposed
  37630. */
  37631. isDisposed(): boolean;
  37632. /**
  37633. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37634. * @see https://doc.babylonjs.com/how_to/parenting
  37635. */
  37636. set parent(parent: Nullable<Node>);
  37637. get parent(): Nullable<Node>;
  37638. /** @hidden */
  37639. _addToSceneRootNodes(): void;
  37640. /** @hidden */
  37641. _removeFromSceneRootNodes(): void;
  37642. private _animationPropertiesOverride;
  37643. /**
  37644. * Gets or sets the animation properties override
  37645. */
  37646. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37647. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37648. /**
  37649. * Gets a string identifying the name of the class
  37650. * @returns "Node" string
  37651. */
  37652. getClassName(): string;
  37653. /** @hidden */
  37654. readonly _isNode: boolean;
  37655. /**
  37656. * An event triggered when the mesh is disposed
  37657. */
  37658. onDisposeObservable: Observable<Node>;
  37659. private _onDisposeObserver;
  37660. /**
  37661. * Sets a callback that will be raised when the node will be disposed
  37662. */
  37663. set onDispose(callback: () => void);
  37664. /**
  37665. * Creates a new Node
  37666. * @param name the name and id to be given to this node
  37667. * @param scene the scene this node will be added to
  37668. */
  37669. constructor(name: string, scene?: Nullable<Scene>);
  37670. /**
  37671. * Gets the scene of the node
  37672. * @returns a scene
  37673. */
  37674. getScene(): Scene;
  37675. /**
  37676. * Gets the engine of the node
  37677. * @returns a Engine
  37678. */
  37679. getEngine(): Engine;
  37680. private _behaviors;
  37681. /**
  37682. * Attach a behavior to the node
  37683. * @see https://doc.babylonjs.com/features/behaviour
  37684. * @param behavior defines the behavior to attach
  37685. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37686. * @returns the current Node
  37687. */
  37688. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37689. /**
  37690. * Remove an attached behavior
  37691. * @see https://doc.babylonjs.com/features/behaviour
  37692. * @param behavior defines the behavior to attach
  37693. * @returns the current Node
  37694. */
  37695. removeBehavior(behavior: Behavior<Node>): Node;
  37696. /**
  37697. * Gets the list of attached behaviors
  37698. * @see https://doc.babylonjs.com/features/behaviour
  37699. */
  37700. get behaviors(): Behavior<Node>[];
  37701. /**
  37702. * Gets an attached behavior by name
  37703. * @param name defines the name of the behavior to look for
  37704. * @see https://doc.babylonjs.com/features/behaviour
  37705. * @returns null if behavior was not found else the requested behavior
  37706. */
  37707. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37708. /**
  37709. * Returns the latest update of the World matrix
  37710. * @returns a Matrix
  37711. */
  37712. getWorldMatrix(): Matrix;
  37713. /** @hidden */
  37714. _getWorldMatrixDeterminant(): number;
  37715. /**
  37716. * Returns directly the latest state of the mesh World matrix.
  37717. * A Matrix is returned.
  37718. */
  37719. get worldMatrixFromCache(): Matrix;
  37720. /** @hidden */
  37721. _initCache(): void;
  37722. /** @hidden */
  37723. updateCache(force?: boolean): void;
  37724. /** @hidden */
  37725. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37726. /** @hidden */
  37727. _updateCache(ignoreParentClass?: boolean): void;
  37728. /** @hidden */
  37729. _isSynchronized(): boolean;
  37730. /** @hidden */
  37731. _markSyncedWithParent(): void;
  37732. /** @hidden */
  37733. isSynchronizedWithParent(): boolean;
  37734. /** @hidden */
  37735. isSynchronized(): boolean;
  37736. /**
  37737. * Is this node ready to be used/rendered
  37738. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37739. * @return true if the node is ready
  37740. */
  37741. isReady(completeCheck?: boolean): boolean;
  37742. /**
  37743. * Is this node enabled?
  37744. * 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
  37745. * @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
  37746. * @return whether this node (and its parent) is enabled
  37747. */
  37748. isEnabled(checkAncestors?: boolean): boolean;
  37749. /** @hidden */
  37750. protected _syncParentEnabledState(): void;
  37751. /**
  37752. * Set the enabled state of this node
  37753. * @param value defines the new enabled state
  37754. */
  37755. setEnabled(value: boolean): void;
  37756. /**
  37757. * Is this node a descendant of the given node?
  37758. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37759. * @param ancestor defines the parent node to inspect
  37760. * @returns a boolean indicating if this node is a descendant of the given node
  37761. */
  37762. isDescendantOf(ancestor: Node): boolean;
  37763. /** @hidden */
  37764. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37765. /**
  37766. * Will return all nodes that have this node as ascendant
  37767. * @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
  37768. * @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
  37769. * @return all children nodes of all types
  37770. */
  37771. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37772. /**
  37773. * Get all child-meshes of this node
  37774. * @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)
  37775. * @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
  37776. * @returns an array of AbstractMesh
  37777. */
  37778. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37779. /**
  37780. * Get all direct children of this node
  37781. * @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
  37782. * @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)
  37783. * @returns an array of Node
  37784. */
  37785. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37786. /** @hidden */
  37787. _setReady(state: boolean): void;
  37788. /**
  37789. * Get an animation by name
  37790. * @param name defines the name of the animation to look for
  37791. * @returns null if not found else the requested animation
  37792. */
  37793. getAnimationByName(name: string): Nullable<Animation>;
  37794. /**
  37795. * Creates an animation range for this node
  37796. * @param name defines the name of the range
  37797. * @param from defines the starting key
  37798. * @param to defines the end key
  37799. */
  37800. createAnimationRange(name: string, from: number, to: number): void;
  37801. /**
  37802. * Delete a specific animation range
  37803. * @param name defines the name of the range to delete
  37804. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37805. */
  37806. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37807. /**
  37808. * Get an animation range by name
  37809. * @param name defines the name of the animation range to look for
  37810. * @returns null if not found else the requested animation range
  37811. */
  37812. getAnimationRange(name: string): Nullable<AnimationRange>;
  37813. /**
  37814. * Gets the list of all animation ranges defined on this node
  37815. * @returns an array
  37816. */
  37817. getAnimationRanges(): Nullable<AnimationRange>[];
  37818. /**
  37819. * Will start the animation sequence
  37820. * @param name defines the range frames for animation sequence
  37821. * @param loop defines if the animation should loop (false by default)
  37822. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37823. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37824. * @returns the object created for this animation. If range does not exist, it will return null
  37825. */
  37826. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37827. /**
  37828. * Serialize animation ranges into a JSON compatible object
  37829. * @returns serialization object
  37830. */
  37831. serializeAnimationRanges(): any;
  37832. /**
  37833. * Computes the world matrix of the node
  37834. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37835. * @returns the world matrix
  37836. */
  37837. computeWorldMatrix(force?: boolean): Matrix;
  37838. /**
  37839. * Releases resources associated with this node.
  37840. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37841. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37842. */
  37843. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37844. /**
  37845. * Parse animation range data from a serialization object and store them into a given node
  37846. * @param node defines where to store the animation ranges
  37847. * @param parsedNode defines the serialization object to read data from
  37848. * @param scene defines the hosting scene
  37849. */
  37850. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37851. /**
  37852. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37853. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37854. * @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
  37855. * @returns the new bounding vectors
  37856. */
  37857. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37858. min: Vector3;
  37859. max: Vector3;
  37860. };
  37861. }
  37862. }
  37863. declare module "babylonjs/Animations/animation" {
  37864. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37865. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37866. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37867. import { Nullable } from "babylonjs/types";
  37868. import { Scene } from "babylonjs/scene";
  37869. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37870. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37871. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37872. import { Node } from "babylonjs/node";
  37873. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37874. import { Size } from "babylonjs/Maths/math.size";
  37875. import { Animatable } from "babylonjs/Animations/animatable";
  37876. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37877. /**
  37878. * @hidden
  37879. */
  37880. export class _IAnimationState {
  37881. key: number;
  37882. repeatCount: number;
  37883. workValue?: any;
  37884. loopMode?: number;
  37885. offsetValue?: any;
  37886. highLimitValue?: any;
  37887. }
  37888. /**
  37889. * Class used to store any kind of animation
  37890. */
  37891. export class Animation {
  37892. /**Name of the animation */
  37893. name: string;
  37894. /**Property to animate */
  37895. targetProperty: string;
  37896. /**The frames per second of the animation */
  37897. framePerSecond: number;
  37898. /**The data type of the animation */
  37899. dataType: number;
  37900. /**The loop mode of the animation */
  37901. loopMode?: number | undefined;
  37902. /**Specifies if blending should be enabled */
  37903. enableBlending?: boolean | undefined;
  37904. /**
  37905. * Use matrix interpolation instead of using direct key value when animating matrices
  37906. */
  37907. static AllowMatricesInterpolation: boolean;
  37908. /**
  37909. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37910. */
  37911. static AllowMatrixDecomposeForInterpolation: boolean;
  37912. /** Define the Url to load snippets */
  37913. static SnippetUrl: string;
  37914. /** Snippet ID if the animation was created from the snippet server */
  37915. snippetId: string;
  37916. /**
  37917. * Stores the key frames of the animation
  37918. */
  37919. private _keys;
  37920. /**
  37921. * Stores the easing function of the animation
  37922. */
  37923. private _easingFunction;
  37924. /**
  37925. * @hidden Internal use only
  37926. */
  37927. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37928. /**
  37929. * The set of event that will be linked to this animation
  37930. */
  37931. private _events;
  37932. /**
  37933. * Stores an array of target property paths
  37934. */
  37935. targetPropertyPath: string[];
  37936. /**
  37937. * Stores the blending speed of the animation
  37938. */
  37939. blendingSpeed: number;
  37940. /**
  37941. * Stores the animation ranges for the animation
  37942. */
  37943. private _ranges;
  37944. /**
  37945. * @hidden Internal use
  37946. */
  37947. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37948. /**
  37949. * Sets up an animation
  37950. * @param property The property to animate
  37951. * @param animationType The animation type to apply
  37952. * @param framePerSecond The frames per second of the animation
  37953. * @param easingFunction The easing function used in the animation
  37954. * @returns The created animation
  37955. */
  37956. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37957. /**
  37958. * Create and start an animation on a node
  37959. * @param name defines the name of the global animation that will be run on all nodes
  37960. * @param node defines the root node where the animation will take place
  37961. * @param targetProperty defines property to animate
  37962. * @param framePerSecond defines the number of frame per second yo use
  37963. * @param totalFrame defines the number of frames in total
  37964. * @param from defines the initial value
  37965. * @param to defines the final value
  37966. * @param loopMode defines which loop mode you want to use (off by default)
  37967. * @param easingFunction defines the easing function to use (linear by default)
  37968. * @param onAnimationEnd defines the callback to call when animation end
  37969. * @returns the animatable created for this animation
  37970. */
  37971. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37972. /**
  37973. * Create and start an animation on a node and its descendants
  37974. * @param name defines the name of the global animation that will be run on all nodes
  37975. * @param node defines the root node where the animation will take place
  37976. * @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
  37977. * @param targetProperty defines property to animate
  37978. * @param framePerSecond defines the number of frame per second to use
  37979. * @param totalFrame defines the number of frames in total
  37980. * @param from defines the initial value
  37981. * @param to defines the final value
  37982. * @param loopMode defines which loop mode you want to use (off by default)
  37983. * @param easingFunction defines the easing function to use (linear by default)
  37984. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37985. * @returns the list of animatables created for all nodes
  37986. * @example https://www.babylonjs-playground.com/#MH0VLI
  37987. */
  37988. 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[]>;
  37989. /**
  37990. * Creates a new animation, merges it with the existing animations and starts it
  37991. * @param name Name of the animation
  37992. * @param node Node which contains the scene that begins the animations
  37993. * @param targetProperty Specifies which property to animate
  37994. * @param framePerSecond The frames per second of the animation
  37995. * @param totalFrame The total number of frames
  37996. * @param from The frame at the beginning of the animation
  37997. * @param to The frame at the end of the animation
  37998. * @param loopMode Specifies the loop mode of the animation
  37999. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38000. * @param onAnimationEnd Callback to run once the animation is complete
  38001. * @returns Nullable animation
  38002. */
  38003. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38004. /**
  38005. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38006. * @param sourceAnimation defines the Animation containing keyframes to convert
  38007. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38008. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38009. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38010. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38011. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38012. */
  38013. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38014. /**
  38015. * Transition property of an host to the target Value
  38016. * @param property The property to transition
  38017. * @param targetValue The target Value of the property
  38018. * @param host The object where the property to animate belongs
  38019. * @param scene Scene used to run the animation
  38020. * @param frameRate Framerate (in frame/s) to use
  38021. * @param transition The transition type we want to use
  38022. * @param duration The duration of the animation, in milliseconds
  38023. * @param onAnimationEnd Callback trigger at the end of the animation
  38024. * @returns Nullable animation
  38025. */
  38026. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38027. /**
  38028. * Return the array of runtime animations currently using this animation
  38029. */
  38030. get runtimeAnimations(): RuntimeAnimation[];
  38031. /**
  38032. * Specifies if any of the runtime animations are currently running
  38033. */
  38034. get hasRunningRuntimeAnimations(): boolean;
  38035. /**
  38036. * Initializes the animation
  38037. * @param name Name of the animation
  38038. * @param targetProperty Property to animate
  38039. * @param framePerSecond The frames per second of the animation
  38040. * @param dataType The data type of the animation
  38041. * @param loopMode The loop mode of the animation
  38042. * @param enableBlending Specifies if blending should be enabled
  38043. */
  38044. constructor(
  38045. /**Name of the animation */
  38046. name: string,
  38047. /**Property to animate */
  38048. targetProperty: string,
  38049. /**The frames per second of the animation */
  38050. framePerSecond: number,
  38051. /**The data type of the animation */
  38052. dataType: number,
  38053. /**The loop mode of the animation */
  38054. loopMode?: number | undefined,
  38055. /**Specifies if blending should be enabled */
  38056. enableBlending?: boolean | undefined);
  38057. /**
  38058. * Converts the animation to a string
  38059. * @param fullDetails support for multiple levels of logging within scene loading
  38060. * @returns String form of the animation
  38061. */
  38062. toString(fullDetails?: boolean): string;
  38063. /**
  38064. * Add an event to this animation
  38065. * @param event Event to add
  38066. */
  38067. addEvent(event: AnimationEvent): void;
  38068. /**
  38069. * Remove all events found at the given frame
  38070. * @param frame The frame to remove events from
  38071. */
  38072. removeEvents(frame: number): void;
  38073. /**
  38074. * Retrieves all the events from the animation
  38075. * @returns Events from the animation
  38076. */
  38077. getEvents(): AnimationEvent[];
  38078. /**
  38079. * Creates an animation range
  38080. * @param name Name of the animation range
  38081. * @param from Starting frame of the animation range
  38082. * @param to Ending frame of the animation
  38083. */
  38084. createRange(name: string, from: number, to: number): void;
  38085. /**
  38086. * Deletes an animation range by name
  38087. * @param name Name of the animation range to delete
  38088. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38089. */
  38090. deleteRange(name: string, deleteFrames?: boolean): void;
  38091. /**
  38092. * Gets the animation range by name, or null if not defined
  38093. * @param name Name of the animation range
  38094. * @returns Nullable animation range
  38095. */
  38096. getRange(name: string): Nullable<AnimationRange>;
  38097. /**
  38098. * Gets the key frames from the animation
  38099. * @returns The key frames of the animation
  38100. */
  38101. getKeys(): Array<IAnimationKey>;
  38102. /**
  38103. * Gets the highest frame rate of the animation
  38104. * @returns Highest frame rate of the animation
  38105. */
  38106. getHighestFrame(): number;
  38107. /**
  38108. * Gets the easing function of the animation
  38109. * @returns Easing function of the animation
  38110. */
  38111. getEasingFunction(): IEasingFunction;
  38112. /**
  38113. * Sets the easing function of the animation
  38114. * @param easingFunction A custom mathematical formula for animation
  38115. */
  38116. setEasingFunction(easingFunction: EasingFunction): void;
  38117. /**
  38118. * Interpolates a scalar linearly
  38119. * @param startValue Start value of the animation curve
  38120. * @param endValue End value of the animation curve
  38121. * @param gradient Scalar amount to interpolate
  38122. * @returns Interpolated scalar value
  38123. */
  38124. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38125. /**
  38126. * Interpolates a scalar cubically
  38127. * @param startValue Start value of the animation curve
  38128. * @param outTangent End tangent of the animation
  38129. * @param endValue End value of the animation curve
  38130. * @param inTangent Start tangent of the animation curve
  38131. * @param gradient Scalar amount to interpolate
  38132. * @returns Interpolated scalar value
  38133. */
  38134. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38135. /**
  38136. * Interpolates a quaternion using a spherical linear interpolation
  38137. * @param startValue Start value of the animation curve
  38138. * @param endValue End value of the animation curve
  38139. * @param gradient Scalar amount to interpolate
  38140. * @returns Interpolated quaternion value
  38141. */
  38142. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38143. /**
  38144. * Interpolates a quaternion cubically
  38145. * @param startValue Start value of the animation curve
  38146. * @param outTangent End tangent of the animation curve
  38147. * @param endValue End value of the animation curve
  38148. * @param inTangent Start tangent of the animation curve
  38149. * @param gradient Scalar amount to interpolate
  38150. * @returns Interpolated quaternion value
  38151. */
  38152. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38153. /**
  38154. * Interpolates a Vector3 linearl
  38155. * @param startValue Start value of the animation curve
  38156. * @param endValue End value of the animation curve
  38157. * @param gradient Scalar amount to interpolate
  38158. * @returns Interpolated scalar value
  38159. */
  38160. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38161. /**
  38162. * Interpolates a Vector3 cubically
  38163. * @param startValue Start value of the animation curve
  38164. * @param outTangent End tangent of the animation
  38165. * @param endValue End value of the animation curve
  38166. * @param inTangent Start tangent of the animation curve
  38167. * @param gradient Scalar amount to interpolate
  38168. * @returns InterpolatedVector3 value
  38169. */
  38170. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38171. /**
  38172. * Interpolates a Vector2 linearly
  38173. * @param startValue Start value of the animation curve
  38174. * @param endValue End value of the animation curve
  38175. * @param gradient Scalar amount to interpolate
  38176. * @returns Interpolated Vector2 value
  38177. */
  38178. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38179. /**
  38180. * Interpolates a Vector2 cubically
  38181. * @param startValue Start value of the animation curve
  38182. * @param outTangent End tangent of the animation
  38183. * @param endValue End value of the animation curve
  38184. * @param inTangent Start tangent of the animation curve
  38185. * @param gradient Scalar amount to interpolate
  38186. * @returns Interpolated Vector2 value
  38187. */
  38188. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38189. /**
  38190. * Interpolates a size linearly
  38191. * @param startValue Start value of the animation curve
  38192. * @param endValue End value of the animation curve
  38193. * @param gradient Scalar amount to interpolate
  38194. * @returns Interpolated Size value
  38195. */
  38196. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38197. /**
  38198. * Interpolates a Color3 linearly
  38199. * @param startValue Start value of the animation curve
  38200. * @param endValue End value of the animation curve
  38201. * @param gradient Scalar amount to interpolate
  38202. * @returns Interpolated Color3 value
  38203. */
  38204. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38205. /**
  38206. * Interpolates a Color4 linearly
  38207. * @param startValue Start value of the animation curve
  38208. * @param endValue End value of the animation curve
  38209. * @param gradient Scalar amount to interpolate
  38210. * @returns Interpolated Color3 value
  38211. */
  38212. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38213. /**
  38214. * @hidden Internal use only
  38215. */
  38216. _getKeyValue(value: any): any;
  38217. /**
  38218. * @hidden Internal use only
  38219. */
  38220. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38221. /**
  38222. * Defines the function to use to interpolate matrices
  38223. * @param startValue defines the start matrix
  38224. * @param endValue defines the end matrix
  38225. * @param gradient defines the gradient between both matrices
  38226. * @param result defines an optional target matrix where to store the interpolation
  38227. * @returns the interpolated matrix
  38228. */
  38229. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38230. /**
  38231. * Makes a copy of the animation
  38232. * @returns Cloned animation
  38233. */
  38234. clone(): Animation;
  38235. /**
  38236. * Sets the key frames of the animation
  38237. * @param values The animation key frames to set
  38238. */
  38239. setKeys(values: Array<IAnimationKey>): void;
  38240. /**
  38241. * Serializes the animation to an object
  38242. * @returns Serialized object
  38243. */
  38244. serialize(): any;
  38245. /**
  38246. * Float animation type
  38247. */
  38248. static readonly ANIMATIONTYPE_FLOAT: number;
  38249. /**
  38250. * Vector3 animation type
  38251. */
  38252. static readonly ANIMATIONTYPE_VECTOR3: number;
  38253. /**
  38254. * Quaternion animation type
  38255. */
  38256. static readonly ANIMATIONTYPE_QUATERNION: number;
  38257. /**
  38258. * Matrix animation type
  38259. */
  38260. static readonly ANIMATIONTYPE_MATRIX: number;
  38261. /**
  38262. * Color3 animation type
  38263. */
  38264. static readonly ANIMATIONTYPE_COLOR3: number;
  38265. /**
  38266. * Color3 animation type
  38267. */
  38268. static readonly ANIMATIONTYPE_COLOR4: number;
  38269. /**
  38270. * Vector2 animation type
  38271. */
  38272. static readonly ANIMATIONTYPE_VECTOR2: number;
  38273. /**
  38274. * Size animation type
  38275. */
  38276. static readonly ANIMATIONTYPE_SIZE: number;
  38277. /**
  38278. * Relative Loop Mode
  38279. */
  38280. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38281. /**
  38282. * Cycle Loop Mode
  38283. */
  38284. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38285. /**
  38286. * Constant Loop Mode
  38287. */
  38288. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38289. /** @hidden */
  38290. static _UniversalLerp(left: any, right: any, amount: number): any;
  38291. /**
  38292. * Parses an animation object and creates an animation
  38293. * @param parsedAnimation Parsed animation object
  38294. * @returns Animation object
  38295. */
  38296. static Parse(parsedAnimation: any): Animation;
  38297. /**
  38298. * Appends the serialized animations from the source animations
  38299. * @param source Source containing the animations
  38300. * @param destination Target to store the animations
  38301. */
  38302. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38303. /**
  38304. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38305. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38306. * @param url defines the url to load from
  38307. * @returns a promise that will resolve to the new animation or an array of animations
  38308. */
  38309. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38310. /**
  38311. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38312. * @param snippetId defines the snippet to load
  38313. * @returns a promise that will resolve to the new animation or a new array of animations
  38314. */
  38315. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38316. }
  38317. }
  38318. declare module "babylonjs/Animations/animatable.interface" {
  38319. import { Nullable } from "babylonjs/types";
  38320. import { Animation } from "babylonjs/Animations/animation";
  38321. /**
  38322. * Interface containing an array of animations
  38323. */
  38324. export interface IAnimatable {
  38325. /**
  38326. * Array of animations
  38327. */
  38328. animations: Nullable<Array<Animation>>;
  38329. }
  38330. }
  38331. declare module "babylonjs/Misc/decorators" {
  38332. import { Nullable } from "babylonjs/types";
  38333. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38334. import { Scene } from "babylonjs/scene";
  38335. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38336. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38337. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38339. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38340. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38341. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38342. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38343. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38344. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38345. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38346. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38347. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38348. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38349. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38350. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38351. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38352. /**
  38353. * Decorator used to define property that can be serialized as reference to a camera
  38354. * @param sourceName defines the name of the property to decorate
  38355. */
  38356. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38357. /**
  38358. * Class used to help serialization objects
  38359. */
  38360. export class SerializationHelper {
  38361. /** @hidden */
  38362. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38363. /** @hidden */
  38364. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38365. /** @hidden */
  38366. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38367. /** @hidden */
  38368. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38369. /**
  38370. * Appends the serialized animations from the source animations
  38371. * @param source Source containing the animations
  38372. * @param destination Target to store the animations
  38373. */
  38374. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38375. /**
  38376. * Static function used to serialized a specific entity
  38377. * @param entity defines the entity to serialize
  38378. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38379. * @returns a JSON compatible object representing the serialization of the entity
  38380. */
  38381. static Serialize<T>(entity: T, serializationObject?: any): any;
  38382. /**
  38383. * Creates a new entity from a serialization data object
  38384. * @param creationFunction defines a function used to instanciated the new entity
  38385. * @param source defines the source serialization data
  38386. * @param scene defines the hosting scene
  38387. * @param rootUrl defines the root url for resources
  38388. * @returns a new entity
  38389. */
  38390. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38391. /**
  38392. * Clones an object
  38393. * @param creationFunction defines the function used to instanciate the new object
  38394. * @param source defines the source object
  38395. * @returns the cloned object
  38396. */
  38397. static Clone<T>(creationFunction: () => T, source: T): T;
  38398. /**
  38399. * Instanciates a new object based on a source one (some data will be shared between both object)
  38400. * @param creationFunction defines the function used to instanciate the new object
  38401. * @param source defines the source object
  38402. * @returns the new object
  38403. */
  38404. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38405. }
  38406. }
  38407. declare module "babylonjs/Cameras/camera" {
  38408. import { SmartArray } from "babylonjs/Misc/smartArray";
  38409. import { Observable } from "babylonjs/Misc/observable";
  38410. import { Nullable } from "babylonjs/types";
  38411. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38412. import { Scene } from "babylonjs/scene";
  38413. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38414. import { Node } from "babylonjs/node";
  38415. import { Mesh } from "babylonjs/Meshes/mesh";
  38416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38417. import { ICullable } from "babylonjs/Culling/boundingInfo";
  38418. import { Viewport } from "babylonjs/Maths/math.viewport";
  38419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38420. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38421. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38422. import { Ray } from "babylonjs/Culling/ray";
  38423. /**
  38424. * This is the base class of all the camera used in the application.
  38425. * @see https://doc.babylonjs.com/features/cameras
  38426. */
  38427. export class Camera extends Node {
  38428. /** @hidden */
  38429. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38430. /**
  38431. * This is the default projection mode used by the cameras.
  38432. * It helps recreating a feeling of perspective and better appreciate depth.
  38433. * This is the best way to simulate real life cameras.
  38434. */
  38435. static readonly PERSPECTIVE_CAMERA: number;
  38436. /**
  38437. * This helps creating camera with an orthographic mode.
  38438. * 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.
  38439. */
  38440. static readonly ORTHOGRAPHIC_CAMERA: number;
  38441. /**
  38442. * This is the default FOV mode for perspective cameras.
  38443. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38444. */
  38445. static readonly FOVMODE_VERTICAL_FIXED: number;
  38446. /**
  38447. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38448. */
  38449. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38450. /**
  38451. * This specifies ther is no need for a camera rig.
  38452. * Basically only one eye is rendered corresponding to the camera.
  38453. */
  38454. static readonly RIG_MODE_NONE: number;
  38455. /**
  38456. * Simulates a camera Rig with one blue eye and one red eye.
  38457. * This can be use with 3d blue and red glasses.
  38458. */
  38459. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38460. /**
  38461. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38462. */
  38463. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38464. /**
  38465. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38466. */
  38467. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38468. /**
  38469. * Defines that both eyes of the camera will be rendered over under each other.
  38470. */
  38471. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38472. /**
  38473. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38474. */
  38475. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38476. /**
  38477. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38478. */
  38479. static readonly RIG_MODE_VR: number;
  38480. /**
  38481. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38482. */
  38483. static readonly RIG_MODE_WEBVR: number;
  38484. /**
  38485. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38486. */
  38487. static readonly RIG_MODE_CUSTOM: number;
  38488. /**
  38489. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38490. */
  38491. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38492. /**
  38493. * Define the input manager associated with the camera.
  38494. */
  38495. inputs: CameraInputsManager<Camera>;
  38496. /** @hidden */
  38497. _position: Vector3;
  38498. /**
  38499. * Define the current local position of the camera in the scene
  38500. */
  38501. get position(): Vector3;
  38502. set position(newPosition: Vector3);
  38503. protected _upVector: Vector3;
  38504. /**
  38505. * The vector the camera should consider as up.
  38506. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38507. */
  38508. set upVector(vec: Vector3);
  38509. get upVector(): Vector3;
  38510. /**
  38511. * Define the current limit on the left side for an orthographic camera
  38512. * In scene unit
  38513. */
  38514. orthoLeft: Nullable<number>;
  38515. /**
  38516. * Define the current limit on the right side for an orthographic camera
  38517. * In scene unit
  38518. */
  38519. orthoRight: Nullable<number>;
  38520. /**
  38521. * Define the current limit on the bottom side for an orthographic camera
  38522. * In scene unit
  38523. */
  38524. orthoBottom: Nullable<number>;
  38525. /**
  38526. * Define the current limit on the top side for an orthographic camera
  38527. * In scene unit
  38528. */
  38529. orthoTop: Nullable<number>;
  38530. /**
  38531. * Field Of View is set in Radians. (default is 0.8)
  38532. */
  38533. fov: number;
  38534. /**
  38535. * Define the minimum distance the camera can see from.
  38536. * This is important to note that the depth buffer are not infinite and the closer it starts
  38537. * the more your scene might encounter depth fighting issue.
  38538. */
  38539. minZ: number;
  38540. /**
  38541. * Define the maximum distance the camera can see to.
  38542. * This is important to note that the depth buffer are not infinite and the further it end
  38543. * the more your scene might encounter depth fighting issue.
  38544. */
  38545. maxZ: number;
  38546. /**
  38547. * Define the default inertia of the camera.
  38548. * This helps giving a smooth feeling to the camera movement.
  38549. */
  38550. inertia: number;
  38551. /**
  38552. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38553. */
  38554. mode: number;
  38555. /**
  38556. * Define whether the camera is intermediate.
  38557. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38558. */
  38559. isIntermediate: boolean;
  38560. /**
  38561. * Define the viewport of the camera.
  38562. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38563. */
  38564. viewport: Viewport;
  38565. /**
  38566. * Restricts the camera to viewing objects with the same layerMask.
  38567. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38568. */
  38569. layerMask: number;
  38570. /**
  38571. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38572. */
  38573. fovMode: number;
  38574. /**
  38575. * Rig mode of the camera.
  38576. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38577. * This is normally controlled byt the camera themselves as internal use.
  38578. */
  38579. cameraRigMode: number;
  38580. /**
  38581. * Defines the distance between both "eyes" in case of a RIG
  38582. */
  38583. interaxialDistance: number;
  38584. /**
  38585. * Defines if stereoscopic rendering is done side by side or over under.
  38586. */
  38587. isStereoscopicSideBySide: boolean;
  38588. /**
  38589. * 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
  38590. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  38591. * else in the scene. (Eg. security camera)
  38592. *
  38593. * 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)
  38594. */
  38595. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  38596. /**
  38597. * When set, the camera will render to this render target instead of the default canvas
  38598. *
  38599. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38600. */
  38601. outputRenderTarget: Nullable<RenderTargetTexture>;
  38602. /**
  38603. * Observable triggered when the camera view matrix has changed.
  38604. */
  38605. onViewMatrixChangedObservable: Observable<Camera>;
  38606. /**
  38607. * Observable triggered when the camera Projection matrix has changed.
  38608. */
  38609. onProjectionMatrixChangedObservable: Observable<Camera>;
  38610. /**
  38611. * Observable triggered when the inputs have been processed.
  38612. */
  38613. onAfterCheckInputsObservable: Observable<Camera>;
  38614. /**
  38615. * Observable triggered when reset has been called and applied to the camera.
  38616. */
  38617. onRestoreStateObservable: Observable<Camera>;
  38618. /**
  38619. * Is this camera a part of a rig system?
  38620. */
  38621. isRigCamera: boolean;
  38622. /**
  38623. * If isRigCamera set to true this will be set with the parent camera.
  38624. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38625. */
  38626. rigParent?: Camera;
  38627. /** @hidden */
  38628. _cameraRigParams: any;
  38629. /** @hidden */
  38630. _rigCameras: Camera[];
  38631. /** @hidden */
  38632. _rigPostProcess: Nullable<PostProcess>;
  38633. protected _webvrViewMatrix: Matrix;
  38634. /** @hidden */
  38635. _skipRendering: boolean;
  38636. /** @hidden */
  38637. _projectionMatrix: Matrix;
  38638. /** @hidden */
  38639. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  38640. /** @hidden */
  38641. _activeMeshes: SmartArray<AbstractMesh>;
  38642. protected _globalPosition: Vector3;
  38643. /** @hidden */
  38644. _computedViewMatrix: Matrix;
  38645. private _doNotComputeProjectionMatrix;
  38646. private _transformMatrix;
  38647. private _frustumPlanes;
  38648. private _refreshFrustumPlanes;
  38649. private _storedFov;
  38650. private _stateStored;
  38651. /**
  38652. * Instantiates a new camera object.
  38653. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38654. * @see https://doc.babylonjs.com/features/cameras
  38655. * @param name Defines the name of the camera in the scene
  38656. * @param position Defines the position of the camera
  38657. * @param scene Defines the scene the camera belongs too
  38658. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38659. */
  38660. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38661. /**
  38662. * Store current camera state (fov, position, etc..)
  38663. * @returns the camera
  38664. */
  38665. storeState(): Camera;
  38666. /**
  38667. * Restores the camera state values if it has been stored. You must call storeState() first
  38668. */
  38669. protected _restoreStateValues(): boolean;
  38670. /**
  38671. * Restored camera state. You must call storeState() first.
  38672. * @returns true if restored and false otherwise
  38673. */
  38674. restoreState(): boolean;
  38675. /**
  38676. * Gets the class name of the camera.
  38677. * @returns the class name
  38678. */
  38679. getClassName(): string;
  38680. /** @hidden */
  38681. readonly _isCamera: boolean;
  38682. /**
  38683. * Gets a string representation of the camera useful for debug purpose.
  38684. * @param fullDetails Defines that a more verboe level of logging is required
  38685. * @returns the string representation
  38686. */
  38687. toString(fullDetails?: boolean): string;
  38688. /**
  38689. * Gets the current world space position of the camera.
  38690. */
  38691. get globalPosition(): Vector3;
  38692. /**
  38693. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38694. * @returns the active meshe list
  38695. */
  38696. getActiveMeshes(): SmartArray<AbstractMesh>;
  38697. /**
  38698. * Check whether a mesh is part of the current active mesh list of the camera
  38699. * @param mesh Defines the mesh to check
  38700. * @returns true if active, false otherwise
  38701. */
  38702. isActiveMesh(mesh: Mesh): boolean;
  38703. /**
  38704. * Is this camera ready to be used/rendered
  38705. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38706. * @return true if the camera is ready
  38707. */
  38708. isReady(completeCheck?: boolean): boolean;
  38709. /** @hidden */
  38710. _initCache(): void;
  38711. /** @hidden */
  38712. _updateCache(ignoreParentClass?: boolean): void;
  38713. /** @hidden */
  38714. _isSynchronized(): boolean;
  38715. /** @hidden */
  38716. _isSynchronizedViewMatrix(): boolean;
  38717. /** @hidden */
  38718. _isSynchronizedProjectionMatrix(): boolean;
  38719. /**
  38720. * Attach the input controls to a specific dom element to get the input from.
  38721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38722. */
  38723. attachControl(noPreventDefault?: boolean): void;
  38724. /**
  38725. * Attach the input controls to a specific dom element to get the input from.
  38726. * @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
  38727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38728. * BACK COMPAT SIGNATURE ONLY.
  38729. */
  38730. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38731. /**
  38732. * Detach the current controls from the specified dom element.
  38733. */
  38734. detachControl(): void;
  38735. /**
  38736. * Detach the current controls from the specified dom element.
  38737. * @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
  38738. */
  38739. detachControl(ignored: any): void;
  38740. /**
  38741. * Update the camera state according to the different inputs gathered during the frame.
  38742. */
  38743. update(): void;
  38744. /** @hidden */
  38745. _checkInputs(): void;
  38746. /** @hidden */
  38747. get rigCameras(): Camera[];
  38748. /**
  38749. * Gets the post process used by the rig cameras
  38750. */
  38751. get rigPostProcess(): Nullable<PostProcess>;
  38752. /**
  38753. * Internal, gets the first post proces.
  38754. * @returns the first post process to be run on this camera.
  38755. */
  38756. _getFirstPostProcess(): Nullable<PostProcess>;
  38757. private _cascadePostProcessesToRigCams;
  38758. /**
  38759. * Attach a post process to the camera.
  38760. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38761. * @param postProcess The post process to attach to the camera
  38762. * @param insertAt The position of the post process in case several of them are in use in the scene
  38763. * @returns the position the post process has been inserted at
  38764. */
  38765. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38766. /**
  38767. * Detach a post process to the camera.
  38768. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38769. * @param postProcess The post process to detach from the camera
  38770. */
  38771. detachPostProcess(postProcess: PostProcess): void;
  38772. /**
  38773. * Gets the current world matrix of the camera
  38774. */
  38775. getWorldMatrix(): Matrix;
  38776. /** @hidden */
  38777. _getViewMatrix(): Matrix;
  38778. /**
  38779. * Gets the current view matrix of the camera.
  38780. * @param force forces the camera to recompute the matrix without looking at the cached state
  38781. * @returns the view matrix
  38782. */
  38783. getViewMatrix(force?: boolean): Matrix;
  38784. /**
  38785. * Freeze the projection matrix.
  38786. * It will prevent the cache check of the camera projection compute and can speed up perf
  38787. * if no parameter of the camera are meant to change
  38788. * @param projection Defines manually a projection if necessary
  38789. */
  38790. freezeProjectionMatrix(projection?: Matrix): void;
  38791. /**
  38792. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38793. */
  38794. unfreezeProjectionMatrix(): void;
  38795. /**
  38796. * Gets the current projection matrix of the camera.
  38797. * @param force forces the camera to recompute the matrix without looking at the cached state
  38798. * @returns the projection matrix
  38799. */
  38800. getProjectionMatrix(force?: boolean): Matrix;
  38801. /**
  38802. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38803. * @returns a Matrix
  38804. */
  38805. getTransformationMatrix(): Matrix;
  38806. private _updateFrustumPlanes;
  38807. /**
  38808. * Checks if a cullable object (mesh...) is in the camera frustum
  38809. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38810. * @param target The object to check
  38811. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38812. * @returns true if the object is in frustum otherwise false
  38813. */
  38814. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38815. /**
  38816. * Checks if a cullable object (mesh...) is in the camera frustum
  38817. * Unlike isInFrustum this cheks the full bounding box
  38818. * @param target The object to check
  38819. * @returns true if the object is in frustum otherwise false
  38820. */
  38821. isCompletelyInFrustum(target: ICullable): boolean;
  38822. /**
  38823. * Gets a ray in the forward direction from the camera.
  38824. * @param length Defines the length of the ray to create
  38825. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38826. * @param origin Defines the start point of the ray which defaults to the camera position
  38827. * @returns the forward ray
  38828. */
  38829. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38830. /**
  38831. * Gets a ray in the forward direction from the camera.
  38832. * @param refRay the ray to (re)use when setting the values
  38833. * @param length Defines the length of the ray to create
  38834. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38835. * @param origin Defines the start point of the ray which defaults to the camera position
  38836. * @returns the forward ray
  38837. */
  38838. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38839. /**
  38840. * Releases resources associated with this node.
  38841. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38842. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38843. */
  38844. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38845. /** @hidden */
  38846. _isLeftCamera: boolean;
  38847. /**
  38848. * Gets the left camera of a rig setup in case of Rigged Camera
  38849. */
  38850. get isLeftCamera(): boolean;
  38851. /** @hidden */
  38852. _isRightCamera: boolean;
  38853. /**
  38854. * Gets the right camera of a rig setup in case of Rigged Camera
  38855. */
  38856. get isRightCamera(): boolean;
  38857. /**
  38858. * Gets the left camera of a rig setup in case of Rigged Camera
  38859. */
  38860. get leftCamera(): Nullable<FreeCamera>;
  38861. /**
  38862. * Gets the right camera of a rig setup in case of Rigged Camera
  38863. */
  38864. get rightCamera(): Nullable<FreeCamera>;
  38865. /**
  38866. * Gets the left camera target of a rig setup in case of Rigged Camera
  38867. * @returns the target position
  38868. */
  38869. getLeftTarget(): Nullable<Vector3>;
  38870. /**
  38871. * Gets the right camera target of a rig setup in case of Rigged Camera
  38872. * @returns the target position
  38873. */
  38874. getRightTarget(): Nullable<Vector3>;
  38875. /**
  38876. * @hidden
  38877. */
  38878. setCameraRigMode(mode: number, rigParams: any): void;
  38879. /** @hidden */
  38880. static _setStereoscopicRigMode(camera: Camera): void;
  38881. /** @hidden */
  38882. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38883. /** @hidden */
  38884. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38885. /** @hidden */
  38886. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38887. /** @hidden */
  38888. _getVRProjectionMatrix(): Matrix;
  38889. protected _updateCameraRotationMatrix(): void;
  38890. protected _updateWebVRCameraRotationMatrix(): void;
  38891. /**
  38892. * This function MUST be overwritten by the different WebVR cameras available.
  38893. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38894. * @hidden
  38895. */
  38896. _getWebVRProjectionMatrix(): Matrix;
  38897. /**
  38898. * This function MUST be overwritten by the different WebVR cameras available.
  38899. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38900. * @hidden
  38901. */
  38902. _getWebVRViewMatrix(): Matrix;
  38903. /** @hidden */
  38904. setCameraRigParameter(name: string, value: any): void;
  38905. /**
  38906. * needs to be overridden by children so sub has required properties to be copied
  38907. * @hidden
  38908. */
  38909. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38910. /**
  38911. * May need to be overridden by children
  38912. * @hidden
  38913. */
  38914. _updateRigCameras(): void;
  38915. /** @hidden */
  38916. _setupInputs(): void;
  38917. /**
  38918. * Serialiaze the camera setup to a json represention
  38919. * @returns the JSON representation
  38920. */
  38921. serialize(): any;
  38922. /**
  38923. * Clones the current camera.
  38924. * @param name The cloned camera name
  38925. * @returns the cloned camera
  38926. */
  38927. clone(name: string): Camera;
  38928. /**
  38929. * Gets the direction of the camera relative to a given local axis.
  38930. * @param localAxis Defines the reference axis to provide a relative direction.
  38931. * @return the direction
  38932. */
  38933. getDirection(localAxis: Vector3): Vector3;
  38934. /**
  38935. * Returns the current camera absolute rotation
  38936. */
  38937. get absoluteRotation(): Quaternion;
  38938. /**
  38939. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38940. * @param localAxis Defines the reference axis to provide a relative direction.
  38941. * @param result Defines the vector to store the result in
  38942. */
  38943. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38944. /**
  38945. * Gets a camera constructor for a given camera type
  38946. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38947. * @param name The name of the camera the result will be able to instantiate
  38948. * @param scene The scene the result will construct the camera in
  38949. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38950. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38951. * @returns a factory method to construc the camera
  38952. */
  38953. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38954. /**
  38955. * Compute the world matrix of the camera.
  38956. * @returns the camera world matrix
  38957. */
  38958. computeWorldMatrix(): Matrix;
  38959. /**
  38960. * Parse a JSON and creates the camera from the parsed information
  38961. * @param parsedCamera The JSON to parse
  38962. * @param scene The scene to instantiate the camera in
  38963. * @returns the newly constructed camera
  38964. */
  38965. static Parse(parsedCamera: any, scene: Scene): Camera;
  38966. }
  38967. }
  38968. declare module "babylonjs/PostProcesses/postProcessManager" {
  38969. import { Nullable } from "babylonjs/types";
  38970. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38971. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38972. import { Scene } from "babylonjs/scene";
  38973. /**
  38974. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38975. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38976. */
  38977. export class PostProcessManager {
  38978. private _scene;
  38979. private _indexBuffer;
  38980. private _vertexBuffers;
  38981. /**
  38982. * Creates a new instance PostProcess
  38983. * @param scene The scene that the post process is associated with.
  38984. */
  38985. constructor(scene: Scene);
  38986. private _prepareBuffers;
  38987. private _buildIndexBuffer;
  38988. /**
  38989. * Rebuilds the vertex buffers of the manager.
  38990. * @hidden
  38991. */
  38992. _rebuild(): void;
  38993. /**
  38994. * Prepares a frame to be run through a post process.
  38995. * @param sourceTexture The input texture to the post procesess. (default: null)
  38996. * @param postProcesses An array of post processes to be run. (default: null)
  38997. * @returns True if the post processes were able to be run.
  38998. * @hidden
  38999. */
  39000. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  39001. /**
  39002. * Manually render a set of post processes to a texture.
  39003. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  39004. * @param postProcesses An array of post processes to be run.
  39005. * @param targetTexture The target texture to render to.
  39006. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  39007. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  39008. * @param lodLevel defines which lod of the texture to render to
  39009. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  39010. */
  39011. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  39012. /**
  39013. * Finalize the result of the output of the postprocesses.
  39014. * @param doNotPresent If true the result will not be displayed to the screen.
  39015. * @param targetTexture The target texture to render to.
  39016. * @param faceIndex The index of the face to bind the target texture to.
  39017. * @param postProcesses The array of post processes to render.
  39018. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  39019. * @hidden
  39020. */
  39021. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  39022. /**
  39023. * Disposes of the post process manager.
  39024. */
  39025. dispose(): void;
  39026. }
  39027. }
  39028. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  39029. import { Observable } from "babylonjs/Misc/observable";
  39030. import { SmartArray } from "babylonjs/Misc/smartArray";
  39031. import { Nullable, Immutable } from "babylonjs/types";
  39032. import { Camera } from "babylonjs/Cameras/camera";
  39033. import { Scene } from "babylonjs/scene";
  39034. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  39035. import { Color4 } from "babylonjs/Maths/math.color";
  39036. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  39037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39038. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39040. import { Texture } from "babylonjs/Materials/Textures/texture";
  39041. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39042. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  39043. import "babylonjs/Engines/Extensions/engine.renderTarget";
  39044. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  39045. import { Engine } from "babylonjs/Engines/engine";
  39046. /**
  39047. * This Helps creating a texture that will be created from a camera in your scene.
  39048. * It is basically a dynamic texture that could be used to create special effects for instance.
  39049. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39050. */
  39051. export class RenderTargetTexture extends Texture {
  39052. /**
  39053. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39054. */
  39055. static readonly REFRESHRATE_RENDER_ONCE: number;
  39056. /**
  39057. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  39058. */
  39059. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39060. /**
  39061. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39062. * the central point of your effect and can save a lot of performances.
  39063. */
  39064. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39065. /**
  39066. * Use this predicate to dynamically define the list of mesh you want to render.
  39067. * If set, the renderList property will be overwritten.
  39068. */
  39069. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39070. private _renderList;
  39071. /**
  39072. * Use this list to define the list of mesh you want to render.
  39073. */
  39074. get renderList(): Nullable<Array<AbstractMesh>>;
  39075. set renderList(value: Nullable<Array<AbstractMesh>>);
  39076. /**
  39077. * Use this function to overload the renderList array at rendering time.
  39078. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  39079. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39080. * the cube (if the RTT is a cube, else layerOrFace=0).
  39081. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39082. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39083. * hold dummy elements!
  39084. */
  39085. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39086. private _hookArray;
  39087. /**
  39088. * Define if particles should be rendered in your texture.
  39089. */
  39090. renderParticles: boolean;
  39091. /**
  39092. * Define if sprites should be rendered in your texture.
  39093. */
  39094. renderSprites: boolean;
  39095. /**
  39096. * Define the camera used to render the texture.
  39097. */
  39098. activeCamera: Nullable<Camera>;
  39099. /**
  39100. * Override the mesh isReady function with your own one.
  39101. */
  39102. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39103. /**
  39104. * Override the render function of the texture with your own one.
  39105. */
  39106. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39107. /**
  39108. * Define if camera post processes should be use while rendering the texture.
  39109. */
  39110. useCameraPostProcesses: boolean;
  39111. /**
  39112. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39113. */
  39114. ignoreCameraViewport: boolean;
  39115. private _postProcessManager;
  39116. private _postProcesses;
  39117. private _resizeObserver;
  39118. /**
  39119. * An event triggered when the texture is unbind.
  39120. */
  39121. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39122. /**
  39123. * An event triggered when the texture is unbind.
  39124. */
  39125. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39126. private _onAfterUnbindObserver;
  39127. /**
  39128. * Set a after unbind callback in the texture.
  39129. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39130. */
  39131. set onAfterUnbind(callback: () => void);
  39132. /**
  39133. * An event triggered before rendering the texture
  39134. */
  39135. onBeforeRenderObservable: Observable<number>;
  39136. private _onBeforeRenderObserver;
  39137. /**
  39138. * Set a before render callback in the texture.
  39139. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39140. */
  39141. set onBeforeRender(callback: (faceIndex: number) => void);
  39142. /**
  39143. * An event triggered after rendering the texture
  39144. */
  39145. onAfterRenderObservable: Observable<number>;
  39146. private _onAfterRenderObserver;
  39147. /**
  39148. * Set a after render callback in the texture.
  39149. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39150. */
  39151. set onAfterRender(callback: (faceIndex: number) => void);
  39152. /**
  39153. * An event triggered after the texture clear
  39154. */
  39155. onClearObservable: Observable<Engine>;
  39156. private _onClearObserver;
  39157. /**
  39158. * Set a clear callback in the texture.
  39159. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39160. */
  39161. set onClear(callback: (Engine: Engine) => void);
  39162. /**
  39163. * An event triggered when the texture is resized.
  39164. */
  39165. onResizeObservable: Observable<RenderTargetTexture>;
  39166. /**
  39167. * Define the clear color of the Render Target if it should be different from the scene.
  39168. */
  39169. clearColor: Color4;
  39170. protected _size: number | {
  39171. width: number;
  39172. height: number;
  39173. layers?: number;
  39174. };
  39175. protected _initialSizeParameter: number | {
  39176. width: number;
  39177. height: number;
  39178. } | {
  39179. ratio: number;
  39180. };
  39181. protected _sizeRatio: Nullable<number>;
  39182. /** @hidden */
  39183. _generateMipMaps: boolean;
  39184. protected _renderingManager: RenderingManager;
  39185. /** @hidden */
  39186. _waitingRenderList?: string[];
  39187. protected _doNotChangeAspectRatio: boolean;
  39188. protected _currentRefreshId: number;
  39189. protected _refreshRate: number;
  39190. protected _textureMatrix: Matrix;
  39191. protected _samples: number;
  39192. protected _renderTargetOptions: RenderTargetCreationOptions;
  39193. /**
  39194. * Gets render target creation options that were used.
  39195. */
  39196. get renderTargetOptions(): RenderTargetCreationOptions;
  39197. protected _onRatioRescale(): void;
  39198. /**
  39199. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39200. * It must define where the camera used to render the texture is set
  39201. */
  39202. boundingBoxPosition: Vector3;
  39203. private _boundingBoxSize;
  39204. /**
  39205. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39206. * When defined, the cubemap will switch to local mode
  39207. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39208. * @example https://www.babylonjs-playground.com/#RNASML
  39209. */
  39210. set boundingBoxSize(value: Vector3);
  39211. get boundingBoxSize(): Vector3;
  39212. /**
  39213. * In case the RTT has been created with a depth texture, get the associated
  39214. * depth texture.
  39215. * Otherwise, return null.
  39216. */
  39217. get depthStencilTexture(): Nullable<InternalTexture>;
  39218. /**
  39219. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  39220. * or used a shadow, depth texture...
  39221. * @param name The friendly name of the texture
  39222. * @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)
  39223. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39224. * @param generateMipMaps True if mip maps need to be generated after render.
  39225. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39226. * @param type The type of the buffer in the RTT (int, half float, float...)
  39227. * @param isCube True if a cube texture needs to be created
  39228. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39229. * @param generateDepthBuffer True to generate a depth buffer
  39230. * @param generateStencilBuffer True to generate a stencil buffer
  39231. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  39232. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  39233. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39234. */
  39235. constructor(name: string, size: number | {
  39236. width: number;
  39237. height: number;
  39238. layers?: number;
  39239. } | {
  39240. ratio: number;
  39241. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  39242. /**
  39243. * Creates a depth stencil texture.
  39244. * This is only available in WebGL 2 or with the depth texture extension available.
  39245. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  39246. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  39247. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  39248. */
  39249. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  39250. private _processSizeParameter;
  39251. /**
  39252. * Define the number of samples to use in case of MSAA.
  39253. * It defaults to one meaning no MSAA has been enabled.
  39254. */
  39255. get samples(): number;
  39256. set samples(value: number);
  39257. /**
  39258. * Resets the refresh counter of the texture and start bak from scratch.
  39259. * Could be useful to regenerate the texture if it is setup to render only once.
  39260. */
  39261. resetRefreshCounter(): void;
  39262. /**
  39263. * Define the refresh rate of the texture or the rendering frequency.
  39264. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  39265. */
  39266. get refreshRate(): number;
  39267. set refreshRate(value: number);
  39268. /**
  39269. * Adds a post process to the render target rendering passes.
  39270. * @param postProcess define the post process to add
  39271. */
  39272. addPostProcess(postProcess: PostProcess): void;
  39273. /**
  39274. * Clear all the post processes attached to the render target
  39275. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  39276. */
  39277. clearPostProcesses(dispose?: boolean): void;
  39278. /**
  39279. * Remove one of the post process from the list of attached post processes to the texture
  39280. * @param postProcess define the post process to remove from the list
  39281. */
  39282. removePostProcess(postProcess: PostProcess): void;
  39283. /** @hidden */
  39284. _shouldRender(): boolean;
  39285. /**
  39286. * Gets the actual render size of the texture.
  39287. * @returns the width of the render size
  39288. */
  39289. getRenderSize(): number;
  39290. /**
  39291. * Gets the actual render width of the texture.
  39292. * @returns the width of the render size
  39293. */
  39294. getRenderWidth(): number;
  39295. /**
  39296. * Gets the actual render height of the texture.
  39297. * @returns the height of the render size
  39298. */
  39299. getRenderHeight(): number;
  39300. /**
  39301. * Gets the actual number of layers of the texture.
  39302. * @returns the number of layers
  39303. */
  39304. getRenderLayers(): number;
  39305. /**
  39306. * Get if the texture can be rescaled or not.
  39307. */
  39308. get canRescale(): boolean;
  39309. /**
  39310. * Resize the texture using a ratio.
  39311. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39312. */
  39313. scale(ratio: number): void;
  39314. /**
  39315. * Get the texture reflection matrix used to rotate/transform the reflection.
  39316. * @returns the reflection matrix
  39317. */
  39318. getReflectionTextureMatrix(): Matrix;
  39319. /**
  39320. * Resize the texture to a new desired size.
  39321. * Be carrefull as it will recreate all the data in the new texture.
  39322. * @param size Define the new size. It can be:
  39323. * - a number for squared texture,
  39324. * - an object containing { width: number, height: number }
  39325. * - or an object containing a ratio { ratio: number }
  39326. */
  39327. resize(size: number | {
  39328. width: number;
  39329. height: number;
  39330. } | {
  39331. ratio: number;
  39332. }): void;
  39333. private _defaultRenderListPrepared;
  39334. /**
  39335. * Renders all the objects from the render list into the texture.
  39336. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39337. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39338. */
  39339. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39340. private _bestReflectionRenderTargetDimension;
  39341. private _prepareRenderingManager;
  39342. /**
  39343. * @hidden
  39344. * @param faceIndex face index to bind to if this is a cubetexture
  39345. * @param layer defines the index of the texture to bind in the array
  39346. */
  39347. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39348. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39349. private renderToTarget;
  39350. /**
  39351. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39352. * This allowed control for front to back rendering or reversly depending of the special needs.
  39353. *
  39354. * @param renderingGroupId The rendering group id corresponding to its index
  39355. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39356. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39357. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39358. */
  39359. 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;
  39360. /**
  39361. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39362. *
  39363. * @param renderingGroupId The rendering group id corresponding to its index
  39364. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39365. */
  39366. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39367. /**
  39368. * Clones the texture.
  39369. * @returns the cloned texture
  39370. */
  39371. clone(): RenderTargetTexture;
  39372. /**
  39373. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  39374. * @returns The JSON representation of the texture
  39375. */
  39376. serialize(): any;
  39377. /**
  39378. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39379. */
  39380. disposeFramebufferObjects(): void;
  39381. /**
  39382. * Dispose the texture and release its associated resources.
  39383. */
  39384. dispose(): void;
  39385. /** @hidden */
  39386. _rebuild(): void;
  39387. /**
  39388. * Clear the info related to rendering groups preventing retention point in material dispose.
  39389. */
  39390. freeRenderingGroups(): void;
  39391. /**
  39392. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39393. * @returns the view count
  39394. */
  39395. getViewCount(): number;
  39396. }
  39397. }
  39398. declare module "babylonjs/Materials/effect" {
  39399. import { Observable } from "babylonjs/Misc/observable";
  39400. import { Nullable } from "babylonjs/types";
  39401. import { IDisposable } from "babylonjs/scene";
  39402. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39403. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39404. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  39405. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39406. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39407. import { Engine } from "babylonjs/Engines/engine";
  39408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39409. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  39410. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39411. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39412. /**
  39413. * Options to be used when creating an effect.
  39414. */
  39415. export interface IEffectCreationOptions {
  39416. /**
  39417. * Atrributes that will be used in the shader.
  39418. */
  39419. attributes: string[];
  39420. /**
  39421. * Uniform varible names that will be set in the shader.
  39422. */
  39423. uniformsNames: string[];
  39424. /**
  39425. * Uniform buffer variable names that will be set in the shader.
  39426. */
  39427. uniformBuffersNames: string[];
  39428. /**
  39429. * Sampler texture variable names that will be set in the shader.
  39430. */
  39431. samplers: string[];
  39432. /**
  39433. * Define statements that will be set in the shader.
  39434. */
  39435. defines: any;
  39436. /**
  39437. * Possible fallbacks for this effect to improve performance when needed.
  39438. */
  39439. fallbacks: Nullable<IEffectFallbacks>;
  39440. /**
  39441. * Callback that will be called when the shader is compiled.
  39442. */
  39443. onCompiled: Nullable<(effect: Effect) => void>;
  39444. /**
  39445. * Callback that will be called if an error occurs during shader compilation.
  39446. */
  39447. onError: Nullable<(effect: Effect, errors: string) => void>;
  39448. /**
  39449. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39450. */
  39451. indexParameters?: any;
  39452. /**
  39453. * Max number of lights that can be used in the shader.
  39454. */
  39455. maxSimultaneousLights?: number;
  39456. /**
  39457. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39458. */
  39459. transformFeedbackVaryings?: Nullable<string[]>;
  39460. /**
  39461. * 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
  39462. */
  39463. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39464. /**
  39465. * Is this effect rendering to several color attachments ?
  39466. */
  39467. multiTarget?: boolean;
  39468. }
  39469. /**
  39470. * Effect containing vertex and fragment shader that can be executed on an object.
  39471. */
  39472. export class Effect implements IDisposable {
  39473. /**
  39474. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39475. */
  39476. static ShadersRepository: string;
  39477. /**
  39478. * Enable logging of the shader code when a compilation error occurs
  39479. */
  39480. static LogShaderCodeOnCompilationError: boolean;
  39481. /**
  39482. * Name of the effect.
  39483. */
  39484. name: any;
  39485. /**
  39486. * String container all the define statements that should be set on the shader.
  39487. */
  39488. defines: string;
  39489. /**
  39490. * Callback that will be called when the shader is compiled.
  39491. */
  39492. onCompiled: Nullable<(effect: Effect) => void>;
  39493. /**
  39494. * Callback that will be called if an error occurs during shader compilation.
  39495. */
  39496. onError: Nullable<(effect: Effect, errors: string) => void>;
  39497. /**
  39498. * Callback that will be called when effect is bound.
  39499. */
  39500. onBind: Nullable<(effect: Effect) => void>;
  39501. /**
  39502. * Unique ID of the effect.
  39503. */
  39504. uniqueId: number;
  39505. /**
  39506. * Observable that will be called when the shader is compiled.
  39507. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39508. */
  39509. onCompileObservable: Observable<Effect>;
  39510. /**
  39511. * Observable that will be called if an error occurs during shader compilation.
  39512. */
  39513. onErrorObservable: Observable<Effect>;
  39514. /** @hidden */
  39515. _onBindObservable: Nullable<Observable<Effect>>;
  39516. /**
  39517. * @hidden
  39518. * Specifies if the effect was previously ready
  39519. */
  39520. _wasPreviouslyReady: boolean;
  39521. /**
  39522. * Observable that will be called when effect is bound.
  39523. */
  39524. get onBindObservable(): Observable<Effect>;
  39525. /** @hidden */
  39526. _bonesComputationForcedToCPU: boolean;
  39527. /** @hidden */
  39528. _multiTarget: boolean;
  39529. private static _uniqueIdSeed;
  39530. private _engine;
  39531. private _uniformBuffersNames;
  39532. private _uniformBuffersNamesList;
  39533. private _uniformsNames;
  39534. private _samplerList;
  39535. private _samplers;
  39536. private _isReady;
  39537. private _compilationError;
  39538. private _allFallbacksProcessed;
  39539. private _attributesNames;
  39540. private _attributes;
  39541. private _attributeLocationByName;
  39542. private _uniforms;
  39543. /**
  39544. * Key for the effect.
  39545. * @hidden
  39546. */
  39547. _key: string;
  39548. private _indexParameters;
  39549. private _fallbacks;
  39550. private _vertexSourceCode;
  39551. private _fragmentSourceCode;
  39552. private _vertexSourceCodeOverride;
  39553. private _fragmentSourceCodeOverride;
  39554. private _transformFeedbackVaryings;
  39555. private _rawVertexSourceCode;
  39556. private _rawFragmentSourceCode;
  39557. /**
  39558. * Compiled shader to webGL program.
  39559. * @hidden
  39560. */
  39561. _pipelineContext: Nullable<IPipelineContext>;
  39562. private _valueCache;
  39563. private static _baseCache;
  39564. /**
  39565. * Instantiates an effect.
  39566. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39567. * @param baseName Name of the effect.
  39568. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39569. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39570. * @param samplers List of sampler variables that will be passed to the shader.
  39571. * @param engine Engine to be used to render the effect
  39572. * @param defines Define statements to be added to the shader.
  39573. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39574. * @param onCompiled Callback that will be called when the shader is compiled.
  39575. * @param onError Callback that will be called if an error occurs during shader compilation.
  39576. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39577. */
  39578. 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);
  39579. private _useFinalCode;
  39580. /**
  39581. * Unique key for this effect
  39582. */
  39583. get key(): string;
  39584. /**
  39585. * If the effect has been compiled and prepared.
  39586. * @returns if the effect is compiled and prepared.
  39587. */
  39588. isReady(): boolean;
  39589. private _isReadyInternal;
  39590. /**
  39591. * The engine the effect was initialized with.
  39592. * @returns the engine.
  39593. */
  39594. getEngine(): Engine;
  39595. /**
  39596. * The pipeline context for this effect
  39597. * @returns the associated pipeline context
  39598. */
  39599. getPipelineContext(): Nullable<IPipelineContext>;
  39600. /**
  39601. * The set of names of attribute variables for the shader.
  39602. * @returns An array of attribute names.
  39603. */
  39604. getAttributesNames(): string[];
  39605. /**
  39606. * Returns the attribute at the given index.
  39607. * @param index The index of the attribute.
  39608. * @returns The location of the attribute.
  39609. */
  39610. getAttributeLocation(index: number): number;
  39611. /**
  39612. * Returns the attribute based on the name of the variable.
  39613. * @param name of the attribute to look up.
  39614. * @returns the attribute location.
  39615. */
  39616. getAttributeLocationByName(name: string): number;
  39617. /**
  39618. * The number of attributes.
  39619. * @returns the numnber of attributes.
  39620. */
  39621. getAttributesCount(): number;
  39622. /**
  39623. * Gets the index of a uniform variable.
  39624. * @param uniformName of the uniform to look up.
  39625. * @returns the index.
  39626. */
  39627. getUniformIndex(uniformName: string): number;
  39628. /**
  39629. * Returns the attribute based on the name of the variable.
  39630. * @param uniformName of the uniform to look up.
  39631. * @returns the location of the uniform.
  39632. */
  39633. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39634. /**
  39635. * Returns an array of sampler variable names
  39636. * @returns The array of sampler variable names.
  39637. */
  39638. getSamplers(): string[];
  39639. /**
  39640. * Returns an array of uniform variable names
  39641. * @returns The array of uniform variable names.
  39642. */
  39643. getUniformNames(): string[];
  39644. /**
  39645. * Returns an array of uniform buffer variable names
  39646. * @returns The array of uniform buffer variable names.
  39647. */
  39648. getUniformBuffersNames(): string[];
  39649. /**
  39650. * Returns the index parameters used to create the effect
  39651. * @returns The index parameters object
  39652. */
  39653. getIndexParameters(): any;
  39654. /**
  39655. * The error from the last compilation.
  39656. * @returns the error string.
  39657. */
  39658. getCompilationError(): string;
  39659. /**
  39660. * Gets a boolean indicating that all fallbacks were used during compilation
  39661. * @returns true if all fallbacks were used
  39662. */
  39663. allFallbacksProcessed(): boolean;
  39664. /**
  39665. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39666. * @param func The callback to be used.
  39667. */
  39668. executeWhenCompiled(func: (effect: Effect) => void): void;
  39669. private _checkIsReady;
  39670. private _loadShader;
  39671. /**
  39672. * Gets the vertex shader source code of this effect
  39673. */
  39674. get vertexSourceCode(): string;
  39675. /**
  39676. * Gets the fragment shader source code of this effect
  39677. */
  39678. get fragmentSourceCode(): string;
  39679. /**
  39680. * Gets the vertex shader source code before it has been processed by the preprocessor
  39681. */
  39682. get rawVertexSourceCode(): string;
  39683. /**
  39684. * Gets the fragment shader source code before it has been processed by the preprocessor
  39685. */
  39686. get rawFragmentSourceCode(): string;
  39687. /**
  39688. * Recompiles the webGL program
  39689. * @param vertexSourceCode The source code for the vertex shader.
  39690. * @param fragmentSourceCode The source code for the fragment shader.
  39691. * @param onCompiled Callback called when completed.
  39692. * @param onError Callback called on error.
  39693. * @hidden
  39694. */
  39695. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39696. /**
  39697. * Prepares the effect
  39698. * @hidden
  39699. */
  39700. _prepareEffect(): void;
  39701. private _getShaderCodeAndErrorLine;
  39702. private _processCompilationErrors;
  39703. /**
  39704. * Checks if the effect is supported. (Must be called after compilation)
  39705. */
  39706. get isSupported(): boolean;
  39707. /**
  39708. * Binds a texture to the engine to be used as output of the shader.
  39709. * @param channel Name of the output variable.
  39710. * @param texture Texture to bind.
  39711. * @hidden
  39712. */
  39713. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39714. /**
  39715. * Sets a texture on the engine to be used in the shader.
  39716. * @param channel Name of the sampler variable.
  39717. * @param texture Texture to set.
  39718. */
  39719. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39720. /**
  39721. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39722. * @param channel Name of the sampler variable.
  39723. * @param texture Texture to set.
  39724. */
  39725. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39726. /**
  39727. * Sets an array of textures on the engine to be used in the shader.
  39728. * @param channel Name of the variable.
  39729. * @param textures Textures to set.
  39730. */
  39731. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39732. /**
  39733. * 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)
  39734. * @param channel Name of the sampler variable.
  39735. * @param postProcess Post process to get the input texture from.
  39736. */
  39737. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39738. /**
  39739. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39740. * 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)
  39741. * @param channel Name of the sampler variable.
  39742. * @param postProcess Post process to get the output texture from.
  39743. */
  39744. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39745. /** @hidden */
  39746. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39747. /** @hidden */
  39748. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39749. /** @hidden */
  39750. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39751. /** @hidden */
  39752. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39753. /**
  39754. * Binds a buffer to a uniform.
  39755. * @param buffer Buffer to bind.
  39756. * @param name Name of the uniform variable to bind to.
  39757. */
  39758. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39759. /**
  39760. * Binds block to a uniform.
  39761. * @param blockName Name of the block to bind.
  39762. * @param index Index to bind.
  39763. */
  39764. bindUniformBlock(blockName: string, index: number): void;
  39765. /**
  39766. * Sets an interger value on a uniform variable.
  39767. * @param uniformName Name of the variable.
  39768. * @param value Value to be set.
  39769. * @returns this effect.
  39770. */
  39771. setInt(uniformName: string, value: number): Effect;
  39772. /**
  39773. * Sets an int 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. setIntArray(uniformName: string, array: Int32Array): Effect;
  39779. /**
  39780. * 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)
  39781. * @param uniformName Name of the variable.
  39782. * @param array array to be set.
  39783. * @returns this effect.
  39784. */
  39785. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39786. /**
  39787. * 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)
  39788. * @param uniformName Name of the variable.
  39789. * @param array array to be set.
  39790. * @returns this effect.
  39791. */
  39792. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39793. /**
  39794. * 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)
  39795. * @param uniformName Name of the variable.
  39796. * @param array array to be set.
  39797. * @returns this effect.
  39798. */
  39799. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39800. /**
  39801. * Sets an float array on a uniform variable.
  39802. * @param uniformName Name of the variable.
  39803. * @param array array to be set.
  39804. * @returns this effect.
  39805. */
  39806. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39807. /**
  39808. * 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)
  39809. * @param uniformName Name of the variable.
  39810. * @param array array to be set.
  39811. * @returns this effect.
  39812. */
  39813. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39814. /**
  39815. * 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)
  39816. * @param uniformName Name of the variable.
  39817. * @param array array to be set.
  39818. * @returns this effect.
  39819. */
  39820. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39821. /**
  39822. * 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)
  39823. * @param uniformName Name of the variable.
  39824. * @param array array to be set.
  39825. * @returns this effect.
  39826. */
  39827. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39828. /**
  39829. * Sets an array on a uniform variable.
  39830. * @param uniformName Name of the variable.
  39831. * @param array array to be set.
  39832. * @returns this effect.
  39833. */
  39834. setArray(uniformName: string, array: number[]): Effect;
  39835. /**
  39836. * 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)
  39837. * @param uniformName Name of the variable.
  39838. * @param array array to be set.
  39839. * @returns this effect.
  39840. */
  39841. setArray2(uniformName: string, array: number[]): Effect;
  39842. /**
  39843. * 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)
  39844. * @param uniformName Name of the variable.
  39845. * @param array array to be set.
  39846. * @returns this effect.
  39847. */
  39848. setArray3(uniformName: string, array: number[]): Effect;
  39849. /**
  39850. * 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)
  39851. * @param uniformName Name of the variable.
  39852. * @param array array to be set.
  39853. * @returns this effect.
  39854. */
  39855. setArray4(uniformName: string, array: number[]): Effect;
  39856. /**
  39857. * Sets matrices on a uniform variable.
  39858. * @param uniformName Name of the variable.
  39859. * @param matrices matrices to be set.
  39860. * @returns this effect.
  39861. */
  39862. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39863. /**
  39864. * Sets matrix on a uniform variable.
  39865. * @param uniformName Name of the variable.
  39866. * @param matrix matrix to be set.
  39867. * @returns this effect.
  39868. */
  39869. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39870. /**
  39871. * 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)
  39872. * @param uniformName Name of the variable.
  39873. * @param matrix matrix to be set.
  39874. * @returns this effect.
  39875. */
  39876. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39877. /**
  39878. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39879. * @param uniformName Name of the variable.
  39880. * @param matrix matrix to be set.
  39881. * @returns this effect.
  39882. */
  39883. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39884. /**
  39885. * Sets a float on a uniform variable.
  39886. * @param uniformName Name of the variable.
  39887. * @param value value to be set.
  39888. * @returns this effect.
  39889. */
  39890. setFloat(uniformName: string, value: number): Effect;
  39891. /**
  39892. * Sets a boolean on a uniform variable.
  39893. * @param uniformName Name of the variable.
  39894. * @param bool value to be set.
  39895. * @returns this effect.
  39896. */
  39897. setBool(uniformName: string, bool: boolean): Effect;
  39898. /**
  39899. * Sets a Vector2 on a uniform variable.
  39900. * @param uniformName Name of the variable.
  39901. * @param vector2 vector2 to be set.
  39902. * @returns this effect.
  39903. */
  39904. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39905. /**
  39906. * Sets a float2 on a uniform variable.
  39907. * @param uniformName Name of the variable.
  39908. * @param x First float in float2.
  39909. * @param y Second float in float2.
  39910. * @returns this effect.
  39911. */
  39912. setFloat2(uniformName: string, x: number, y: number): Effect;
  39913. /**
  39914. * Sets a Vector3 on a uniform variable.
  39915. * @param uniformName Name of the variable.
  39916. * @param vector3 Value to be set.
  39917. * @returns this effect.
  39918. */
  39919. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39920. /**
  39921. * Sets a float3 on a uniform variable.
  39922. * @param uniformName Name of the variable.
  39923. * @param x First float in float3.
  39924. * @param y Second float in float3.
  39925. * @param z Third float in float3.
  39926. * @returns this effect.
  39927. */
  39928. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39929. /**
  39930. * Sets a Vector4 on a uniform variable.
  39931. * @param uniformName Name of the variable.
  39932. * @param vector4 Value to be set.
  39933. * @returns this effect.
  39934. */
  39935. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39936. /**
  39937. * Sets a float4 on a uniform variable.
  39938. * @param uniformName Name of the variable.
  39939. * @param x First float in float4.
  39940. * @param y Second float in float4.
  39941. * @param z Third float in float4.
  39942. * @param w Fourth float in float4.
  39943. * @returns this effect.
  39944. */
  39945. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39946. /**
  39947. * Sets a Color3 on a uniform variable.
  39948. * @param uniformName Name of the variable.
  39949. * @param color3 Value to be set.
  39950. * @returns this effect.
  39951. */
  39952. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39953. /**
  39954. * Sets a Color4 on a uniform variable.
  39955. * @param uniformName Name of the variable.
  39956. * @param color3 Value to be set.
  39957. * @param alpha Alpha value to be set.
  39958. * @returns this effect.
  39959. */
  39960. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39961. /**
  39962. * Sets a Color4 on a uniform variable
  39963. * @param uniformName defines the name of the variable
  39964. * @param color4 defines the value to be set
  39965. * @returns this effect.
  39966. */
  39967. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39968. /** Release all associated resources */
  39969. dispose(): void;
  39970. /**
  39971. * This function will add a new shader to the shader store
  39972. * @param name the name of the shader
  39973. * @param pixelShader optional pixel shader content
  39974. * @param vertexShader optional vertex shader content
  39975. */
  39976. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39977. /**
  39978. * Store of each shader (The can be looked up using effect.key)
  39979. */
  39980. static ShadersStore: {
  39981. [key: string]: string;
  39982. };
  39983. /**
  39984. * Store of each included file for a shader (The can be looked up using effect.key)
  39985. */
  39986. static IncludesShadersStore: {
  39987. [key: string]: string;
  39988. };
  39989. /**
  39990. * Resets the cache of effects.
  39991. */
  39992. static ResetCache(): void;
  39993. }
  39994. }
  39995. declare module "babylonjs/Engines/engineCapabilities" {
  39996. /**
  39997. * Interface used to describe the capabilities of the engine relatively to the current browser
  39998. */
  39999. export interface EngineCapabilities {
  40000. /** Maximum textures units per fragment shader */
  40001. maxTexturesImageUnits: number;
  40002. /** Maximum texture units per vertex shader */
  40003. maxVertexTextureImageUnits: number;
  40004. /** Maximum textures units in the entire pipeline */
  40005. maxCombinedTexturesImageUnits: number;
  40006. /** Maximum texture size */
  40007. maxTextureSize: number;
  40008. /** Maximum texture samples */
  40009. maxSamples?: number;
  40010. /** Maximum cube texture size */
  40011. maxCubemapTextureSize: number;
  40012. /** Maximum render texture size */
  40013. maxRenderTextureSize: number;
  40014. /** Maximum number of vertex attributes */
  40015. maxVertexAttribs: number;
  40016. /** Maximum number of varyings */
  40017. maxVaryingVectors: number;
  40018. /** Maximum number of uniforms per vertex shader */
  40019. maxVertexUniformVectors: number;
  40020. /** Maximum number of uniforms per fragment shader */
  40021. maxFragmentUniformVectors: number;
  40022. /** Defines if standard derivates (dx/dy) are supported */
  40023. standardDerivatives: boolean;
  40024. /** Defines if s3tc texture compression is supported */
  40025. s3tc?: WEBGL_compressed_texture_s3tc;
  40026. /** Defines if pvrtc texture compression is supported */
  40027. pvrtc: any;
  40028. /** Defines if etc1 texture compression is supported */
  40029. etc1: any;
  40030. /** Defines if etc2 texture compression is supported */
  40031. etc2: any;
  40032. /** Defines if astc texture compression is supported */
  40033. astc: any;
  40034. /** Defines if bptc texture compression is supported */
  40035. bptc: any;
  40036. /** Defines if float textures are supported */
  40037. textureFloat: boolean;
  40038. /** Defines if vertex array objects are supported */
  40039. vertexArrayObject: boolean;
  40040. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40041. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40042. /** Gets the maximum level of anisotropy supported */
  40043. maxAnisotropy: number;
  40044. /** Defines if instancing is supported */
  40045. instancedArrays: boolean;
  40046. /** Defines if 32 bits indices are supported */
  40047. uintIndices: boolean;
  40048. /** Defines if high precision shaders are supported */
  40049. highPrecisionShaderSupported: boolean;
  40050. /** Defines if depth reading in the fragment shader is supported */
  40051. fragmentDepthSupported: boolean;
  40052. /** Defines if float texture linear filtering is supported*/
  40053. textureFloatLinearFiltering: boolean;
  40054. /** Defines if rendering to float textures is supported */
  40055. textureFloatRender: boolean;
  40056. /** Defines if half float textures are supported*/
  40057. textureHalfFloat: boolean;
  40058. /** Defines if half float texture linear filtering is supported*/
  40059. textureHalfFloatLinearFiltering: boolean;
  40060. /** Defines if rendering to half float textures is supported */
  40061. textureHalfFloatRender: boolean;
  40062. /** Defines if textureLOD shader command is supported */
  40063. textureLOD: boolean;
  40064. /** Defines if draw buffers extension is supported */
  40065. drawBuffersExtension: boolean;
  40066. /** Defines if depth textures are supported */
  40067. depthTextureExtension: boolean;
  40068. /** Defines if float color buffer are supported */
  40069. colorBufferFloat: boolean;
  40070. /** Gets disjoint timer query extension (null if not supported) */
  40071. timerQuery?: EXT_disjoint_timer_query;
  40072. /** Defines if timestamp can be used with timer query */
  40073. canUseTimestampForTimerQuery: boolean;
  40074. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40075. multiview?: any;
  40076. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40077. oculusMultiview?: any;
  40078. /** Function used to let the system compiles shaders in background */
  40079. parallelShaderCompile?: {
  40080. COMPLETION_STATUS_KHR: number;
  40081. };
  40082. /** Max number of texture samples for MSAA */
  40083. maxMSAASamples: number;
  40084. /** Defines if the blend min max extension is supported */
  40085. blendMinMax: boolean;
  40086. }
  40087. }
  40088. declare module "babylonjs/States/depthCullingState" {
  40089. import { Nullable } from "babylonjs/types";
  40090. /**
  40091. * @hidden
  40092. **/
  40093. export class DepthCullingState {
  40094. private _isDepthTestDirty;
  40095. private _isDepthMaskDirty;
  40096. private _isDepthFuncDirty;
  40097. private _isCullFaceDirty;
  40098. private _isCullDirty;
  40099. private _isZOffsetDirty;
  40100. private _isFrontFaceDirty;
  40101. private _depthTest;
  40102. private _depthMask;
  40103. private _depthFunc;
  40104. private _cull;
  40105. private _cullFace;
  40106. private _zOffset;
  40107. private _frontFace;
  40108. /**
  40109. * Initializes the state.
  40110. */
  40111. constructor();
  40112. get isDirty(): boolean;
  40113. get zOffset(): number;
  40114. set zOffset(value: number);
  40115. get cullFace(): Nullable<number>;
  40116. set cullFace(value: Nullable<number>);
  40117. get cull(): Nullable<boolean>;
  40118. set cull(value: Nullable<boolean>);
  40119. get depthFunc(): Nullable<number>;
  40120. set depthFunc(value: Nullable<number>);
  40121. get depthMask(): boolean;
  40122. set depthMask(value: boolean);
  40123. get depthTest(): boolean;
  40124. set depthTest(value: boolean);
  40125. get frontFace(): Nullable<number>;
  40126. set frontFace(value: Nullable<number>);
  40127. reset(): void;
  40128. apply(gl: WebGLRenderingContext): void;
  40129. }
  40130. }
  40131. declare module "babylonjs/States/stencilState" {
  40132. /**
  40133. * @hidden
  40134. **/
  40135. export class StencilState {
  40136. /** 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 */
  40137. static readonly ALWAYS: number;
  40138. /** Passed to stencilOperation to specify that stencil value must be kept */
  40139. static readonly KEEP: number;
  40140. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40141. static readonly REPLACE: number;
  40142. private _isStencilTestDirty;
  40143. private _isStencilMaskDirty;
  40144. private _isStencilFuncDirty;
  40145. private _isStencilOpDirty;
  40146. private _stencilTest;
  40147. private _stencilMask;
  40148. private _stencilFunc;
  40149. private _stencilFuncRef;
  40150. private _stencilFuncMask;
  40151. private _stencilOpStencilFail;
  40152. private _stencilOpDepthFail;
  40153. private _stencilOpStencilDepthPass;
  40154. get isDirty(): boolean;
  40155. get stencilFunc(): number;
  40156. set stencilFunc(value: number);
  40157. get stencilFuncRef(): number;
  40158. set stencilFuncRef(value: number);
  40159. get stencilFuncMask(): number;
  40160. set stencilFuncMask(value: number);
  40161. get stencilOpStencilFail(): number;
  40162. set stencilOpStencilFail(value: number);
  40163. get stencilOpDepthFail(): number;
  40164. set stencilOpDepthFail(value: number);
  40165. get stencilOpStencilDepthPass(): number;
  40166. set stencilOpStencilDepthPass(value: number);
  40167. get stencilMask(): number;
  40168. set stencilMask(value: number);
  40169. get stencilTest(): boolean;
  40170. set stencilTest(value: boolean);
  40171. constructor();
  40172. reset(): void;
  40173. apply(gl: WebGLRenderingContext): void;
  40174. }
  40175. }
  40176. declare module "babylonjs/States/alphaCullingState" {
  40177. /**
  40178. * @hidden
  40179. **/
  40180. export class AlphaState {
  40181. private _isAlphaBlendDirty;
  40182. private _isBlendFunctionParametersDirty;
  40183. private _isBlendEquationParametersDirty;
  40184. private _isBlendConstantsDirty;
  40185. private _alphaBlend;
  40186. private _blendFunctionParameters;
  40187. private _blendEquationParameters;
  40188. private _blendConstants;
  40189. /**
  40190. * Initializes the state.
  40191. */
  40192. constructor();
  40193. get isDirty(): boolean;
  40194. get alphaBlend(): boolean;
  40195. set alphaBlend(value: boolean);
  40196. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  40197. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  40198. setAlphaEquationParameters(rgb: number, alpha: number): void;
  40199. reset(): void;
  40200. apply(gl: WebGLRenderingContext): void;
  40201. }
  40202. }
  40203. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  40204. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40205. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40206. /** @hidden */
  40207. export class WebGLShaderProcessor implements IShaderProcessor {
  40208. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  40209. }
  40210. }
  40211. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  40212. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40213. /** @hidden */
  40214. export class WebGL2ShaderProcessor implements IShaderProcessor {
  40215. attributeProcessor(attribute: string): string;
  40216. varyingProcessor(varying: string, isFragment: boolean): string;
  40217. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  40218. }
  40219. }
  40220. declare module "babylonjs/Engines/instancingAttributeInfo" {
  40221. /**
  40222. * Interface for attribute information associated with buffer instanciation
  40223. */
  40224. export interface InstancingAttributeInfo {
  40225. /**
  40226. * Name of the GLSL attribute
  40227. * if attribute index is not specified, this is used to retrieve the index from the effect
  40228. */
  40229. attributeName: string;
  40230. /**
  40231. * Index/offset of the attribute in the vertex shader
  40232. * if not specified, this will be computes from the name.
  40233. */
  40234. index?: number;
  40235. /**
  40236. * size of the attribute, 1, 2, 3 or 4
  40237. */
  40238. attributeSize: number;
  40239. /**
  40240. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  40241. */
  40242. offset: number;
  40243. /**
  40244. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  40245. * default to 1
  40246. */
  40247. divisor?: number;
  40248. /**
  40249. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  40250. * default is FLOAT
  40251. */
  40252. attributeType?: number;
  40253. /**
  40254. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  40255. */
  40256. normalized?: boolean;
  40257. }
  40258. }
  40259. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  40260. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40261. import { Nullable } from "babylonjs/types";
  40262. module "babylonjs/Engines/thinEngine" {
  40263. interface ThinEngine {
  40264. /**
  40265. * Update a video texture
  40266. * @param texture defines the texture to update
  40267. * @param video defines the video element to use
  40268. * @param invertY defines if data must be stored with Y axis inverted
  40269. */
  40270. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40271. }
  40272. }
  40273. }
  40274. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  40275. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40276. import { Nullable } from "babylonjs/types";
  40277. module "babylonjs/Engines/thinEngine" {
  40278. interface ThinEngine {
  40279. /**
  40280. * Creates a dynamic texture
  40281. * @param width defines the width of the texture
  40282. * @param height defines the height of the texture
  40283. * @param generateMipMaps defines if the engine should generate the mip levels
  40284. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40285. * @returns the dynamic texture inside an InternalTexture
  40286. */
  40287. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40288. /**
  40289. * Update the content of a dynamic texture
  40290. * @param texture defines the texture to update
  40291. * @param source defines the source containing the data
  40292. * @param invertY defines if data must be stored with Y axis inverted
  40293. * @param premulAlpha defines if alpha is stored as premultiplied
  40294. * @param format defines the format of the data
  40295. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40296. */
  40297. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40298. }
  40299. }
  40300. }
  40301. declare module "babylonjs/Materials/Textures/videoTexture" {
  40302. import { Observable } from "babylonjs/Misc/observable";
  40303. import { Nullable } from "babylonjs/types";
  40304. import { Scene } from "babylonjs/scene";
  40305. import { Texture } from "babylonjs/Materials/Textures/texture";
  40306. import "babylonjs/Engines/Extensions/engine.videoTexture";
  40307. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  40308. /**
  40309. * Settings for finer control over video usage
  40310. */
  40311. export interface VideoTextureSettings {
  40312. /**
  40313. * Applies `autoplay` to video, if specified
  40314. */
  40315. autoPlay?: boolean;
  40316. /**
  40317. * Applies `muted` to video, if specified
  40318. */
  40319. muted?: boolean;
  40320. /**
  40321. * Applies `loop` to video, if specified
  40322. */
  40323. loop?: boolean;
  40324. /**
  40325. * Automatically updates internal texture from video at every frame in the render loop
  40326. */
  40327. autoUpdateTexture: boolean;
  40328. /**
  40329. * Image src displayed during the video loading or until the user interacts with the video.
  40330. */
  40331. poster?: string;
  40332. }
  40333. /**
  40334. * If you want to display a video in your scene, this is the special texture for that.
  40335. * This special texture works similar to other textures, with the exception of a few parameters.
  40336. * @see https://doc.babylonjs.com/how_to/video_texture
  40337. */
  40338. export class VideoTexture extends Texture {
  40339. /**
  40340. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40341. */
  40342. readonly autoUpdateTexture: boolean;
  40343. /**
  40344. * The video instance used by the texture internally
  40345. */
  40346. readonly video: HTMLVideoElement;
  40347. private _onUserActionRequestedObservable;
  40348. /**
  40349. * Event triggerd when a dom action is required by the user to play the video.
  40350. * This happens due to recent changes in browser policies preventing video to auto start.
  40351. */
  40352. get onUserActionRequestedObservable(): Observable<Texture>;
  40353. private _generateMipMaps;
  40354. private _stillImageCaptured;
  40355. private _displayingPosterTexture;
  40356. private _settings;
  40357. private _createInternalTextureOnEvent;
  40358. private _frameId;
  40359. private _currentSrc;
  40360. /**
  40361. * Creates a video texture.
  40362. * If you want to display a video in your scene, this is the special texture for that.
  40363. * This special texture works similar to other textures, with the exception of a few parameters.
  40364. * @see https://doc.babylonjs.com/how_to/video_texture
  40365. * @param name optional name, will detect from video source, if not defined
  40366. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40367. * @param scene is obviously the current scene.
  40368. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40369. * @param invertY is false by default but can be used to invert video on Y axis
  40370. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40371. * @param settings allows finer control over video usage
  40372. */
  40373. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40374. private _getName;
  40375. private _getVideo;
  40376. private _createInternalTexture;
  40377. private reset;
  40378. /**
  40379. * @hidden Internal method to initiate `update`.
  40380. */
  40381. _rebuild(): void;
  40382. /**
  40383. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40384. */
  40385. update(): void;
  40386. /**
  40387. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40388. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  40389. */
  40390. updateTexture(isVisible: boolean): void;
  40391. protected _updateInternalTexture: () => void;
  40392. /**
  40393. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40394. * @param url New url.
  40395. */
  40396. updateURL(url: string): void;
  40397. /**
  40398. * Clones the texture.
  40399. * @returns the cloned texture
  40400. */
  40401. clone(): VideoTexture;
  40402. /**
  40403. * Dispose the texture and release its associated resources.
  40404. */
  40405. dispose(): void;
  40406. /**
  40407. * Creates a video texture straight from a stream.
  40408. * @param scene Define the scene the texture should be created in
  40409. * @param stream Define the stream the texture should be created from
  40410. * @returns The created video texture as a promise
  40411. */
  40412. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40413. /**
  40414. * Creates a video texture straight from your WebCam video feed.
  40415. * @param scene Define the scene the texture should be created in
  40416. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40417. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40418. * @returns The created video texture as a promise
  40419. */
  40420. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40421. minWidth: number;
  40422. maxWidth: number;
  40423. minHeight: number;
  40424. maxHeight: number;
  40425. deviceId: string;
  40426. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40427. /**
  40428. * Creates a video texture straight from your WebCam video feed.
  40429. * @param scene Define the scene the texture should be created in
  40430. * @param onReady Define a callback to triggered once the texture will be ready
  40431. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40432. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40433. */
  40434. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40435. minWidth: number;
  40436. maxWidth: number;
  40437. minHeight: number;
  40438. maxHeight: number;
  40439. deviceId: string;
  40440. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40441. }
  40442. }
  40443. declare module "babylonjs/Engines/thinEngine" {
  40444. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  40445. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  40446. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40447. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40448. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  40449. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  40450. import { Observable } from "babylonjs/Misc/observable";
  40451. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  40452. import { StencilState } from "babylonjs/States/stencilState";
  40453. import { AlphaState } from "babylonjs/States/alphaCullingState";
  40454. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40455. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  40456. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40457. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40458. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40459. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  40460. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  40461. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  40462. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40463. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40464. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40465. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  40466. import { WebRequest } from "babylonjs/Misc/webRequest";
  40467. import { LoadFileError } from "babylonjs/Misc/fileTools";
  40468. /**
  40469. * Defines the interface used by objects working like Scene
  40470. * @hidden
  40471. */
  40472. export interface ISceneLike {
  40473. _addPendingData(data: any): void;
  40474. _removePendingData(data: any): void;
  40475. offlineProvider: IOfflineProvider;
  40476. }
  40477. /**
  40478. * Information about the current host
  40479. */
  40480. export interface HostInformation {
  40481. /**
  40482. * Defines if the current host is a mobile
  40483. */
  40484. isMobile: boolean;
  40485. }
  40486. /** Interface defining initialization parameters for Engine class */
  40487. export interface EngineOptions extends WebGLContextAttributes {
  40488. /**
  40489. * Defines if the engine should no exceed a specified device ratio
  40490. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40491. */
  40492. limitDeviceRatio?: number;
  40493. /**
  40494. * Defines if webvr should be enabled automatically
  40495. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40496. */
  40497. autoEnableWebVR?: boolean;
  40498. /**
  40499. * Defines if webgl2 should be turned off even if supported
  40500. * @see https://doc.babylonjs.com/features/webgl2
  40501. */
  40502. disableWebGL2Support?: boolean;
  40503. /**
  40504. * Defines if webaudio should be initialized as well
  40505. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40506. */
  40507. audioEngine?: boolean;
  40508. /**
  40509. * Defines if animations should run using a deterministic lock step
  40510. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40511. */
  40512. deterministicLockstep?: boolean;
  40513. /** Defines the maximum steps to use with deterministic lock step mode */
  40514. lockstepMaxSteps?: number;
  40515. /** Defines the seconds between each deterministic lock step */
  40516. timeStep?: number;
  40517. /**
  40518. * Defines that engine should ignore context lost events
  40519. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40520. */
  40521. doNotHandleContextLost?: boolean;
  40522. /**
  40523. * Defines that engine should ignore modifying touch action attribute and style
  40524. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40525. */
  40526. doNotHandleTouchAction?: boolean;
  40527. /**
  40528. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40529. */
  40530. useHighPrecisionFloats?: boolean;
  40531. /**
  40532. * Make the canvas XR Compatible for XR sessions
  40533. */
  40534. xrCompatible?: boolean;
  40535. /**
  40536. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40537. */
  40538. useHighPrecisionMatrix?: boolean;
  40539. /**
  40540. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40541. */
  40542. failIfMajorPerformanceCaveat?: boolean;
  40543. }
  40544. /**
  40545. * The base engine class (root of all engines)
  40546. */
  40547. export class ThinEngine {
  40548. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40549. static ExceptionList: ({
  40550. key: string;
  40551. capture: string;
  40552. captureConstraint: number;
  40553. targets: string[];
  40554. } | {
  40555. key: string;
  40556. capture: null;
  40557. captureConstraint: null;
  40558. targets: string[];
  40559. })[];
  40560. /** @hidden */
  40561. static _TextureLoaders: IInternalTextureLoader[];
  40562. /**
  40563. * Returns the current npm package of the sdk
  40564. */
  40565. static get NpmPackage(): string;
  40566. /**
  40567. * Returns the current version of the framework
  40568. */
  40569. static get Version(): string;
  40570. /**
  40571. * Returns a string describing the current engine
  40572. */
  40573. get description(): string;
  40574. /**
  40575. * Gets or sets the epsilon value used by collision engine
  40576. */
  40577. static CollisionsEpsilon: number;
  40578. /**
  40579. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40580. */
  40581. static get ShadersRepository(): string;
  40582. static set ShadersRepository(value: string);
  40583. /** @hidden */
  40584. _shaderProcessor: IShaderProcessor;
  40585. /**
  40586. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40587. */
  40588. forcePOTTextures: boolean;
  40589. /**
  40590. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40591. */
  40592. isFullscreen: boolean;
  40593. /**
  40594. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40595. */
  40596. cullBackFaces: boolean;
  40597. /**
  40598. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40599. */
  40600. renderEvenInBackground: boolean;
  40601. /**
  40602. * Gets or sets a boolean indicating that cache can be kept between frames
  40603. */
  40604. preventCacheWipeBetweenFrames: boolean;
  40605. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40606. validateShaderPrograms: boolean;
  40607. /**
  40608. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40609. * This can provide greater z depth for distant objects.
  40610. */
  40611. useReverseDepthBuffer: boolean;
  40612. /**
  40613. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40614. */
  40615. disableUniformBuffers: boolean;
  40616. /** @hidden */
  40617. _uniformBuffers: UniformBuffer[];
  40618. /**
  40619. * Gets a boolean indicating that the engine supports uniform buffers
  40620. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40621. */
  40622. get supportsUniformBuffers(): boolean;
  40623. /** @hidden */
  40624. _gl: WebGLRenderingContext;
  40625. /** @hidden */
  40626. _webGLVersion: number;
  40627. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40628. protected _windowIsBackground: boolean;
  40629. protected _creationOptions: EngineOptions;
  40630. protected _highPrecisionShadersAllowed: boolean;
  40631. /** @hidden */
  40632. get _shouldUseHighPrecisionShader(): boolean;
  40633. /**
  40634. * Gets a boolean indicating that only power of 2 textures are supported
  40635. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40636. */
  40637. get needPOTTextures(): boolean;
  40638. /** @hidden */
  40639. _badOS: boolean;
  40640. /** @hidden */
  40641. _badDesktopOS: boolean;
  40642. private _hardwareScalingLevel;
  40643. /** @hidden */
  40644. _caps: EngineCapabilities;
  40645. private _isStencilEnable;
  40646. private _glVersion;
  40647. private _glRenderer;
  40648. private _glVendor;
  40649. /** @hidden */
  40650. _videoTextureSupported: boolean;
  40651. protected _renderingQueueLaunched: boolean;
  40652. protected _activeRenderLoops: (() => void)[];
  40653. /**
  40654. * Observable signaled when a context lost event is raised
  40655. */
  40656. onContextLostObservable: Observable<ThinEngine>;
  40657. /**
  40658. * Observable signaled when a context restored event is raised
  40659. */
  40660. onContextRestoredObservable: Observable<ThinEngine>;
  40661. private _onContextLost;
  40662. private _onContextRestored;
  40663. protected _contextWasLost: boolean;
  40664. /** @hidden */
  40665. _doNotHandleContextLost: boolean;
  40666. /**
  40667. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40668. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40669. */
  40670. get doNotHandleContextLost(): boolean;
  40671. set doNotHandleContextLost(value: boolean);
  40672. /**
  40673. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40674. */
  40675. disableVertexArrayObjects: boolean;
  40676. /** @hidden */
  40677. protected _colorWrite: boolean;
  40678. /** @hidden */
  40679. protected _colorWriteChanged: boolean;
  40680. /** @hidden */
  40681. protected _depthCullingState: DepthCullingState;
  40682. /** @hidden */
  40683. protected _stencilState: StencilState;
  40684. /** @hidden */
  40685. _alphaState: AlphaState;
  40686. /** @hidden */
  40687. _alphaMode: number;
  40688. /** @hidden */
  40689. _alphaEquation: number;
  40690. /** @hidden */
  40691. _internalTexturesCache: InternalTexture[];
  40692. /** @hidden */
  40693. protected _activeChannel: number;
  40694. private _currentTextureChannel;
  40695. /** @hidden */
  40696. protected _boundTexturesCache: {
  40697. [key: string]: Nullable<InternalTexture>;
  40698. };
  40699. /** @hidden */
  40700. protected _currentEffect: Nullable<Effect>;
  40701. /** @hidden */
  40702. protected _currentProgram: Nullable<WebGLProgram>;
  40703. private _compiledEffects;
  40704. private _vertexAttribArraysEnabled;
  40705. /** @hidden */
  40706. protected _cachedViewport: Nullable<IViewportLike>;
  40707. private _cachedVertexArrayObject;
  40708. /** @hidden */
  40709. protected _cachedVertexBuffers: any;
  40710. /** @hidden */
  40711. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40712. /** @hidden */
  40713. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40714. /** @hidden */
  40715. _currentRenderTarget: Nullable<InternalTexture>;
  40716. private _uintIndicesCurrentlySet;
  40717. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40718. /** @hidden */
  40719. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40720. /** @hidden */
  40721. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40722. private _currentBufferPointers;
  40723. private _currentInstanceLocations;
  40724. private _currentInstanceBuffers;
  40725. private _textureUnits;
  40726. /** @hidden */
  40727. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40728. /** @hidden */
  40729. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40730. /** @hidden */
  40731. _boundRenderFunction: any;
  40732. private _vaoRecordInProgress;
  40733. private _mustWipeVertexAttributes;
  40734. private _emptyTexture;
  40735. private _emptyCubeTexture;
  40736. private _emptyTexture3D;
  40737. private _emptyTexture2DArray;
  40738. /** @hidden */
  40739. _frameHandler: number;
  40740. private _nextFreeTextureSlots;
  40741. private _maxSimultaneousTextures;
  40742. private _activeRequests;
  40743. /** @hidden */
  40744. _transformTextureUrl: Nullable<(url: string) => string>;
  40745. /**
  40746. * Gets information about the current host
  40747. */
  40748. hostInformation: HostInformation;
  40749. protected get _supportsHardwareTextureRescaling(): boolean;
  40750. private _framebufferDimensionsObject;
  40751. /**
  40752. * sets the object from which width and height will be taken from when getting render width and height
  40753. * Will fallback to the gl object
  40754. * @param dimensions the framebuffer width and height that will be used.
  40755. */
  40756. set framebufferDimensionsObject(dimensions: Nullable<{
  40757. framebufferWidth: number;
  40758. framebufferHeight: number;
  40759. }>);
  40760. /**
  40761. * Gets the current viewport
  40762. */
  40763. get currentViewport(): Nullable<IViewportLike>;
  40764. /**
  40765. * Gets the default empty texture
  40766. */
  40767. get emptyTexture(): InternalTexture;
  40768. /**
  40769. * Gets the default empty 3D texture
  40770. */
  40771. get emptyTexture3D(): InternalTexture;
  40772. /**
  40773. * Gets the default empty 2D array texture
  40774. */
  40775. get emptyTexture2DArray(): InternalTexture;
  40776. /**
  40777. * Gets the default empty cube texture
  40778. */
  40779. get emptyCubeTexture(): InternalTexture;
  40780. /**
  40781. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40782. */
  40783. readonly premultipliedAlpha: boolean;
  40784. /**
  40785. * Observable event triggered before each texture is initialized
  40786. */
  40787. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40788. /**
  40789. * Creates a new engine
  40790. * @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
  40791. * @param antialias defines enable antialiasing (default: false)
  40792. * @param options defines further options to be sent to the getContext() function
  40793. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40794. */
  40795. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40796. private _rebuildInternalTextures;
  40797. private _rebuildEffects;
  40798. /**
  40799. * Gets a boolean indicating if all created effects are ready
  40800. * @returns true if all effects are ready
  40801. */
  40802. areAllEffectsReady(): boolean;
  40803. protected _rebuildBuffers(): void;
  40804. protected _initGLContext(): void;
  40805. /**
  40806. * Gets version of the current webGL context
  40807. */
  40808. get webGLVersion(): number;
  40809. /**
  40810. * Gets a string identifying the name of the class
  40811. * @returns "Engine" string
  40812. */
  40813. getClassName(): string;
  40814. /**
  40815. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40816. */
  40817. get isStencilEnable(): boolean;
  40818. /** @hidden */
  40819. _prepareWorkingCanvas(): void;
  40820. /**
  40821. * Reset the texture cache to empty state
  40822. */
  40823. resetTextureCache(): void;
  40824. /**
  40825. * Gets an object containing information about the current webGL context
  40826. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40827. */
  40828. getGlInfo(): {
  40829. vendor: string;
  40830. renderer: string;
  40831. version: string;
  40832. };
  40833. /**
  40834. * Defines the hardware scaling level.
  40835. * By default the hardware scaling level is computed from the window device ratio.
  40836. * 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.
  40837. * @param level defines the level to use
  40838. */
  40839. setHardwareScalingLevel(level: number): void;
  40840. /**
  40841. * Gets the current hardware scaling level.
  40842. * By default the hardware scaling level is computed from the window device ratio.
  40843. * 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.
  40844. * @returns a number indicating the current hardware scaling level
  40845. */
  40846. getHardwareScalingLevel(): number;
  40847. /**
  40848. * Gets the list of loaded textures
  40849. * @returns an array containing all loaded textures
  40850. */
  40851. getLoadedTexturesCache(): InternalTexture[];
  40852. /**
  40853. * Gets the object containing all engine capabilities
  40854. * @returns the EngineCapabilities object
  40855. */
  40856. getCaps(): EngineCapabilities;
  40857. /**
  40858. * stop executing a render loop function and remove it from the execution array
  40859. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40860. */
  40861. stopRenderLoop(renderFunction?: () => void): void;
  40862. /** @hidden */
  40863. _renderLoop(): void;
  40864. /**
  40865. * Gets the HTML canvas attached with the current webGL context
  40866. * @returns a HTML canvas
  40867. */
  40868. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40869. /**
  40870. * Gets host window
  40871. * @returns the host window object
  40872. */
  40873. getHostWindow(): Nullable<Window>;
  40874. /**
  40875. * Gets the current render width
  40876. * @param useScreen defines if screen size must be used (or the current render target if any)
  40877. * @returns a number defining the current render width
  40878. */
  40879. getRenderWidth(useScreen?: boolean): number;
  40880. /**
  40881. * Gets the current render height
  40882. * @param useScreen defines if screen size must be used (or the current render target if any)
  40883. * @returns a number defining the current render height
  40884. */
  40885. getRenderHeight(useScreen?: boolean): number;
  40886. /**
  40887. * Can be used to override the current requestAnimationFrame requester.
  40888. * @hidden
  40889. */
  40890. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40891. /**
  40892. * Register and execute a render loop. The engine can have more than one render function
  40893. * @param renderFunction defines the function to continuously execute
  40894. */
  40895. runRenderLoop(renderFunction: () => void): void;
  40896. /**
  40897. * Clear the current render buffer or the current render target (if any is set up)
  40898. * @param color defines the color to use
  40899. * @param backBuffer defines if the back buffer must be cleared
  40900. * @param depth defines if the depth buffer must be cleared
  40901. * @param stencil defines if the stencil buffer must be cleared
  40902. */
  40903. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40904. private _viewportCached;
  40905. /** @hidden */
  40906. _viewport(x: number, y: number, width: number, height: number): void;
  40907. /**
  40908. * Set the WebGL's viewport
  40909. * @param viewport defines the viewport element to be used
  40910. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40911. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40912. */
  40913. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40914. /**
  40915. * Begin a new frame
  40916. */
  40917. beginFrame(): void;
  40918. /**
  40919. * Enf the current frame
  40920. */
  40921. endFrame(): void;
  40922. /**
  40923. * Resize the view according to the canvas' size
  40924. */
  40925. resize(): void;
  40926. /**
  40927. * Force a specific size of the canvas
  40928. * @param width defines the new canvas' width
  40929. * @param height defines the new canvas' height
  40930. * @returns true if the size was changed
  40931. */
  40932. setSize(width: number, height: number): boolean;
  40933. /**
  40934. * Binds the frame buffer to the specified texture.
  40935. * @param texture The texture to render to or null for the default canvas
  40936. * @param faceIndex The face of the texture to render to in case of cube texture
  40937. * @param requiredWidth The width of the target to render to
  40938. * @param requiredHeight The height of the target to render to
  40939. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40940. * @param lodLevel defines the lod level to bind to the frame buffer
  40941. * @param layer defines the 2d array index to bind to frame buffer to
  40942. */
  40943. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40944. /** @hidden */
  40945. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40946. /**
  40947. * Unbind the current render target texture from the webGL context
  40948. * @param texture defines the render target texture to unbind
  40949. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40950. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40951. */
  40952. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40953. /**
  40954. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40955. */
  40956. flushFramebuffer(): void;
  40957. /**
  40958. * Unbind the current render target and bind the default framebuffer
  40959. */
  40960. restoreDefaultFramebuffer(): void;
  40961. /** @hidden */
  40962. protected _resetVertexBufferBinding(): void;
  40963. /**
  40964. * Creates a vertex buffer
  40965. * @param data the data for the vertex buffer
  40966. * @returns the new WebGL static buffer
  40967. */
  40968. createVertexBuffer(data: DataArray): DataBuffer;
  40969. private _createVertexBuffer;
  40970. /**
  40971. * Creates a dynamic vertex buffer
  40972. * @param data the data for the dynamic vertex buffer
  40973. * @returns the new WebGL dynamic buffer
  40974. */
  40975. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40976. protected _resetIndexBufferBinding(): void;
  40977. /**
  40978. * Creates a new index buffer
  40979. * @param indices defines the content of the index buffer
  40980. * @param updatable defines if the index buffer must be updatable
  40981. * @returns a new webGL buffer
  40982. */
  40983. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40984. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40985. /**
  40986. * Bind a webGL buffer to the webGL context
  40987. * @param buffer defines the buffer to bind
  40988. */
  40989. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40990. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40991. private bindBuffer;
  40992. /**
  40993. * update the bound buffer with the given data
  40994. * @param data defines the data to update
  40995. */
  40996. updateArrayBuffer(data: Float32Array): void;
  40997. private _vertexAttribPointer;
  40998. /** @hidden */
  40999. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  41000. private _bindVertexBuffersAttributes;
  41001. /**
  41002. * Records a vertex array object
  41003. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41004. * @param vertexBuffers defines the list of vertex buffers to store
  41005. * @param indexBuffer defines the index buffer to store
  41006. * @param effect defines the effect to store
  41007. * @returns the new vertex array object
  41008. */
  41009. recordVertexArrayObject(vertexBuffers: {
  41010. [key: string]: VertexBuffer;
  41011. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  41012. /**
  41013. * Bind a specific vertex array object
  41014. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  41015. * @param vertexArrayObject defines the vertex array object to bind
  41016. * @param indexBuffer defines the index buffer to bind
  41017. */
  41018. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  41019. /**
  41020. * Bind webGl buffers directly to the webGL context
  41021. * @param vertexBuffer defines the vertex buffer to bind
  41022. * @param indexBuffer defines the index buffer to bind
  41023. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  41024. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  41025. * @param effect defines the effect associated with the vertex buffer
  41026. */
  41027. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  41028. private _unbindVertexArrayObject;
  41029. /**
  41030. * Bind a list of vertex buffers to the webGL context
  41031. * @param vertexBuffers defines the list of vertex buffers to bind
  41032. * @param indexBuffer defines the index buffer to bind
  41033. * @param effect defines the effect associated with the vertex buffers
  41034. */
  41035. bindBuffers(vertexBuffers: {
  41036. [key: string]: Nullable<VertexBuffer>;
  41037. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  41038. /**
  41039. * Unbind all instance attributes
  41040. */
  41041. unbindInstanceAttributes(): void;
  41042. /**
  41043. * Release and free the memory of a vertex array object
  41044. * @param vao defines the vertex array object to delete
  41045. */
  41046. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  41047. /** @hidden */
  41048. _releaseBuffer(buffer: DataBuffer): boolean;
  41049. protected _deleteBuffer(buffer: DataBuffer): void;
  41050. /**
  41051. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  41052. * @param instancesBuffer defines the webGL buffer to update and bind
  41053. * @param data defines the data to store in the buffer
  41054. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  41055. */
  41056. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  41057. /**
  41058. * Bind the content of a webGL buffer used with instantiation
  41059. * @param instancesBuffer defines the webGL buffer to bind
  41060. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  41061. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  41062. */
  41063. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  41064. /**
  41065. * Disable the instance attribute corresponding to the name in parameter
  41066. * @param name defines the name of the attribute to disable
  41067. */
  41068. disableInstanceAttributeByName(name: string): void;
  41069. /**
  41070. * Disable the instance attribute corresponding to the location in parameter
  41071. * @param attributeLocation defines the attribute location of the attribute to disable
  41072. */
  41073. disableInstanceAttribute(attributeLocation: number): void;
  41074. /**
  41075. * Disable the attribute corresponding to the location in parameter
  41076. * @param attributeLocation defines the attribute location of the attribute to disable
  41077. */
  41078. disableAttributeByIndex(attributeLocation: number): void;
  41079. /**
  41080. * Send a draw order
  41081. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41082. * @param indexStart defines the starting index
  41083. * @param indexCount defines the number of index to draw
  41084. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41085. */
  41086. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41087. /**
  41088. * Draw a list of points
  41089. * @param verticesStart defines the index of first vertex to draw
  41090. * @param verticesCount defines the count of vertices to draw
  41091. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41092. */
  41093. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41094. /**
  41095. * Draw a list of unindexed primitives
  41096. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41097. * @param verticesStart defines the index of first vertex to draw
  41098. * @param verticesCount defines the count of vertices to draw
  41099. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41100. */
  41101. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41102. /**
  41103. * Draw a list of indexed primitives
  41104. * @param fillMode defines the primitive to use
  41105. * @param indexStart defines the starting index
  41106. * @param indexCount defines the number of index to draw
  41107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41108. */
  41109. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41110. /**
  41111. * Draw a list of unindexed primitives
  41112. * @param fillMode defines the primitive to use
  41113. * @param verticesStart defines the index of first vertex to draw
  41114. * @param verticesCount defines the count of vertices to draw
  41115. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41116. */
  41117. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41118. private _drawMode;
  41119. /** @hidden */
  41120. protected _reportDrawCall(): void;
  41121. /** @hidden */
  41122. _releaseEffect(effect: Effect): void;
  41123. /** @hidden */
  41124. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41125. /**
  41126. * Create a new effect (used to store vertex/fragment shaders)
  41127. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  41128. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  41129. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  41130. * @param samplers defines an array of string used to represent textures
  41131. * @param defines defines the string containing the defines to use to compile the shaders
  41132. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  41133. * @param onCompiled defines a function to call when the effect creation is successful
  41134. * @param onError defines a function to call when the effect creation has failed
  41135. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  41136. * @returns the new Effect
  41137. */
  41138. 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;
  41139. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  41140. private _compileShader;
  41141. private _compileRawShader;
  41142. /** @hidden */
  41143. _getShaderSource(shader: WebGLShader): Nullable<string>;
  41144. /**
  41145. * Directly creates a webGL program
  41146. * @param pipelineContext defines the pipeline context to attach to
  41147. * @param vertexCode defines the vertex shader code to use
  41148. * @param fragmentCode defines the fragment shader code to use
  41149. * @param context defines the webGL context to use (if not set, the current one will be used)
  41150. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41151. * @returns the new webGL program
  41152. */
  41153. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41154. /**
  41155. * Creates a webGL program
  41156. * @param pipelineContext defines the pipeline context to attach to
  41157. * @param vertexCode defines the vertex shader code to use
  41158. * @param fragmentCode defines the fragment shader code to use
  41159. * @param defines defines the string containing the defines to use to compile the shaders
  41160. * @param context defines the webGL context to use (if not set, the current one will be used)
  41161. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41162. * @returns the new webGL program
  41163. */
  41164. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41165. /**
  41166. * Creates a new pipeline context
  41167. * @returns the new pipeline
  41168. */
  41169. createPipelineContext(): IPipelineContext;
  41170. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41171. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  41172. /** @hidden */
  41173. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  41174. /** @hidden */
  41175. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41176. /** @hidden */
  41177. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41178. /**
  41179. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41180. * @param pipelineContext defines the pipeline context to use
  41181. * @param uniformsNames defines the list of uniform names
  41182. * @returns an array of webGL uniform locations
  41183. */
  41184. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41185. /**
  41186. * Gets the lsit of active attributes for a given webGL program
  41187. * @param pipelineContext defines the pipeline context to use
  41188. * @param attributesNames defines the list of attribute names to get
  41189. * @returns an array of indices indicating the offset of each attribute
  41190. */
  41191. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41192. /**
  41193. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  41194. * @param effect defines the effect to activate
  41195. */
  41196. enableEffect(effect: Nullable<Effect>): void;
  41197. /**
  41198. * Set the value of an uniform to a number (int)
  41199. * @param uniform defines the webGL uniform location where to store the value
  41200. * @param value defines the int number to store
  41201. * @returns true if the value was set
  41202. */
  41203. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41204. /**
  41205. * Set the value of an uniform to an array of int32
  41206. * @param uniform defines the webGL uniform location where to store the value
  41207. * @param array defines the array of int32 to store
  41208. * @returns true if the value was set
  41209. */
  41210. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41211. /**
  41212. * Set the value of an uniform to an array of int32 (stored as vec2)
  41213. * @param uniform defines the webGL uniform location where to store the value
  41214. * @param array defines the array of int32 to store
  41215. * @returns true if the value was set
  41216. */
  41217. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41218. /**
  41219. * Set the value of an uniform to an array of int32 (stored as vec3)
  41220. * @param uniform defines the webGL uniform location where to store the value
  41221. * @param array defines the array of int32 to store
  41222. * @returns true if the value was set
  41223. */
  41224. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41225. /**
  41226. * Set the value of an uniform to an array of int32 (stored as vec4)
  41227. * @param uniform defines the webGL uniform location where to store the value
  41228. * @param array defines the array of int32 to store
  41229. * @returns true if the value was set
  41230. */
  41231. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41232. /**
  41233. * Set the value of an uniform to an array of number
  41234. * @param uniform defines the webGL uniform location where to store the value
  41235. * @param array defines the array of number to store
  41236. * @returns true if the value was set
  41237. */
  41238. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41239. /**
  41240. * Set the value of an uniform to an array of number (stored as vec2)
  41241. * @param uniform defines the webGL uniform location where to store the value
  41242. * @param array defines the array of number to store
  41243. * @returns true if the value was set
  41244. */
  41245. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41246. /**
  41247. * Set the value of an uniform to an array of number (stored as vec3)
  41248. * @param uniform defines the webGL uniform location where to store the value
  41249. * @param array defines the array of number to store
  41250. * @returns true if the value was set
  41251. */
  41252. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41253. /**
  41254. * Set the value of an uniform to an array of number (stored as vec4)
  41255. * @param uniform defines the webGL uniform location where to store the value
  41256. * @param array defines the array of number to store
  41257. * @returns true if the value was set
  41258. */
  41259. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41260. /**
  41261. * Set the value of an uniform to an array of float32 (stored as matrices)
  41262. * @param uniform defines the webGL uniform location where to store the value
  41263. * @param matrices defines the array of float32 to store
  41264. * @returns true if the value was set
  41265. */
  41266. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41267. /**
  41268. * Set the value of an uniform to a matrix (3x3)
  41269. * @param uniform defines the webGL uniform location where to store the value
  41270. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41271. * @returns true if the value was set
  41272. */
  41273. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41274. /**
  41275. * Set the value of an uniform to a matrix (2x2)
  41276. * @param uniform defines the webGL uniform location where to store the value
  41277. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41278. * @returns true if the value was set
  41279. */
  41280. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41281. /**
  41282. * Set the value of an uniform to a number (float)
  41283. * @param uniform defines the webGL uniform location where to store the value
  41284. * @param value defines the float number to store
  41285. * @returns true if the value was transfered
  41286. */
  41287. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41288. /**
  41289. * Set the value of an uniform to a vec2
  41290. * @param uniform defines the webGL uniform location where to store the value
  41291. * @param x defines the 1st component of the value
  41292. * @param y defines the 2nd component of the value
  41293. * @returns true if the value was set
  41294. */
  41295. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41296. /**
  41297. * Set the value of an uniform to a vec3
  41298. * @param uniform defines the webGL uniform location where to store the value
  41299. * @param x defines the 1st component of the value
  41300. * @param y defines the 2nd component of the value
  41301. * @param z defines the 3rd component of the value
  41302. * @returns true if the value was set
  41303. */
  41304. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41305. /**
  41306. * Set the value of an uniform to a vec4
  41307. * @param uniform defines the webGL uniform location where to store the value
  41308. * @param x defines the 1st component of the value
  41309. * @param y defines the 2nd component of the value
  41310. * @param z defines the 3rd component of the value
  41311. * @param w defines the 4th component of the value
  41312. * @returns true if the value was set
  41313. */
  41314. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41315. /**
  41316. * Apply all cached states (depth, culling, stencil and alpha)
  41317. */
  41318. applyStates(): void;
  41319. /**
  41320. * Enable or disable color writing
  41321. * @param enable defines the state to set
  41322. */
  41323. setColorWrite(enable: boolean): void;
  41324. /**
  41325. * Gets a boolean indicating if color writing is enabled
  41326. * @returns the current color writing state
  41327. */
  41328. getColorWrite(): boolean;
  41329. /**
  41330. * Gets the depth culling state manager
  41331. */
  41332. get depthCullingState(): DepthCullingState;
  41333. /**
  41334. * Gets the alpha state manager
  41335. */
  41336. get alphaState(): AlphaState;
  41337. /**
  41338. * Gets the stencil state manager
  41339. */
  41340. get stencilState(): StencilState;
  41341. /**
  41342. * Clears the list of texture accessible through engine.
  41343. * This can help preventing texture load conflict due to name collision.
  41344. */
  41345. clearInternalTexturesCache(): void;
  41346. /**
  41347. * Force the entire cache to be cleared
  41348. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41349. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41350. */
  41351. wipeCaches(bruteForce?: boolean): void;
  41352. /** @hidden */
  41353. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41354. min: number;
  41355. mag: number;
  41356. };
  41357. /** @hidden */
  41358. _createTexture(): WebGLTexture;
  41359. /**
  41360. * Usually called from Texture.ts.
  41361. * Passed information to create a WebGLTexture
  41362. * @param url defines a value which contains one of the following:
  41363. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41364. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41365. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41366. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41367. * @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)
  41368. * @param scene needed for loading to the correct scene
  41369. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41370. * @param onLoad optional callback to be called upon successful completion
  41371. * @param onError optional callback to be called upon failure
  41372. * @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
  41373. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41374. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41375. * @param forcedExtension defines the extension to use to pick the right loader
  41376. * @param mimeType defines an optional mime type
  41377. * @param loaderOptions options to be passed to the loader
  41378. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41379. */
  41380. 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;
  41381. /**
  41382. * Loads an image as an HTMLImageElement.
  41383. * @param input url string, ArrayBuffer, or Blob to load
  41384. * @param onLoad callback called when the image successfully loads
  41385. * @param onError callback called when the image fails to load
  41386. * @param offlineProvider offline provider for caching
  41387. * @param mimeType optional mime type
  41388. * @returns the HTMLImageElement of the loaded image
  41389. * @hidden
  41390. */
  41391. 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>;
  41392. /**
  41393. * @hidden
  41394. */
  41395. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41396. private _unpackFlipYCached;
  41397. /**
  41398. * In case you are sharing the context with other applications, it might
  41399. * be interested to not cache the unpack flip y state to ensure a consistent
  41400. * value would be set.
  41401. */
  41402. enableUnpackFlipYCached: boolean;
  41403. /** @hidden */
  41404. _unpackFlipY(value: boolean): void;
  41405. /** @hidden */
  41406. _getUnpackAlignement(): number;
  41407. private _getTextureTarget;
  41408. /**
  41409. * Update the sampling mode of a given texture
  41410. * @param samplingMode defines the required sampling mode
  41411. * @param texture defines the texture to update
  41412. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41413. */
  41414. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41415. /**
  41416. * Update the sampling mode of a given texture
  41417. * @param texture defines the texture to update
  41418. * @param wrapU defines the texture wrap mode of the u coordinates
  41419. * @param wrapV defines the texture wrap mode of the v coordinates
  41420. * @param wrapR defines the texture wrap mode of the r coordinates
  41421. */
  41422. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41423. /** @hidden */
  41424. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41425. width: number;
  41426. height: number;
  41427. layers?: number;
  41428. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  41429. /** @hidden */
  41430. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41431. /** @hidden */
  41432. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41433. /**
  41434. * Update a portion of an internal texture
  41435. * @param texture defines the texture to update
  41436. * @param imageData defines the data to store into the texture
  41437. * @param xOffset defines the x coordinates of the update rectangle
  41438. * @param yOffset defines the y coordinates of the update rectangle
  41439. * @param width defines the width of the update rectangle
  41440. * @param height defines the height of the update rectangle
  41441. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41442. * @param lod defines the lod level to update (0 by default)
  41443. */
  41444. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41445. /** @hidden */
  41446. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41447. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41448. private _prepareWebGLTexture;
  41449. /** @hidden */
  41450. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41451. private _getDepthStencilBuffer;
  41452. /** @hidden */
  41453. _releaseFramebufferObjects(texture: InternalTexture): void;
  41454. /** @hidden */
  41455. _releaseTexture(texture: InternalTexture): void;
  41456. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41457. protected _setProgram(program: WebGLProgram): void;
  41458. protected _boundUniforms: {
  41459. [key: number]: WebGLUniformLocation;
  41460. };
  41461. /**
  41462. * Binds an effect to the webGL context
  41463. * @param effect defines the effect to bind
  41464. */
  41465. bindSamplers(effect: Effect): void;
  41466. private _activateCurrentTexture;
  41467. /** @hidden */
  41468. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41469. /** @hidden */
  41470. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  41471. /**
  41472. * Unbind all textures from the webGL context
  41473. */
  41474. unbindAllTextures(): void;
  41475. /**
  41476. * Sets a texture to the according uniform.
  41477. * @param channel The texture channel
  41478. * @param uniform The uniform to set
  41479. * @param texture The texture to apply
  41480. */
  41481. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  41482. private _bindSamplerUniformToChannel;
  41483. private _getTextureWrapMode;
  41484. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  41485. /**
  41486. * Sets an array of texture to the webGL context
  41487. * @param channel defines the channel where the texture array must be set
  41488. * @param uniform defines the associated uniform location
  41489. * @param textures defines the array of textures to bind
  41490. */
  41491. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  41492. /** @hidden */
  41493. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41494. private _setTextureParameterFloat;
  41495. private _setTextureParameterInteger;
  41496. /**
  41497. * Unbind all vertex attributes from the webGL context
  41498. */
  41499. unbindAllAttributes(): void;
  41500. /**
  41501. * 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
  41502. */
  41503. releaseEffects(): void;
  41504. /**
  41505. * Dispose and release all associated resources
  41506. */
  41507. dispose(): void;
  41508. /**
  41509. * Attach a new callback raised when context lost event is fired
  41510. * @param callback defines the callback to call
  41511. */
  41512. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41513. /**
  41514. * Attach a new callback raised when context restored event is fired
  41515. * @param callback defines the callback to call
  41516. */
  41517. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41518. /**
  41519. * Get the current error code of the webGL context
  41520. * @returns the error code
  41521. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41522. */
  41523. getError(): number;
  41524. private _canRenderToFloatFramebuffer;
  41525. private _canRenderToHalfFloatFramebuffer;
  41526. private _canRenderToFramebuffer;
  41527. /** @hidden */
  41528. _getWebGLTextureType(type: number): number;
  41529. /** @hidden */
  41530. _getInternalFormat(format: number): number;
  41531. /** @hidden */
  41532. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41533. /** @hidden */
  41534. _getRGBAMultiSampleBufferFormat(type: number): number;
  41535. /** @hidden */
  41536. _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;
  41537. /**
  41538. * Loads a file from a url
  41539. * @param url url to load
  41540. * @param onSuccess callback called when the file successfully loads
  41541. * @param onProgress callback called while file is loading (if the server supports this mode)
  41542. * @param offlineProvider defines the offline provider for caching
  41543. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41544. * @param onError callback called when the file fails to load
  41545. * @returns a file request object
  41546. * @hidden
  41547. */
  41548. 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;
  41549. /**
  41550. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41551. * @param x defines the x coordinate of the rectangle where pixels must be read
  41552. * @param y defines the y coordinate of the rectangle where pixels must be read
  41553. * @param width defines the width of the rectangle where pixels must be read
  41554. * @param height defines the height of the rectangle where pixels must be read
  41555. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41556. * @returns a Uint8Array containing RGBA colors
  41557. */
  41558. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  41559. private static _IsSupported;
  41560. private static _HasMajorPerformanceCaveat;
  41561. /**
  41562. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41563. */
  41564. static get IsSupported(): boolean;
  41565. /**
  41566. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41567. * @returns true if the engine can be created
  41568. * @ignorenaming
  41569. */
  41570. static isSupported(): boolean;
  41571. /**
  41572. * 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)
  41573. */
  41574. static get HasMajorPerformanceCaveat(): boolean;
  41575. /**
  41576. * Find the next highest power of two.
  41577. * @param x Number to start search from.
  41578. * @return Next highest power of two.
  41579. */
  41580. static CeilingPOT(x: number): number;
  41581. /**
  41582. * Find the next lowest power of two.
  41583. * @param x Number to start search from.
  41584. * @return Next lowest power of two.
  41585. */
  41586. static FloorPOT(x: number): number;
  41587. /**
  41588. * Find the nearest power of two.
  41589. * @param x Number to start search from.
  41590. * @return Next nearest power of two.
  41591. */
  41592. static NearestPOT(x: number): number;
  41593. /**
  41594. * Get the closest exponent of two
  41595. * @param value defines the value to approximate
  41596. * @param max defines the maximum value to return
  41597. * @param mode defines how to define the closest value
  41598. * @returns closest exponent of two of the given value
  41599. */
  41600. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41601. /**
  41602. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41603. * @param func - the function to be called
  41604. * @param requester - the object that will request the next frame. Falls back to window.
  41605. * @returns frame number
  41606. */
  41607. static QueueNewFrame(func: () => void, requester?: any): number;
  41608. /**
  41609. * Gets host document
  41610. * @returns the host document object
  41611. */
  41612. getHostDocument(): Nullable<Document>;
  41613. }
  41614. }
  41615. declare module "babylonjs/Materials/Textures/internalTexture" {
  41616. import { Observable } from "babylonjs/Misc/observable";
  41617. import { Nullable, int } from "babylonjs/types";
  41618. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41619. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41620. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41621. /**
  41622. * Defines the source of the internal texture
  41623. */
  41624. export enum InternalTextureSource {
  41625. /**
  41626. * The source of the texture data is unknown
  41627. */
  41628. Unknown = 0,
  41629. /**
  41630. * Texture data comes from an URL
  41631. */
  41632. Url = 1,
  41633. /**
  41634. * Texture data is only used for temporary storage
  41635. */
  41636. Temp = 2,
  41637. /**
  41638. * Texture data comes from raw data (ArrayBuffer)
  41639. */
  41640. Raw = 3,
  41641. /**
  41642. * Texture content is dynamic (video or dynamic texture)
  41643. */
  41644. Dynamic = 4,
  41645. /**
  41646. * Texture content is generated by rendering to it
  41647. */
  41648. RenderTarget = 5,
  41649. /**
  41650. * Texture content is part of a multi render target process
  41651. */
  41652. MultiRenderTarget = 6,
  41653. /**
  41654. * Texture data comes from a cube data file
  41655. */
  41656. Cube = 7,
  41657. /**
  41658. * Texture data comes from a raw cube data
  41659. */
  41660. CubeRaw = 8,
  41661. /**
  41662. * Texture data come from a prefiltered cube data file
  41663. */
  41664. CubePrefiltered = 9,
  41665. /**
  41666. * Texture content is raw 3D data
  41667. */
  41668. Raw3D = 10,
  41669. /**
  41670. * Texture content is raw 2D array data
  41671. */
  41672. Raw2DArray = 11,
  41673. /**
  41674. * Texture content is a depth texture
  41675. */
  41676. Depth = 12,
  41677. /**
  41678. * Texture data comes from a raw cube data encoded with RGBD
  41679. */
  41680. CubeRawRGBD = 13
  41681. }
  41682. /**
  41683. * Class used to store data associated with WebGL texture data for the engine
  41684. * This class should not be used directly
  41685. */
  41686. export class InternalTexture {
  41687. /** @hidden */
  41688. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41689. /**
  41690. * Defines if the texture is ready
  41691. */
  41692. isReady: boolean;
  41693. /**
  41694. * Defines if the texture is a cube texture
  41695. */
  41696. isCube: boolean;
  41697. /**
  41698. * Defines if the texture contains 3D data
  41699. */
  41700. is3D: boolean;
  41701. /**
  41702. * Defines if the texture contains 2D array data
  41703. */
  41704. is2DArray: boolean;
  41705. /**
  41706. * Defines if the texture contains multiview data
  41707. */
  41708. isMultiview: boolean;
  41709. /**
  41710. * Gets the URL used to load this texture
  41711. */
  41712. url: string;
  41713. /** @hidden */
  41714. _originalUrl: string;
  41715. /**
  41716. * Gets the sampling mode of the texture
  41717. */
  41718. samplingMode: number;
  41719. /**
  41720. * Gets a boolean indicating if the texture needs mipmaps generation
  41721. */
  41722. generateMipMaps: boolean;
  41723. /**
  41724. * Gets the number of samples used by the texture (WebGL2+ only)
  41725. */
  41726. samples: number;
  41727. /**
  41728. * Gets the type of the texture (int, float...)
  41729. */
  41730. type: number;
  41731. /**
  41732. * Gets the format of the texture (RGB, RGBA...)
  41733. */
  41734. format: number;
  41735. /**
  41736. * Observable called when the texture is loaded
  41737. */
  41738. onLoadedObservable: Observable<InternalTexture>;
  41739. /**
  41740. * Gets the width of the texture
  41741. */
  41742. width: number;
  41743. /**
  41744. * Gets the height of the texture
  41745. */
  41746. height: number;
  41747. /**
  41748. * Gets the depth of the texture
  41749. */
  41750. depth: number;
  41751. /**
  41752. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41753. */
  41754. baseWidth: number;
  41755. /**
  41756. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41757. */
  41758. baseHeight: number;
  41759. /**
  41760. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41761. */
  41762. baseDepth: number;
  41763. /**
  41764. * Gets a boolean indicating if the texture is inverted on Y axis
  41765. */
  41766. invertY: boolean;
  41767. /** @hidden */
  41768. _invertVScale: boolean;
  41769. /** @hidden */
  41770. _associatedChannel: number;
  41771. /** @hidden */
  41772. _source: InternalTextureSource;
  41773. /** @hidden */
  41774. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41775. /** @hidden */
  41776. _bufferView: Nullable<ArrayBufferView>;
  41777. /** @hidden */
  41778. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41779. /** @hidden */
  41780. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41781. /** @hidden */
  41782. _size: number;
  41783. /** @hidden */
  41784. _extension: string;
  41785. /** @hidden */
  41786. _files: Nullable<string[]>;
  41787. /** @hidden */
  41788. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41789. /** @hidden */
  41790. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41791. /** @hidden */
  41792. _framebuffer: Nullable<WebGLFramebuffer>;
  41793. /** @hidden */
  41794. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41795. /** @hidden */
  41796. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41797. /** @hidden */
  41798. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41799. /** @hidden */
  41800. _attachments: Nullable<number[]>;
  41801. /** @hidden */
  41802. _textureArray: Nullable<InternalTexture[]>;
  41803. /** @hidden */
  41804. _cachedCoordinatesMode: Nullable<number>;
  41805. /** @hidden */
  41806. _cachedWrapU: Nullable<number>;
  41807. /** @hidden */
  41808. _cachedWrapV: Nullable<number>;
  41809. /** @hidden */
  41810. _cachedWrapR: Nullable<number>;
  41811. /** @hidden */
  41812. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41813. /** @hidden */
  41814. _isDisabled: boolean;
  41815. /** @hidden */
  41816. _compression: Nullable<string>;
  41817. /** @hidden */
  41818. _generateStencilBuffer: boolean;
  41819. /** @hidden */
  41820. _generateDepthBuffer: boolean;
  41821. /** @hidden */
  41822. _comparisonFunction: number;
  41823. /** @hidden */
  41824. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41825. /** @hidden */
  41826. _lodGenerationScale: number;
  41827. /** @hidden */
  41828. _lodGenerationOffset: number;
  41829. /** @hidden */
  41830. _depthStencilTexture: Nullable<InternalTexture>;
  41831. /** @hidden */
  41832. _colorTextureArray: Nullable<WebGLTexture>;
  41833. /** @hidden */
  41834. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41835. /** @hidden */
  41836. _lodTextureHigh: Nullable<BaseTexture>;
  41837. /** @hidden */
  41838. _lodTextureMid: Nullable<BaseTexture>;
  41839. /** @hidden */
  41840. _lodTextureLow: Nullable<BaseTexture>;
  41841. /** @hidden */
  41842. _isRGBD: boolean;
  41843. /** @hidden */
  41844. _linearSpecularLOD: boolean;
  41845. /** @hidden */
  41846. _irradianceTexture: Nullable<BaseTexture>;
  41847. /** @hidden */
  41848. _webGLTexture: Nullable<WebGLTexture>;
  41849. /** @hidden */
  41850. _references: number;
  41851. /** @hidden */
  41852. _gammaSpace: Nullable<boolean>;
  41853. private _engine;
  41854. /**
  41855. * Gets the Engine the texture belongs to.
  41856. * @returns The babylon engine
  41857. */
  41858. getEngine(): ThinEngine;
  41859. /**
  41860. * Gets the data source type of the texture
  41861. */
  41862. get source(): InternalTextureSource;
  41863. /**
  41864. * Creates a new InternalTexture
  41865. * @param engine defines the engine to use
  41866. * @param source defines the type of data that will be used
  41867. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41868. */
  41869. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41870. /**
  41871. * Increments the number of references (ie. the number of Texture that point to it)
  41872. */
  41873. incrementReferences(): void;
  41874. /**
  41875. * Change the size of the texture (not the size of the content)
  41876. * @param width defines the new width
  41877. * @param height defines the new height
  41878. * @param depth defines the new depth (1 by default)
  41879. */
  41880. updateSize(width: int, height: int, depth?: int): void;
  41881. /** @hidden */
  41882. _rebuild(): void;
  41883. /** @hidden */
  41884. _swapAndDie(target: InternalTexture): void;
  41885. /**
  41886. * Dispose the current allocated resources
  41887. */
  41888. dispose(): void;
  41889. }
  41890. }
  41891. declare module "babylonjs/Loading/loadingScreen" {
  41892. /**
  41893. * Interface used to present a loading screen while loading a scene
  41894. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41895. */
  41896. export interface ILoadingScreen {
  41897. /**
  41898. * Function called to display the loading screen
  41899. */
  41900. displayLoadingUI: () => void;
  41901. /**
  41902. * Function called to hide the loading screen
  41903. */
  41904. hideLoadingUI: () => void;
  41905. /**
  41906. * Gets or sets the color to use for the background
  41907. */
  41908. loadingUIBackgroundColor: string;
  41909. /**
  41910. * Gets or sets the text to display while loading
  41911. */
  41912. loadingUIText: string;
  41913. }
  41914. /**
  41915. * Class used for the default loading screen
  41916. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41917. */
  41918. export class DefaultLoadingScreen implements ILoadingScreen {
  41919. private _renderingCanvas;
  41920. private _loadingText;
  41921. private _loadingDivBackgroundColor;
  41922. private _loadingDiv;
  41923. private _loadingTextDiv;
  41924. /** Gets or sets the logo url to use for the default loading screen */
  41925. static DefaultLogoUrl: string;
  41926. /** Gets or sets the spinner url to use for the default loading screen */
  41927. static DefaultSpinnerUrl: string;
  41928. /**
  41929. * Creates a new default loading screen
  41930. * @param _renderingCanvas defines the canvas used to render the scene
  41931. * @param _loadingText defines the default text to display
  41932. * @param _loadingDivBackgroundColor defines the default background color
  41933. */
  41934. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41935. /**
  41936. * Function called to display the loading screen
  41937. */
  41938. displayLoadingUI(): void;
  41939. /**
  41940. * Function called to hide the loading screen
  41941. */
  41942. hideLoadingUI(): void;
  41943. /**
  41944. * Gets or sets the text to display while loading
  41945. */
  41946. set loadingUIText(text: string);
  41947. get loadingUIText(): string;
  41948. /**
  41949. * Gets or sets the color to use for the background
  41950. */
  41951. get loadingUIBackgroundColor(): string;
  41952. set loadingUIBackgroundColor(color: string);
  41953. private _resizeLoadingUI;
  41954. }
  41955. }
  41956. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41957. /**
  41958. * Interface for any object that can request an animation frame
  41959. */
  41960. export interface ICustomAnimationFrameRequester {
  41961. /**
  41962. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41963. */
  41964. renderFunction?: Function;
  41965. /**
  41966. * Called to request the next frame to render to
  41967. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41968. */
  41969. requestAnimationFrame: Function;
  41970. /**
  41971. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41972. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41973. */
  41974. requestID?: number;
  41975. }
  41976. }
  41977. declare module "babylonjs/Misc/performanceMonitor" {
  41978. /**
  41979. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41980. */
  41981. export class PerformanceMonitor {
  41982. private _enabled;
  41983. private _rollingFrameTime;
  41984. private _lastFrameTimeMs;
  41985. /**
  41986. * constructor
  41987. * @param frameSampleSize The number of samples required to saturate the sliding window
  41988. */
  41989. constructor(frameSampleSize?: number);
  41990. /**
  41991. * Samples current frame
  41992. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41993. */
  41994. sampleFrame(timeMs?: number): void;
  41995. /**
  41996. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41997. */
  41998. get averageFrameTime(): number;
  41999. /**
  42000. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  42001. */
  42002. get averageFrameTimeVariance(): number;
  42003. /**
  42004. * Returns the frame time of the most recent frame
  42005. */
  42006. get instantaneousFrameTime(): number;
  42007. /**
  42008. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  42009. */
  42010. get averageFPS(): number;
  42011. /**
  42012. * Returns the average framerate in frames per second using the most recent frame time
  42013. */
  42014. get instantaneousFPS(): number;
  42015. /**
  42016. * Returns true if enough samples have been taken to completely fill the sliding window
  42017. */
  42018. get isSaturated(): boolean;
  42019. /**
  42020. * Enables contributions to the sliding window sample set
  42021. */
  42022. enable(): void;
  42023. /**
  42024. * Disables contributions to the sliding window sample set
  42025. * Samples will not be interpolated over the disabled period
  42026. */
  42027. disable(): void;
  42028. /**
  42029. * Returns true if sampling is enabled
  42030. */
  42031. get isEnabled(): boolean;
  42032. /**
  42033. * Resets performance monitor
  42034. */
  42035. reset(): void;
  42036. }
  42037. /**
  42038. * RollingAverage
  42039. *
  42040. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  42041. */
  42042. export class RollingAverage {
  42043. /**
  42044. * Current average
  42045. */
  42046. average: number;
  42047. /**
  42048. * Current variance
  42049. */
  42050. variance: number;
  42051. protected _samples: Array<number>;
  42052. protected _sampleCount: number;
  42053. protected _pos: number;
  42054. protected _m2: number;
  42055. /**
  42056. * constructor
  42057. * @param length The number of samples required to saturate the sliding window
  42058. */
  42059. constructor(length: number);
  42060. /**
  42061. * Adds a sample to the sample set
  42062. * @param v The sample value
  42063. */
  42064. add(v: number): void;
  42065. /**
  42066. * Returns previously added values or null if outside of history or outside the sliding window domain
  42067. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  42068. * @return Value previously recorded with add() or null if outside of range
  42069. */
  42070. history(i: number): number;
  42071. /**
  42072. * Returns true if enough samples have been taken to completely fill the sliding window
  42073. * @return true if sample-set saturated
  42074. */
  42075. isSaturated(): boolean;
  42076. /**
  42077. * Resets the rolling average (equivalent to 0 samples taken so far)
  42078. */
  42079. reset(): void;
  42080. /**
  42081. * Wraps a value around the sample range boundaries
  42082. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  42083. * @return Wrapped position in sample range
  42084. */
  42085. protected _wrapPosition(i: number): number;
  42086. }
  42087. }
  42088. declare module "babylonjs/Misc/perfCounter" {
  42089. /**
  42090. * This class is used to track a performance counter which is number based.
  42091. * The user has access to many properties which give statistics of different nature.
  42092. *
  42093. * The implementer can track two kinds of Performance Counter: time and count.
  42094. * 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.
  42095. * 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.
  42096. */
  42097. export class PerfCounter {
  42098. /**
  42099. * Gets or sets a global boolean to turn on and off all the counters
  42100. */
  42101. static Enabled: boolean;
  42102. /**
  42103. * Returns the smallest value ever
  42104. */
  42105. get min(): number;
  42106. /**
  42107. * Returns the biggest value ever
  42108. */
  42109. get max(): number;
  42110. /**
  42111. * Returns the average value since the performance counter is running
  42112. */
  42113. get average(): number;
  42114. /**
  42115. * Returns the average value of the last second the counter was monitored
  42116. */
  42117. get lastSecAverage(): number;
  42118. /**
  42119. * Returns the current value
  42120. */
  42121. get current(): number;
  42122. /**
  42123. * Gets the accumulated total
  42124. */
  42125. get total(): number;
  42126. /**
  42127. * Gets the total value count
  42128. */
  42129. get count(): number;
  42130. /**
  42131. * Creates a new counter
  42132. */
  42133. constructor();
  42134. /**
  42135. * Call this method to start monitoring a new frame.
  42136. * 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.
  42137. */
  42138. fetchNewFrame(): void;
  42139. /**
  42140. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42141. * @param newCount the count value to add to the monitored count
  42142. * @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.
  42143. */
  42144. addCount(newCount: number, fetchResult: boolean): void;
  42145. /**
  42146. * Start monitoring this performance counter
  42147. */
  42148. beginMonitoring(): void;
  42149. /**
  42150. * Compute the time lapsed since the previous beginMonitoring() call.
  42151. * @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
  42152. */
  42153. endMonitoring(newFrame?: boolean): void;
  42154. private _fetchResult;
  42155. private _startMonitoringTime;
  42156. private _min;
  42157. private _max;
  42158. private _average;
  42159. private _current;
  42160. private _totalValueCount;
  42161. private _totalAccumulated;
  42162. private _lastSecAverage;
  42163. private _lastSecAccumulated;
  42164. private _lastSecTime;
  42165. private _lastSecValueCount;
  42166. }
  42167. }
  42168. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  42169. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42170. import { Nullable } from "babylonjs/types";
  42171. module "babylonjs/Engines/thinEngine" {
  42172. interface ThinEngine {
  42173. /** @hidden */
  42174. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  42175. }
  42176. }
  42177. }
  42178. declare module "babylonjs/Audio/analyser" {
  42179. import { Scene } from "babylonjs/scene";
  42180. /**
  42181. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42182. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42183. */
  42184. export class Analyser {
  42185. /**
  42186. * Gets or sets the smoothing
  42187. * @ignorenaming
  42188. */
  42189. SMOOTHING: number;
  42190. /**
  42191. * Gets or sets the FFT table size
  42192. * @ignorenaming
  42193. */
  42194. FFT_SIZE: number;
  42195. /**
  42196. * Gets or sets the bar graph amplitude
  42197. * @ignorenaming
  42198. */
  42199. BARGRAPHAMPLITUDE: number;
  42200. /**
  42201. * Gets or sets the position of the debug canvas
  42202. * @ignorenaming
  42203. */
  42204. DEBUGCANVASPOS: {
  42205. x: number;
  42206. y: number;
  42207. };
  42208. /**
  42209. * Gets or sets the debug canvas size
  42210. * @ignorenaming
  42211. */
  42212. DEBUGCANVASSIZE: {
  42213. width: number;
  42214. height: number;
  42215. };
  42216. private _byteFreqs;
  42217. private _byteTime;
  42218. private _floatFreqs;
  42219. private _webAudioAnalyser;
  42220. private _debugCanvas;
  42221. private _debugCanvasContext;
  42222. private _scene;
  42223. private _registerFunc;
  42224. private _audioEngine;
  42225. /**
  42226. * Creates a new analyser
  42227. * @param scene defines hosting scene
  42228. */
  42229. constructor(scene: Scene);
  42230. /**
  42231. * Get the number of data values you will have to play with for the visualization
  42232. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42233. * @returns a number
  42234. */
  42235. getFrequencyBinCount(): number;
  42236. /**
  42237. * Gets the current frequency data as a byte array
  42238. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42239. * @returns a Uint8Array
  42240. */
  42241. getByteFrequencyData(): Uint8Array;
  42242. /**
  42243. * Gets the current waveform as a byte array
  42244. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42245. * @returns a Uint8Array
  42246. */
  42247. getByteTimeDomainData(): Uint8Array;
  42248. /**
  42249. * Gets the current frequency data as a float array
  42250. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42251. * @returns a Float32Array
  42252. */
  42253. getFloatFrequencyData(): Float32Array;
  42254. /**
  42255. * Renders the debug canvas
  42256. */
  42257. drawDebugCanvas(): void;
  42258. /**
  42259. * Stops rendering the debug canvas and removes it
  42260. */
  42261. stopDebugCanvas(): void;
  42262. /**
  42263. * Connects two audio nodes
  42264. * @param inputAudioNode defines first node to connect
  42265. * @param outputAudioNode defines second node to connect
  42266. */
  42267. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42268. /**
  42269. * Releases all associated resources
  42270. */
  42271. dispose(): void;
  42272. }
  42273. }
  42274. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  42275. import { Observable } from "babylonjs/Misc/observable";
  42276. import { IDisposable } from "babylonjs/scene";
  42277. import { Nullable } from "babylonjs/types";
  42278. import { Analyser } from "babylonjs/Audio/analyser";
  42279. /**
  42280. * This represents an audio engine and it is responsible
  42281. * to play, synchronize and analyse sounds throughout the application.
  42282. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42283. */
  42284. export interface IAudioEngine extends IDisposable {
  42285. /**
  42286. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42287. */
  42288. readonly canUseWebAudio: boolean;
  42289. /**
  42290. * Gets the current AudioContext if available.
  42291. */
  42292. readonly audioContext: Nullable<AudioContext>;
  42293. /**
  42294. * The master gain node defines the global audio volume of your audio engine.
  42295. */
  42296. readonly masterGain: GainNode;
  42297. /**
  42298. * Gets whether or not mp3 are supported by your browser.
  42299. */
  42300. readonly isMP3supported: boolean;
  42301. /**
  42302. * Gets whether or not ogg are supported by your browser.
  42303. */
  42304. readonly isOGGsupported: boolean;
  42305. /**
  42306. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42307. * @ignoreNaming
  42308. */
  42309. WarnedWebAudioUnsupported: boolean;
  42310. /**
  42311. * Defines if the audio engine relies on a custom unlocked button.
  42312. * In this case, the embedded button will not be displayed.
  42313. */
  42314. useCustomUnlockedButton: boolean;
  42315. /**
  42316. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42317. */
  42318. readonly unlocked: boolean;
  42319. /**
  42320. * Event raised when audio has been unlocked on the browser.
  42321. */
  42322. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42323. /**
  42324. * Event raised when audio has been locked on the browser.
  42325. */
  42326. onAudioLockedObservable: Observable<IAudioEngine>;
  42327. /**
  42328. * Flags the audio engine in Locked state.
  42329. * This happens due to new browser policies preventing audio to autoplay.
  42330. */
  42331. lock(): void;
  42332. /**
  42333. * Unlocks the audio engine once a user action has been done on the dom.
  42334. * This is helpful to resume play once browser policies have been satisfied.
  42335. */
  42336. unlock(): void;
  42337. /**
  42338. * Gets the global volume sets on the master gain.
  42339. * @returns the global volume if set or -1 otherwise
  42340. */
  42341. getGlobalVolume(): number;
  42342. /**
  42343. * Sets the global volume of your experience (sets on the master gain).
  42344. * @param newVolume Defines the new global volume of the application
  42345. */
  42346. setGlobalVolume(newVolume: number): void;
  42347. /**
  42348. * Connect the audio engine to an audio analyser allowing some amazing
  42349. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42350. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42351. * @param analyser The analyser to connect to the engine
  42352. */
  42353. connectToAnalyser(analyser: Analyser): void;
  42354. }
  42355. }
  42356. declare module "babylonjs/Engines/engine" {
  42357. import { Observable } from "babylonjs/Misc/observable";
  42358. import { Nullable } from "babylonjs/types";
  42359. import { Scene } from "babylonjs/scene";
  42360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42361. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42362. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  42363. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  42364. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42365. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  42366. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  42367. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  42368. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42369. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  42370. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42371. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  42372. import "babylonjs/Engines/Extensions/engine.alpha";
  42373. import "babylonjs/Engines/Extensions/engine.readTexture";
  42374. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  42375. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  42376. import { Material } from "babylonjs/Materials/material";
  42377. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42378. /**
  42379. * Defines the interface used by display changed events
  42380. */
  42381. export interface IDisplayChangedEventArgs {
  42382. /** Gets the vrDisplay object (if any) */
  42383. vrDisplay: Nullable<any>;
  42384. /** Gets a boolean indicating if webVR is supported */
  42385. vrSupported: boolean;
  42386. }
  42387. /**
  42388. * Defines the interface used by objects containing a viewport (like a camera)
  42389. */
  42390. interface IViewportOwnerLike {
  42391. /**
  42392. * Gets or sets the viewport
  42393. */
  42394. viewport: IViewportLike;
  42395. }
  42396. /**
  42397. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42398. */
  42399. export class Engine extends ThinEngine {
  42400. /** Defines that alpha blending is disabled */
  42401. static readonly ALPHA_DISABLE: number;
  42402. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42403. static readonly ALPHA_ADD: number;
  42404. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42405. static readonly ALPHA_COMBINE: number;
  42406. /** Defines that alpha blending to DEST - SRC * DEST */
  42407. static readonly ALPHA_SUBTRACT: number;
  42408. /** Defines that alpha blending to SRC * DEST */
  42409. static readonly ALPHA_MULTIPLY: number;
  42410. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42411. static readonly ALPHA_MAXIMIZED: number;
  42412. /** Defines that alpha blending to SRC + DEST */
  42413. static readonly ALPHA_ONEONE: number;
  42414. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42415. static readonly ALPHA_PREMULTIPLIED: number;
  42416. /**
  42417. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42418. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42419. */
  42420. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42421. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42422. static readonly ALPHA_INTERPOLATE: number;
  42423. /**
  42424. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42425. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42426. */
  42427. static readonly ALPHA_SCREENMODE: number;
  42428. /** Defines that the ressource is not delayed*/
  42429. static readonly DELAYLOADSTATE_NONE: number;
  42430. /** Defines that the ressource was successfully delay loaded */
  42431. static readonly DELAYLOADSTATE_LOADED: number;
  42432. /** Defines that the ressource is currently delay loading */
  42433. static readonly DELAYLOADSTATE_LOADING: number;
  42434. /** Defines that the ressource is delayed and has not started loading */
  42435. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42436. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42437. static readonly NEVER: number;
  42438. /** 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 */
  42439. static readonly ALWAYS: number;
  42440. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42441. static readonly LESS: number;
  42442. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42443. static readonly EQUAL: number;
  42444. /** 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 */
  42445. static readonly LEQUAL: number;
  42446. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42447. static readonly GREATER: number;
  42448. /** 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 */
  42449. static readonly GEQUAL: number;
  42450. /** 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 */
  42451. static readonly NOTEQUAL: number;
  42452. /** Passed to stencilOperation to specify that stencil value must be kept */
  42453. static readonly KEEP: number;
  42454. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42455. static readonly REPLACE: number;
  42456. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42457. static readonly INCR: number;
  42458. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42459. static readonly DECR: number;
  42460. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42461. static readonly INVERT: number;
  42462. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42463. static readonly INCR_WRAP: number;
  42464. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42465. static readonly DECR_WRAP: number;
  42466. /** Texture is not repeating outside of 0..1 UVs */
  42467. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42468. /** Texture is repeating outside of 0..1 UVs */
  42469. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42470. /** Texture is repeating and mirrored */
  42471. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42472. /** ALPHA */
  42473. static readonly TEXTUREFORMAT_ALPHA: number;
  42474. /** LUMINANCE */
  42475. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42476. /** LUMINANCE_ALPHA */
  42477. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42478. /** RGB */
  42479. static readonly TEXTUREFORMAT_RGB: number;
  42480. /** RGBA */
  42481. static readonly TEXTUREFORMAT_RGBA: number;
  42482. /** RED */
  42483. static readonly TEXTUREFORMAT_RED: number;
  42484. /** RED (2nd reference) */
  42485. static readonly TEXTUREFORMAT_R: number;
  42486. /** RG */
  42487. static readonly TEXTUREFORMAT_RG: number;
  42488. /** RED_INTEGER */
  42489. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42490. /** RED_INTEGER (2nd reference) */
  42491. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42492. /** RG_INTEGER */
  42493. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42494. /** RGB_INTEGER */
  42495. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42496. /** RGBA_INTEGER */
  42497. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42498. /** UNSIGNED_BYTE */
  42499. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42500. /** UNSIGNED_BYTE (2nd reference) */
  42501. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42502. /** FLOAT */
  42503. static readonly TEXTURETYPE_FLOAT: number;
  42504. /** HALF_FLOAT */
  42505. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42506. /** BYTE */
  42507. static readonly TEXTURETYPE_BYTE: number;
  42508. /** SHORT */
  42509. static readonly TEXTURETYPE_SHORT: number;
  42510. /** UNSIGNED_SHORT */
  42511. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42512. /** INT */
  42513. static readonly TEXTURETYPE_INT: number;
  42514. /** UNSIGNED_INT */
  42515. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42516. /** UNSIGNED_SHORT_4_4_4_4 */
  42517. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42518. /** UNSIGNED_SHORT_5_5_5_1 */
  42519. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42520. /** UNSIGNED_SHORT_5_6_5 */
  42521. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42522. /** UNSIGNED_INT_2_10_10_10_REV */
  42523. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42524. /** UNSIGNED_INT_24_8 */
  42525. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42526. /** UNSIGNED_INT_10F_11F_11F_REV */
  42527. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42528. /** UNSIGNED_INT_5_9_9_9_REV */
  42529. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42530. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42531. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42532. /** nearest is mag = nearest and min = nearest and mip = linear */
  42533. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42534. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42535. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42536. /** Trilinear is mag = linear and min = linear and mip = linear */
  42537. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42538. /** nearest is mag = nearest and min = nearest and mip = linear */
  42539. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42540. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42541. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42542. /** Trilinear is mag = linear and min = linear and mip = linear */
  42543. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42544. /** mag = nearest and min = nearest and mip = nearest */
  42545. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42546. /** mag = nearest and min = linear and mip = nearest */
  42547. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42548. /** mag = nearest and min = linear and mip = linear */
  42549. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42550. /** mag = nearest and min = linear and mip = none */
  42551. static readonly TEXTURE_NEAREST_LINEAR: number;
  42552. /** mag = nearest and min = nearest and mip = none */
  42553. static readonly TEXTURE_NEAREST_NEAREST: number;
  42554. /** mag = linear and min = nearest and mip = nearest */
  42555. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42556. /** mag = linear and min = nearest and mip = linear */
  42557. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42558. /** mag = linear and min = linear and mip = none */
  42559. static readonly TEXTURE_LINEAR_LINEAR: number;
  42560. /** mag = linear and min = nearest and mip = none */
  42561. static readonly TEXTURE_LINEAR_NEAREST: number;
  42562. /** Explicit coordinates mode */
  42563. static readonly TEXTURE_EXPLICIT_MODE: number;
  42564. /** Spherical coordinates mode */
  42565. static readonly TEXTURE_SPHERICAL_MODE: number;
  42566. /** Planar coordinates mode */
  42567. static readonly TEXTURE_PLANAR_MODE: number;
  42568. /** Cubic coordinates mode */
  42569. static readonly TEXTURE_CUBIC_MODE: number;
  42570. /** Projection coordinates mode */
  42571. static readonly TEXTURE_PROJECTION_MODE: number;
  42572. /** Skybox coordinates mode */
  42573. static readonly TEXTURE_SKYBOX_MODE: number;
  42574. /** Inverse Cubic coordinates mode */
  42575. static readonly TEXTURE_INVCUBIC_MODE: number;
  42576. /** Equirectangular coordinates mode */
  42577. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42578. /** Equirectangular Fixed coordinates mode */
  42579. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42580. /** Equirectangular Fixed Mirrored coordinates mode */
  42581. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42582. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42583. static readonly SCALEMODE_FLOOR: number;
  42584. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42585. static readonly SCALEMODE_NEAREST: number;
  42586. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42587. static readonly SCALEMODE_CEILING: number;
  42588. /**
  42589. * Returns the current npm package of the sdk
  42590. */
  42591. static get NpmPackage(): string;
  42592. /**
  42593. * Returns the current version of the framework
  42594. */
  42595. static get Version(): string;
  42596. /** Gets the list of created engines */
  42597. static get Instances(): Engine[];
  42598. /**
  42599. * Gets the latest created engine
  42600. */
  42601. static get LastCreatedEngine(): Nullable<Engine>;
  42602. /**
  42603. * Gets the latest created scene
  42604. */
  42605. static get LastCreatedScene(): Nullable<Scene>;
  42606. /**
  42607. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42608. * @param flag defines which part of the materials must be marked as dirty
  42609. * @param predicate defines a predicate used to filter which materials should be affected
  42610. */
  42611. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42612. /**
  42613. * Method called to create the default loading screen.
  42614. * This can be overriden in your own app.
  42615. * @param canvas The rendering canvas element
  42616. * @returns The loading screen
  42617. */
  42618. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42619. /**
  42620. * Method called to create the default rescale post process on each engine.
  42621. */
  42622. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42623. /**
  42624. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42625. **/
  42626. enableOfflineSupport: boolean;
  42627. /**
  42628. * 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)
  42629. **/
  42630. disableManifestCheck: boolean;
  42631. /**
  42632. * Gets the list of created scenes
  42633. */
  42634. scenes: Scene[];
  42635. /**
  42636. * Event raised when a new scene is created
  42637. */
  42638. onNewSceneAddedObservable: Observable<Scene>;
  42639. /**
  42640. * Gets the list of created postprocesses
  42641. */
  42642. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42643. /**
  42644. * Gets a boolean indicating if the pointer is currently locked
  42645. */
  42646. isPointerLock: boolean;
  42647. /**
  42648. * Observable event triggered each time the rendering canvas is resized
  42649. */
  42650. onResizeObservable: Observable<Engine>;
  42651. /**
  42652. * Observable event triggered each time the canvas loses focus
  42653. */
  42654. onCanvasBlurObservable: Observable<Engine>;
  42655. /**
  42656. * Observable event triggered each time the canvas gains focus
  42657. */
  42658. onCanvasFocusObservable: Observable<Engine>;
  42659. /**
  42660. * Observable event triggered each time the canvas receives pointerout event
  42661. */
  42662. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42663. /**
  42664. * Observable raised when the engine begins a new frame
  42665. */
  42666. onBeginFrameObservable: Observable<Engine>;
  42667. /**
  42668. * If set, will be used to request the next animation frame for the render loop
  42669. */
  42670. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42671. /**
  42672. * Observable raised when the engine ends the current frame
  42673. */
  42674. onEndFrameObservable: Observable<Engine>;
  42675. /**
  42676. * Observable raised when the engine is about to compile a shader
  42677. */
  42678. onBeforeShaderCompilationObservable: Observable<Engine>;
  42679. /**
  42680. * Observable raised when the engine has jsut compiled a shader
  42681. */
  42682. onAfterShaderCompilationObservable: Observable<Engine>;
  42683. /**
  42684. * Gets the audio engine
  42685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42686. * @ignorenaming
  42687. */
  42688. static audioEngine: IAudioEngine;
  42689. /**
  42690. * Default AudioEngine factory responsible of creating the Audio Engine.
  42691. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42692. */
  42693. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42694. /**
  42695. * Default offline support factory responsible of creating a tool used to store data locally.
  42696. * By default, this will create a Database object if the workload has been embedded.
  42697. */
  42698. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42699. private _loadingScreen;
  42700. private _pointerLockRequested;
  42701. private _rescalePostProcess;
  42702. private _deterministicLockstep;
  42703. private _lockstepMaxSteps;
  42704. private _timeStep;
  42705. protected get _supportsHardwareTextureRescaling(): boolean;
  42706. private _fps;
  42707. private _deltaTime;
  42708. /** @hidden */
  42709. _drawCalls: PerfCounter;
  42710. /** 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 */
  42711. canvasTabIndex: number;
  42712. /**
  42713. * Turn this value on if you want to pause FPS computation when in background
  42714. */
  42715. disablePerformanceMonitorInBackground: boolean;
  42716. private _performanceMonitor;
  42717. /**
  42718. * Gets the performance monitor attached to this engine
  42719. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42720. */
  42721. get performanceMonitor(): PerformanceMonitor;
  42722. private _onFocus;
  42723. private _onBlur;
  42724. private _onCanvasPointerOut;
  42725. private _onCanvasBlur;
  42726. private _onCanvasFocus;
  42727. private _onFullscreenChange;
  42728. private _onPointerLockChange;
  42729. /**
  42730. * Gets the HTML element used to attach event listeners
  42731. * @returns a HTML element
  42732. */
  42733. getInputElement(): Nullable<HTMLElement>;
  42734. /**
  42735. * Creates a new engine
  42736. * @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
  42737. * @param antialias defines enable antialiasing (default: false)
  42738. * @param options defines further options to be sent to the getContext() function
  42739. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42740. */
  42741. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42742. /**
  42743. * Gets current aspect ratio
  42744. * @param viewportOwner defines the camera to use to get the aspect ratio
  42745. * @param useScreen defines if screen size must be used (or the current render target if any)
  42746. * @returns a number defining the aspect ratio
  42747. */
  42748. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42749. /**
  42750. * Gets current screen aspect ratio
  42751. * @returns a number defining the aspect ratio
  42752. */
  42753. getScreenAspectRatio(): number;
  42754. /**
  42755. * Gets the client rect of the HTML canvas attached with the current webGL context
  42756. * @returns a client rectanglee
  42757. */
  42758. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42759. /**
  42760. * Gets the client rect of the HTML element used for events
  42761. * @returns a client rectanglee
  42762. */
  42763. getInputElementClientRect(): Nullable<ClientRect>;
  42764. /**
  42765. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42766. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42767. * @returns true if engine is in deterministic lock step mode
  42768. */
  42769. isDeterministicLockStep(): boolean;
  42770. /**
  42771. * Gets the max steps when engine is running in deterministic lock step
  42772. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42773. * @returns the max steps
  42774. */
  42775. getLockstepMaxSteps(): number;
  42776. /**
  42777. * Returns the time in ms between steps when using deterministic lock step.
  42778. * @returns time step in (ms)
  42779. */
  42780. getTimeStep(): number;
  42781. /**
  42782. * Force the mipmap generation for the given render target texture
  42783. * @param texture defines the render target texture to use
  42784. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42785. */
  42786. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42787. /** States */
  42788. /**
  42789. * Set various states to the webGL context
  42790. * @param culling defines backface culling state
  42791. * @param zOffset defines the value to apply to zOffset (0 by default)
  42792. * @param force defines if states must be applied even if cache is up to date
  42793. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42794. */
  42795. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42796. /**
  42797. * Set the z offset to apply to current rendering
  42798. * @param value defines the offset to apply
  42799. */
  42800. setZOffset(value: number): void;
  42801. /**
  42802. * Gets the current value of the zOffset
  42803. * @returns the current zOffset state
  42804. */
  42805. getZOffset(): number;
  42806. /**
  42807. * Enable or disable depth buffering
  42808. * @param enable defines the state to set
  42809. */
  42810. setDepthBuffer(enable: boolean): void;
  42811. /**
  42812. * Gets a boolean indicating if depth writing is enabled
  42813. * @returns the current depth writing state
  42814. */
  42815. getDepthWrite(): boolean;
  42816. /**
  42817. * Enable or disable depth writing
  42818. * @param enable defines the state to set
  42819. */
  42820. setDepthWrite(enable: boolean): void;
  42821. /**
  42822. * Gets a boolean indicating if stencil buffer is enabled
  42823. * @returns the current stencil buffer state
  42824. */
  42825. getStencilBuffer(): boolean;
  42826. /**
  42827. * Enable or disable the stencil buffer
  42828. * @param enable defines if the stencil buffer must be enabled or disabled
  42829. */
  42830. setStencilBuffer(enable: boolean): void;
  42831. /**
  42832. * Gets the current stencil mask
  42833. * @returns a number defining the new stencil mask to use
  42834. */
  42835. getStencilMask(): number;
  42836. /**
  42837. * Sets the current stencil mask
  42838. * @param mask defines the new stencil mask to use
  42839. */
  42840. setStencilMask(mask: number): void;
  42841. /**
  42842. * Gets the current stencil function
  42843. * @returns a number defining the stencil function to use
  42844. */
  42845. getStencilFunction(): number;
  42846. /**
  42847. * Gets the current stencil reference value
  42848. * @returns a number defining the stencil reference value to use
  42849. */
  42850. getStencilFunctionReference(): number;
  42851. /**
  42852. * Gets the current stencil mask
  42853. * @returns a number defining the stencil mask to use
  42854. */
  42855. getStencilFunctionMask(): number;
  42856. /**
  42857. * Sets the current stencil function
  42858. * @param stencilFunc defines the new stencil function to use
  42859. */
  42860. setStencilFunction(stencilFunc: number): void;
  42861. /**
  42862. * Sets the current stencil reference
  42863. * @param reference defines the new stencil reference to use
  42864. */
  42865. setStencilFunctionReference(reference: number): void;
  42866. /**
  42867. * Sets the current stencil mask
  42868. * @param mask defines the new stencil mask to use
  42869. */
  42870. setStencilFunctionMask(mask: number): void;
  42871. /**
  42872. * Gets the current stencil operation when stencil fails
  42873. * @returns a number defining stencil operation to use when stencil fails
  42874. */
  42875. getStencilOperationFail(): number;
  42876. /**
  42877. * Gets the current stencil operation when depth fails
  42878. * @returns a number defining stencil operation to use when depth fails
  42879. */
  42880. getStencilOperationDepthFail(): number;
  42881. /**
  42882. * Gets the current stencil operation when stencil passes
  42883. * @returns a number defining stencil operation to use when stencil passes
  42884. */
  42885. getStencilOperationPass(): number;
  42886. /**
  42887. * Sets the stencil operation to use when stencil fails
  42888. * @param operation defines the stencil operation to use when stencil fails
  42889. */
  42890. setStencilOperationFail(operation: number): void;
  42891. /**
  42892. * Sets the stencil operation to use when depth fails
  42893. * @param operation defines the stencil operation to use when depth fails
  42894. */
  42895. setStencilOperationDepthFail(operation: number): void;
  42896. /**
  42897. * Sets the stencil operation to use when stencil passes
  42898. * @param operation defines the stencil operation to use when stencil passes
  42899. */
  42900. setStencilOperationPass(operation: number): void;
  42901. /**
  42902. * Sets a boolean indicating if the dithering state is enabled or disabled
  42903. * @param value defines the dithering state
  42904. */
  42905. setDitheringState(value: boolean): void;
  42906. /**
  42907. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42908. * @param value defines the rasterizer state
  42909. */
  42910. setRasterizerState(value: boolean): void;
  42911. /**
  42912. * Gets the current depth function
  42913. * @returns a number defining the depth function
  42914. */
  42915. getDepthFunction(): Nullable<number>;
  42916. /**
  42917. * Sets the current depth function
  42918. * @param depthFunc defines the function to use
  42919. */
  42920. setDepthFunction(depthFunc: number): void;
  42921. /**
  42922. * Sets the current depth function to GREATER
  42923. */
  42924. setDepthFunctionToGreater(): void;
  42925. /**
  42926. * Sets the current depth function to GEQUAL
  42927. */
  42928. setDepthFunctionToGreaterOrEqual(): void;
  42929. /**
  42930. * Sets the current depth function to LESS
  42931. */
  42932. setDepthFunctionToLess(): void;
  42933. /**
  42934. * Sets the current depth function to LEQUAL
  42935. */
  42936. setDepthFunctionToLessOrEqual(): void;
  42937. private _cachedStencilBuffer;
  42938. private _cachedStencilFunction;
  42939. private _cachedStencilMask;
  42940. private _cachedStencilOperationPass;
  42941. private _cachedStencilOperationFail;
  42942. private _cachedStencilOperationDepthFail;
  42943. private _cachedStencilReference;
  42944. /**
  42945. * Caches the the state of the stencil buffer
  42946. */
  42947. cacheStencilState(): void;
  42948. /**
  42949. * Restores the state of the stencil buffer
  42950. */
  42951. restoreStencilState(): void;
  42952. /**
  42953. * Directly set the WebGL Viewport
  42954. * @param x defines the x coordinate of the viewport (in screen space)
  42955. * @param y defines the y coordinate of the viewport (in screen space)
  42956. * @param width defines the width of the viewport (in screen space)
  42957. * @param height defines the height of the viewport (in screen space)
  42958. * @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
  42959. */
  42960. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42961. /**
  42962. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42963. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42964. * @param y defines the y-coordinate of the corner of the clear rectangle
  42965. * @param width defines the width of the clear rectangle
  42966. * @param height defines the height of the clear rectangle
  42967. * @param clearColor defines the clear color
  42968. */
  42969. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42970. /**
  42971. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42972. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42973. * @param y defines the y-coordinate of the corner of the clear rectangle
  42974. * @param width defines the width of the clear rectangle
  42975. * @param height defines the height of the clear rectangle
  42976. */
  42977. enableScissor(x: number, y: number, width: number, height: number): void;
  42978. /**
  42979. * Disable previously set scissor test rectangle
  42980. */
  42981. disableScissor(): void;
  42982. protected _reportDrawCall(): void;
  42983. /**
  42984. * Initializes a webVR display and starts listening to display change events
  42985. * The onVRDisplayChangedObservable will be notified upon these changes
  42986. * @returns The onVRDisplayChangedObservable
  42987. */
  42988. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42989. /** @hidden */
  42990. _prepareVRComponent(): void;
  42991. /** @hidden */
  42992. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42993. /** @hidden */
  42994. _submitVRFrame(): void;
  42995. /**
  42996. * Call this function to leave webVR mode
  42997. * Will do nothing if webVR is not supported or if there is no webVR device
  42998. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42999. */
  43000. disableVR(): void;
  43001. /**
  43002. * Gets a boolean indicating that the system is in VR mode and is presenting
  43003. * @returns true if VR mode is engaged
  43004. */
  43005. isVRPresenting(): boolean;
  43006. /** @hidden */
  43007. _requestVRFrame(): void;
  43008. /** @hidden */
  43009. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43010. /**
  43011. * Gets the source code of the vertex shader associated with a specific webGL program
  43012. * @param program defines the program to use
  43013. * @returns a string containing the source code of the vertex shader associated with the program
  43014. */
  43015. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  43016. /**
  43017. * Gets the source code of the fragment shader associated with a specific webGL program
  43018. * @param program defines the program to use
  43019. * @returns a string containing the source code of the fragment shader associated with the program
  43020. */
  43021. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  43022. /**
  43023. * Sets a depth stencil texture from a render target to the according uniform.
  43024. * @param channel The texture channel
  43025. * @param uniform The uniform to set
  43026. * @param texture The render target texture containing the depth stencil texture to apply
  43027. */
  43028. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  43029. /**
  43030. * Sets a texture to the webGL context from a postprocess
  43031. * @param channel defines the channel to use
  43032. * @param postProcess defines the source postprocess
  43033. */
  43034. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  43035. /**
  43036. * Binds the output of the passed in post process to the texture channel specified
  43037. * @param channel The channel the texture should be bound to
  43038. * @param postProcess The post process which's output should be bound
  43039. */
  43040. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  43041. protected _rebuildBuffers(): void;
  43042. /** @hidden */
  43043. _renderFrame(): void;
  43044. _renderLoop(): void;
  43045. /** @hidden */
  43046. _renderViews(): boolean;
  43047. /**
  43048. * Toggle full screen mode
  43049. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43050. */
  43051. switchFullscreen(requestPointerLock: boolean): void;
  43052. /**
  43053. * Enters full screen mode
  43054. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43055. */
  43056. enterFullscreen(requestPointerLock: boolean): void;
  43057. /**
  43058. * Exits full screen mode
  43059. */
  43060. exitFullscreen(): void;
  43061. /**
  43062. * Enters Pointerlock mode
  43063. */
  43064. enterPointerlock(): void;
  43065. /**
  43066. * Exits Pointerlock mode
  43067. */
  43068. exitPointerlock(): void;
  43069. /**
  43070. * Begin a new frame
  43071. */
  43072. beginFrame(): void;
  43073. /**
  43074. * Enf the current frame
  43075. */
  43076. endFrame(): void;
  43077. resize(): void;
  43078. /**
  43079. * Force a specific size of the canvas
  43080. * @param width defines the new canvas' width
  43081. * @param height defines the new canvas' height
  43082. * @returns true if the size was changed
  43083. */
  43084. setSize(width: number, height: number): boolean;
  43085. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43086. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43087. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43088. _releaseTexture(texture: InternalTexture): void;
  43089. /**
  43090. * @hidden
  43091. * Rescales a texture
  43092. * @param source input texutre
  43093. * @param destination destination texture
  43094. * @param scene scene to use to render the resize
  43095. * @param internalFormat format to use when resizing
  43096. * @param onComplete callback to be called when resize has completed
  43097. */
  43098. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  43099. /**
  43100. * Gets the current framerate
  43101. * @returns a number representing the framerate
  43102. */
  43103. getFps(): number;
  43104. /**
  43105. * Gets the time spent between current and previous frame
  43106. * @returns a number representing the delta time in ms
  43107. */
  43108. getDeltaTime(): number;
  43109. private _measureFps;
  43110. /** @hidden */
  43111. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  43112. /**
  43113. * Updates the sample count of a render target texture
  43114. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43115. * @param texture defines the texture to update
  43116. * @param samples defines the sample count to set
  43117. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43118. */
  43119. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  43120. /**
  43121. * Updates a depth texture Comparison Mode and Function.
  43122. * If the comparison Function is equal to 0, the mode will be set to none.
  43123. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  43124. * @param texture The texture to set the comparison function for
  43125. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  43126. */
  43127. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  43128. /**
  43129. * Creates a webGL buffer to use with instanciation
  43130. * @param capacity defines the size of the buffer
  43131. * @returns the webGL buffer
  43132. */
  43133. createInstancesBuffer(capacity: number): DataBuffer;
  43134. /**
  43135. * Delete a webGL buffer used with instanciation
  43136. * @param buffer defines the webGL buffer to delete
  43137. */
  43138. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43139. private _clientWaitAsync;
  43140. /** @hidden */
  43141. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  43142. dispose(): void;
  43143. private _disableTouchAction;
  43144. /**
  43145. * Display the loading screen
  43146. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43147. */
  43148. displayLoadingUI(): void;
  43149. /**
  43150. * Hide the loading screen
  43151. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43152. */
  43153. hideLoadingUI(): void;
  43154. /**
  43155. * Gets the current loading screen object
  43156. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43157. */
  43158. get loadingScreen(): ILoadingScreen;
  43159. /**
  43160. * Sets the current loading screen object
  43161. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43162. */
  43163. set loadingScreen(loadingScreen: ILoadingScreen);
  43164. /**
  43165. * Sets the current loading screen text
  43166. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43167. */
  43168. set loadingUIText(text: string);
  43169. /**
  43170. * Sets the current loading screen background color
  43171. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43172. */
  43173. set loadingUIBackgroundColor(color: string);
  43174. /** Pointerlock and fullscreen */
  43175. /**
  43176. * Ask the browser to promote the current element to pointerlock mode
  43177. * @param element defines the DOM element to promote
  43178. */
  43179. static _RequestPointerlock(element: HTMLElement): void;
  43180. /**
  43181. * Asks the browser to exit pointerlock mode
  43182. */
  43183. static _ExitPointerlock(): void;
  43184. /**
  43185. * Ask the browser to promote the current element to fullscreen rendering mode
  43186. * @param element defines the DOM element to promote
  43187. */
  43188. static _RequestFullscreen(element: HTMLElement): void;
  43189. /**
  43190. * Asks the browser to exit fullscreen mode
  43191. */
  43192. static _ExitFullscreen(): void;
  43193. }
  43194. }
  43195. declare module "babylonjs/Engines/engineStore" {
  43196. import { Nullable } from "babylonjs/types";
  43197. import { Engine } from "babylonjs/Engines/engine";
  43198. import { Scene } from "babylonjs/scene";
  43199. /**
  43200. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43201. * during the life time of the application.
  43202. */
  43203. export class EngineStore {
  43204. /** Gets the list of created engines */
  43205. static Instances: import("babylonjs/Engines/engine").Engine[];
  43206. /** @hidden */
  43207. static _LastCreatedScene: Nullable<Scene>;
  43208. /**
  43209. * Gets the latest created engine
  43210. */
  43211. static get LastCreatedEngine(): Nullable<Engine>;
  43212. /**
  43213. * Gets the latest created scene
  43214. */
  43215. static get LastCreatedScene(): Nullable<Scene>;
  43216. /**
  43217. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43218. * @ignorenaming
  43219. */
  43220. static UseFallbackTexture: boolean;
  43221. /**
  43222. * Texture content used if a texture cannot loaded
  43223. * @ignorenaming
  43224. */
  43225. static FallbackTexture: string;
  43226. }
  43227. }
  43228. declare module "babylonjs/Misc/promise" {
  43229. /**
  43230. * Helper class that provides a small promise polyfill
  43231. */
  43232. export class PromisePolyfill {
  43233. /**
  43234. * Static function used to check if the polyfill is required
  43235. * If this is the case then the function will inject the polyfill to window.Promise
  43236. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43237. */
  43238. static Apply(force?: boolean): void;
  43239. }
  43240. }
  43241. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  43242. /**
  43243. * Interface for screenshot methods with describe argument called `size` as object with options
  43244. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43245. */
  43246. export interface IScreenshotSize {
  43247. /**
  43248. * number in pixels for canvas height
  43249. */
  43250. height?: number;
  43251. /**
  43252. * multiplier allowing render at a higher or lower resolution
  43253. * If value is defined then height and width will be ignored and taken from camera
  43254. */
  43255. precision?: number;
  43256. /**
  43257. * number in pixels for canvas width
  43258. */
  43259. width?: number;
  43260. }
  43261. }
  43262. declare module "babylonjs/Misc/tools" {
  43263. import { Nullable, float } from "babylonjs/types";
  43264. import { DomManagement } from "babylonjs/Misc/domManagement";
  43265. import { WebRequest } from "babylonjs/Misc/webRequest";
  43266. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43267. import { ReadFileError } from "babylonjs/Misc/fileTools";
  43268. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43269. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  43270. import { Camera } from "babylonjs/Cameras/camera";
  43271. import { Engine } from "babylonjs/Engines/engine";
  43272. interface IColor4Like {
  43273. r: float;
  43274. g: float;
  43275. b: float;
  43276. a: float;
  43277. }
  43278. /**
  43279. * Class containing a set of static utilities functions
  43280. */
  43281. export class Tools {
  43282. /**
  43283. * Gets or sets the base URL to use to load assets
  43284. */
  43285. static get BaseUrl(): string;
  43286. static set BaseUrl(value: string);
  43287. /**
  43288. * Enable/Disable Custom HTTP Request Headers globally.
  43289. * default = false
  43290. * @see CustomRequestHeaders
  43291. */
  43292. static UseCustomRequestHeaders: boolean;
  43293. /**
  43294. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43295. * i.e. when loading files, where the server/service expects an Authorization header
  43296. */
  43297. static CustomRequestHeaders: {
  43298. [key: string]: string;
  43299. };
  43300. /**
  43301. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43302. */
  43303. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43304. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43305. /**
  43306. * Default behaviour for cors in the application.
  43307. * It can be a string if the expected behavior is identical in the entire app.
  43308. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43309. */
  43310. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43311. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43312. /**
  43313. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43314. * @ignorenaming
  43315. */
  43316. static get UseFallbackTexture(): boolean;
  43317. static set UseFallbackTexture(value: boolean);
  43318. /**
  43319. * Use this object to register external classes like custom textures or material
  43320. * to allow the laoders to instantiate them
  43321. */
  43322. static get RegisteredExternalClasses(): {
  43323. [key: string]: Object;
  43324. };
  43325. static set RegisteredExternalClasses(classes: {
  43326. [key: string]: Object;
  43327. });
  43328. /**
  43329. * Texture content used if a texture cannot loaded
  43330. * @ignorenaming
  43331. */
  43332. static get fallbackTexture(): string;
  43333. static set fallbackTexture(value: string);
  43334. /**
  43335. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43336. * @param u defines the coordinate on X axis
  43337. * @param v defines the coordinate on Y axis
  43338. * @param width defines the width of the source data
  43339. * @param height defines the height of the source data
  43340. * @param pixels defines the source byte array
  43341. * @param color defines the output color
  43342. */
  43343. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43344. /**
  43345. * Interpolates between a and b via alpha
  43346. * @param a The lower value (returned when alpha = 0)
  43347. * @param b The upper value (returned when alpha = 1)
  43348. * @param alpha The interpolation-factor
  43349. * @return The mixed value
  43350. */
  43351. static Mix(a: number, b: number, alpha: number): number;
  43352. /**
  43353. * Tries to instantiate a new object from a given class name
  43354. * @param className defines the class name to instantiate
  43355. * @returns the new object or null if the system was not able to do the instantiation
  43356. */
  43357. static Instantiate(className: string): any;
  43358. /**
  43359. * Provides a slice function that will work even on IE
  43360. * @param data defines the array to slice
  43361. * @param start defines the start of the data (optional)
  43362. * @param end defines the end of the data (optional)
  43363. * @returns the new sliced array
  43364. */
  43365. static Slice<T>(data: T, start?: number, end?: number): T;
  43366. /**
  43367. * Provides a slice function that will work even on IE
  43368. * The difference between this and Slice is that this will force-convert to array
  43369. * @param data defines the array to slice
  43370. * @param start defines the start of the data (optional)
  43371. * @param end defines the end of the data (optional)
  43372. * @returns the new sliced array
  43373. */
  43374. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43375. /**
  43376. * Polyfill for setImmediate
  43377. * @param action defines the action to execute after the current execution block
  43378. */
  43379. static SetImmediate(action: () => void): void;
  43380. /**
  43381. * Function indicating if a number is an exponent of 2
  43382. * @param value defines the value to test
  43383. * @returns true if the value is an exponent of 2
  43384. */
  43385. static IsExponentOfTwo(value: number): boolean;
  43386. private static _tmpFloatArray;
  43387. /**
  43388. * Returns the nearest 32-bit single precision float representation of a Number
  43389. * @param value A Number. If the parameter is of a different type, it will get converted
  43390. * to a number or to NaN if it cannot be converted
  43391. * @returns number
  43392. */
  43393. static FloatRound(value: number): number;
  43394. /**
  43395. * Extracts the filename from a path
  43396. * @param path defines the path to use
  43397. * @returns the filename
  43398. */
  43399. static GetFilename(path: string): string;
  43400. /**
  43401. * Extracts the "folder" part of a path (everything before the filename).
  43402. * @param uri The URI to extract the info from
  43403. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43404. * @returns The "folder" part of the path
  43405. */
  43406. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43407. /**
  43408. * Extracts text content from a DOM element hierarchy
  43409. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43410. */
  43411. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43412. /**
  43413. * Convert an angle in radians to degrees
  43414. * @param angle defines the angle to convert
  43415. * @returns the angle in degrees
  43416. */
  43417. static ToDegrees(angle: number): number;
  43418. /**
  43419. * Convert an angle in degrees to radians
  43420. * @param angle defines the angle to convert
  43421. * @returns the angle in radians
  43422. */
  43423. static ToRadians(angle: number): number;
  43424. /**
  43425. * Returns an array if obj is not an array
  43426. * @param obj defines the object to evaluate as an array
  43427. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43428. * @returns either obj directly if obj is an array or a new array containing obj
  43429. */
  43430. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43431. /**
  43432. * Gets the pointer prefix to use
  43433. * @param engine defines the engine we are finding the prefix for
  43434. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43435. */
  43436. static GetPointerPrefix(engine: Engine): string;
  43437. /**
  43438. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43439. * @param url define the url we are trying
  43440. * @param element define the dom element where to configure the cors policy
  43441. */
  43442. static SetCorsBehavior(url: string | string[], element: {
  43443. crossOrigin: string | null;
  43444. }): void;
  43445. /**
  43446. * Removes unwanted characters from an url
  43447. * @param url defines the url to clean
  43448. * @returns the cleaned url
  43449. */
  43450. static CleanUrl(url: string): string;
  43451. /**
  43452. * Gets or sets a function used to pre-process url before using them to load assets
  43453. */
  43454. static get PreprocessUrl(): (url: string) => string;
  43455. static set PreprocessUrl(processor: (url: string) => string);
  43456. /**
  43457. * Loads an image as an HTMLImageElement.
  43458. * @param input url string, ArrayBuffer, or Blob to load
  43459. * @param onLoad callback called when the image successfully loads
  43460. * @param onError callback called when the image fails to load
  43461. * @param offlineProvider offline provider for caching
  43462. * @param mimeType optional mime type
  43463. * @returns the HTMLImageElement of the loaded image
  43464. */
  43465. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43466. /**
  43467. * Loads a file from a url
  43468. * @param url url string, ArrayBuffer, or Blob to load
  43469. * @param onSuccess callback called when the file successfully loads
  43470. * @param onProgress callback called while file is loading (if the server supports this mode)
  43471. * @param offlineProvider defines the offline provider for caching
  43472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43473. * @param onError callback called when the file fails to load
  43474. * @returns a file request object
  43475. */
  43476. 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;
  43477. /**
  43478. * Loads a file from a url
  43479. * @param url the file url to load
  43480. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43481. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43482. */
  43483. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43484. /**
  43485. * Load a script (identified by an url). When the url returns, the
  43486. * content of this file is added into a new script element, attached to the DOM (body element)
  43487. * @param scriptUrl defines the url of the script to laod
  43488. * @param onSuccess defines the callback called when the script is loaded
  43489. * @param onError defines the callback to call if an error occurs
  43490. * @param scriptId defines the id of the script element
  43491. */
  43492. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43493. /**
  43494. * Load an asynchronous script (identified by an url). When the url returns, the
  43495. * content of this file is added into a new script element, attached to the DOM (body element)
  43496. * @param scriptUrl defines the url of the script to laod
  43497. * @param scriptId defines the id of the script element
  43498. * @returns a promise request object
  43499. */
  43500. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43501. /**
  43502. * Loads a file from a blob
  43503. * @param fileToLoad defines the blob to use
  43504. * @param callback defines the callback to call when data is loaded
  43505. * @param progressCallback defines the callback to call during loading process
  43506. * @returns a file request object
  43507. */
  43508. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43509. /**
  43510. * Reads a file from a File object
  43511. * @param file defines the file to load
  43512. * @param onSuccess defines the callback to call when data is loaded
  43513. * @param onProgress defines the callback to call during loading process
  43514. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43515. * @param onError defines the callback to call when an error occurs
  43516. * @returns a file request object
  43517. */
  43518. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43519. /**
  43520. * Creates a data url from a given string content
  43521. * @param content defines the content to convert
  43522. * @returns the new data url link
  43523. */
  43524. static FileAsURL(content: string): string;
  43525. /**
  43526. * Format the given number to a specific decimal format
  43527. * @param value defines the number to format
  43528. * @param decimals defines the number of decimals to use
  43529. * @returns the formatted string
  43530. */
  43531. static Format(value: number, decimals?: number): string;
  43532. /**
  43533. * Tries to copy an object by duplicating every property
  43534. * @param source defines the source object
  43535. * @param destination defines the target object
  43536. * @param doNotCopyList defines a list of properties to avoid
  43537. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43538. */
  43539. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43540. /**
  43541. * Gets a boolean indicating if the given object has no own property
  43542. * @param obj defines the object to test
  43543. * @returns true if object has no own property
  43544. */
  43545. static IsEmpty(obj: any): boolean;
  43546. /**
  43547. * Function used to register events at window level
  43548. * @param windowElement defines the Window object to use
  43549. * @param events defines the events to register
  43550. */
  43551. static RegisterTopRootEvents(windowElement: Window, events: {
  43552. name: string;
  43553. handler: Nullable<(e: FocusEvent) => any>;
  43554. }[]): void;
  43555. /**
  43556. * Function used to unregister events from window level
  43557. * @param windowElement defines the Window object to use
  43558. * @param events defines the events to unregister
  43559. */
  43560. static UnregisterTopRootEvents(windowElement: Window, events: {
  43561. name: string;
  43562. handler: Nullable<(e: FocusEvent) => any>;
  43563. }[]): void;
  43564. /**
  43565. * @ignore
  43566. */
  43567. static _ScreenshotCanvas: HTMLCanvasElement;
  43568. /**
  43569. * Dumps the current bound framebuffer
  43570. * @param width defines the rendering width
  43571. * @param height defines the rendering height
  43572. * @param engine defines the hosting engine
  43573. * @param successCallback defines the callback triggered once the data are available
  43574. * @param mimeType defines the mime type of the result
  43575. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43576. */
  43577. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43578. /**
  43579. * Converts the canvas data to blob.
  43580. * This acts as a polyfill for browsers not supporting the to blob function.
  43581. * @param canvas Defines the canvas to extract the data from
  43582. * @param successCallback Defines the callback triggered once the data are available
  43583. * @param mimeType Defines the mime type of the result
  43584. */
  43585. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43586. /**
  43587. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43588. * @param successCallback defines the callback triggered once the data are available
  43589. * @param mimeType defines the mime type of the result
  43590. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43591. */
  43592. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43593. /**
  43594. * Downloads a blob in the browser
  43595. * @param blob defines the blob to download
  43596. * @param fileName defines the name of the downloaded file
  43597. */
  43598. static Download(blob: Blob, fileName: string): void;
  43599. /**
  43600. * Will return the right value of the noPreventDefault variable
  43601. * Needed to keep backwards compatibility to the old API.
  43602. *
  43603. * @param args arguments passed to the attachControl function
  43604. * @returns the correct value for noPreventDefault
  43605. */
  43606. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43607. /**
  43608. * Captures a screenshot of the current rendering
  43609. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43610. * @param engine defines the rendering engine
  43611. * @param camera defines the source camera
  43612. * @param size This parameter can be set to a single number or to an object with the
  43613. * following (optional) properties: precision, width, height. If a single number is passed,
  43614. * it will be used for both width and height. If an object is passed, the screenshot size
  43615. * will be derived from the parameters. The precision property is a multiplier allowing
  43616. * rendering at a higher or lower resolution
  43617. * @param successCallback defines the callback receives a single parameter which contains the
  43618. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43619. * src parameter of an <img> to display it
  43620. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43621. * Check your browser for supported MIME types
  43622. */
  43623. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43624. /**
  43625. * Captures a screenshot of the current rendering
  43626. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43627. * @param engine defines the rendering engine
  43628. * @param camera defines the source camera
  43629. * @param size This parameter can be set to a single number or to an object with the
  43630. * following (optional) properties: precision, width, height. If a single number is passed,
  43631. * it will be used for both width and height. If an object is passed, the screenshot size
  43632. * will be derived from the parameters. The precision property is a multiplier allowing
  43633. * rendering at a higher or lower resolution
  43634. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43635. * Check your browser for supported MIME types
  43636. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43637. * to the src parameter of an <img> to display it
  43638. */
  43639. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43640. /**
  43641. * Generates an image screenshot from the specified camera.
  43642. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43643. * @param engine The engine to use for rendering
  43644. * @param camera The camera to use for rendering
  43645. * @param size This parameter can be set to a single number or to an object with the
  43646. * following (optional) properties: precision, width, height. If a single number is passed,
  43647. * it will be used for both width and height. If an object is passed, the screenshot size
  43648. * will be derived from the parameters. The precision property is a multiplier allowing
  43649. * rendering at a higher or lower resolution
  43650. * @param successCallback The callback receives a single parameter which contains the
  43651. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43652. * src parameter of an <img> to display it
  43653. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43654. * Check your browser for supported MIME types
  43655. * @param samples Texture samples (default: 1)
  43656. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43657. * @param fileName A name for for the downloaded file.
  43658. */
  43659. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43660. /**
  43661. * Generates an image screenshot from the specified camera.
  43662. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43663. * @param engine The engine to use for rendering
  43664. * @param camera The camera to use for rendering
  43665. * @param size This parameter can be set to a single number or to an object with the
  43666. * following (optional) properties: precision, width, height. If a single number is passed,
  43667. * it will be used for both width and height. If an object is passed, the screenshot size
  43668. * will be derived from the parameters. The precision property is a multiplier allowing
  43669. * rendering at a higher or lower resolution
  43670. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43671. * Check your browser for supported MIME types
  43672. * @param samples Texture samples (default: 1)
  43673. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43674. * @param fileName A name for for the downloaded file.
  43675. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43676. * to the src parameter of an <img> to display it
  43677. */
  43678. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43679. /**
  43680. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43681. * Be aware Math.random() could cause collisions, but:
  43682. * "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"
  43683. * @returns a pseudo random id
  43684. */
  43685. static RandomId(): string;
  43686. /**
  43687. * Test if the given uri is a base64 string
  43688. * @param uri The uri to test
  43689. * @return True if the uri is a base64 string or false otherwise
  43690. */
  43691. static IsBase64(uri: string): boolean;
  43692. /**
  43693. * Decode the given base64 uri.
  43694. * @param uri The uri to decode
  43695. * @return The decoded base64 data.
  43696. */
  43697. static DecodeBase64(uri: string): ArrayBuffer;
  43698. /**
  43699. * Gets the absolute url.
  43700. * @param url the input url
  43701. * @return the absolute url
  43702. */
  43703. static GetAbsoluteUrl(url: string): string;
  43704. /**
  43705. * No log
  43706. */
  43707. static readonly NoneLogLevel: number;
  43708. /**
  43709. * Only message logs
  43710. */
  43711. static readonly MessageLogLevel: number;
  43712. /**
  43713. * Only warning logs
  43714. */
  43715. static readonly WarningLogLevel: number;
  43716. /**
  43717. * Only error logs
  43718. */
  43719. static readonly ErrorLogLevel: number;
  43720. /**
  43721. * All logs
  43722. */
  43723. static readonly AllLogLevel: number;
  43724. /**
  43725. * Gets a value indicating the number of loading errors
  43726. * @ignorenaming
  43727. */
  43728. static get errorsCount(): number;
  43729. /**
  43730. * Callback called when a new log is added
  43731. */
  43732. static OnNewCacheEntry: (entry: string) => void;
  43733. /**
  43734. * Log a message to the console
  43735. * @param message defines the message to log
  43736. */
  43737. static Log(message: string): void;
  43738. /**
  43739. * Write a warning message to the console
  43740. * @param message defines the message to log
  43741. */
  43742. static Warn(message: string): void;
  43743. /**
  43744. * Write an error message to the console
  43745. * @param message defines the message to log
  43746. */
  43747. static Error(message: string): void;
  43748. /**
  43749. * Gets current log cache (list of logs)
  43750. */
  43751. static get LogCache(): string;
  43752. /**
  43753. * Clears the log cache
  43754. */
  43755. static ClearLogCache(): void;
  43756. /**
  43757. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43758. */
  43759. static set LogLevels(level: number);
  43760. /**
  43761. * Checks if the window object exists
  43762. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43763. */
  43764. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43765. /**
  43766. * No performance log
  43767. */
  43768. static readonly PerformanceNoneLogLevel: number;
  43769. /**
  43770. * Use user marks to log performance
  43771. */
  43772. static readonly PerformanceUserMarkLogLevel: number;
  43773. /**
  43774. * Log performance to the console
  43775. */
  43776. static readonly PerformanceConsoleLogLevel: number;
  43777. private static _performance;
  43778. /**
  43779. * Sets the current performance log level
  43780. */
  43781. static set PerformanceLogLevel(level: number);
  43782. private static _StartPerformanceCounterDisabled;
  43783. private static _EndPerformanceCounterDisabled;
  43784. private static _StartUserMark;
  43785. private static _EndUserMark;
  43786. private static _StartPerformanceConsole;
  43787. private static _EndPerformanceConsole;
  43788. /**
  43789. * Starts a performance counter
  43790. */
  43791. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43792. /**
  43793. * Ends a specific performance coutner
  43794. */
  43795. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43796. /**
  43797. * Gets either window.performance.now() if supported or Date.now() else
  43798. */
  43799. static get Now(): number;
  43800. /**
  43801. * This method will return the name of the class used to create the instance of the given object.
  43802. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43803. * @param object the object to get the class name from
  43804. * @param isType defines if the object is actually a type
  43805. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43806. */
  43807. static GetClassName(object: any, isType?: boolean): string;
  43808. /**
  43809. * Gets the first element of an array satisfying a given predicate
  43810. * @param array defines the array to browse
  43811. * @param predicate defines the predicate to use
  43812. * @returns null if not found or the element
  43813. */
  43814. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43815. /**
  43816. * This method will return the name of the full name of the class, including its owning module (if any).
  43817. * 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).
  43818. * @param object the object to get the class name from
  43819. * @param isType defines if the object is actually a type
  43820. * @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.
  43821. * @ignorenaming
  43822. */
  43823. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43824. /**
  43825. * Returns a promise that resolves after the given amount of time.
  43826. * @param delay Number of milliseconds to delay
  43827. * @returns Promise that resolves after the given amount of time
  43828. */
  43829. static DelayAsync(delay: number): Promise<void>;
  43830. /**
  43831. * Utility function to detect if the current user agent is Safari
  43832. * @returns whether or not the current user agent is safari
  43833. */
  43834. static IsSafari(): boolean;
  43835. }
  43836. /**
  43837. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43838. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43839. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43840. * @param name The name of the class, case should be preserved
  43841. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43842. */
  43843. export function className(name: string, module?: string): (target: Object) => void;
  43844. /**
  43845. * An implementation of a loop for asynchronous functions.
  43846. */
  43847. export class AsyncLoop {
  43848. /**
  43849. * Defines the number of iterations for the loop
  43850. */
  43851. iterations: number;
  43852. /**
  43853. * Defines the current index of the loop.
  43854. */
  43855. index: number;
  43856. private _done;
  43857. private _fn;
  43858. private _successCallback;
  43859. /**
  43860. * Constructor.
  43861. * @param iterations the number of iterations.
  43862. * @param func the function to run each iteration
  43863. * @param successCallback the callback that will be called upon succesful execution
  43864. * @param offset starting offset.
  43865. */
  43866. constructor(
  43867. /**
  43868. * Defines the number of iterations for the loop
  43869. */
  43870. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43871. /**
  43872. * Execute the next iteration. Must be called after the last iteration was finished.
  43873. */
  43874. executeNext(): void;
  43875. /**
  43876. * Break the loop and run the success callback.
  43877. */
  43878. breakLoop(): void;
  43879. /**
  43880. * Create and run an async loop.
  43881. * @param iterations the number of iterations.
  43882. * @param fn the function to run each iteration
  43883. * @param successCallback the callback that will be called upon succesful execution
  43884. * @param offset starting offset.
  43885. * @returns the created async loop object
  43886. */
  43887. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43888. /**
  43889. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43890. * @param iterations total number of iterations
  43891. * @param syncedIterations number of synchronous iterations in each async iteration.
  43892. * @param fn the function to call each iteration.
  43893. * @param callback a success call back that will be called when iterating stops.
  43894. * @param breakFunction a break condition (optional)
  43895. * @param timeout timeout settings for the setTimeout function. default - 0.
  43896. * @returns the created async loop object
  43897. */
  43898. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43899. }
  43900. }
  43901. declare module "babylonjs/Misc/stringDictionary" {
  43902. import { Nullable } from "babylonjs/types";
  43903. /**
  43904. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43905. * The underlying implementation relies on an associative array to ensure the best performances.
  43906. * The value can be anything including 'null' but except 'undefined'
  43907. */
  43908. export class StringDictionary<T> {
  43909. /**
  43910. * This will clear this dictionary and copy the content from the 'source' one.
  43911. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43912. * @param source the dictionary to take the content from and copy to this dictionary
  43913. */
  43914. copyFrom(source: StringDictionary<T>): void;
  43915. /**
  43916. * Get a value based from its key
  43917. * @param key the given key to get the matching value from
  43918. * @return the value if found, otherwise undefined is returned
  43919. */
  43920. get(key: string): T | undefined;
  43921. /**
  43922. * Get a value from its key or add it if it doesn't exist.
  43923. * This method will ensure you that a given key/data will be present in the dictionary.
  43924. * @param key the given key to get the matching value from
  43925. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43926. * The factory will only be invoked if there's no data for the given key.
  43927. * @return the value corresponding to the key.
  43928. */
  43929. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43930. /**
  43931. * Get a value from its key if present in the dictionary otherwise add it
  43932. * @param key the key to get the value from
  43933. * @param val if there's no such key/value pair in the dictionary add it with this value
  43934. * @return the value corresponding to the key
  43935. */
  43936. getOrAdd(key: string, val: T): T;
  43937. /**
  43938. * Check if there's a given key in the dictionary
  43939. * @param key the key to check for
  43940. * @return true if the key is present, false otherwise
  43941. */
  43942. contains(key: string): boolean;
  43943. /**
  43944. * Add a new key and its corresponding value
  43945. * @param key the key to add
  43946. * @param value the value corresponding to the key
  43947. * @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
  43948. */
  43949. add(key: string, value: T): boolean;
  43950. /**
  43951. * Update a specific value associated to a key
  43952. * @param key defines the key to use
  43953. * @param value defines the value to store
  43954. * @returns true if the value was updated (or false if the key was not found)
  43955. */
  43956. set(key: string, value: T): boolean;
  43957. /**
  43958. * Get the element of the given key and remove it from the dictionary
  43959. * @param key defines the key to search
  43960. * @returns the value associated with the key or null if not found
  43961. */
  43962. getAndRemove(key: string): Nullable<T>;
  43963. /**
  43964. * Remove a key/value from the dictionary.
  43965. * @param key the key to remove
  43966. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43967. */
  43968. remove(key: string): boolean;
  43969. /**
  43970. * Clear the whole content of the dictionary
  43971. */
  43972. clear(): void;
  43973. /**
  43974. * Gets the current count
  43975. */
  43976. get count(): number;
  43977. /**
  43978. * Execute a callback on each key/val of the dictionary.
  43979. * Note that you can remove any element in this dictionary in the callback implementation
  43980. * @param callback the callback to execute on a given key/value pair
  43981. */
  43982. forEach(callback: (key: string, val: T) => void): void;
  43983. /**
  43984. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43985. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43986. * Note that you can remove any element in this dictionary in the callback implementation
  43987. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43988. * @returns the first item
  43989. */
  43990. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43991. private _count;
  43992. private _data;
  43993. }
  43994. }
  43995. declare module "babylonjs/Collisions/collisionCoordinator" {
  43996. import { Nullable } from "babylonjs/types";
  43997. import { Scene } from "babylonjs/scene";
  43998. import { Vector3 } from "babylonjs/Maths/math.vector";
  43999. import { Collider } from "babylonjs/Collisions/collider";
  44000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44001. /** @hidden */
  44002. export interface ICollisionCoordinator {
  44003. createCollider(): Collider;
  44004. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  44005. init(scene: Scene): void;
  44006. }
  44007. /** @hidden */
  44008. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  44009. private _scene;
  44010. private _scaledPosition;
  44011. private _scaledVelocity;
  44012. private _finalPosition;
  44013. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  44014. createCollider(): Collider;
  44015. init(scene: Scene): void;
  44016. private _collideWithWorld;
  44017. }
  44018. }
  44019. declare module "babylonjs/Inputs/scene.inputManager" {
  44020. import { Nullable } from "babylonjs/types";
  44021. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44022. import { Vector2 } from "babylonjs/Maths/math.vector";
  44023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44024. import { Scene } from "babylonjs/scene";
  44025. /**
  44026. * Class used to manage all inputs for the scene.
  44027. */
  44028. export class InputManager {
  44029. /** The distance in pixel that you have to move to prevent some events */
  44030. static DragMovementThreshold: number;
  44031. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  44032. static LongPressDelay: number;
  44033. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  44034. static DoubleClickDelay: number;
  44035. /** If you need to check double click without raising a single click at first click, enable this flag */
  44036. static ExclusiveDoubleClickMode: boolean;
  44037. /** 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. */
  44038. private _alreadyAttached;
  44039. private _alreadyAttachedTo;
  44040. private _wheelEventName;
  44041. private _onPointerMove;
  44042. private _onPointerDown;
  44043. private _onPointerUp;
  44044. private _initClickEvent;
  44045. private _initActionManager;
  44046. private _delayedSimpleClick;
  44047. private _delayedSimpleClickTimeout;
  44048. private _previousDelayedSimpleClickTimeout;
  44049. private _meshPickProceed;
  44050. private _previousButtonPressed;
  44051. private _currentPickResult;
  44052. private _previousPickResult;
  44053. private _totalPointersPressed;
  44054. private _doubleClickOccured;
  44055. private _pointerOverMesh;
  44056. private _pickedDownMesh;
  44057. private _pickedUpMesh;
  44058. private _pointerX;
  44059. private _pointerY;
  44060. private _unTranslatedPointerX;
  44061. private _unTranslatedPointerY;
  44062. private _startingPointerPosition;
  44063. private _previousStartingPointerPosition;
  44064. private _startingPointerTime;
  44065. private _previousStartingPointerTime;
  44066. private _pointerCaptures;
  44067. private _meshUnderPointerId;
  44068. private _onKeyDown;
  44069. private _onKeyUp;
  44070. private _keyboardIsAttached;
  44071. private _onCanvasFocusObserver;
  44072. private _onCanvasBlurObserver;
  44073. private _scene;
  44074. /**
  44075. * Creates a new InputManager
  44076. * @param scene defines the hosting scene
  44077. */
  44078. constructor(scene: Scene);
  44079. /**
  44080. * Gets the mesh that is currently under the pointer
  44081. */
  44082. get meshUnderPointer(): Nullable<AbstractMesh>;
  44083. /**
  44084. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  44085. * @param pointerId the pointer id to use
  44086. * @returns The mesh under this pointer id or null if not found
  44087. */
  44088. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  44089. /**
  44090. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  44091. */
  44092. get unTranslatedPointer(): Vector2;
  44093. /**
  44094. * Gets or sets the current on-screen X position of the pointer
  44095. */
  44096. get pointerX(): number;
  44097. set pointerX(value: number);
  44098. /**
  44099. * Gets or sets the current on-screen Y position of the pointer
  44100. */
  44101. get pointerY(): number;
  44102. set pointerY(value: number);
  44103. private _updatePointerPosition;
  44104. private _processPointerMove;
  44105. private _setRayOnPointerInfo;
  44106. private _checkPrePointerObservable;
  44107. /**
  44108. * Use this method to simulate a pointer move on a mesh
  44109. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44110. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44111. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44112. */
  44113. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44114. /**
  44115. * Use this method to simulate a pointer down on a mesh
  44116. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44117. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44118. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44119. */
  44120. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44121. private _processPointerDown;
  44122. /** @hidden */
  44123. _isPointerSwiping(): boolean;
  44124. /**
  44125. * Use this method to simulate a pointer up on a mesh
  44126. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44127. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44128. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44129. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44130. */
  44131. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44132. private _processPointerUp;
  44133. /**
  44134. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44135. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44136. * @returns true if the pointer was captured
  44137. */
  44138. isPointerCaptured(pointerId?: number): boolean;
  44139. /**
  44140. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44141. * @param attachUp defines if you want to attach events to pointerup
  44142. * @param attachDown defines if you want to attach events to pointerdown
  44143. * @param attachMove defines if you want to attach events to pointermove
  44144. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44145. */
  44146. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44147. /**
  44148. * Detaches all event handlers
  44149. */
  44150. detachControl(): void;
  44151. /**
  44152. * Force the value of meshUnderPointer
  44153. * @param mesh defines the mesh to use
  44154. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44155. */
  44156. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44157. /**
  44158. * Gets the mesh under the pointer
  44159. * @returns a Mesh or null if no mesh is under the pointer
  44160. */
  44161. getPointerOverMesh(): Nullable<AbstractMesh>;
  44162. }
  44163. }
  44164. declare module "babylonjs/Animations/animationGroup" {
  44165. import { Animatable } from "babylonjs/Animations/animatable";
  44166. import { Animation } from "babylonjs/Animations/animation";
  44167. import { Scene, IDisposable } from "babylonjs/scene";
  44168. import { Observable } from "babylonjs/Misc/observable";
  44169. import { Nullable } from "babylonjs/types";
  44170. import "babylonjs/Animations/animatable";
  44171. /**
  44172. * This class defines the direct association between an animation and a target
  44173. */
  44174. export class TargetedAnimation {
  44175. /**
  44176. * Animation to perform
  44177. */
  44178. animation: Animation;
  44179. /**
  44180. * Target to animate
  44181. */
  44182. target: any;
  44183. /**
  44184. * Returns the string "TargetedAnimation"
  44185. * @returns "TargetedAnimation"
  44186. */
  44187. getClassName(): string;
  44188. /**
  44189. * Serialize the object
  44190. * @returns the JSON object representing the current entity
  44191. */
  44192. serialize(): any;
  44193. }
  44194. /**
  44195. * Use this class to create coordinated animations on multiple targets
  44196. */
  44197. export class AnimationGroup implements IDisposable {
  44198. /** The name of the animation group */
  44199. name: string;
  44200. private _scene;
  44201. private _targetedAnimations;
  44202. private _animatables;
  44203. private _from;
  44204. private _to;
  44205. private _isStarted;
  44206. private _isPaused;
  44207. private _speedRatio;
  44208. private _loopAnimation;
  44209. private _isAdditive;
  44210. /**
  44211. * Gets or sets the unique id of the node
  44212. */
  44213. uniqueId: number;
  44214. /**
  44215. * This observable will notify when one animation have ended
  44216. */
  44217. onAnimationEndObservable: Observable<TargetedAnimation>;
  44218. /**
  44219. * Observer raised when one animation loops
  44220. */
  44221. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44222. /**
  44223. * Observer raised when all animations have looped
  44224. */
  44225. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44226. /**
  44227. * This observable will notify when all animations have ended.
  44228. */
  44229. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44230. /**
  44231. * This observable will notify when all animations have paused.
  44232. */
  44233. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44234. /**
  44235. * This observable will notify when all animations are playing.
  44236. */
  44237. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44238. /**
  44239. * Gets the first frame
  44240. */
  44241. get from(): number;
  44242. /**
  44243. * Gets the last frame
  44244. */
  44245. get to(): number;
  44246. /**
  44247. * Define if the animations are started
  44248. */
  44249. get isStarted(): boolean;
  44250. /**
  44251. * Gets a value indicating that the current group is playing
  44252. */
  44253. get isPlaying(): boolean;
  44254. /**
  44255. * Gets or sets the speed ratio to use for all animations
  44256. */
  44257. get speedRatio(): number;
  44258. /**
  44259. * Gets or sets the speed ratio to use for all animations
  44260. */
  44261. set speedRatio(value: number);
  44262. /**
  44263. * Gets or sets if all animations should loop or not
  44264. */
  44265. get loopAnimation(): boolean;
  44266. set loopAnimation(value: boolean);
  44267. /**
  44268. * Gets or sets if all animations should be evaluated additively
  44269. */
  44270. get isAdditive(): boolean;
  44271. set isAdditive(value: boolean);
  44272. /**
  44273. * Gets the targeted animations for this animation group
  44274. */
  44275. get targetedAnimations(): Array<TargetedAnimation>;
  44276. /**
  44277. * returning the list of animatables controlled by this animation group.
  44278. */
  44279. get animatables(): Array<Animatable>;
  44280. /**
  44281. * Gets the list of target animations
  44282. */
  44283. get children(): TargetedAnimation[];
  44284. /**
  44285. * Instantiates a new Animation Group.
  44286. * This helps managing several animations at once.
  44287. * @see https://doc.babylonjs.com/how_to/group
  44288. * @param name Defines the name of the group
  44289. * @param scene Defines the scene the group belongs to
  44290. */
  44291. constructor(
  44292. /** The name of the animation group */
  44293. name: string, scene?: Nullable<Scene>);
  44294. /**
  44295. * Add an animation (with its target) in the group
  44296. * @param animation defines the animation we want to add
  44297. * @param target defines the target of the animation
  44298. * @returns the TargetedAnimation object
  44299. */
  44300. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44301. /**
  44302. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44303. * It can add constant keys at begin or end
  44304. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44305. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44306. * @returns the animation group
  44307. */
  44308. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44309. private _animationLoopCount;
  44310. private _animationLoopFlags;
  44311. private _processLoop;
  44312. /**
  44313. * Start all animations on given targets
  44314. * @param loop defines if animations must loop
  44315. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44316. * @param from defines the from key (optional)
  44317. * @param to defines the to key (optional)
  44318. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44319. * @returns the current animation group
  44320. */
  44321. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44322. /**
  44323. * Pause all animations
  44324. * @returns the animation group
  44325. */
  44326. pause(): AnimationGroup;
  44327. /**
  44328. * Play all animations to initial state
  44329. * This function will start() the animations if they were not started or will restart() them if they were paused
  44330. * @param loop defines if animations must loop
  44331. * @returns the animation group
  44332. */
  44333. play(loop?: boolean): AnimationGroup;
  44334. /**
  44335. * Reset all animations to initial state
  44336. * @returns the animation group
  44337. */
  44338. reset(): AnimationGroup;
  44339. /**
  44340. * Restart animations from key 0
  44341. * @returns the animation group
  44342. */
  44343. restart(): AnimationGroup;
  44344. /**
  44345. * Stop all animations
  44346. * @returns the animation group
  44347. */
  44348. stop(): AnimationGroup;
  44349. /**
  44350. * Set animation weight for all animatables
  44351. * @param weight defines the weight to use
  44352. * @return the animationGroup
  44353. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44354. */
  44355. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44356. /**
  44357. * Synchronize and normalize all animatables with a source animatable
  44358. * @param root defines the root animatable to synchronize with
  44359. * @return the animationGroup
  44360. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44361. */
  44362. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44363. /**
  44364. * Goes to a specific frame in this animation group
  44365. * @param frame the frame number to go to
  44366. * @return the animationGroup
  44367. */
  44368. goToFrame(frame: number): AnimationGroup;
  44369. /**
  44370. * Dispose all associated resources
  44371. */
  44372. dispose(): void;
  44373. private _checkAnimationGroupEnded;
  44374. /**
  44375. * Clone the current animation group and returns a copy
  44376. * @param newName defines the name of the new group
  44377. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44378. * @returns the new aniamtion group
  44379. */
  44380. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44381. /**
  44382. * Serializes the animationGroup to an object
  44383. * @returns Serialized object
  44384. */
  44385. serialize(): any;
  44386. /**
  44387. * Returns a new AnimationGroup object parsed from the source provided.
  44388. * @param parsedAnimationGroup defines the source
  44389. * @param scene defines the scene that will receive the animationGroup
  44390. * @returns a new AnimationGroup
  44391. */
  44392. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44393. /**
  44394. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44395. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44396. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44397. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44398. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44399. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44400. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44401. */
  44402. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44403. /**
  44404. * Returns the string "AnimationGroup"
  44405. * @returns "AnimationGroup"
  44406. */
  44407. getClassName(): string;
  44408. /**
  44409. * Creates a detailled string about the object
  44410. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44411. * @returns a string representing the object
  44412. */
  44413. toString(fullDetails?: boolean): string;
  44414. }
  44415. }
  44416. declare module "babylonjs/scene" {
  44417. import { Nullable } from "babylonjs/types";
  44418. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  44419. import { Observable } from "babylonjs/Misc/observable";
  44420. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44421. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  44422. import { Geometry } from "babylonjs/Meshes/geometry";
  44423. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44424. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44426. import { Mesh } from "babylonjs/Meshes/mesh";
  44427. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44428. import { Bone } from "babylonjs/Bones/bone";
  44429. import { Skeleton } from "babylonjs/Bones/skeleton";
  44430. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  44431. import { Camera } from "babylonjs/Cameras/camera";
  44432. import { AbstractScene } from "babylonjs/abstractScene";
  44433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44434. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44435. import { Material } from "babylonjs/Materials/material";
  44436. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44437. import { Effect } from "babylonjs/Materials/effect";
  44438. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44439. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  44440. import { Light } from "babylonjs/Lights/light";
  44441. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44442. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  44443. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  44444. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  44445. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  44446. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44447. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  44448. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  44449. import { Engine } from "babylonjs/Engines/engine";
  44450. import { Node } from "babylonjs/node";
  44451. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  44452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  44453. import { WebRequest } from "babylonjs/Misc/webRequest";
  44454. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  44455. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  44456. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44457. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  44458. import { Plane } from "babylonjs/Maths/math.plane";
  44459. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  44460. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  44461. import { Ray } from "babylonjs/Culling/ray";
  44462. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  44463. import { Animation } from "babylonjs/Animations/animation";
  44464. import { Animatable } from "babylonjs/Animations/animatable";
  44465. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44466. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  44467. import { Collider } from "babylonjs/Collisions/collider";
  44468. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44469. /**
  44470. * Define an interface for all classes that will hold resources
  44471. */
  44472. export interface IDisposable {
  44473. /**
  44474. * Releases all held resources
  44475. */
  44476. dispose(): void;
  44477. }
  44478. /** Interface defining initialization parameters for Scene class */
  44479. export interface SceneOptions {
  44480. /**
  44481. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  44482. * It will improve performance when the number of geometries becomes important.
  44483. */
  44484. useGeometryUniqueIdsMap?: boolean;
  44485. /**
  44486. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  44487. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44488. */
  44489. useMaterialMeshMap?: boolean;
  44490. /**
  44491. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  44492. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44493. */
  44494. useClonedMeshMap?: boolean;
  44495. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  44496. virtual?: boolean;
  44497. }
  44498. /**
  44499. * Represents a scene to be rendered by the engine.
  44500. * @see https://doc.babylonjs.com/features/scene
  44501. */
  44502. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  44503. /** The fog is deactivated */
  44504. static readonly FOGMODE_NONE: number;
  44505. /** The fog density is following an exponential function */
  44506. static readonly FOGMODE_EXP: number;
  44507. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  44508. static readonly FOGMODE_EXP2: number;
  44509. /** The fog density is following a linear function. */
  44510. static readonly FOGMODE_LINEAR: number;
  44511. /**
  44512. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  44513. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44514. */
  44515. static MinDeltaTime: number;
  44516. /**
  44517. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44518. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44519. */
  44520. static MaxDeltaTime: number;
  44521. /**
  44522. * Factory used to create the default material.
  44523. * @param name The name of the material to create
  44524. * @param scene The scene to create the material for
  44525. * @returns The default material
  44526. */
  44527. static DefaultMaterialFactory(scene: Scene): Material;
  44528. /**
  44529. * Factory used to create the a collision coordinator.
  44530. * @returns The collision coordinator
  44531. */
  44532. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44533. /** @hidden */
  44534. _inputManager: InputManager;
  44535. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44536. cameraToUseForPointers: Nullable<Camera>;
  44537. /** @hidden */
  44538. readonly _isScene: boolean;
  44539. /** @hidden */
  44540. _blockEntityCollection: boolean;
  44541. /**
  44542. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44543. */
  44544. autoClear: boolean;
  44545. /**
  44546. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44547. */
  44548. autoClearDepthAndStencil: boolean;
  44549. /**
  44550. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44551. */
  44552. clearColor: Color4;
  44553. /**
  44554. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44555. */
  44556. ambientColor: Color3;
  44557. /**
  44558. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44559. * It should only be one of the following (if not the default embedded one):
  44560. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44561. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44562. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44563. * The material properties need to be setup according to the type of texture in use.
  44564. */
  44565. environmentBRDFTexture: BaseTexture;
  44566. /**
  44567. * Texture used in all pbr material as the reflection texture.
  44568. * As in the majority of the scene they are the same (exception for multi room and so on),
  44569. * this is easier to reference from here than from all the materials.
  44570. */
  44571. get environmentTexture(): Nullable<BaseTexture>;
  44572. /**
  44573. * Texture used in all pbr material as the reflection texture.
  44574. * As in the majority of the scene they are the same (exception for multi room and so on),
  44575. * this is easier to set here than in all the materials.
  44576. */
  44577. set environmentTexture(value: Nullable<BaseTexture>);
  44578. /** @hidden */
  44579. protected _environmentIntensity: number;
  44580. /**
  44581. * Intensity of the environment in all pbr material.
  44582. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44583. * As in the majority of the scene they are the same (exception for multi room and so on),
  44584. * this is easier to reference from here than from all the materials.
  44585. */
  44586. get environmentIntensity(): number;
  44587. /**
  44588. * Intensity of the environment in all pbr material.
  44589. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44590. * As in the majority of the scene they are the same (exception for multi room and so on),
  44591. * this is easier to set here than in all the materials.
  44592. */
  44593. set environmentIntensity(value: number);
  44594. /** @hidden */
  44595. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44596. /**
  44597. * Default image processing configuration used either in the rendering
  44598. * Forward main pass or through the imageProcessingPostProcess if present.
  44599. * As in the majority of the scene they are the same (exception for multi camera),
  44600. * this is easier to reference from here than from all the materials and post process.
  44601. *
  44602. * No setter as we it is a shared configuration, you can set the values instead.
  44603. */
  44604. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44605. private _forceWireframe;
  44606. /**
  44607. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44608. */
  44609. set forceWireframe(value: boolean);
  44610. get forceWireframe(): boolean;
  44611. private _skipFrustumClipping;
  44612. /**
  44613. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44614. */
  44615. set skipFrustumClipping(value: boolean);
  44616. get skipFrustumClipping(): boolean;
  44617. private _forcePointsCloud;
  44618. /**
  44619. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44620. */
  44621. set forcePointsCloud(value: boolean);
  44622. get forcePointsCloud(): boolean;
  44623. /**
  44624. * Gets or sets the active clipplane 1
  44625. */
  44626. clipPlane: Nullable<Plane>;
  44627. /**
  44628. * Gets or sets the active clipplane 2
  44629. */
  44630. clipPlane2: Nullable<Plane>;
  44631. /**
  44632. * Gets or sets the active clipplane 3
  44633. */
  44634. clipPlane3: Nullable<Plane>;
  44635. /**
  44636. * Gets or sets the active clipplane 4
  44637. */
  44638. clipPlane4: Nullable<Plane>;
  44639. /**
  44640. * Gets or sets the active clipplane 5
  44641. */
  44642. clipPlane5: Nullable<Plane>;
  44643. /**
  44644. * Gets or sets the active clipplane 6
  44645. */
  44646. clipPlane6: Nullable<Plane>;
  44647. /**
  44648. * Gets or sets a boolean indicating if animations are enabled
  44649. */
  44650. animationsEnabled: boolean;
  44651. private _animationPropertiesOverride;
  44652. /**
  44653. * Gets or sets the animation properties override
  44654. */
  44655. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44656. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44657. /**
  44658. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44659. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44660. */
  44661. useConstantAnimationDeltaTime: boolean;
  44662. /**
  44663. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44664. * Please note that it requires to run a ray cast through the scene on every frame
  44665. */
  44666. constantlyUpdateMeshUnderPointer: boolean;
  44667. /**
  44668. * Defines the HTML cursor to use when hovering over interactive elements
  44669. */
  44670. hoverCursor: string;
  44671. /**
  44672. * Defines the HTML default cursor to use (empty by default)
  44673. */
  44674. defaultCursor: string;
  44675. /**
  44676. * Defines whether cursors are handled by the scene.
  44677. */
  44678. doNotHandleCursors: boolean;
  44679. /**
  44680. * This is used to call preventDefault() on pointer down
  44681. * in order to block unwanted artifacts like system double clicks
  44682. */
  44683. preventDefaultOnPointerDown: boolean;
  44684. /**
  44685. * This is used to call preventDefault() on pointer up
  44686. * in order to block unwanted artifacts like system double clicks
  44687. */
  44688. preventDefaultOnPointerUp: boolean;
  44689. /**
  44690. * Gets or sets user defined metadata
  44691. */
  44692. metadata: any;
  44693. /**
  44694. * For internal use only. Please do not use.
  44695. */
  44696. reservedDataStore: any;
  44697. /**
  44698. * Gets the name of the plugin used to load this scene (null by default)
  44699. */
  44700. loadingPluginName: string;
  44701. /**
  44702. * Use this array to add regular expressions used to disable offline support for specific urls
  44703. */
  44704. disableOfflineSupportExceptionRules: RegExp[];
  44705. /**
  44706. * An event triggered when the scene is disposed.
  44707. */
  44708. onDisposeObservable: Observable<Scene>;
  44709. private _onDisposeObserver;
  44710. /** Sets a function to be executed when this scene is disposed. */
  44711. set onDispose(callback: () => void);
  44712. /**
  44713. * An event triggered before rendering the scene (right after animations and physics)
  44714. */
  44715. onBeforeRenderObservable: Observable<Scene>;
  44716. private _onBeforeRenderObserver;
  44717. /** Sets a function to be executed before rendering this scene */
  44718. set beforeRender(callback: Nullable<() => void>);
  44719. /**
  44720. * An event triggered after rendering the scene
  44721. */
  44722. onAfterRenderObservable: Observable<Scene>;
  44723. /**
  44724. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44725. */
  44726. onAfterRenderCameraObservable: Observable<Camera>;
  44727. private _onAfterRenderObserver;
  44728. /** Sets a function to be executed after rendering this scene */
  44729. set afterRender(callback: Nullable<() => void>);
  44730. /**
  44731. * An event triggered before animating the scene
  44732. */
  44733. onBeforeAnimationsObservable: Observable<Scene>;
  44734. /**
  44735. * An event triggered after animations processing
  44736. */
  44737. onAfterAnimationsObservable: Observable<Scene>;
  44738. /**
  44739. * An event triggered before draw calls are ready to be sent
  44740. */
  44741. onBeforeDrawPhaseObservable: Observable<Scene>;
  44742. /**
  44743. * An event triggered after draw calls have been sent
  44744. */
  44745. onAfterDrawPhaseObservable: Observable<Scene>;
  44746. /**
  44747. * An event triggered when the scene is ready
  44748. */
  44749. onReadyObservable: Observable<Scene>;
  44750. /**
  44751. * An event triggered before rendering a camera
  44752. */
  44753. onBeforeCameraRenderObservable: Observable<Camera>;
  44754. private _onBeforeCameraRenderObserver;
  44755. /** Sets a function to be executed before rendering a camera*/
  44756. set beforeCameraRender(callback: () => void);
  44757. /**
  44758. * An event triggered after rendering a camera
  44759. */
  44760. onAfterCameraRenderObservable: Observable<Camera>;
  44761. private _onAfterCameraRenderObserver;
  44762. /** Sets a function to be executed after rendering a camera*/
  44763. set afterCameraRender(callback: () => void);
  44764. /**
  44765. * An event triggered when active meshes evaluation is about to start
  44766. */
  44767. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44768. /**
  44769. * An event triggered when active meshes evaluation is done
  44770. */
  44771. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44772. /**
  44773. * An event triggered when particles rendering is about to start
  44774. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44775. */
  44776. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44777. /**
  44778. * An event triggered when particles rendering is done
  44779. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44780. */
  44781. onAfterParticlesRenderingObservable: Observable<Scene>;
  44782. /**
  44783. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44784. */
  44785. onDataLoadedObservable: Observable<Scene>;
  44786. /**
  44787. * An event triggered when a camera is created
  44788. */
  44789. onNewCameraAddedObservable: Observable<Camera>;
  44790. /**
  44791. * An event triggered when a camera is removed
  44792. */
  44793. onCameraRemovedObservable: Observable<Camera>;
  44794. /**
  44795. * An event triggered when a light is created
  44796. */
  44797. onNewLightAddedObservable: Observable<Light>;
  44798. /**
  44799. * An event triggered when a light is removed
  44800. */
  44801. onLightRemovedObservable: Observable<Light>;
  44802. /**
  44803. * An event triggered when a geometry is created
  44804. */
  44805. onNewGeometryAddedObservable: Observable<Geometry>;
  44806. /**
  44807. * An event triggered when a geometry is removed
  44808. */
  44809. onGeometryRemovedObservable: Observable<Geometry>;
  44810. /**
  44811. * An event triggered when a transform node is created
  44812. */
  44813. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44814. /**
  44815. * An event triggered when a transform node is removed
  44816. */
  44817. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44818. /**
  44819. * An event triggered when a mesh is created
  44820. */
  44821. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44822. /**
  44823. * An event triggered when a mesh is removed
  44824. */
  44825. onMeshRemovedObservable: Observable<AbstractMesh>;
  44826. /**
  44827. * An event triggered when a skeleton is created
  44828. */
  44829. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44830. /**
  44831. * An event triggered when a skeleton is removed
  44832. */
  44833. onSkeletonRemovedObservable: Observable<Skeleton>;
  44834. /**
  44835. * An event triggered when a material is created
  44836. */
  44837. onNewMaterialAddedObservable: Observable<Material>;
  44838. /**
  44839. * An event triggered when a multi material is created
  44840. */
  44841. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  44842. /**
  44843. * An event triggered when a material is removed
  44844. */
  44845. onMaterialRemovedObservable: Observable<Material>;
  44846. /**
  44847. * An event triggered when a multi material is removed
  44848. */
  44849. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  44850. /**
  44851. * An event triggered when a texture is created
  44852. */
  44853. onNewTextureAddedObservable: Observable<BaseTexture>;
  44854. /**
  44855. * An event triggered when a texture is removed
  44856. */
  44857. onTextureRemovedObservable: Observable<BaseTexture>;
  44858. /**
  44859. * An event triggered when render targets are about to be rendered
  44860. * Can happen multiple times per frame.
  44861. */
  44862. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44863. /**
  44864. * An event triggered when render targets were rendered.
  44865. * Can happen multiple times per frame.
  44866. */
  44867. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44868. /**
  44869. * An event triggered before calculating deterministic simulation step
  44870. */
  44871. onBeforeStepObservable: Observable<Scene>;
  44872. /**
  44873. * An event triggered after calculating deterministic simulation step
  44874. */
  44875. onAfterStepObservable: Observable<Scene>;
  44876. /**
  44877. * An event triggered when the activeCamera property is updated
  44878. */
  44879. onActiveCameraChanged: Observable<Scene>;
  44880. /**
  44881. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44882. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44883. * 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)
  44884. */
  44885. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44886. /**
  44887. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44888. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44889. * 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)
  44890. */
  44891. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44892. /**
  44893. * This Observable will when a mesh has been imported into the scene.
  44894. */
  44895. onMeshImportedObservable: Observable<AbstractMesh>;
  44896. /**
  44897. * This Observable will when an animation file has been imported into the scene.
  44898. */
  44899. onAnimationFileImportedObservable: Observable<Scene>;
  44900. /**
  44901. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44902. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44903. */
  44904. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44905. /** @hidden */
  44906. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44907. /**
  44908. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44909. */
  44910. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44911. /**
  44912. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44913. */
  44914. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44915. /**
  44916. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44917. */
  44918. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44919. /** Callback called when a pointer move is detected */
  44920. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44921. /** Callback called when a pointer down is detected */
  44922. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44923. /** Callback called when a pointer up is detected */
  44924. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44925. /** Callback called when a pointer pick is detected */
  44926. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44927. /**
  44928. * 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).
  44929. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44930. */
  44931. onPrePointerObservable: Observable<PointerInfoPre>;
  44932. /**
  44933. * Observable event triggered each time an input event is received from the rendering canvas
  44934. */
  44935. onPointerObservable: Observable<PointerInfo>;
  44936. /**
  44937. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44938. */
  44939. get unTranslatedPointer(): Vector2;
  44940. /**
  44941. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44942. */
  44943. static get DragMovementThreshold(): number;
  44944. static set DragMovementThreshold(value: number);
  44945. /**
  44946. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44947. */
  44948. static get LongPressDelay(): number;
  44949. static set LongPressDelay(value: number);
  44950. /**
  44951. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44952. */
  44953. static get DoubleClickDelay(): number;
  44954. static set DoubleClickDelay(value: number);
  44955. /** If you need to check double click without raising a single click at first click, enable this flag */
  44956. static get ExclusiveDoubleClickMode(): boolean;
  44957. static set ExclusiveDoubleClickMode(value: boolean);
  44958. /** @hidden */
  44959. _mirroredCameraPosition: Nullable<Vector3>;
  44960. /**
  44961. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44962. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44963. */
  44964. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44965. /**
  44966. * Observable event triggered each time an keyboard event is received from the hosting window
  44967. */
  44968. onKeyboardObservable: Observable<KeyboardInfo>;
  44969. private _useRightHandedSystem;
  44970. /**
  44971. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44972. */
  44973. set useRightHandedSystem(value: boolean);
  44974. get useRightHandedSystem(): boolean;
  44975. private _timeAccumulator;
  44976. private _currentStepId;
  44977. private _currentInternalStep;
  44978. /**
  44979. * Sets the step Id used by deterministic lock step
  44980. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44981. * @param newStepId defines the step Id
  44982. */
  44983. setStepId(newStepId: number): void;
  44984. /**
  44985. * Gets the step Id used by deterministic lock step
  44986. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44987. * @returns the step Id
  44988. */
  44989. getStepId(): number;
  44990. /**
  44991. * Gets the internal step used by deterministic lock step
  44992. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44993. * @returns the internal step
  44994. */
  44995. getInternalStep(): number;
  44996. private _fogEnabled;
  44997. /**
  44998. * Gets or sets a boolean indicating if fog is enabled on this scene
  44999. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45000. * (Default is true)
  45001. */
  45002. set fogEnabled(value: boolean);
  45003. get fogEnabled(): boolean;
  45004. private _fogMode;
  45005. /**
  45006. * Gets or sets the fog mode to use
  45007. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45008. * | mode | value |
  45009. * | --- | --- |
  45010. * | FOGMODE_NONE | 0 |
  45011. * | FOGMODE_EXP | 1 |
  45012. * | FOGMODE_EXP2 | 2 |
  45013. * | FOGMODE_LINEAR | 3 |
  45014. */
  45015. set fogMode(value: number);
  45016. get fogMode(): number;
  45017. /**
  45018. * Gets or sets the fog color to use
  45019. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45020. * (Default is Color3(0.2, 0.2, 0.3))
  45021. */
  45022. fogColor: Color3;
  45023. /**
  45024. * Gets or sets the fog density to use
  45025. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45026. * (Default is 0.1)
  45027. */
  45028. fogDensity: number;
  45029. /**
  45030. * Gets or sets the fog start distance to use
  45031. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45032. * (Default is 0)
  45033. */
  45034. fogStart: number;
  45035. /**
  45036. * Gets or sets the fog end distance to use
  45037. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45038. * (Default is 1000)
  45039. */
  45040. fogEnd: number;
  45041. /**
  45042. * Flag indicating that the frame buffer binding is handled by another component
  45043. */
  45044. prePass: boolean;
  45045. private _shadowsEnabled;
  45046. /**
  45047. * Gets or sets a boolean indicating if shadows are enabled on this scene
  45048. */
  45049. set shadowsEnabled(value: boolean);
  45050. get shadowsEnabled(): boolean;
  45051. private _lightsEnabled;
  45052. /**
  45053. * Gets or sets a boolean indicating if lights are enabled on this scene
  45054. */
  45055. set lightsEnabled(value: boolean);
  45056. get lightsEnabled(): boolean;
  45057. /** All of the active cameras added to this scene. */
  45058. activeCameras: Nullable<Camera[]>;
  45059. /** @hidden */
  45060. _activeCamera: Nullable<Camera>;
  45061. /** Gets or sets the current active camera */
  45062. get activeCamera(): Nullable<Camera>;
  45063. set activeCamera(value: Nullable<Camera>);
  45064. private _defaultMaterial;
  45065. /** The default material used on meshes when no material is affected */
  45066. get defaultMaterial(): Material;
  45067. /** The default material used on meshes when no material is affected */
  45068. set defaultMaterial(value: Material);
  45069. private _texturesEnabled;
  45070. /**
  45071. * Gets or sets a boolean indicating if textures are enabled on this scene
  45072. */
  45073. set texturesEnabled(value: boolean);
  45074. get texturesEnabled(): boolean;
  45075. /**
  45076. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  45077. */
  45078. physicsEnabled: boolean;
  45079. /**
  45080. * Gets or sets a boolean indicating if particles are enabled on this scene
  45081. */
  45082. particlesEnabled: boolean;
  45083. /**
  45084. * Gets or sets a boolean indicating if sprites are enabled on this scene
  45085. */
  45086. spritesEnabled: boolean;
  45087. private _skeletonsEnabled;
  45088. /**
  45089. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  45090. */
  45091. set skeletonsEnabled(value: boolean);
  45092. get skeletonsEnabled(): boolean;
  45093. /**
  45094. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  45095. */
  45096. lensFlaresEnabled: boolean;
  45097. /**
  45098. * Gets or sets a boolean indicating if collisions are enabled on this scene
  45099. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45100. */
  45101. collisionsEnabled: boolean;
  45102. private _collisionCoordinator;
  45103. /** @hidden */
  45104. get collisionCoordinator(): ICollisionCoordinator;
  45105. /**
  45106. * Defines the gravity applied to this scene (used only for collisions)
  45107. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45108. */
  45109. gravity: Vector3;
  45110. /**
  45111. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  45112. */
  45113. postProcessesEnabled: boolean;
  45114. /**
  45115. * Gets the current postprocess manager
  45116. */
  45117. postProcessManager: PostProcessManager;
  45118. /**
  45119. * Gets or sets a boolean indicating if render targets are enabled on this scene
  45120. */
  45121. renderTargetsEnabled: boolean;
  45122. /**
  45123. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  45124. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  45125. */
  45126. dumpNextRenderTargets: boolean;
  45127. /**
  45128. * The list of user defined render targets added to the scene
  45129. */
  45130. customRenderTargets: RenderTargetTexture[];
  45131. /**
  45132. * Defines if texture loading must be delayed
  45133. * If true, textures will only be loaded when they need to be rendered
  45134. */
  45135. useDelayedTextureLoading: boolean;
  45136. /**
  45137. * Gets the list of meshes imported to the scene through SceneLoader
  45138. */
  45139. importedMeshesFiles: String[];
  45140. /**
  45141. * Gets or sets a boolean indicating if probes are enabled on this scene
  45142. */
  45143. probesEnabled: boolean;
  45144. /**
  45145. * Gets or sets the current offline provider to use to store scene data
  45146. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  45147. */
  45148. offlineProvider: IOfflineProvider;
  45149. /**
  45150. * Gets or sets the action manager associated with the scene
  45151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45152. */
  45153. actionManager: AbstractActionManager;
  45154. private _meshesForIntersections;
  45155. /**
  45156. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  45157. */
  45158. proceduralTexturesEnabled: boolean;
  45159. private _engine;
  45160. private _totalVertices;
  45161. /** @hidden */
  45162. _activeIndices: PerfCounter;
  45163. /** @hidden */
  45164. _activeParticles: PerfCounter;
  45165. /** @hidden */
  45166. _activeBones: PerfCounter;
  45167. private _animationRatio;
  45168. /** @hidden */
  45169. _animationTimeLast: number;
  45170. /** @hidden */
  45171. _animationTime: number;
  45172. /**
  45173. * Gets or sets a general scale for animation speed
  45174. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  45175. */
  45176. animationTimeScale: number;
  45177. /** @hidden */
  45178. _cachedMaterial: Nullable<Material>;
  45179. /** @hidden */
  45180. _cachedEffect: Nullable<Effect>;
  45181. /** @hidden */
  45182. _cachedVisibility: Nullable<number>;
  45183. private _renderId;
  45184. private _frameId;
  45185. private _executeWhenReadyTimeoutId;
  45186. private _intermediateRendering;
  45187. private _viewUpdateFlag;
  45188. private _projectionUpdateFlag;
  45189. /** @hidden */
  45190. _toBeDisposed: Nullable<IDisposable>[];
  45191. private _activeRequests;
  45192. /** @hidden */
  45193. _pendingData: any[];
  45194. private _isDisposed;
  45195. /**
  45196. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  45197. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  45198. */
  45199. dispatchAllSubMeshesOfActiveMeshes: boolean;
  45200. private _activeMeshes;
  45201. private _processedMaterials;
  45202. private _renderTargets;
  45203. /** @hidden */
  45204. _activeParticleSystems: SmartArray<IParticleSystem>;
  45205. private _activeSkeletons;
  45206. private _softwareSkinnedMeshes;
  45207. private _renderingManager;
  45208. /** @hidden */
  45209. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  45210. private _transformMatrix;
  45211. private _sceneUbo;
  45212. /** @hidden */
  45213. _viewMatrix: Matrix;
  45214. private _projectionMatrix;
  45215. /** @hidden */
  45216. _forcedViewPosition: Nullable<Vector3>;
  45217. /** @hidden */
  45218. _frustumPlanes: Plane[];
  45219. /**
  45220. * Gets the list of frustum planes (built from the active camera)
  45221. */
  45222. get frustumPlanes(): Plane[];
  45223. /**
  45224. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  45225. * This is useful if there are more lights that the maximum simulteanous authorized
  45226. */
  45227. requireLightSorting: boolean;
  45228. /** @hidden */
  45229. readonly useMaterialMeshMap: boolean;
  45230. /** @hidden */
  45231. readonly useClonedMeshMap: boolean;
  45232. private _externalData;
  45233. private _uid;
  45234. /**
  45235. * @hidden
  45236. * Backing store of defined scene components.
  45237. */
  45238. _components: ISceneComponent[];
  45239. /**
  45240. * @hidden
  45241. * Backing store of defined scene components.
  45242. */
  45243. _serializableComponents: ISceneSerializableComponent[];
  45244. /**
  45245. * List of components to register on the next registration step.
  45246. */
  45247. private _transientComponents;
  45248. /**
  45249. * Registers the transient components if needed.
  45250. */
  45251. private _registerTransientComponents;
  45252. /**
  45253. * @hidden
  45254. * Add a component to the scene.
  45255. * Note that the ccomponent could be registered on th next frame if this is called after
  45256. * the register component stage.
  45257. * @param component Defines the component to add to the scene
  45258. */
  45259. _addComponent(component: ISceneComponent): void;
  45260. /**
  45261. * @hidden
  45262. * Gets a component from the scene.
  45263. * @param name defines the name of the component to retrieve
  45264. * @returns the component or null if not present
  45265. */
  45266. _getComponent(name: string): Nullable<ISceneComponent>;
  45267. /**
  45268. * @hidden
  45269. * Defines the actions happening before camera updates.
  45270. */
  45271. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  45272. /**
  45273. * @hidden
  45274. * Defines the actions happening before clear the canvas.
  45275. */
  45276. _beforeClearStage: Stage<SimpleStageAction>;
  45277. /**
  45278. * @hidden
  45279. * Defines the actions when collecting render targets for the frame.
  45280. */
  45281. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45282. /**
  45283. * @hidden
  45284. * Defines the actions happening for one camera in the frame.
  45285. */
  45286. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45287. /**
  45288. * @hidden
  45289. * Defines the actions happening during the per mesh ready checks.
  45290. */
  45291. _isReadyForMeshStage: Stage<MeshStageAction>;
  45292. /**
  45293. * @hidden
  45294. * Defines the actions happening before evaluate active mesh checks.
  45295. */
  45296. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  45297. /**
  45298. * @hidden
  45299. * Defines the actions happening during the evaluate sub mesh checks.
  45300. */
  45301. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  45302. /**
  45303. * @hidden
  45304. * Defines the actions happening during the active mesh stage.
  45305. */
  45306. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  45307. /**
  45308. * @hidden
  45309. * Defines the actions happening during the per camera render target step.
  45310. */
  45311. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  45312. /**
  45313. * @hidden
  45314. * Defines the actions happening just before the active camera is drawing.
  45315. */
  45316. _beforeCameraDrawStage: Stage<CameraStageAction>;
  45317. /**
  45318. * @hidden
  45319. * Defines the actions happening just before a render target is drawing.
  45320. */
  45321. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45322. /**
  45323. * @hidden
  45324. * Defines the actions happening just before a rendering group is drawing.
  45325. */
  45326. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45327. /**
  45328. * @hidden
  45329. * Defines the actions happening just before a mesh is drawing.
  45330. */
  45331. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45332. /**
  45333. * @hidden
  45334. * Defines the actions happening just after a mesh has been drawn.
  45335. */
  45336. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45337. /**
  45338. * @hidden
  45339. * Defines the actions happening just after a rendering group has been drawn.
  45340. */
  45341. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45342. /**
  45343. * @hidden
  45344. * Defines the actions happening just after the active camera has been drawn.
  45345. */
  45346. _afterCameraDrawStage: Stage<CameraStageAction>;
  45347. /**
  45348. * @hidden
  45349. * Defines the actions happening just after a render target has been drawn.
  45350. */
  45351. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45352. /**
  45353. * @hidden
  45354. * Defines the actions happening just after rendering all cameras and computing intersections.
  45355. */
  45356. _afterRenderStage: Stage<SimpleStageAction>;
  45357. /**
  45358. * @hidden
  45359. * Defines the actions happening when a pointer move event happens.
  45360. */
  45361. _pointerMoveStage: Stage<PointerMoveStageAction>;
  45362. /**
  45363. * @hidden
  45364. * Defines the actions happening when a pointer down event happens.
  45365. */
  45366. _pointerDownStage: Stage<PointerUpDownStageAction>;
  45367. /**
  45368. * @hidden
  45369. * Defines the actions happening when a pointer up event happens.
  45370. */
  45371. _pointerUpStage: Stage<PointerUpDownStageAction>;
  45372. /**
  45373. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  45374. */
  45375. private geometriesByUniqueId;
  45376. /**
  45377. * Creates a new Scene
  45378. * @param engine defines the engine to use to render this scene
  45379. * @param options defines the scene options
  45380. */
  45381. constructor(engine: Engine, options?: SceneOptions);
  45382. /**
  45383. * Gets a string identifying the name of the class
  45384. * @returns "Scene" string
  45385. */
  45386. getClassName(): string;
  45387. private _defaultMeshCandidates;
  45388. /**
  45389. * @hidden
  45390. */
  45391. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45392. private _defaultSubMeshCandidates;
  45393. /**
  45394. * @hidden
  45395. */
  45396. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45397. /**
  45398. * Sets the default candidate providers for the scene.
  45399. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  45400. * and getCollidingSubMeshCandidates to their default function
  45401. */
  45402. setDefaultCandidateProviders(): void;
  45403. /**
  45404. * Gets the mesh that is currently under the pointer
  45405. */
  45406. get meshUnderPointer(): Nullable<AbstractMesh>;
  45407. /**
  45408. * Gets or sets the current on-screen X position of the pointer
  45409. */
  45410. get pointerX(): number;
  45411. set pointerX(value: number);
  45412. /**
  45413. * Gets or sets the current on-screen Y position of the pointer
  45414. */
  45415. get pointerY(): number;
  45416. set pointerY(value: number);
  45417. /**
  45418. * Gets the cached material (ie. the latest rendered one)
  45419. * @returns the cached material
  45420. */
  45421. getCachedMaterial(): Nullable<Material>;
  45422. /**
  45423. * Gets the cached effect (ie. the latest rendered one)
  45424. * @returns the cached effect
  45425. */
  45426. getCachedEffect(): Nullable<Effect>;
  45427. /**
  45428. * Gets the cached visibility state (ie. the latest rendered one)
  45429. * @returns the cached visibility state
  45430. */
  45431. getCachedVisibility(): Nullable<number>;
  45432. /**
  45433. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  45434. * @param material defines the current material
  45435. * @param effect defines the current effect
  45436. * @param visibility defines the current visibility state
  45437. * @returns true if one parameter is not cached
  45438. */
  45439. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  45440. /**
  45441. * Gets the engine associated with the scene
  45442. * @returns an Engine
  45443. */
  45444. getEngine(): Engine;
  45445. /**
  45446. * Gets the total number of vertices rendered per frame
  45447. * @returns the total number of vertices rendered per frame
  45448. */
  45449. getTotalVertices(): number;
  45450. /**
  45451. * Gets the performance counter for total vertices
  45452. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45453. */
  45454. get totalVerticesPerfCounter(): PerfCounter;
  45455. /**
  45456. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  45457. * @returns the total number of active indices rendered per frame
  45458. */
  45459. getActiveIndices(): number;
  45460. /**
  45461. * Gets the performance counter for active indices
  45462. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45463. */
  45464. get totalActiveIndicesPerfCounter(): PerfCounter;
  45465. /**
  45466. * Gets the total number of active particles rendered per frame
  45467. * @returns the total number of active particles rendered per frame
  45468. */
  45469. getActiveParticles(): number;
  45470. /**
  45471. * Gets the performance counter for active particles
  45472. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45473. */
  45474. get activeParticlesPerfCounter(): PerfCounter;
  45475. /**
  45476. * Gets the total number of active bones rendered per frame
  45477. * @returns the total number of active bones rendered per frame
  45478. */
  45479. getActiveBones(): number;
  45480. /**
  45481. * Gets the performance counter for active bones
  45482. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45483. */
  45484. get activeBonesPerfCounter(): PerfCounter;
  45485. /**
  45486. * Gets the array of active meshes
  45487. * @returns an array of AbstractMesh
  45488. */
  45489. getActiveMeshes(): SmartArray<AbstractMesh>;
  45490. /**
  45491. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  45492. * @returns a number
  45493. */
  45494. getAnimationRatio(): number;
  45495. /**
  45496. * Gets an unique Id for the current render phase
  45497. * @returns a number
  45498. */
  45499. getRenderId(): number;
  45500. /**
  45501. * Gets an unique Id for the current frame
  45502. * @returns a number
  45503. */
  45504. getFrameId(): number;
  45505. /** Call this function if you want to manually increment the render Id*/
  45506. incrementRenderId(): void;
  45507. private _createUbo;
  45508. /**
  45509. * Use this method to simulate a pointer move on a mesh
  45510. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45511. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45512. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45513. * @returns the current scene
  45514. */
  45515. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45516. /**
  45517. * Use this method to simulate a pointer down on a mesh
  45518. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45519. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45520. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45521. * @returns the current scene
  45522. */
  45523. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45524. /**
  45525. * Use this method to simulate a pointer up on a mesh
  45526. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45527. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45528. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45529. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45530. * @returns the current scene
  45531. */
  45532. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45533. /**
  45534. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45535. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45536. * @returns true if the pointer was captured
  45537. */
  45538. isPointerCaptured(pointerId?: number): boolean;
  45539. /**
  45540. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45541. * @param attachUp defines if you want to attach events to pointerup
  45542. * @param attachDown defines if you want to attach events to pointerdown
  45543. * @param attachMove defines if you want to attach events to pointermove
  45544. */
  45545. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45546. /** Detaches all event handlers*/
  45547. detachControl(): void;
  45548. /**
  45549. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45550. * Delay loaded resources are not taking in account
  45551. * @return true if all required resources are ready
  45552. */
  45553. isReady(): boolean;
  45554. /** Resets all cached information relative to material (including effect and visibility) */
  45555. resetCachedMaterial(): void;
  45556. /**
  45557. * Registers a function to be called before every frame render
  45558. * @param func defines the function to register
  45559. */
  45560. registerBeforeRender(func: () => void): void;
  45561. /**
  45562. * Unregisters a function called before every frame render
  45563. * @param func defines the function to unregister
  45564. */
  45565. unregisterBeforeRender(func: () => void): void;
  45566. /**
  45567. * Registers a function to be called after every frame render
  45568. * @param func defines the function to register
  45569. */
  45570. registerAfterRender(func: () => void): void;
  45571. /**
  45572. * Unregisters a function called after every frame render
  45573. * @param func defines the function to unregister
  45574. */
  45575. unregisterAfterRender(func: () => void): void;
  45576. private _executeOnceBeforeRender;
  45577. /**
  45578. * The provided function will run before render once and will be disposed afterwards.
  45579. * A timeout delay can be provided so that the function will be executed in N ms.
  45580. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45581. * @param func The function to be executed.
  45582. * @param timeout optional delay in ms
  45583. */
  45584. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45585. /** @hidden */
  45586. _addPendingData(data: any): void;
  45587. /** @hidden */
  45588. _removePendingData(data: any): void;
  45589. /**
  45590. * Returns the number of items waiting to be loaded
  45591. * @returns the number of items waiting to be loaded
  45592. */
  45593. getWaitingItemsCount(): number;
  45594. /**
  45595. * Returns a boolean indicating if the scene is still loading data
  45596. */
  45597. get isLoading(): boolean;
  45598. /**
  45599. * Registers a function to be executed when the scene is ready
  45600. * @param {Function} func - the function to be executed
  45601. */
  45602. executeWhenReady(func: () => void): void;
  45603. /**
  45604. * Returns a promise that resolves when the scene is ready
  45605. * @returns A promise that resolves when the scene is ready
  45606. */
  45607. whenReadyAsync(): Promise<void>;
  45608. /** @hidden */
  45609. _checkIsReady(): void;
  45610. /**
  45611. * Gets all animatable attached to the scene
  45612. */
  45613. get animatables(): Animatable[];
  45614. /**
  45615. * Resets the last animation time frame.
  45616. * Useful to override when animations start running when loading a scene for the first time.
  45617. */
  45618. resetLastAnimationTimeFrame(): void;
  45619. /**
  45620. * Gets the current view matrix
  45621. * @returns a Matrix
  45622. */
  45623. getViewMatrix(): Matrix;
  45624. /**
  45625. * Gets the current projection matrix
  45626. * @returns a Matrix
  45627. */
  45628. getProjectionMatrix(): Matrix;
  45629. /**
  45630. * Gets the current transform matrix
  45631. * @returns a Matrix made of View * Projection
  45632. */
  45633. getTransformMatrix(): Matrix;
  45634. /**
  45635. * Sets the current transform matrix
  45636. * @param viewL defines the View matrix to use
  45637. * @param projectionL defines the Projection matrix to use
  45638. * @param viewR defines the right View matrix to use (if provided)
  45639. * @param projectionR defines the right Projection matrix to use (if provided)
  45640. */
  45641. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45642. /**
  45643. * Gets the uniform buffer used to store scene data
  45644. * @returns a UniformBuffer
  45645. */
  45646. getSceneUniformBuffer(): UniformBuffer;
  45647. /**
  45648. * Gets an unique (relatively to the current scene) Id
  45649. * @returns an unique number for the scene
  45650. */
  45651. getUniqueId(): number;
  45652. /**
  45653. * Add a mesh to the list of scene's meshes
  45654. * @param newMesh defines the mesh to add
  45655. * @param recursive if all child meshes should also be added to the scene
  45656. */
  45657. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45658. /**
  45659. * Remove a mesh for the list of scene's meshes
  45660. * @param toRemove defines the mesh to remove
  45661. * @param recursive if all child meshes should also be removed from the scene
  45662. * @returns the index where the mesh was in the mesh list
  45663. */
  45664. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45665. /**
  45666. * Add a transform node to the list of scene's transform nodes
  45667. * @param newTransformNode defines the transform node to add
  45668. */
  45669. addTransformNode(newTransformNode: TransformNode): void;
  45670. /**
  45671. * Remove a transform node for the list of scene's transform nodes
  45672. * @param toRemove defines the transform node to remove
  45673. * @returns the index where the transform node was in the transform node list
  45674. */
  45675. removeTransformNode(toRemove: TransformNode): number;
  45676. /**
  45677. * Remove a skeleton for the list of scene's skeletons
  45678. * @param toRemove defines the skeleton to remove
  45679. * @returns the index where the skeleton was in the skeleton list
  45680. */
  45681. removeSkeleton(toRemove: Skeleton): number;
  45682. /**
  45683. * Remove a morph target for the list of scene's morph targets
  45684. * @param toRemove defines the morph target to remove
  45685. * @returns the index where the morph target was in the morph target list
  45686. */
  45687. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45688. /**
  45689. * Remove a light for the list of scene's lights
  45690. * @param toRemove defines the light to remove
  45691. * @returns the index where the light was in the light list
  45692. */
  45693. removeLight(toRemove: Light): number;
  45694. /**
  45695. * Remove a camera for the list of scene's cameras
  45696. * @param toRemove defines the camera to remove
  45697. * @returns the index where the camera was in the camera list
  45698. */
  45699. removeCamera(toRemove: Camera): number;
  45700. /**
  45701. * Remove a particle system for the list of scene's particle systems
  45702. * @param toRemove defines the particle system to remove
  45703. * @returns the index where the particle system was in the particle system list
  45704. */
  45705. removeParticleSystem(toRemove: IParticleSystem): number;
  45706. /**
  45707. * Remove a animation for the list of scene's animations
  45708. * @param toRemove defines the animation to remove
  45709. * @returns the index where the animation was in the animation list
  45710. */
  45711. removeAnimation(toRemove: Animation): number;
  45712. /**
  45713. * Will stop the animation of the given target
  45714. * @param target - the target
  45715. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45716. * @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)
  45717. */
  45718. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45719. /**
  45720. * Removes the given animation group from this scene.
  45721. * @param toRemove The animation group to remove
  45722. * @returns The index of the removed animation group
  45723. */
  45724. removeAnimationGroup(toRemove: AnimationGroup): number;
  45725. /**
  45726. * Removes the given multi-material from this scene.
  45727. * @param toRemove The multi-material to remove
  45728. * @returns The index of the removed multi-material
  45729. */
  45730. removeMultiMaterial(toRemove: MultiMaterial): number;
  45731. /**
  45732. * Removes the given material from this scene.
  45733. * @param toRemove The material to remove
  45734. * @returns The index of the removed material
  45735. */
  45736. removeMaterial(toRemove: Material): number;
  45737. /**
  45738. * Removes the given action manager from this scene.
  45739. * @param toRemove The action manager to remove
  45740. * @returns The index of the removed action manager
  45741. */
  45742. removeActionManager(toRemove: AbstractActionManager): number;
  45743. /**
  45744. * Removes the given texture from this scene.
  45745. * @param toRemove The texture to remove
  45746. * @returns The index of the removed texture
  45747. */
  45748. removeTexture(toRemove: BaseTexture): number;
  45749. /**
  45750. * Adds the given light to this scene
  45751. * @param newLight The light to add
  45752. */
  45753. addLight(newLight: Light): void;
  45754. /**
  45755. * Sorts the list list based on light priorities
  45756. */
  45757. sortLightsByPriority(): void;
  45758. /**
  45759. * Adds the given camera to this scene
  45760. * @param newCamera The camera to add
  45761. */
  45762. addCamera(newCamera: Camera): void;
  45763. /**
  45764. * Adds the given skeleton to this scene
  45765. * @param newSkeleton The skeleton to add
  45766. */
  45767. addSkeleton(newSkeleton: Skeleton): void;
  45768. /**
  45769. * Adds the given particle system to this scene
  45770. * @param newParticleSystem The particle system to add
  45771. */
  45772. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45773. /**
  45774. * Adds the given animation to this scene
  45775. * @param newAnimation The animation to add
  45776. */
  45777. addAnimation(newAnimation: Animation): void;
  45778. /**
  45779. * Adds the given animation group to this scene.
  45780. * @param newAnimationGroup The animation group to add
  45781. */
  45782. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45783. /**
  45784. * Adds the given multi-material to this scene
  45785. * @param newMultiMaterial The multi-material to add
  45786. */
  45787. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45788. /**
  45789. * Adds the given material to this scene
  45790. * @param newMaterial The material to add
  45791. */
  45792. addMaterial(newMaterial: Material): void;
  45793. /**
  45794. * Adds the given morph target to this scene
  45795. * @param newMorphTargetManager The morph target to add
  45796. */
  45797. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45798. /**
  45799. * Adds the given geometry to this scene
  45800. * @param newGeometry The geometry to add
  45801. */
  45802. addGeometry(newGeometry: Geometry): void;
  45803. /**
  45804. * Adds the given action manager to this scene
  45805. * @param newActionManager The action manager to add
  45806. */
  45807. addActionManager(newActionManager: AbstractActionManager): void;
  45808. /**
  45809. * Adds the given texture to this scene.
  45810. * @param newTexture The texture to add
  45811. */
  45812. addTexture(newTexture: BaseTexture): void;
  45813. /**
  45814. * Switch active camera
  45815. * @param newCamera defines the new active camera
  45816. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45817. */
  45818. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45819. /**
  45820. * sets the active camera of the scene using its ID
  45821. * @param id defines the camera's ID
  45822. * @return the new active camera or null if none found.
  45823. */
  45824. setActiveCameraByID(id: string): Nullable<Camera>;
  45825. /**
  45826. * sets the active camera of the scene using its name
  45827. * @param name defines the camera's name
  45828. * @returns the new active camera or null if none found.
  45829. */
  45830. setActiveCameraByName(name: string): Nullable<Camera>;
  45831. /**
  45832. * get an animation group using its name
  45833. * @param name defines the material's name
  45834. * @return the animation group or null if none found.
  45835. */
  45836. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45837. /**
  45838. * Get a material using its unique id
  45839. * @param uniqueId defines the material's unique id
  45840. * @return the material or null if none found.
  45841. */
  45842. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45843. /**
  45844. * get a material using its id
  45845. * @param id defines the material's ID
  45846. * @return the material or null if none found.
  45847. */
  45848. getMaterialByID(id: string): Nullable<Material>;
  45849. /**
  45850. * Gets a the last added material using a given id
  45851. * @param id defines the material's ID
  45852. * @return the last material with the given id or null if none found.
  45853. */
  45854. getLastMaterialByID(id: string): Nullable<Material>;
  45855. /**
  45856. * Gets a material using its name
  45857. * @param name defines the material's name
  45858. * @return the material or null if none found.
  45859. */
  45860. getMaterialByName(name: string): Nullable<Material>;
  45861. /**
  45862. * Get a texture using its unique id
  45863. * @param uniqueId defines the texture's unique id
  45864. * @return the texture or null if none found.
  45865. */
  45866. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45867. /**
  45868. * Gets a camera using its id
  45869. * @param id defines the id to look for
  45870. * @returns the camera or null if not found
  45871. */
  45872. getCameraByID(id: string): Nullable<Camera>;
  45873. /**
  45874. * Gets a camera using its unique id
  45875. * @param uniqueId defines the unique id to look for
  45876. * @returns the camera or null if not found
  45877. */
  45878. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45879. /**
  45880. * Gets a camera using its name
  45881. * @param name defines the camera's name
  45882. * @return the camera or null if none found.
  45883. */
  45884. getCameraByName(name: string): Nullable<Camera>;
  45885. /**
  45886. * Gets a bone using its id
  45887. * @param id defines the bone's id
  45888. * @return the bone or null if not found
  45889. */
  45890. getBoneByID(id: string): Nullable<Bone>;
  45891. /**
  45892. * Gets a bone using its id
  45893. * @param name defines the bone's name
  45894. * @return the bone or null if not found
  45895. */
  45896. getBoneByName(name: string): Nullable<Bone>;
  45897. /**
  45898. * Gets a light node using its name
  45899. * @param name defines the the light's name
  45900. * @return the light or null if none found.
  45901. */
  45902. getLightByName(name: string): Nullable<Light>;
  45903. /**
  45904. * Gets a light node using its id
  45905. * @param id defines the light's id
  45906. * @return the light or null if none found.
  45907. */
  45908. getLightByID(id: string): Nullable<Light>;
  45909. /**
  45910. * Gets a light node using its scene-generated unique ID
  45911. * @param uniqueId defines the light's unique id
  45912. * @return the light or null if none found.
  45913. */
  45914. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45915. /**
  45916. * Gets a particle system by id
  45917. * @param id defines the particle system id
  45918. * @return the corresponding system or null if none found
  45919. */
  45920. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45921. /**
  45922. * Gets a geometry using its ID
  45923. * @param id defines the geometry's id
  45924. * @return the geometry or null if none found.
  45925. */
  45926. getGeometryByID(id: string): Nullable<Geometry>;
  45927. private _getGeometryByUniqueID;
  45928. /**
  45929. * Add a new geometry to this scene
  45930. * @param geometry defines the geometry to be added to the scene.
  45931. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45932. * @return a boolean defining if the geometry was added or not
  45933. */
  45934. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45935. /**
  45936. * Removes an existing geometry
  45937. * @param geometry defines the geometry to be removed from the scene
  45938. * @return a boolean defining if the geometry was removed or not
  45939. */
  45940. removeGeometry(geometry: Geometry): boolean;
  45941. /**
  45942. * Gets the list of geometries attached to the scene
  45943. * @returns an array of Geometry
  45944. */
  45945. getGeometries(): Geometry[];
  45946. /**
  45947. * Gets the first added mesh found of a given ID
  45948. * @param id defines the id to search for
  45949. * @return the mesh found or null if not found at all
  45950. */
  45951. getMeshByID(id: string): Nullable<AbstractMesh>;
  45952. /**
  45953. * Gets a list of meshes using their id
  45954. * @param id defines the id to search for
  45955. * @returns a list of meshes
  45956. */
  45957. getMeshesByID(id: string): Array<AbstractMesh>;
  45958. /**
  45959. * Gets the first added transform node found of a given ID
  45960. * @param id defines the id to search for
  45961. * @return the found transform node or null if not found at all.
  45962. */
  45963. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45964. /**
  45965. * Gets a transform node with its auto-generated unique id
  45966. * @param uniqueId efines the unique id to search for
  45967. * @return the found transform node or null if not found at all.
  45968. */
  45969. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45970. /**
  45971. * Gets a list of transform nodes using their id
  45972. * @param id defines the id to search for
  45973. * @returns a list of transform nodes
  45974. */
  45975. getTransformNodesByID(id: string): Array<TransformNode>;
  45976. /**
  45977. * Gets a mesh with its auto-generated unique id
  45978. * @param uniqueId defines the unique id to search for
  45979. * @return the found mesh or null if not found at all.
  45980. */
  45981. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45982. /**
  45983. * Gets a the last added mesh using a given id
  45984. * @param id defines the id to search for
  45985. * @return the found mesh or null if not found at all.
  45986. */
  45987. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45988. /**
  45989. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45990. * @param id defines the id to search for
  45991. * @return the found node or null if not found at all
  45992. */
  45993. getLastEntryByID(id: string): Nullable<Node>;
  45994. /**
  45995. * Gets a node (Mesh, Camera, Light) using a given id
  45996. * @param id defines the id to search for
  45997. * @return the found node or null if not found at all
  45998. */
  45999. getNodeByID(id: string): Nullable<Node>;
  46000. /**
  46001. * Gets a node (Mesh, Camera, Light) using a given name
  46002. * @param name defines the name to search for
  46003. * @return the found node or null if not found at all.
  46004. */
  46005. getNodeByName(name: string): Nullable<Node>;
  46006. /**
  46007. * Gets a mesh using a given name
  46008. * @param name defines the name to search for
  46009. * @return the found mesh or null if not found at all.
  46010. */
  46011. getMeshByName(name: string): Nullable<AbstractMesh>;
  46012. /**
  46013. * Gets a transform node using a given name
  46014. * @param name defines the name to search for
  46015. * @return the found transform node or null if not found at all.
  46016. */
  46017. getTransformNodeByName(name: string): Nullable<TransformNode>;
  46018. /**
  46019. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  46020. * @param id defines the id to search for
  46021. * @return the found skeleton or null if not found at all.
  46022. */
  46023. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  46024. /**
  46025. * Gets a skeleton using a given auto generated unique id
  46026. * @param uniqueId defines the unique id to search for
  46027. * @return the found skeleton or null if not found at all.
  46028. */
  46029. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  46030. /**
  46031. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  46032. * @param id defines the id to search for
  46033. * @return the found skeleton or null if not found at all.
  46034. */
  46035. getSkeletonById(id: string): Nullable<Skeleton>;
  46036. /**
  46037. * Gets a skeleton using a given name
  46038. * @param name defines the name to search for
  46039. * @return the found skeleton or null if not found at all.
  46040. */
  46041. getSkeletonByName(name: string): Nullable<Skeleton>;
  46042. /**
  46043. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  46044. * @param id defines the id to search for
  46045. * @return the found morph target manager or null if not found at all.
  46046. */
  46047. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  46048. /**
  46049. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  46050. * @param id defines the id to search for
  46051. * @return the found morph target or null if not found at all.
  46052. */
  46053. getMorphTargetById(id: string): Nullable<MorphTarget>;
  46054. /**
  46055. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  46056. * @param name defines the name to search for
  46057. * @return the found morph target or null if not found at all.
  46058. */
  46059. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  46060. /**
  46061. * Gets a post process using a given name (if many are found, this function will pick the first one)
  46062. * @param name defines the name to search for
  46063. * @return the found post process or null if not found at all.
  46064. */
  46065. getPostProcessByName(name: string): Nullable<PostProcess>;
  46066. /**
  46067. * Gets a boolean indicating if the given mesh is active
  46068. * @param mesh defines the mesh to look for
  46069. * @returns true if the mesh is in the active list
  46070. */
  46071. isActiveMesh(mesh: AbstractMesh): boolean;
  46072. /**
  46073. * Return a unique id as a string which can serve as an identifier for the scene
  46074. */
  46075. get uid(): string;
  46076. /**
  46077. * Add an externaly attached data from its key.
  46078. * This method call will fail and return false, if such key already exists.
  46079. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  46080. * @param key the unique key that identifies the data
  46081. * @param data the data object to associate to the key for this Engine instance
  46082. * @return true if no such key were already present and the data was added successfully, false otherwise
  46083. */
  46084. addExternalData<T>(key: string, data: T): boolean;
  46085. /**
  46086. * Get an externaly attached data from its key
  46087. * @param key the unique key that identifies the data
  46088. * @return the associated data, if present (can be null), or undefined if not present
  46089. */
  46090. getExternalData<T>(key: string): Nullable<T>;
  46091. /**
  46092. * Get an externaly attached data from its key, create it using a factory if it's not already present
  46093. * @param key the unique key that identifies the data
  46094. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  46095. * @return the associated data, can be null if the factory returned null.
  46096. */
  46097. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  46098. /**
  46099. * Remove an externaly attached data from the Engine instance
  46100. * @param key the unique key that identifies the data
  46101. * @return true if the data was successfully removed, false if it doesn't exist
  46102. */
  46103. removeExternalData(key: string): boolean;
  46104. private _evaluateSubMesh;
  46105. /**
  46106. * Clear the processed materials smart array preventing retention point in material dispose.
  46107. */
  46108. freeProcessedMaterials(): void;
  46109. private _preventFreeActiveMeshesAndRenderingGroups;
  46110. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  46111. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  46112. * when disposing several meshes in a row or a hierarchy of meshes.
  46113. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  46114. */
  46115. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  46116. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  46117. /**
  46118. * Clear the active meshes smart array preventing retention point in mesh dispose.
  46119. */
  46120. freeActiveMeshes(): void;
  46121. /**
  46122. * Clear the info related to rendering groups preventing retention points during dispose.
  46123. */
  46124. freeRenderingGroups(): void;
  46125. /** @hidden */
  46126. _isInIntermediateRendering(): boolean;
  46127. /**
  46128. * Lambda returning the list of potentially active meshes.
  46129. */
  46130. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  46131. /**
  46132. * Lambda returning the list of potentially active sub meshes.
  46133. */
  46134. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  46135. /**
  46136. * Lambda returning the list of potentially intersecting sub meshes.
  46137. */
  46138. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  46139. /**
  46140. * Lambda returning the list of potentially colliding sub meshes.
  46141. */
  46142. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  46143. /** @hidden */
  46144. _activeMeshesFrozen: boolean;
  46145. private _skipEvaluateActiveMeshesCompletely;
  46146. /**
  46147. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  46148. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  46149. * @param onSuccess optional success callback
  46150. * @param onError optional error callback
  46151. * @returns the current scene
  46152. */
  46153. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  46154. /**
  46155. * Use this function to restart evaluating active meshes on every frame
  46156. * @returns the current scene
  46157. */
  46158. unfreezeActiveMeshes(): Scene;
  46159. private _evaluateActiveMeshes;
  46160. private _activeMesh;
  46161. /**
  46162. * Update the transform matrix to update from the current active camera
  46163. * @param force defines a boolean used to force the update even if cache is up to date
  46164. */
  46165. updateTransformMatrix(force?: boolean): void;
  46166. private _bindFrameBuffer;
  46167. /** @hidden */
  46168. _allowPostProcessClearColor: boolean;
  46169. /** @hidden */
  46170. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  46171. private _processSubCameras;
  46172. private _checkIntersections;
  46173. /** @hidden */
  46174. _advancePhysicsEngineStep(step: number): void;
  46175. /**
  46176. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  46177. */
  46178. getDeterministicFrameTime: () => number;
  46179. /** @hidden */
  46180. _animate(): void;
  46181. /** Execute all animations (for a frame) */
  46182. animate(): void;
  46183. /**
  46184. * Render the scene
  46185. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  46186. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  46187. */
  46188. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  46189. /**
  46190. * Freeze all materials
  46191. * A frozen material will not be updatable but should be faster to render
  46192. */
  46193. freezeMaterials(): void;
  46194. /**
  46195. * Unfreeze all materials
  46196. * A frozen material will not be updatable but should be faster to render
  46197. */
  46198. unfreezeMaterials(): void;
  46199. /**
  46200. * Releases all held ressources
  46201. */
  46202. dispose(): void;
  46203. /**
  46204. * Gets if the scene is already disposed
  46205. */
  46206. get isDisposed(): boolean;
  46207. /**
  46208. * Call this function to reduce memory footprint of the scene.
  46209. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  46210. */
  46211. clearCachedVertexData(): void;
  46212. /**
  46213. * This function will remove the local cached buffer data from texture.
  46214. * It will save memory but will prevent the texture from being rebuilt
  46215. */
  46216. cleanCachedTextureBuffer(): void;
  46217. /**
  46218. * Get the world extend vectors with an optional filter
  46219. *
  46220. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  46221. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  46222. */
  46223. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  46224. min: Vector3;
  46225. max: Vector3;
  46226. };
  46227. /**
  46228. * Creates a ray that can be used to pick in the scene
  46229. * @param x defines the x coordinate of the origin (on-screen)
  46230. * @param y defines the y coordinate of the origin (on-screen)
  46231. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46232. * @param camera defines the camera to use for the picking
  46233. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46234. * @returns a Ray
  46235. */
  46236. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  46237. /**
  46238. * Creates a ray that can be used to pick in the scene
  46239. * @param x defines the x coordinate of the origin (on-screen)
  46240. * @param y defines the y coordinate of the origin (on-screen)
  46241. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46242. * @param result defines the ray where to store the picking ray
  46243. * @param camera defines the camera to use for the picking
  46244. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46245. * @returns the current scene
  46246. */
  46247. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  46248. /**
  46249. * Creates a ray that can be used to pick in the scene
  46250. * @param x defines the x coordinate of the origin (on-screen)
  46251. * @param y defines the y coordinate of the origin (on-screen)
  46252. * @param camera defines the camera to use for the picking
  46253. * @returns a Ray
  46254. */
  46255. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  46256. /**
  46257. * Creates a ray that can be used to pick in the scene
  46258. * @param x defines the x coordinate of the origin (on-screen)
  46259. * @param y defines the y coordinate of the origin (on-screen)
  46260. * @param result defines the ray where to store the picking ray
  46261. * @param camera defines the camera to use for the picking
  46262. * @returns the current scene
  46263. */
  46264. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  46265. /** Launch a ray to try to pick a mesh in the scene
  46266. * @param x position on screen
  46267. * @param y position on screen
  46268. * @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
  46269. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46270. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46271. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46272. * @returns a PickingInfo
  46273. */
  46274. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46275. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  46276. * @param x position on screen
  46277. * @param y position on screen
  46278. * @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
  46279. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46280. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46281. * @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)
  46282. */
  46283. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  46284. /** Use the given ray to pick a mesh in the scene
  46285. * @param ray The ray to use to pick meshes
  46286. * @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
  46287. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46288. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46289. * @returns a PickingInfo
  46290. */
  46291. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46292. /**
  46293. * Launch a ray to try to pick a mesh in the scene
  46294. * @param x X position on screen
  46295. * @param y Y position on screen
  46296. * @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
  46297. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46298. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46299. * @returns an array of PickingInfo
  46300. */
  46301. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46302. /**
  46303. * Launch a ray to try to pick a mesh in the scene
  46304. * @param ray Ray to use
  46305. * @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
  46306. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46307. * @returns an array of PickingInfo
  46308. */
  46309. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46310. /**
  46311. * Force the value of meshUnderPointer
  46312. * @param mesh defines the mesh to use
  46313. * @param pointerId optional pointer id when using more than one pointer
  46314. */
  46315. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  46316. /**
  46317. * Gets the mesh under the pointer
  46318. * @returns a Mesh or null if no mesh is under the pointer
  46319. */
  46320. getPointerOverMesh(): Nullable<AbstractMesh>;
  46321. /** @hidden */
  46322. _rebuildGeometries(): void;
  46323. /** @hidden */
  46324. _rebuildTextures(): void;
  46325. private _getByTags;
  46326. /**
  46327. * Get a list of meshes by tags
  46328. * @param tagsQuery defines the tags query to use
  46329. * @param forEach defines a predicate used to filter results
  46330. * @returns an array of Mesh
  46331. */
  46332. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  46333. /**
  46334. * Get a list of cameras by tags
  46335. * @param tagsQuery defines the tags query to use
  46336. * @param forEach defines a predicate used to filter results
  46337. * @returns an array of Camera
  46338. */
  46339. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  46340. /**
  46341. * Get a list of lights by tags
  46342. * @param tagsQuery defines the tags query to use
  46343. * @param forEach defines a predicate used to filter results
  46344. * @returns an array of Light
  46345. */
  46346. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  46347. /**
  46348. * Get a list of materials by tags
  46349. * @param tagsQuery defines the tags query to use
  46350. * @param forEach defines a predicate used to filter results
  46351. * @returns an array of Material
  46352. */
  46353. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  46354. /**
  46355. * Get a list of transform nodes by tags
  46356. * @param tagsQuery defines the tags query to use
  46357. * @param forEach defines a predicate used to filter results
  46358. * @returns an array of TransformNode
  46359. */
  46360. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  46361. /**
  46362. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46363. * This allowed control for front to back rendering or reversly depending of the special needs.
  46364. *
  46365. * @param renderingGroupId The rendering group id corresponding to its index
  46366. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46367. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46368. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46369. */
  46370. 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;
  46371. /**
  46372. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46373. *
  46374. * @param renderingGroupId The rendering group id corresponding to its index
  46375. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46376. * @param depth Automatically clears depth between groups if true and autoClear is true.
  46377. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  46378. */
  46379. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  46380. /**
  46381. * Gets the current auto clear configuration for one rendering group of the rendering
  46382. * manager.
  46383. * @param index the rendering group index to get the information for
  46384. * @returns The auto clear setup for the requested rendering group
  46385. */
  46386. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  46387. private _blockMaterialDirtyMechanism;
  46388. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  46389. get blockMaterialDirtyMechanism(): boolean;
  46390. set blockMaterialDirtyMechanism(value: boolean);
  46391. /**
  46392. * Will flag all materials as dirty to trigger new shader compilation
  46393. * @param flag defines the flag used to specify which material part must be marked as dirty
  46394. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  46395. */
  46396. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  46397. /** @hidden */
  46398. _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;
  46399. /** @hidden */
  46400. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46401. /** @hidden */
  46402. _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;
  46403. /** @hidden */
  46404. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  46405. /** @hidden */
  46406. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  46407. /** @hidden */
  46408. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46409. }
  46410. }
  46411. declare module "babylonjs/assetContainer" {
  46412. import { AbstractScene } from "babylonjs/abstractScene";
  46413. import { Scene } from "babylonjs/scene";
  46414. import { Mesh } from "babylonjs/Meshes/mesh";
  46415. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46416. import { Skeleton } from "babylonjs/Bones/skeleton";
  46417. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46418. import { Animatable } from "babylonjs/Animations/animatable";
  46419. import { Nullable } from "babylonjs/types";
  46420. import { Node } from "babylonjs/node";
  46421. /**
  46422. * Set of assets to keep when moving a scene into an asset container.
  46423. */
  46424. export class KeepAssets extends AbstractScene {
  46425. }
  46426. /**
  46427. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  46428. */
  46429. export class InstantiatedEntries {
  46430. /**
  46431. * List of new root nodes (eg. nodes with no parent)
  46432. */
  46433. rootNodes: TransformNode[];
  46434. /**
  46435. * List of new skeletons
  46436. */
  46437. skeletons: Skeleton[];
  46438. /**
  46439. * List of new animation groups
  46440. */
  46441. animationGroups: AnimationGroup[];
  46442. }
  46443. /**
  46444. * Container with a set of assets that can be added or removed from a scene.
  46445. */
  46446. export class AssetContainer extends AbstractScene {
  46447. private _wasAddedToScene;
  46448. /**
  46449. * The scene the AssetContainer belongs to.
  46450. */
  46451. scene: Scene;
  46452. /**
  46453. * Instantiates an AssetContainer.
  46454. * @param scene The scene the AssetContainer belongs to.
  46455. */
  46456. constructor(scene: Scene);
  46457. /**
  46458. * Instantiate or clone all meshes and add the new ones to the scene.
  46459. * Skeletons and animation groups will all be cloned
  46460. * @param nameFunction defines an optional function used to get new names for clones
  46461. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  46462. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  46463. */
  46464. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  46465. /**
  46466. * Adds all the assets from the container to the scene.
  46467. */
  46468. addAllToScene(): void;
  46469. /**
  46470. * Removes all the assets in the container from the scene
  46471. */
  46472. removeAllFromScene(): void;
  46473. /**
  46474. * Disposes all the assets in the container
  46475. */
  46476. dispose(): void;
  46477. private _moveAssets;
  46478. /**
  46479. * Removes all the assets contained in the scene and adds them to the container.
  46480. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  46481. */
  46482. moveAllFromScene(keepAssets?: KeepAssets): void;
  46483. /**
  46484. * 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.
  46485. * @returns the root mesh
  46486. */
  46487. createRootMesh(): Mesh;
  46488. /**
  46489. * Merge animations (direct and animation groups) from this asset container into a scene
  46490. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46491. * @param animatables set of animatables to retarget to a node from the scene
  46492. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  46493. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  46494. */
  46495. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  46496. }
  46497. }
  46498. declare module "babylonjs/abstractScene" {
  46499. import { Scene } from "babylonjs/scene";
  46500. import { Nullable } from "babylonjs/types";
  46501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46502. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46503. import { Geometry } from "babylonjs/Meshes/geometry";
  46504. import { Skeleton } from "babylonjs/Bones/skeleton";
  46505. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  46506. import { AssetContainer } from "babylonjs/assetContainer";
  46507. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  46508. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46509. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46510. import { Material } from "babylonjs/Materials/material";
  46511. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  46512. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  46513. import { Camera } from "babylonjs/Cameras/camera";
  46514. import { Light } from "babylonjs/Lights/light";
  46515. import { Node } from "babylonjs/node";
  46516. import { Animation } from "babylonjs/Animations/animation";
  46517. /**
  46518. * Defines how the parser contract is defined.
  46519. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  46520. */
  46521. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  46522. /**
  46523. * Defines how the individual parser contract is defined.
  46524. * These parser can parse an individual asset
  46525. */
  46526. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46527. /**
  46528. * Base class of the scene acting as a container for the different elements composing a scene.
  46529. * This class is dynamically extended by the different components of the scene increasing
  46530. * flexibility and reducing coupling
  46531. */
  46532. export abstract class AbstractScene {
  46533. /**
  46534. * Stores the list of available parsers in the application.
  46535. */
  46536. private static _BabylonFileParsers;
  46537. /**
  46538. * Stores the list of available individual parsers in the application.
  46539. */
  46540. private static _IndividualBabylonFileParsers;
  46541. /**
  46542. * Adds a parser in the list of available ones
  46543. * @param name Defines the name of the parser
  46544. * @param parser Defines the parser to add
  46545. */
  46546. static AddParser(name: string, parser: BabylonFileParser): void;
  46547. /**
  46548. * Gets a general parser from the list of avaialble ones
  46549. * @param name Defines the name of the parser
  46550. * @returns the requested parser or null
  46551. */
  46552. static GetParser(name: string): Nullable<BabylonFileParser>;
  46553. /**
  46554. * Adds n individual parser in the list of available ones
  46555. * @param name Defines the name of the parser
  46556. * @param parser Defines the parser to add
  46557. */
  46558. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46559. /**
  46560. * Gets an individual parser from the list of avaialble ones
  46561. * @param name Defines the name of the parser
  46562. * @returns the requested parser or null
  46563. */
  46564. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46565. /**
  46566. * Parser json data and populate both a scene and its associated container object
  46567. * @param jsonData Defines the data to parse
  46568. * @param scene Defines the scene to parse the data for
  46569. * @param container Defines the container attached to the parsing sequence
  46570. * @param rootUrl Defines the root url of the data
  46571. */
  46572. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46573. /**
  46574. * Gets the list of root nodes (ie. nodes with no parent)
  46575. */
  46576. rootNodes: Node[];
  46577. /** All of the cameras added to this scene
  46578. * @see https://doc.babylonjs.com/babylon101/cameras
  46579. */
  46580. cameras: Camera[];
  46581. /**
  46582. * All of the lights added to this scene
  46583. * @see https://doc.babylonjs.com/babylon101/lights
  46584. */
  46585. lights: Light[];
  46586. /**
  46587. * All of the (abstract) meshes added to this scene
  46588. */
  46589. meshes: AbstractMesh[];
  46590. /**
  46591. * The list of skeletons added to the scene
  46592. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46593. */
  46594. skeletons: Skeleton[];
  46595. /**
  46596. * All of the particle systems added to this scene
  46597. * @see https://doc.babylonjs.com/babylon101/particles
  46598. */
  46599. particleSystems: IParticleSystem[];
  46600. /**
  46601. * Gets a list of Animations associated with the scene
  46602. */
  46603. animations: Animation[];
  46604. /**
  46605. * All of the animation groups added to this scene
  46606. * @see https://doc.babylonjs.com/how_to/group
  46607. */
  46608. animationGroups: AnimationGroup[];
  46609. /**
  46610. * All of the multi-materials added to this scene
  46611. * @see https://doc.babylonjs.com/how_to/multi_materials
  46612. */
  46613. multiMaterials: MultiMaterial[];
  46614. /**
  46615. * All of the materials added to this scene
  46616. * In the context of a Scene, it is not supposed to be modified manually.
  46617. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46618. * Note also that the order of the Material within the array is not significant and might change.
  46619. * @see https://doc.babylonjs.com/babylon101/materials
  46620. */
  46621. materials: Material[];
  46622. /**
  46623. * The list of morph target managers added to the scene
  46624. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46625. */
  46626. morphTargetManagers: MorphTargetManager[];
  46627. /**
  46628. * The list of geometries used in the scene.
  46629. */
  46630. geometries: Geometry[];
  46631. /**
  46632. * All of the tranform nodes added to this scene
  46633. * In the context of a Scene, it is not supposed to be modified manually.
  46634. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46635. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46636. * @see https://doc.babylonjs.com/how_to/transformnode
  46637. */
  46638. transformNodes: TransformNode[];
  46639. /**
  46640. * ActionManagers available on the scene.
  46641. */
  46642. actionManagers: AbstractActionManager[];
  46643. /**
  46644. * Textures to keep.
  46645. */
  46646. textures: BaseTexture[];
  46647. /** @hidden */
  46648. protected _environmentTexture: Nullable<BaseTexture>;
  46649. /**
  46650. * Texture used in all pbr material as the reflection texture.
  46651. * As in the majority of the scene they are the same (exception for multi room and so on),
  46652. * this is easier to reference from here than from all the materials.
  46653. */
  46654. get environmentTexture(): Nullable<BaseTexture>;
  46655. set environmentTexture(value: Nullable<BaseTexture>);
  46656. /**
  46657. * The list of postprocesses added to the scene
  46658. */
  46659. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46660. /**
  46661. * @returns all meshes, lights, cameras, transformNodes and bones
  46662. */
  46663. getNodes(): Array<Node>;
  46664. }
  46665. }
  46666. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  46667. /**
  46668. * Interface used to define options for Sound class
  46669. */
  46670. export interface ISoundOptions {
  46671. /**
  46672. * Does the sound autoplay once loaded.
  46673. */
  46674. autoplay?: boolean;
  46675. /**
  46676. * Does the sound loop after it finishes playing once.
  46677. */
  46678. loop?: boolean;
  46679. /**
  46680. * Sound's volume
  46681. */
  46682. volume?: number;
  46683. /**
  46684. * Is it a spatial sound?
  46685. */
  46686. spatialSound?: boolean;
  46687. /**
  46688. * Maximum distance to hear that sound
  46689. */
  46690. maxDistance?: number;
  46691. /**
  46692. * Uses user defined attenuation function
  46693. */
  46694. useCustomAttenuation?: boolean;
  46695. /**
  46696. * Define the roll off factor of spatial sounds.
  46697. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46698. */
  46699. rolloffFactor?: number;
  46700. /**
  46701. * Define the reference distance the sound should be heard perfectly.
  46702. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46703. */
  46704. refDistance?: number;
  46705. /**
  46706. * Define the distance attenuation model the sound will follow.
  46707. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46708. */
  46709. distanceModel?: string;
  46710. /**
  46711. * Defines the playback speed (1 by default)
  46712. */
  46713. playbackRate?: number;
  46714. /**
  46715. * Defines if the sound is from a streaming source
  46716. */
  46717. streaming?: boolean;
  46718. /**
  46719. * Defines an optional length (in seconds) inside the sound file
  46720. */
  46721. length?: number;
  46722. /**
  46723. * Defines an optional offset (in seconds) inside the sound file
  46724. */
  46725. offset?: number;
  46726. /**
  46727. * If true, URLs will not be required to state the audio file codec to use.
  46728. */
  46729. skipCodecCheck?: boolean;
  46730. }
  46731. }
  46732. declare module "babylonjs/Audio/sound" {
  46733. import { Observable } from "babylonjs/Misc/observable";
  46734. import { Vector3 } from "babylonjs/Maths/math.vector";
  46735. import { Nullable } from "babylonjs/types";
  46736. import { Scene } from "babylonjs/scene";
  46737. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46738. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  46739. /**
  46740. * Defines a sound that can be played in the application.
  46741. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46742. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46743. */
  46744. export class Sound {
  46745. /**
  46746. * The name of the sound in the scene.
  46747. */
  46748. name: string;
  46749. /**
  46750. * Does the sound autoplay once loaded.
  46751. */
  46752. autoplay: boolean;
  46753. /**
  46754. * Does the sound loop after it finishes playing once.
  46755. */
  46756. loop: boolean;
  46757. /**
  46758. * Does the sound use a custom attenuation curve to simulate the falloff
  46759. * happening when the source gets further away from the camera.
  46760. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46761. */
  46762. useCustomAttenuation: boolean;
  46763. /**
  46764. * The sound track id this sound belongs to.
  46765. */
  46766. soundTrackId: number;
  46767. /**
  46768. * Is this sound currently played.
  46769. */
  46770. isPlaying: boolean;
  46771. /**
  46772. * Is this sound currently paused.
  46773. */
  46774. isPaused: boolean;
  46775. /**
  46776. * Does this sound enables spatial sound.
  46777. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46778. */
  46779. spatialSound: boolean;
  46780. /**
  46781. * Define the reference distance the sound should be heard perfectly.
  46782. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46783. */
  46784. refDistance: number;
  46785. /**
  46786. * Define the roll off factor of spatial sounds.
  46787. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46788. */
  46789. rolloffFactor: number;
  46790. /**
  46791. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46792. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46793. */
  46794. maxDistance: number;
  46795. /**
  46796. * Define the distance attenuation model the sound will follow.
  46797. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46798. */
  46799. distanceModel: string;
  46800. /**
  46801. * @hidden
  46802. * Back Compat
  46803. **/
  46804. onended: () => any;
  46805. /**
  46806. * Gets or sets an object used to store user defined information for the sound.
  46807. */
  46808. metadata: any;
  46809. /**
  46810. * Observable event when the current playing sound finishes.
  46811. */
  46812. onEndedObservable: Observable<Sound>;
  46813. /**
  46814. * Gets the current time for the sound.
  46815. */
  46816. get currentTime(): number;
  46817. private _panningModel;
  46818. private _playbackRate;
  46819. private _streaming;
  46820. private _startTime;
  46821. private _startOffset;
  46822. private _position;
  46823. /** @hidden */
  46824. _positionInEmitterSpace: boolean;
  46825. private _localDirection;
  46826. private _volume;
  46827. private _isReadyToPlay;
  46828. private _isDirectional;
  46829. private _readyToPlayCallback;
  46830. private _audioBuffer;
  46831. private _soundSource;
  46832. private _streamingSource;
  46833. private _soundPanner;
  46834. private _soundGain;
  46835. private _inputAudioNode;
  46836. private _outputAudioNode;
  46837. private _coneInnerAngle;
  46838. private _coneOuterAngle;
  46839. private _coneOuterGain;
  46840. private _scene;
  46841. private _connectedTransformNode;
  46842. private _customAttenuationFunction;
  46843. private _registerFunc;
  46844. private _isOutputConnected;
  46845. private _htmlAudioElement;
  46846. private _urlType;
  46847. private _length?;
  46848. private _offset?;
  46849. /** @hidden */
  46850. static _SceneComponentInitialization: (scene: Scene) => void;
  46851. /**
  46852. * Create a sound and attach it to a scene
  46853. * @param name Name of your sound
  46854. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46855. * @param scene defines the scene the sound belongs to
  46856. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46857. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46858. */
  46859. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46860. /**
  46861. * Release the sound and its associated resources
  46862. */
  46863. dispose(): void;
  46864. /**
  46865. * Gets if the sounds is ready to be played or not.
  46866. * @returns true if ready, otherwise false
  46867. */
  46868. isReady(): boolean;
  46869. private _soundLoaded;
  46870. /**
  46871. * Sets the data of the sound from an audiobuffer
  46872. * @param audioBuffer The audioBuffer containing the data
  46873. */
  46874. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46875. /**
  46876. * Updates the current sounds options such as maxdistance, loop...
  46877. * @param options A JSON object containing values named as the object properties
  46878. */
  46879. updateOptions(options: ISoundOptions): void;
  46880. private _createSpatialParameters;
  46881. private _updateSpatialParameters;
  46882. /**
  46883. * Switch the panning model to HRTF:
  46884. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46885. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46886. */
  46887. switchPanningModelToHRTF(): void;
  46888. /**
  46889. * Switch the panning model to Equal Power:
  46890. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46891. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46892. */
  46893. switchPanningModelToEqualPower(): void;
  46894. private _switchPanningModel;
  46895. /**
  46896. * Connect this sound to a sound track audio node like gain...
  46897. * @param soundTrackAudioNode the sound track audio node to connect to
  46898. */
  46899. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46900. /**
  46901. * Transform this sound into a directional source
  46902. * @param coneInnerAngle Size of the inner cone in degree
  46903. * @param coneOuterAngle Size of the outer cone in degree
  46904. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46905. */
  46906. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46907. /**
  46908. * Gets or sets the inner angle for the directional cone.
  46909. */
  46910. get directionalConeInnerAngle(): number;
  46911. /**
  46912. * Gets or sets the inner angle for the directional cone.
  46913. */
  46914. set directionalConeInnerAngle(value: number);
  46915. /**
  46916. * Gets or sets the outer angle for the directional cone.
  46917. */
  46918. get directionalConeOuterAngle(): number;
  46919. /**
  46920. * Gets or sets the outer angle for the directional cone.
  46921. */
  46922. set directionalConeOuterAngle(value: number);
  46923. /**
  46924. * Sets the position of the emitter if spatial sound is enabled
  46925. * @param newPosition Defines the new posisiton
  46926. */
  46927. setPosition(newPosition: Vector3): void;
  46928. /**
  46929. * Sets the local direction of the emitter if spatial sound is enabled
  46930. * @param newLocalDirection Defines the new local direction
  46931. */
  46932. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46933. private _updateDirection;
  46934. /** @hidden */
  46935. updateDistanceFromListener(): void;
  46936. /**
  46937. * Sets a new custom attenuation function for the sound.
  46938. * @param callback Defines the function used for the attenuation
  46939. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46940. */
  46941. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46942. /**
  46943. * Play the sound
  46944. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46945. * @param offset (optional) Start the sound at a specific time in seconds
  46946. * @param length (optional) Sound duration (in seconds)
  46947. */
  46948. play(time?: number, offset?: number, length?: number): void;
  46949. private _onended;
  46950. /**
  46951. * Stop the sound
  46952. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46953. */
  46954. stop(time?: number): void;
  46955. /**
  46956. * Put the sound in pause
  46957. */
  46958. pause(): void;
  46959. /**
  46960. * Sets a dedicated volume for this sounds
  46961. * @param newVolume Define the new volume of the sound
  46962. * @param time Define time for gradual change to new volume
  46963. */
  46964. setVolume(newVolume: number, time?: number): void;
  46965. /**
  46966. * Set the sound play back rate
  46967. * @param newPlaybackRate Define the playback rate the sound should be played at
  46968. */
  46969. setPlaybackRate(newPlaybackRate: number): void;
  46970. /**
  46971. * Gets the volume of the sound.
  46972. * @returns the volume of the sound
  46973. */
  46974. getVolume(): number;
  46975. /**
  46976. * Attach the sound to a dedicated mesh
  46977. * @param transformNode The transform node to connect the sound with
  46978. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46979. */
  46980. attachToMesh(transformNode: TransformNode): void;
  46981. /**
  46982. * Detach the sound from the previously attached mesh
  46983. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46984. */
  46985. detachFromMesh(): void;
  46986. private _onRegisterAfterWorldMatrixUpdate;
  46987. /**
  46988. * Clone the current sound in the scene.
  46989. * @returns the new sound clone
  46990. */
  46991. clone(): Nullable<Sound>;
  46992. /**
  46993. * Gets the current underlying audio buffer containing the data
  46994. * @returns the audio buffer
  46995. */
  46996. getAudioBuffer(): Nullable<AudioBuffer>;
  46997. /**
  46998. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46999. * @returns the source node
  47000. */
  47001. getSoundSource(): Nullable<AudioBufferSourceNode>;
  47002. /**
  47003. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  47004. * @returns the gain node
  47005. */
  47006. getSoundGain(): Nullable<GainNode>;
  47007. /**
  47008. * Serializes the Sound in a JSON representation
  47009. * @returns the JSON representation of the sound
  47010. */
  47011. serialize(): any;
  47012. /**
  47013. * Parse a JSON representation of a sound to innstantiate in a given scene
  47014. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  47015. * @param scene Define the scene the new parsed sound should be created in
  47016. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  47017. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  47018. * @returns the newly parsed sound
  47019. */
  47020. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  47021. }
  47022. }
  47023. declare module "babylonjs/Actions/directAudioActions" {
  47024. import { Action } from "babylonjs/Actions/action";
  47025. import { Condition } from "babylonjs/Actions/condition";
  47026. import { Sound } from "babylonjs/Audio/sound";
  47027. /**
  47028. * This defines an action helpful to play a defined sound on a triggered action.
  47029. */
  47030. export class PlaySoundAction extends Action {
  47031. private _sound;
  47032. /**
  47033. * Instantiate the action
  47034. * @param triggerOptions defines the trigger options
  47035. * @param sound defines the sound to play
  47036. * @param condition defines the trigger related conditions
  47037. */
  47038. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  47039. /** @hidden */
  47040. _prepare(): void;
  47041. /**
  47042. * Execute the action and play the sound.
  47043. */
  47044. execute(): void;
  47045. /**
  47046. * Serializes the actions and its related information.
  47047. * @param parent defines the object to serialize in
  47048. * @returns the serialized object
  47049. */
  47050. serialize(parent: any): any;
  47051. }
  47052. /**
  47053. * This defines an action helpful to stop a defined sound on a triggered action.
  47054. */
  47055. export class StopSoundAction extends Action {
  47056. private _sound;
  47057. /**
  47058. * Instantiate the action
  47059. * @param triggerOptions defines the trigger options
  47060. * @param sound defines the sound to stop
  47061. * @param condition defines the trigger related conditions
  47062. */
  47063. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  47064. /** @hidden */
  47065. _prepare(): void;
  47066. /**
  47067. * Execute the action and stop the sound.
  47068. */
  47069. execute(): void;
  47070. /**
  47071. * Serializes the actions and its related information.
  47072. * @param parent defines the object to serialize in
  47073. * @returns the serialized object
  47074. */
  47075. serialize(parent: any): any;
  47076. }
  47077. }
  47078. declare module "babylonjs/Actions/interpolateValueAction" {
  47079. import { Action } from "babylonjs/Actions/action";
  47080. import { Condition } from "babylonjs/Actions/condition";
  47081. import { Observable } from "babylonjs/Misc/observable";
  47082. /**
  47083. * This defines an action responsible to change the value of a property
  47084. * by interpolating between its current value and the newly set one once triggered.
  47085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47086. */
  47087. export class InterpolateValueAction extends Action {
  47088. /**
  47089. * Defines the path of the property where the value should be interpolated
  47090. */
  47091. propertyPath: string;
  47092. /**
  47093. * Defines the target value at the end of the interpolation.
  47094. */
  47095. value: any;
  47096. /**
  47097. * Defines the time it will take for the property to interpolate to the value.
  47098. */
  47099. duration: number;
  47100. /**
  47101. * Defines if the other scene animations should be stopped when the action has been triggered
  47102. */
  47103. stopOtherAnimations?: boolean;
  47104. /**
  47105. * Defines a callback raised once the interpolation animation has been done.
  47106. */
  47107. onInterpolationDone?: () => void;
  47108. /**
  47109. * Observable triggered once the interpolation animation has been done.
  47110. */
  47111. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  47112. private _target;
  47113. private _effectiveTarget;
  47114. private _property;
  47115. /**
  47116. * Instantiate the action
  47117. * @param triggerOptions defines the trigger options
  47118. * @param target defines the object containing the value to interpolate
  47119. * @param propertyPath defines the path to the property in the target object
  47120. * @param value defines the target value at the end of the interpolation
  47121. * @param duration deines the time it will take for the property to interpolate to the value.
  47122. * @param condition defines the trigger related conditions
  47123. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  47124. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  47125. */
  47126. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  47127. /** @hidden */
  47128. _prepare(): void;
  47129. /**
  47130. * Execute the action starts the value interpolation.
  47131. */
  47132. execute(): void;
  47133. /**
  47134. * Serializes the actions and its related information.
  47135. * @param parent defines the object to serialize in
  47136. * @returns the serialized object
  47137. */
  47138. serialize(parent: any): any;
  47139. }
  47140. }
  47141. declare module "babylonjs/Actions/index" {
  47142. export * from "babylonjs/Actions/abstractActionManager";
  47143. export * from "babylonjs/Actions/action";
  47144. export * from "babylonjs/Actions/actionEvent";
  47145. export * from "babylonjs/Actions/actionManager";
  47146. export * from "babylonjs/Actions/condition";
  47147. export * from "babylonjs/Actions/directActions";
  47148. export * from "babylonjs/Actions/directAudioActions";
  47149. export * from "babylonjs/Actions/interpolateValueAction";
  47150. }
  47151. declare module "babylonjs/Animations/index" {
  47152. export * from "babylonjs/Animations/animatable";
  47153. export * from "babylonjs/Animations/animation";
  47154. export * from "babylonjs/Animations/animationGroup";
  47155. export * from "babylonjs/Animations/animationPropertiesOverride";
  47156. export * from "babylonjs/Animations/easing";
  47157. export * from "babylonjs/Animations/runtimeAnimation";
  47158. export * from "babylonjs/Animations/animationEvent";
  47159. export * from "babylonjs/Animations/animationGroup";
  47160. export * from "babylonjs/Animations/animationKey";
  47161. export * from "babylonjs/Animations/animationRange";
  47162. export * from "babylonjs/Animations/animatable.interface";
  47163. }
  47164. declare module "babylonjs/Audio/audioEngine" {
  47165. import { Analyser } from "babylonjs/Audio/analyser";
  47166. import { Nullable } from "babylonjs/types";
  47167. import { Observable } from "babylonjs/Misc/observable";
  47168. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  47169. /**
  47170. * This represents the default audio engine used in babylon.
  47171. * It is responsible to play, synchronize and analyse sounds throughout the application.
  47172. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47173. */
  47174. export class AudioEngine implements IAudioEngine {
  47175. private _audioContext;
  47176. private _audioContextInitialized;
  47177. private _muteButton;
  47178. private _hostElement;
  47179. /**
  47180. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  47181. */
  47182. canUseWebAudio: boolean;
  47183. /**
  47184. * The master gain node defines the global audio volume of your audio engine.
  47185. */
  47186. masterGain: GainNode;
  47187. /**
  47188. * Defines if Babylon should emit a warning if WebAudio is not supported.
  47189. * @ignoreNaming
  47190. */
  47191. WarnedWebAudioUnsupported: boolean;
  47192. /**
  47193. * Gets whether or not mp3 are supported by your browser.
  47194. */
  47195. isMP3supported: boolean;
  47196. /**
  47197. * Gets whether or not ogg are supported by your browser.
  47198. */
  47199. isOGGsupported: boolean;
  47200. /**
  47201. * Gets whether audio has been unlocked on the device.
  47202. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  47203. * a user interaction has happened.
  47204. */
  47205. unlocked: boolean;
  47206. /**
  47207. * Defines if the audio engine relies on a custom unlocked button.
  47208. * In this case, the embedded button will not be displayed.
  47209. */
  47210. useCustomUnlockedButton: boolean;
  47211. /**
  47212. * Event raised when audio has been unlocked on the browser.
  47213. */
  47214. onAudioUnlockedObservable: Observable<IAudioEngine>;
  47215. /**
  47216. * Event raised when audio has been locked on the browser.
  47217. */
  47218. onAudioLockedObservable: Observable<IAudioEngine>;
  47219. /**
  47220. * Gets the current AudioContext if available.
  47221. */
  47222. get audioContext(): Nullable<AudioContext>;
  47223. private _connectedAnalyser;
  47224. /**
  47225. * Instantiates a new audio engine.
  47226. *
  47227. * There should be only one per page as some browsers restrict the number
  47228. * of audio contexts you can create.
  47229. * @param hostElement defines the host element where to display the mute icon if necessary
  47230. */
  47231. constructor(hostElement?: Nullable<HTMLElement>);
  47232. /**
  47233. * Flags the audio engine in Locked state.
  47234. * This happens due to new browser policies preventing audio to autoplay.
  47235. */
  47236. lock(): void;
  47237. /**
  47238. * Unlocks the audio engine once a user action has been done on the dom.
  47239. * This is helpful to resume play once browser policies have been satisfied.
  47240. */
  47241. unlock(): void;
  47242. private _resumeAudioContext;
  47243. private _initializeAudioContext;
  47244. private _tryToRun;
  47245. private _triggerRunningState;
  47246. private _triggerSuspendedState;
  47247. private _displayMuteButton;
  47248. private _moveButtonToTopLeft;
  47249. private _onResize;
  47250. private _hideMuteButton;
  47251. /**
  47252. * Destroy and release the resources associated with the audio ccontext.
  47253. */
  47254. dispose(): void;
  47255. /**
  47256. * Gets the global volume sets on the master gain.
  47257. * @returns the global volume if set or -1 otherwise
  47258. */
  47259. getGlobalVolume(): number;
  47260. /**
  47261. * Sets the global volume of your experience (sets on the master gain).
  47262. * @param newVolume Defines the new global volume of the application
  47263. */
  47264. setGlobalVolume(newVolume: number): void;
  47265. /**
  47266. * Connect the audio engine to an audio analyser allowing some amazing
  47267. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47268. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47269. * @param analyser The analyser to connect to the engine
  47270. */
  47271. connectToAnalyser(analyser: Analyser): void;
  47272. }
  47273. }
  47274. declare module "babylonjs/Audio/soundTrack" {
  47275. import { Sound } from "babylonjs/Audio/sound";
  47276. import { Analyser } from "babylonjs/Audio/analyser";
  47277. import { Scene } from "babylonjs/scene";
  47278. /**
  47279. * Options allowed during the creation of a sound track.
  47280. */
  47281. export interface ISoundTrackOptions {
  47282. /**
  47283. * The volume the sound track should take during creation
  47284. */
  47285. volume?: number;
  47286. /**
  47287. * Define if the sound track is the main sound track of the scene
  47288. */
  47289. mainTrack?: boolean;
  47290. }
  47291. /**
  47292. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  47293. * It will be also used in a future release to apply effects on a specific track.
  47294. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47295. */
  47296. export class SoundTrack {
  47297. /**
  47298. * The unique identifier of the sound track in the scene.
  47299. */
  47300. id: number;
  47301. /**
  47302. * The list of sounds included in the sound track.
  47303. */
  47304. soundCollection: Array<Sound>;
  47305. private _outputAudioNode;
  47306. private _scene;
  47307. private _connectedAnalyser;
  47308. private _options;
  47309. private _isInitialized;
  47310. /**
  47311. * Creates a new sound track.
  47312. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47313. * @param scene Define the scene the sound track belongs to
  47314. * @param options
  47315. */
  47316. constructor(scene: Scene, options?: ISoundTrackOptions);
  47317. private _initializeSoundTrackAudioGraph;
  47318. /**
  47319. * Release the sound track and its associated resources
  47320. */
  47321. dispose(): void;
  47322. /**
  47323. * Adds a sound to this sound track
  47324. * @param sound define the cound to add
  47325. * @ignoreNaming
  47326. */
  47327. addSound(sound: Sound): void;
  47328. /**
  47329. * Removes a sound to this sound track
  47330. * @param sound define the cound to remove
  47331. * @ignoreNaming
  47332. */
  47333. removeSound(sound: Sound): void;
  47334. /**
  47335. * Set a global volume for the full sound track.
  47336. * @param newVolume Define the new volume of the sound track
  47337. */
  47338. setVolume(newVolume: number): void;
  47339. /**
  47340. * Switch the panning model to HRTF:
  47341. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47342. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47343. */
  47344. switchPanningModelToHRTF(): void;
  47345. /**
  47346. * Switch the panning model to Equal Power:
  47347. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  47348. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47349. */
  47350. switchPanningModelToEqualPower(): void;
  47351. /**
  47352. * Connect the sound track to an audio analyser allowing some amazing
  47353. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47354. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47355. * @param analyser The analyser to connect to the engine
  47356. */
  47357. connectToAnalyser(analyser: Analyser): void;
  47358. }
  47359. }
  47360. declare module "babylonjs/Audio/audioSceneComponent" {
  47361. import { Sound } from "babylonjs/Audio/sound";
  47362. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  47363. import { Nullable } from "babylonjs/types";
  47364. import { Vector3 } from "babylonjs/Maths/math.vector";
  47365. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47366. import { Scene } from "babylonjs/scene";
  47367. import { AbstractScene } from "babylonjs/abstractScene";
  47368. import "babylonjs/Audio/audioEngine";
  47369. module "babylonjs/abstractScene" {
  47370. interface AbstractScene {
  47371. /**
  47372. * The list of sounds used in the scene.
  47373. */
  47374. sounds: Nullable<Array<Sound>>;
  47375. }
  47376. }
  47377. module "babylonjs/scene" {
  47378. interface Scene {
  47379. /**
  47380. * @hidden
  47381. * Backing field
  47382. */
  47383. _mainSoundTrack: SoundTrack;
  47384. /**
  47385. * The main sound track played by the scene.
  47386. * It cotains your primary collection of sounds.
  47387. */
  47388. mainSoundTrack: SoundTrack;
  47389. /**
  47390. * The list of sound tracks added to the scene
  47391. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47392. */
  47393. soundTracks: Nullable<Array<SoundTrack>>;
  47394. /**
  47395. * Gets a sound using a given name
  47396. * @param name defines the name to search for
  47397. * @return the found sound or null if not found at all.
  47398. */
  47399. getSoundByName(name: string): Nullable<Sound>;
  47400. /**
  47401. * Gets or sets if audio support is enabled
  47402. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47403. */
  47404. audioEnabled: boolean;
  47405. /**
  47406. * Gets or sets if audio will be output to headphones
  47407. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47408. */
  47409. headphone: boolean;
  47410. /**
  47411. * Gets or sets custom audio listener position provider
  47412. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47413. */
  47414. audioListenerPositionProvider: Nullable<() => Vector3>;
  47415. /**
  47416. * Gets or sets a refresh rate when using 3D audio positioning
  47417. */
  47418. audioPositioningRefreshRate: number;
  47419. }
  47420. }
  47421. /**
  47422. * Defines the sound scene component responsible to manage any sounds
  47423. * in a given scene.
  47424. */
  47425. export class AudioSceneComponent implements ISceneSerializableComponent {
  47426. private static _CameraDirectionLH;
  47427. private static _CameraDirectionRH;
  47428. /**
  47429. * The component name helpfull to identify the component in the list of scene components.
  47430. */
  47431. readonly name: string;
  47432. /**
  47433. * The scene the component belongs to.
  47434. */
  47435. scene: Scene;
  47436. private _audioEnabled;
  47437. /**
  47438. * Gets whether audio is enabled or not.
  47439. * Please use related enable/disable method to switch state.
  47440. */
  47441. get audioEnabled(): boolean;
  47442. private _headphone;
  47443. /**
  47444. * Gets whether audio is outputing to headphone or not.
  47445. * Please use the according Switch methods to change output.
  47446. */
  47447. get headphone(): boolean;
  47448. /**
  47449. * Gets or sets a refresh rate when using 3D audio positioning
  47450. */
  47451. audioPositioningRefreshRate: number;
  47452. private _audioListenerPositionProvider;
  47453. /**
  47454. * Gets the current audio listener position provider
  47455. */
  47456. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  47457. /**
  47458. * Sets a custom listener position for all sounds in the scene
  47459. * By default, this is the position of the first active camera
  47460. */
  47461. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  47462. /**
  47463. * Creates a new instance of the component for the given scene
  47464. * @param scene Defines the scene to register the component in
  47465. */
  47466. constructor(scene: Scene);
  47467. /**
  47468. * Registers the component in a given scene
  47469. */
  47470. register(): void;
  47471. /**
  47472. * Rebuilds the elements related to this component in case of
  47473. * context lost for instance.
  47474. */
  47475. rebuild(): void;
  47476. /**
  47477. * Serializes the component data to the specified json object
  47478. * @param serializationObject The object to serialize to
  47479. */
  47480. serialize(serializationObject: any): void;
  47481. /**
  47482. * Adds all the elements from the container to the scene
  47483. * @param container the container holding the elements
  47484. */
  47485. addFromContainer(container: AbstractScene): void;
  47486. /**
  47487. * Removes all the elements in the container from the scene
  47488. * @param container contains the elements to remove
  47489. * @param dispose if the removed element should be disposed (default: false)
  47490. */
  47491. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47492. /**
  47493. * Disposes the component and the associated ressources.
  47494. */
  47495. dispose(): void;
  47496. /**
  47497. * Disables audio in the associated scene.
  47498. */
  47499. disableAudio(): void;
  47500. /**
  47501. * Enables audio in the associated scene.
  47502. */
  47503. enableAudio(): void;
  47504. /**
  47505. * Switch audio to headphone output.
  47506. */
  47507. switchAudioModeForHeadphones(): void;
  47508. /**
  47509. * Switch audio to normal speakers.
  47510. */
  47511. switchAudioModeForNormalSpeakers(): void;
  47512. private _cachedCameraDirection;
  47513. private _cachedCameraPosition;
  47514. private _lastCheck;
  47515. private _afterRender;
  47516. }
  47517. }
  47518. declare module "babylonjs/Audio/weightedsound" {
  47519. import { Sound } from "babylonjs/Audio/sound";
  47520. /**
  47521. * Wraps one or more Sound objects and selects one with random weight for playback.
  47522. */
  47523. export class WeightedSound {
  47524. /** When true a Sound will be selected and played when the current playing Sound completes. */
  47525. loop: boolean;
  47526. private _coneInnerAngle;
  47527. private _coneOuterAngle;
  47528. private _volume;
  47529. /** A Sound is currently playing. */
  47530. isPlaying: boolean;
  47531. /** A Sound is currently paused. */
  47532. isPaused: boolean;
  47533. private _sounds;
  47534. private _weights;
  47535. private _currentIndex?;
  47536. /**
  47537. * Creates a new WeightedSound from the list of sounds given.
  47538. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  47539. * @param sounds Array of Sounds that will be selected from.
  47540. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  47541. */
  47542. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  47543. /**
  47544. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  47545. */
  47546. get directionalConeInnerAngle(): number;
  47547. /**
  47548. * The size of cone in degress for a directional sound in which there will be no attenuation.
  47549. */
  47550. set directionalConeInnerAngle(value: number);
  47551. /**
  47552. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47553. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47554. */
  47555. get directionalConeOuterAngle(): number;
  47556. /**
  47557. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47558. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47559. */
  47560. set directionalConeOuterAngle(value: number);
  47561. /**
  47562. * Playback volume.
  47563. */
  47564. get volume(): number;
  47565. /**
  47566. * Playback volume.
  47567. */
  47568. set volume(value: number);
  47569. private _onended;
  47570. /**
  47571. * Suspend playback
  47572. */
  47573. pause(): void;
  47574. /**
  47575. * Stop playback
  47576. */
  47577. stop(): void;
  47578. /**
  47579. * Start playback.
  47580. * @param startOffset Position the clip head at a specific time in seconds.
  47581. */
  47582. play(startOffset?: number): void;
  47583. }
  47584. }
  47585. declare module "babylonjs/Audio/index" {
  47586. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  47587. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  47588. export * from "babylonjs/Audio/analyser";
  47589. export * from "babylonjs/Audio/audioEngine";
  47590. export * from "babylonjs/Audio/audioSceneComponent";
  47591. export * from "babylonjs/Audio/sound";
  47592. export * from "babylonjs/Audio/soundTrack";
  47593. export * from "babylonjs/Audio/weightedsound";
  47594. }
  47595. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  47596. import { Behavior } from "babylonjs/Behaviors/behavior";
  47597. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47598. import { BackEase } from "babylonjs/Animations/easing";
  47599. /**
  47600. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  47601. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47602. */
  47603. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  47604. /**
  47605. * Gets the name of the behavior.
  47606. */
  47607. get name(): string;
  47608. /**
  47609. * The easing function used by animations
  47610. */
  47611. static EasingFunction: BackEase;
  47612. /**
  47613. * The easing mode used by animations
  47614. */
  47615. static EasingMode: number;
  47616. /**
  47617. * The duration of the animation, in milliseconds
  47618. */
  47619. transitionDuration: number;
  47620. /**
  47621. * Length of the distance animated by the transition when lower radius is reached
  47622. */
  47623. lowerRadiusTransitionRange: number;
  47624. /**
  47625. * Length of the distance animated by the transition when upper radius is reached
  47626. */
  47627. upperRadiusTransitionRange: number;
  47628. private _autoTransitionRange;
  47629. /**
  47630. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47631. */
  47632. get autoTransitionRange(): boolean;
  47633. /**
  47634. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47635. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  47636. */
  47637. set autoTransitionRange(value: boolean);
  47638. private _attachedCamera;
  47639. private _onAfterCheckInputsObserver;
  47640. private _onMeshTargetChangedObserver;
  47641. /**
  47642. * Initializes the behavior.
  47643. */
  47644. init(): void;
  47645. /**
  47646. * Attaches the behavior to its arc rotate camera.
  47647. * @param camera Defines the camera to attach the behavior to
  47648. */
  47649. attach(camera: ArcRotateCamera): void;
  47650. /**
  47651. * Detaches the behavior from its current arc rotate camera.
  47652. */
  47653. detach(): void;
  47654. private _radiusIsAnimating;
  47655. private _radiusBounceTransition;
  47656. private _animatables;
  47657. private _cachedWheelPrecision;
  47658. /**
  47659. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47660. * @param radiusLimit The limit to check against.
  47661. * @return Bool to indicate if at limit.
  47662. */
  47663. private _isRadiusAtLimit;
  47664. /**
  47665. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47666. * @param radiusDelta The delta by which to animate to. Can be negative.
  47667. */
  47668. private _applyBoundRadiusAnimation;
  47669. /**
  47670. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47671. */
  47672. protected _clearAnimationLocks(): void;
  47673. /**
  47674. * Stops and removes all animations that have been applied to the camera
  47675. */
  47676. stopAllAnimations(): void;
  47677. }
  47678. }
  47679. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47680. import { Behavior } from "babylonjs/Behaviors/behavior";
  47681. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47682. import { ExponentialEase } from "babylonjs/Animations/easing";
  47683. import { Nullable } from "babylonjs/types";
  47684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47685. import { Vector3 } from "babylonjs/Maths/math.vector";
  47686. /**
  47687. * 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.
  47688. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47689. */
  47690. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47691. /**
  47692. * Gets the name of the behavior.
  47693. */
  47694. get name(): string;
  47695. private _mode;
  47696. private _radiusScale;
  47697. private _positionScale;
  47698. private _defaultElevation;
  47699. private _elevationReturnTime;
  47700. private _elevationReturnWaitTime;
  47701. private _zoomStopsAnimation;
  47702. private _framingTime;
  47703. /**
  47704. * The easing function used by animations
  47705. */
  47706. static EasingFunction: ExponentialEase;
  47707. /**
  47708. * The easing mode used by animations
  47709. */
  47710. static EasingMode: number;
  47711. /**
  47712. * Sets the current mode used by the behavior
  47713. */
  47714. set mode(mode: number);
  47715. /**
  47716. * Gets current mode used by the behavior.
  47717. */
  47718. get mode(): number;
  47719. /**
  47720. * Sets the scale applied to the radius (1 by default)
  47721. */
  47722. set radiusScale(radius: number);
  47723. /**
  47724. * Gets the scale applied to the radius
  47725. */
  47726. get radiusScale(): number;
  47727. /**
  47728. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47729. */
  47730. set positionScale(scale: number);
  47731. /**
  47732. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47733. */
  47734. get positionScale(): number;
  47735. /**
  47736. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47737. * behaviour is triggered, in radians.
  47738. */
  47739. set defaultElevation(elevation: number);
  47740. /**
  47741. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47742. * behaviour is triggered, in radians.
  47743. */
  47744. get defaultElevation(): number;
  47745. /**
  47746. * Sets the time (in milliseconds) taken to return to the default beta position.
  47747. * Negative value indicates camera should not return to default.
  47748. */
  47749. set elevationReturnTime(speed: number);
  47750. /**
  47751. * Gets the time (in milliseconds) taken to return to the default beta position.
  47752. * Negative value indicates camera should not return to default.
  47753. */
  47754. get elevationReturnTime(): number;
  47755. /**
  47756. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47757. */
  47758. set elevationReturnWaitTime(time: number);
  47759. /**
  47760. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47761. */
  47762. get elevationReturnWaitTime(): number;
  47763. /**
  47764. * Sets the flag that indicates if user zooming should stop animation.
  47765. */
  47766. set zoomStopsAnimation(flag: boolean);
  47767. /**
  47768. * Gets the flag that indicates if user zooming should stop animation.
  47769. */
  47770. get zoomStopsAnimation(): boolean;
  47771. /**
  47772. * Sets the transition time when framing the mesh, in milliseconds
  47773. */
  47774. set framingTime(time: number);
  47775. /**
  47776. * Gets the transition time when framing the mesh, in milliseconds
  47777. */
  47778. get framingTime(): number;
  47779. /**
  47780. * Define if the behavior should automatically change the configured
  47781. * camera limits and sensibilities.
  47782. */
  47783. autoCorrectCameraLimitsAndSensibility: boolean;
  47784. private _onPrePointerObservableObserver;
  47785. private _onAfterCheckInputsObserver;
  47786. private _onMeshTargetChangedObserver;
  47787. private _attachedCamera;
  47788. private _isPointerDown;
  47789. private _lastInteractionTime;
  47790. /**
  47791. * Initializes the behavior.
  47792. */
  47793. init(): void;
  47794. /**
  47795. * Attaches the behavior to its arc rotate camera.
  47796. * @param camera Defines the camera to attach the behavior to
  47797. */
  47798. attach(camera: ArcRotateCamera): void;
  47799. /**
  47800. * Detaches the behavior from its current arc rotate camera.
  47801. */
  47802. detach(): void;
  47803. private _animatables;
  47804. private _betaIsAnimating;
  47805. private _betaTransition;
  47806. private _radiusTransition;
  47807. private _vectorTransition;
  47808. /**
  47809. * Targets the given mesh and updates zoom level accordingly.
  47810. * @param mesh The mesh to target.
  47811. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47812. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47813. */
  47814. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47815. /**
  47816. * Targets the given mesh with its children and updates zoom level accordingly.
  47817. * @param mesh The mesh to target.
  47818. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47819. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47820. */
  47821. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47822. /**
  47823. * Targets the given meshes with their children and updates zoom level accordingly.
  47824. * @param meshes The mesh to target.
  47825. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47826. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47827. */
  47828. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47829. /**
  47830. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47831. * @param minimumWorld Determines the smaller position of the bounding box extend
  47832. * @param maximumWorld Determines the bigger position of the bounding box extend
  47833. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47834. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47835. */
  47836. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47837. /**
  47838. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47839. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47840. * frustum width.
  47841. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47842. * to fully enclose the mesh in the viewing frustum.
  47843. */
  47844. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47845. /**
  47846. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47847. * is automatically returned to its default position (expected to be above ground plane).
  47848. */
  47849. private _maintainCameraAboveGround;
  47850. /**
  47851. * Returns the frustum slope based on the canvas ratio and camera FOV
  47852. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47853. */
  47854. private _getFrustumSlope;
  47855. /**
  47856. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47857. */
  47858. private _clearAnimationLocks;
  47859. /**
  47860. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47861. */
  47862. private _applyUserInteraction;
  47863. /**
  47864. * Stops and removes all animations that have been applied to the camera
  47865. */
  47866. stopAllAnimations(): void;
  47867. /**
  47868. * Gets a value indicating if the user is moving the camera
  47869. */
  47870. get isUserIsMoving(): boolean;
  47871. /**
  47872. * The camera can move all the way towards the mesh.
  47873. */
  47874. static IgnoreBoundsSizeMode: number;
  47875. /**
  47876. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47877. */
  47878. static FitFrustumSidesMode: number;
  47879. }
  47880. }
  47881. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47882. import { Nullable } from "babylonjs/types";
  47883. import { Camera } from "babylonjs/Cameras/camera";
  47884. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47885. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47886. /**
  47887. * Base class for Camera Pointer Inputs.
  47888. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47889. * for example usage.
  47890. */
  47891. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47892. /**
  47893. * Defines the camera the input is attached to.
  47894. */
  47895. abstract camera: Camera;
  47896. /**
  47897. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47898. */
  47899. protected _altKey: boolean;
  47900. protected _ctrlKey: boolean;
  47901. protected _metaKey: boolean;
  47902. protected _shiftKey: boolean;
  47903. /**
  47904. * Which mouse buttons were pressed at time of last mouse event.
  47905. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47906. */
  47907. protected _buttonsPressed: number;
  47908. /**
  47909. * Defines the buttons associated with the input to handle camera move.
  47910. */
  47911. buttons: number[];
  47912. /**
  47913. * Attach the input controls to a specific dom element to get the input from.
  47914. * @param element Defines the element the controls should be listened from
  47915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47916. */
  47917. attachControl(noPreventDefault?: boolean): void;
  47918. /**
  47919. * Detach the current controls from the specified dom element.
  47920. */
  47921. detachControl(): void;
  47922. /**
  47923. * Gets the class name of the current input.
  47924. * @returns the class name
  47925. */
  47926. getClassName(): string;
  47927. /**
  47928. * Get the friendly name associated with the input class.
  47929. * @returns the input friendly name
  47930. */
  47931. getSimpleName(): string;
  47932. /**
  47933. * Called on pointer POINTERDOUBLETAP event.
  47934. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47935. */
  47936. protected onDoubleTap(type: string): void;
  47937. /**
  47938. * Called on pointer POINTERMOVE event if only a single touch is active.
  47939. * Override this method to provide functionality.
  47940. */
  47941. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47942. /**
  47943. * Called on pointer POINTERMOVE event if multiple touches are active.
  47944. * Override this method to provide functionality.
  47945. */
  47946. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47947. /**
  47948. * Called on JS contextmenu event.
  47949. * Override this method to provide functionality.
  47950. */
  47951. protected onContextMenu(evt: PointerEvent): void;
  47952. /**
  47953. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47954. * press.
  47955. * Override this method to provide functionality.
  47956. */
  47957. protected onButtonDown(evt: PointerEvent): void;
  47958. /**
  47959. * Called each time a new POINTERUP event occurs. Ie, for each button
  47960. * release.
  47961. * Override this method to provide functionality.
  47962. */
  47963. protected onButtonUp(evt: PointerEvent): void;
  47964. /**
  47965. * Called when window becomes inactive.
  47966. * Override this method to provide functionality.
  47967. */
  47968. protected onLostFocus(): void;
  47969. private _pointerInput;
  47970. private _observer;
  47971. private _onLostFocus;
  47972. private pointA;
  47973. private pointB;
  47974. }
  47975. }
  47976. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47977. import { Nullable } from "babylonjs/types";
  47978. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47979. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47980. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47981. /**
  47982. * Manage the pointers inputs to control an arc rotate camera.
  47983. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47984. */
  47985. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47986. /**
  47987. * Defines the camera the input is attached to.
  47988. */
  47989. camera: ArcRotateCamera;
  47990. /**
  47991. * Gets the class name of the current input.
  47992. * @returns the class name
  47993. */
  47994. getClassName(): string;
  47995. /**
  47996. * Defines the buttons associated with the input to handle camera move.
  47997. */
  47998. buttons: number[];
  47999. /**
  48000. * Defines the pointer angular sensibility along the X axis or how fast is
  48001. * the camera rotating.
  48002. */
  48003. angularSensibilityX: number;
  48004. /**
  48005. * Defines the pointer angular sensibility along the Y axis or how fast is
  48006. * the camera rotating.
  48007. */
  48008. angularSensibilityY: number;
  48009. /**
  48010. * Defines the pointer pinch precision or how fast is the camera zooming.
  48011. */
  48012. pinchPrecision: number;
  48013. /**
  48014. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48015. * from 0.
  48016. * It defines the percentage of current camera.radius to use as delta when
  48017. * pinch zoom is used.
  48018. */
  48019. pinchDeltaPercentage: number;
  48020. /**
  48021. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48022. * that any object in the plane at the camera's target point will scale
  48023. * perfectly with finger motion.
  48024. * Overrides pinchDeltaPercentage and pinchPrecision.
  48025. */
  48026. useNaturalPinchZoom: boolean;
  48027. /**
  48028. * Defines the pointer panning sensibility or how fast is the camera moving.
  48029. */
  48030. panningSensibility: number;
  48031. /**
  48032. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  48033. */
  48034. multiTouchPanning: boolean;
  48035. /**
  48036. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  48037. * zoom (pinch) through multitouch.
  48038. */
  48039. multiTouchPanAndZoom: boolean;
  48040. /**
  48041. * Revers pinch action direction.
  48042. */
  48043. pinchInwards: boolean;
  48044. private _isPanClick;
  48045. private _twoFingerActivityCount;
  48046. private _isPinching;
  48047. /**
  48048. * Called on pointer POINTERMOVE event if only a single touch is active.
  48049. */
  48050. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48051. /**
  48052. * Called on pointer POINTERDOUBLETAP event.
  48053. */
  48054. protected onDoubleTap(type: string): void;
  48055. /**
  48056. * Called on pointer POINTERMOVE event if multiple touches are active.
  48057. */
  48058. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48059. /**
  48060. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  48061. * press.
  48062. */
  48063. protected onButtonDown(evt: PointerEvent): void;
  48064. /**
  48065. * Called each time a new POINTERUP event occurs. Ie, for each button
  48066. * release.
  48067. */
  48068. protected onButtonUp(evt: PointerEvent): void;
  48069. /**
  48070. * Called when window becomes inactive.
  48071. */
  48072. protected onLostFocus(): void;
  48073. }
  48074. }
  48075. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  48076. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48077. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48078. /**
  48079. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  48080. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48081. */
  48082. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  48083. /**
  48084. * Defines the camera the input is attached to.
  48085. */
  48086. camera: ArcRotateCamera;
  48087. /**
  48088. * Defines the list of key codes associated with the up action (increase alpha)
  48089. */
  48090. keysUp: number[];
  48091. /**
  48092. * Defines the list of key codes associated with the down action (decrease alpha)
  48093. */
  48094. keysDown: number[];
  48095. /**
  48096. * Defines the list of key codes associated with the left action (increase beta)
  48097. */
  48098. keysLeft: number[];
  48099. /**
  48100. * Defines the list of key codes associated with the right action (decrease beta)
  48101. */
  48102. keysRight: number[];
  48103. /**
  48104. * Defines the list of key codes associated with the reset action.
  48105. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  48106. */
  48107. keysReset: number[];
  48108. /**
  48109. * Defines the panning sensibility of the inputs.
  48110. * (How fast is the camera panning)
  48111. */
  48112. panningSensibility: number;
  48113. /**
  48114. * Defines the zooming sensibility of the inputs.
  48115. * (How fast is the camera zooming)
  48116. */
  48117. zoomingSensibility: number;
  48118. /**
  48119. * Defines whether maintaining the alt key down switch the movement mode from
  48120. * orientation to zoom.
  48121. */
  48122. useAltToZoom: boolean;
  48123. /**
  48124. * Rotation speed of the camera
  48125. */
  48126. angularSpeed: number;
  48127. private _keys;
  48128. private _ctrlPressed;
  48129. private _altPressed;
  48130. private _onCanvasBlurObserver;
  48131. private _onKeyboardObserver;
  48132. private _engine;
  48133. private _scene;
  48134. /**
  48135. * Attach the input controls to a specific dom element to get the input from.
  48136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48137. */
  48138. attachControl(noPreventDefault?: boolean): void;
  48139. /**
  48140. * Detach the current controls from the specified dom element.
  48141. */
  48142. detachControl(): void;
  48143. /**
  48144. * Update the current camera state depending on the inputs that have been used this frame.
  48145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48146. */
  48147. checkInputs(): void;
  48148. /**
  48149. * Gets the class name of the current intput.
  48150. * @returns the class name
  48151. */
  48152. getClassName(): string;
  48153. /**
  48154. * Get the friendly name associated with the input class.
  48155. * @returns the input friendly name
  48156. */
  48157. getSimpleName(): string;
  48158. }
  48159. }
  48160. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  48161. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48162. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48163. /**
  48164. * Manage the mouse wheel inputs to control an arc rotate camera.
  48165. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48166. */
  48167. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  48168. /**
  48169. * Defines the camera the input is attached to.
  48170. */
  48171. camera: ArcRotateCamera;
  48172. /**
  48173. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48174. */
  48175. wheelPrecision: number;
  48176. /**
  48177. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48178. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48179. */
  48180. wheelDeltaPercentage: number;
  48181. private _wheel;
  48182. private _observer;
  48183. private computeDeltaFromMouseWheelLegacyEvent;
  48184. /**
  48185. * Attach the input controls to a specific dom element to get the input from.
  48186. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48187. */
  48188. attachControl(noPreventDefault?: boolean): void;
  48189. /**
  48190. * Detach the current controls from the specified dom element.
  48191. */
  48192. detachControl(): void;
  48193. /**
  48194. * Gets the class name of the current intput.
  48195. * @returns the class name
  48196. */
  48197. getClassName(): string;
  48198. /**
  48199. * Get the friendly name associated with the input class.
  48200. * @returns the input friendly name
  48201. */
  48202. getSimpleName(): string;
  48203. }
  48204. }
  48205. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48206. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48207. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48208. /**
  48209. * Default Inputs manager for the ArcRotateCamera.
  48210. * It groups all the default supported inputs for ease of use.
  48211. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48212. */
  48213. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  48214. /**
  48215. * Instantiates a new ArcRotateCameraInputsManager.
  48216. * @param camera Defines the camera the inputs belong to
  48217. */
  48218. constructor(camera: ArcRotateCamera);
  48219. /**
  48220. * Add mouse wheel input support to the input manager.
  48221. * @returns the current input manager
  48222. */
  48223. addMouseWheel(): ArcRotateCameraInputsManager;
  48224. /**
  48225. * Add pointers input support to the input manager.
  48226. * @returns the current input manager
  48227. */
  48228. addPointers(): ArcRotateCameraInputsManager;
  48229. /**
  48230. * Add keyboard input support to the input manager.
  48231. * @returns the current input manager
  48232. */
  48233. addKeyboard(): ArcRotateCameraInputsManager;
  48234. }
  48235. }
  48236. declare module "babylonjs/Cameras/arcRotateCamera" {
  48237. import { Observable } from "babylonjs/Misc/observable";
  48238. import { Nullable } from "babylonjs/types";
  48239. import { Scene } from "babylonjs/scene";
  48240. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48242. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48243. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48244. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  48245. import { Camera } from "babylonjs/Cameras/camera";
  48246. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48247. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  48248. import { Collider } from "babylonjs/Collisions/collider";
  48249. /**
  48250. * This represents an orbital type of camera.
  48251. *
  48252. * 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.
  48253. * 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.
  48254. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  48255. */
  48256. export class ArcRotateCamera extends TargetCamera {
  48257. /**
  48258. * Defines the rotation angle of the camera along the longitudinal axis.
  48259. */
  48260. alpha: number;
  48261. /**
  48262. * Defines the rotation angle of the camera along the latitudinal axis.
  48263. */
  48264. beta: number;
  48265. /**
  48266. * Defines the radius of the camera from it s target point.
  48267. */
  48268. radius: number;
  48269. protected _target: Vector3;
  48270. protected _targetHost: Nullable<AbstractMesh>;
  48271. /**
  48272. * Defines the target point of the camera.
  48273. * The camera looks towards it form the radius distance.
  48274. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  48275. */
  48276. get target(): Vector3;
  48277. set target(value: Vector3);
  48278. /**
  48279. * Define the current local position of the camera in the scene
  48280. */
  48281. get position(): Vector3;
  48282. set position(newPosition: Vector3);
  48283. protected _upToYMatrix: Matrix;
  48284. protected _YToUpMatrix: Matrix;
  48285. /**
  48286. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  48287. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  48288. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  48289. */
  48290. set upVector(vec: Vector3);
  48291. get upVector(): Vector3;
  48292. /**
  48293. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  48294. */
  48295. setMatUp(): void;
  48296. /**
  48297. * Current inertia value on the longitudinal axis.
  48298. * The bigger this number the longer it will take for the camera to stop.
  48299. */
  48300. inertialAlphaOffset: number;
  48301. /**
  48302. * Current inertia value on the latitudinal axis.
  48303. * The bigger this number the longer it will take for the camera to stop.
  48304. */
  48305. inertialBetaOffset: number;
  48306. /**
  48307. * Current inertia value on the radius axis.
  48308. * The bigger this number the longer it will take for the camera to stop.
  48309. */
  48310. inertialRadiusOffset: number;
  48311. /**
  48312. * Minimum allowed angle on the longitudinal axis.
  48313. * This can help limiting how the Camera is able to move in the scene.
  48314. */
  48315. lowerAlphaLimit: Nullable<number>;
  48316. /**
  48317. * Maximum allowed angle on the longitudinal axis.
  48318. * This can help limiting how the Camera is able to move in the scene.
  48319. */
  48320. upperAlphaLimit: Nullable<number>;
  48321. /**
  48322. * Minimum allowed angle on the latitudinal axis.
  48323. * This can help limiting how the Camera is able to move in the scene.
  48324. */
  48325. lowerBetaLimit: number;
  48326. /**
  48327. * Maximum allowed angle on the latitudinal axis.
  48328. * This can help limiting how the Camera is able to move in the scene.
  48329. */
  48330. upperBetaLimit: number;
  48331. /**
  48332. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  48333. * This can help limiting how the Camera is able to move in the scene.
  48334. */
  48335. lowerRadiusLimit: Nullable<number>;
  48336. /**
  48337. * Maximum allowed distance of the camera to the target (The camera can not get further).
  48338. * This can help limiting how the Camera is able to move in the scene.
  48339. */
  48340. upperRadiusLimit: Nullable<number>;
  48341. /**
  48342. * Defines the current inertia value used during panning of the camera along the X axis.
  48343. */
  48344. inertialPanningX: number;
  48345. /**
  48346. * Defines the current inertia value used during panning of the camera along the Y axis.
  48347. */
  48348. inertialPanningY: number;
  48349. /**
  48350. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  48351. * Basically if your fingers moves away from more than this distance you will be considered
  48352. * in pinch mode.
  48353. */
  48354. pinchToPanMaxDistance: number;
  48355. /**
  48356. * Defines the maximum distance the camera can pan.
  48357. * This could help keeping the cammera always in your scene.
  48358. */
  48359. panningDistanceLimit: Nullable<number>;
  48360. /**
  48361. * Defines the target of the camera before paning.
  48362. */
  48363. panningOriginTarget: Vector3;
  48364. /**
  48365. * Defines the value of the inertia used during panning.
  48366. * 0 would mean stop inertia and one would mean no decelleration at all.
  48367. */
  48368. panningInertia: number;
  48369. /**
  48370. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  48371. */
  48372. get angularSensibilityX(): number;
  48373. set angularSensibilityX(value: number);
  48374. /**
  48375. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  48376. */
  48377. get angularSensibilityY(): number;
  48378. set angularSensibilityY(value: number);
  48379. /**
  48380. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  48381. */
  48382. get pinchPrecision(): number;
  48383. set pinchPrecision(value: number);
  48384. /**
  48385. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  48386. * It will be used instead of pinchDeltaPrecision if different from 0.
  48387. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48388. */
  48389. get pinchDeltaPercentage(): number;
  48390. set pinchDeltaPercentage(value: number);
  48391. /**
  48392. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  48393. * and pinch delta percentage.
  48394. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48395. * that any object in the plane at the camera's target point will scale
  48396. * perfectly with finger motion.
  48397. */
  48398. get useNaturalPinchZoom(): boolean;
  48399. set useNaturalPinchZoom(value: boolean);
  48400. /**
  48401. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  48402. */
  48403. get panningSensibility(): number;
  48404. set panningSensibility(value: number);
  48405. /**
  48406. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  48407. */
  48408. get keysUp(): number[];
  48409. set keysUp(value: number[]);
  48410. /**
  48411. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  48412. */
  48413. get keysDown(): number[];
  48414. set keysDown(value: number[]);
  48415. /**
  48416. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  48417. */
  48418. get keysLeft(): number[];
  48419. set keysLeft(value: number[]);
  48420. /**
  48421. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  48422. */
  48423. get keysRight(): number[];
  48424. set keysRight(value: number[]);
  48425. /**
  48426. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48427. */
  48428. get wheelPrecision(): number;
  48429. set wheelPrecision(value: number);
  48430. /**
  48431. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  48432. * It will be used instead of pinchDeltaPrecision if different from 0.
  48433. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48434. */
  48435. get wheelDeltaPercentage(): number;
  48436. set wheelDeltaPercentage(value: number);
  48437. /**
  48438. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  48439. */
  48440. zoomOnFactor: number;
  48441. /**
  48442. * Defines a screen offset for the camera position.
  48443. */
  48444. targetScreenOffset: Vector2;
  48445. /**
  48446. * Allows the camera to be completely reversed.
  48447. * If false the camera can not arrive upside down.
  48448. */
  48449. allowUpsideDown: boolean;
  48450. /**
  48451. * Define if double tap/click is used to restore the previously saved state of the camera.
  48452. */
  48453. useInputToRestoreState: boolean;
  48454. /** @hidden */
  48455. _viewMatrix: Matrix;
  48456. /** @hidden */
  48457. _useCtrlForPanning: boolean;
  48458. /** @hidden */
  48459. _panningMouseButton: number;
  48460. /**
  48461. * Defines the input associated to the camera.
  48462. */
  48463. inputs: ArcRotateCameraInputsManager;
  48464. /** @hidden */
  48465. _reset: () => void;
  48466. /**
  48467. * Defines the allowed panning axis.
  48468. */
  48469. panningAxis: Vector3;
  48470. protected _localDirection: Vector3;
  48471. protected _transformedDirection: Vector3;
  48472. private _bouncingBehavior;
  48473. /**
  48474. * Gets the bouncing behavior of the camera if it has been enabled.
  48475. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48476. */
  48477. get bouncingBehavior(): Nullable<BouncingBehavior>;
  48478. /**
  48479. * Defines if the bouncing behavior of the camera is enabled on the camera.
  48480. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48481. */
  48482. get useBouncingBehavior(): boolean;
  48483. set useBouncingBehavior(value: boolean);
  48484. private _framingBehavior;
  48485. /**
  48486. * Gets the framing behavior of the camera if it has been enabled.
  48487. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48488. */
  48489. get framingBehavior(): Nullable<FramingBehavior>;
  48490. /**
  48491. * Defines if the framing behavior of the camera is enabled on the camera.
  48492. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48493. */
  48494. get useFramingBehavior(): boolean;
  48495. set useFramingBehavior(value: boolean);
  48496. private _autoRotationBehavior;
  48497. /**
  48498. * Gets the auto rotation behavior of the camera if it has been enabled.
  48499. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48500. */
  48501. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  48502. /**
  48503. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  48504. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48505. */
  48506. get useAutoRotationBehavior(): boolean;
  48507. set useAutoRotationBehavior(value: boolean);
  48508. /**
  48509. * Observable triggered when the mesh target has been changed on the camera.
  48510. */
  48511. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  48512. /**
  48513. * Event raised when the camera is colliding with a mesh.
  48514. */
  48515. onCollide: (collidedMesh: AbstractMesh) => void;
  48516. /**
  48517. * Defines whether the camera should check collision with the objects oh the scene.
  48518. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  48519. */
  48520. checkCollisions: boolean;
  48521. /**
  48522. * Defines the collision radius of the camera.
  48523. * This simulates a sphere around the camera.
  48524. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48525. */
  48526. collisionRadius: Vector3;
  48527. protected _collider: Collider;
  48528. protected _previousPosition: Vector3;
  48529. protected _collisionVelocity: Vector3;
  48530. protected _newPosition: Vector3;
  48531. protected _previousAlpha: number;
  48532. protected _previousBeta: number;
  48533. protected _previousRadius: number;
  48534. protected _collisionTriggered: boolean;
  48535. protected _targetBoundingCenter: Nullable<Vector3>;
  48536. private _computationVector;
  48537. /**
  48538. * Instantiates a new ArcRotateCamera in a given scene
  48539. * @param name Defines the name of the camera
  48540. * @param alpha Defines the camera rotation along the logitudinal axis
  48541. * @param beta Defines the camera rotation along the latitudinal axis
  48542. * @param radius Defines the camera distance from its target
  48543. * @param target Defines the camera target
  48544. * @param scene Defines the scene the camera belongs to
  48545. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  48546. */
  48547. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48548. /** @hidden */
  48549. _initCache(): void;
  48550. /** @hidden */
  48551. _updateCache(ignoreParentClass?: boolean): void;
  48552. protected _getTargetPosition(): Vector3;
  48553. private _storedAlpha;
  48554. private _storedBeta;
  48555. private _storedRadius;
  48556. private _storedTarget;
  48557. private _storedTargetScreenOffset;
  48558. /**
  48559. * Stores the current state of the camera (alpha, beta, radius and target)
  48560. * @returns the camera itself
  48561. */
  48562. storeState(): Camera;
  48563. /**
  48564. * @hidden
  48565. * Restored camera state. You must call storeState() first
  48566. */
  48567. _restoreStateValues(): boolean;
  48568. /** @hidden */
  48569. _isSynchronizedViewMatrix(): boolean;
  48570. /**
  48571. * Attach the input controls to a specific dom element to get the input from.
  48572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48573. */
  48574. attachControl(noPreventDefault?: boolean): void;
  48575. /**
  48576. * Attach the input controls to a specific dom element to get the input from.
  48577. * @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
  48578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48579. */
  48580. attachControl(ignored: any, noPreventDefault?: boolean): void;
  48581. /**
  48582. * Attached controls to the current camera.
  48583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48584. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48585. */
  48586. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48587. /**
  48588. * Attached controls to the current camera.
  48589. * @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
  48590. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48591. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48592. */
  48593. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48594. /**
  48595. * Attached controls to the current camera.
  48596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48597. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48598. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  48599. */
  48600. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  48601. /**
  48602. * Detach the current controls from the specified dom element.
  48603. */
  48604. detachControl(): void;
  48605. /**
  48606. * Detach the current controls from the specified dom element.
  48607. * @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
  48608. */
  48609. detachControl(ignored: any): void;
  48610. /** @hidden */
  48611. _checkInputs(): void;
  48612. protected _checkLimits(): void;
  48613. /**
  48614. * Rebuilds angles (alpha, beta) and radius from the give position and target
  48615. */
  48616. rebuildAnglesAndRadius(): void;
  48617. /**
  48618. * Use a position to define the current camera related information like alpha, beta and radius
  48619. * @param position Defines the position to set the camera at
  48620. */
  48621. setPosition(position: Vector3): void;
  48622. /**
  48623. * Defines the target the camera should look at.
  48624. * This will automatically adapt alpha beta and radius to fit within the new target.
  48625. * @param target Defines the new target as a Vector or a mesh
  48626. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  48627. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  48628. */
  48629. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  48630. /** @hidden */
  48631. _getViewMatrix(): Matrix;
  48632. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  48633. /**
  48634. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  48635. * @param meshes Defines the mesh to zoom on
  48636. * @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)
  48637. */
  48638. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  48639. /**
  48640. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  48641. * The target will be changed but the radius
  48642. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  48643. * @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)
  48644. */
  48645. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  48646. min: Vector3;
  48647. max: Vector3;
  48648. distance: number;
  48649. }, doNotUpdateMaxZ?: boolean): void;
  48650. /**
  48651. * @override
  48652. * Override Camera.createRigCamera
  48653. */
  48654. createRigCamera(name: string, cameraIndex: number): Camera;
  48655. /**
  48656. * @hidden
  48657. * @override
  48658. * Override Camera._updateRigCameras
  48659. */
  48660. _updateRigCameras(): void;
  48661. /**
  48662. * Destroy the camera and release the current resources hold by it.
  48663. */
  48664. dispose(): void;
  48665. /**
  48666. * Gets the current object class name.
  48667. * @return the class name
  48668. */
  48669. getClassName(): string;
  48670. }
  48671. }
  48672. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48673. import { Behavior } from "babylonjs/Behaviors/behavior";
  48674. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48675. /**
  48676. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48677. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48678. */
  48679. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48680. /**
  48681. * Gets the name of the behavior.
  48682. */
  48683. get name(): string;
  48684. private _zoomStopsAnimation;
  48685. private _idleRotationSpeed;
  48686. private _idleRotationWaitTime;
  48687. private _idleRotationSpinupTime;
  48688. /**
  48689. * Sets the flag that indicates if user zooming should stop animation.
  48690. */
  48691. set zoomStopsAnimation(flag: boolean);
  48692. /**
  48693. * Gets the flag that indicates if user zooming should stop animation.
  48694. */
  48695. get zoomStopsAnimation(): boolean;
  48696. /**
  48697. * Sets the default speed at which the camera rotates around the model.
  48698. */
  48699. set idleRotationSpeed(speed: number);
  48700. /**
  48701. * Gets the default speed at which the camera rotates around the model.
  48702. */
  48703. get idleRotationSpeed(): number;
  48704. /**
  48705. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48706. */
  48707. set idleRotationWaitTime(time: number);
  48708. /**
  48709. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48710. */
  48711. get idleRotationWaitTime(): number;
  48712. /**
  48713. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48714. */
  48715. set idleRotationSpinupTime(time: number);
  48716. /**
  48717. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48718. */
  48719. get idleRotationSpinupTime(): number;
  48720. /**
  48721. * Gets a value indicating if the camera is currently rotating because of this behavior
  48722. */
  48723. get rotationInProgress(): boolean;
  48724. private _onPrePointerObservableObserver;
  48725. private _onAfterCheckInputsObserver;
  48726. private _attachedCamera;
  48727. private _isPointerDown;
  48728. private _lastFrameTime;
  48729. private _lastInteractionTime;
  48730. private _cameraRotationSpeed;
  48731. /**
  48732. * Initializes the behavior.
  48733. */
  48734. init(): void;
  48735. /**
  48736. * Attaches the behavior to its arc rotate camera.
  48737. * @param camera Defines the camera to attach the behavior to
  48738. */
  48739. attach(camera: ArcRotateCamera): void;
  48740. /**
  48741. * Detaches the behavior from its current arc rotate camera.
  48742. */
  48743. detach(): void;
  48744. /**
  48745. * Returns true if user is scrolling.
  48746. * @return true if user is scrolling.
  48747. */
  48748. private _userIsZooming;
  48749. private _lastFrameRadius;
  48750. private _shouldAnimationStopForInteraction;
  48751. /**
  48752. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48753. */
  48754. private _applyUserInteraction;
  48755. private _userIsMoving;
  48756. }
  48757. }
  48758. declare module "babylonjs/Behaviors/Cameras/index" {
  48759. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48760. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48761. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48762. }
  48763. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48764. import { Mesh } from "babylonjs/Meshes/mesh";
  48765. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48766. import { Behavior } from "babylonjs/Behaviors/behavior";
  48767. /**
  48768. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48769. */
  48770. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48771. private ui;
  48772. /**
  48773. * The name of the behavior
  48774. */
  48775. name: string;
  48776. /**
  48777. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48778. */
  48779. distanceAwayFromFace: number;
  48780. /**
  48781. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48782. */
  48783. distanceAwayFromBottomOfFace: number;
  48784. private _faceVectors;
  48785. private _target;
  48786. private _scene;
  48787. private _onRenderObserver;
  48788. private _tmpMatrix;
  48789. private _tmpVector;
  48790. /**
  48791. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48792. * @param ui The transform node that should be attched to the mesh
  48793. */
  48794. constructor(ui: TransformNode);
  48795. /**
  48796. * Initializes the behavior
  48797. */
  48798. init(): void;
  48799. private _closestFace;
  48800. private _zeroVector;
  48801. private _lookAtTmpMatrix;
  48802. private _lookAtToRef;
  48803. /**
  48804. * Attaches the AttachToBoxBehavior to the passed in mesh
  48805. * @param target The mesh that the specified node will be attached to
  48806. */
  48807. attach(target: Mesh): void;
  48808. /**
  48809. * Detaches the behavior from the mesh
  48810. */
  48811. detach(): void;
  48812. }
  48813. }
  48814. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48815. import { Behavior } from "babylonjs/Behaviors/behavior";
  48816. import { Mesh } from "babylonjs/Meshes/mesh";
  48817. /**
  48818. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48819. */
  48820. export class FadeInOutBehavior implements Behavior<Mesh> {
  48821. /**
  48822. * Time in milliseconds to delay before fading in (Default: 0)
  48823. */
  48824. delay: number;
  48825. /**
  48826. * Time in milliseconds for the mesh to fade in (Default: 300)
  48827. */
  48828. fadeInTime: number;
  48829. private _millisecondsPerFrame;
  48830. private _hovered;
  48831. private _hoverValue;
  48832. private _ownerNode;
  48833. /**
  48834. * Instatiates the FadeInOutBehavior
  48835. */
  48836. constructor();
  48837. /**
  48838. * The name of the behavior
  48839. */
  48840. get name(): string;
  48841. /**
  48842. * Initializes the behavior
  48843. */
  48844. init(): void;
  48845. /**
  48846. * Attaches the fade behavior on the passed in mesh
  48847. * @param ownerNode The mesh that will be faded in/out once attached
  48848. */
  48849. attach(ownerNode: Mesh): void;
  48850. /**
  48851. * Detaches the behavior from the mesh
  48852. */
  48853. detach(): void;
  48854. /**
  48855. * Triggers the mesh to begin fading in or out
  48856. * @param value if the object should fade in or out (true to fade in)
  48857. */
  48858. fadeIn(value: boolean): void;
  48859. private _update;
  48860. private _setAllVisibility;
  48861. }
  48862. }
  48863. declare module "babylonjs/Misc/pivotTools" {
  48864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48865. /**
  48866. * Class containing a set of static utilities functions for managing Pivots
  48867. * @hidden
  48868. */
  48869. export class PivotTools {
  48870. private static _PivotCached;
  48871. private static _OldPivotPoint;
  48872. private static _PivotTranslation;
  48873. private static _PivotTmpVector;
  48874. private static _PivotPostMultiplyPivotMatrix;
  48875. /** @hidden */
  48876. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48877. /** @hidden */
  48878. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48879. }
  48880. }
  48881. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48882. import { Scene } from "babylonjs/scene";
  48883. import { Vector4 } from "babylonjs/Maths/math.vector";
  48884. import { Mesh } from "babylonjs/Meshes/mesh";
  48885. import { Nullable } from "babylonjs/types";
  48886. import { Plane } from "babylonjs/Maths/math.plane";
  48887. /**
  48888. * Class containing static functions to help procedurally build meshes
  48889. */
  48890. export class PlaneBuilder {
  48891. /**
  48892. * Creates a plane mesh
  48893. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48894. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48895. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48899. * @param name defines the name of the mesh
  48900. * @param options defines the options used to create the mesh
  48901. * @param scene defines the hosting scene
  48902. * @returns the plane mesh
  48903. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48904. */
  48905. static CreatePlane(name: string, options: {
  48906. size?: number;
  48907. width?: number;
  48908. height?: number;
  48909. sideOrientation?: number;
  48910. frontUVs?: Vector4;
  48911. backUVs?: Vector4;
  48912. updatable?: boolean;
  48913. sourcePlane?: Plane;
  48914. }, scene?: Nullable<Scene>): Mesh;
  48915. }
  48916. }
  48917. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48918. import { Behavior } from "babylonjs/Behaviors/behavior";
  48919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48920. import { Observable } from "babylonjs/Misc/observable";
  48921. import { Vector3 } from "babylonjs/Maths/math.vector";
  48922. import { Ray } from "babylonjs/Culling/ray";
  48923. import "babylonjs/Meshes/Builders/planeBuilder";
  48924. /**
  48925. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48926. */
  48927. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48928. private static _AnyMouseID;
  48929. /**
  48930. * Abstract mesh the behavior is set on
  48931. */
  48932. attachedNode: AbstractMesh;
  48933. private _dragPlane;
  48934. private _scene;
  48935. private _pointerObserver;
  48936. private _beforeRenderObserver;
  48937. private static _planeScene;
  48938. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48939. /**
  48940. * 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)
  48941. */
  48942. maxDragAngle: number;
  48943. /**
  48944. * @hidden
  48945. */
  48946. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48947. /**
  48948. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48949. */
  48950. currentDraggingPointerID: number;
  48951. /**
  48952. * The last position where the pointer hit the drag plane in world space
  48953. */
  48954. lastDragPosition: Vector3;
  48955. /**
  48956. * If the behavior is currently in a dragging state
  48957. */
  48958. dragging: boolean;
  48959. /**
  48960. * 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)
  48961. */
  48962. dragDeltaRatio: number;
  48963. /**
  48964. * If the drag plane orientation should be updated during the dragging (Default: true)
  48965. */
  48966. updateDragPlane: boolean;
  48967. private _debugMode;
  48968. private _moving;
  48969. /**
  48970. * Fires each time the attached mesh is dragged with the pointer
  48971. * * delta between last drag position and current drag position in world space
  48972. * * dragDistance along the drag axis
  48973. * * dragPlaneNormal normal of the current drag plane used during the drag
  48974. * * dragPlanePoint in world space where the drag intersects the drag plane
  48975. */
  48976. onDragObservable: Observable<{
  48977. delta: Vector3;
  48978. dragPlanePoint: Vector3;
  48979. dragPlaneNormal: Vector3;
  48980. dragDistance: number;
  48981. pointerId: number;
  48982. }>;
  48983. /**
  48984. * Fires each time a drag begins (eg. mouse down on mesh)
  48985. */
  48986. onDragStartObservable: Observable<{
  48987. dragPlanePoint: Vector3;
  48988. pointerId: number;
  48989. }>;
  48990. /**
  48991. * Fires each time a drag ends (eg. mouse release after drag)
  48992. */
  48993. onDragEndObservable: Observable<{
  48994. dragPlanePoint: Vector3;
  48995. pointerId: number;
  48996. }>;
  48997. /**
  48998. * If the attached mesh should be moved when dragged
  48999. */
  49000. moveAttached: boolean;
  49001. /**
  49002. * If the drag behavior will react to drag events (Default: true)
  49003. */
  49004. enabled: boolean;
  49005. /**
  49006. * If pointer events should start and release the drag (Default: true)
  49007. */
  49008. startAndReleaseDragOnPointerEvents: boolean;
  49009. /**
  49010. * If camera controls should be detached during the drag
  49011. */
  49012. detachCameraControls: boolean;
  49013. /**
  49014. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  49015. */
  49016. useObjectOrientationForDragging: boolean;
  49017. private _options;
  49018. /**
  49019. * Gets the options used by the behavior
  49020. */
  49021. get options(): {
  49022. dragAxis?: Vector3;
  49023. dragPlaneNormal?: Vector3;
  49024. };
  49025. /**
  49026. * Sets the options used by the behavior
  49027. */
  49028. set options(options: {
  49029. dragAxis?: Vector3;
  49030. dragPlaneNormal?: Vector3;
  49031. });
  49032. /**
  49033. * Creates a pointer drag behavior that can be attached to a mesh
  49034. * @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)
  49035. */
  49036. constructor(options?: {
  49037. dragAxis?: Vector3;
  49038. dragPlaneNormal?: Vector3;
  49039. });
  49040. /**
  49041. * Predicate to determine if it is valid to move the object to a new position when it is moved
  49042. */
  49043. validateDrag: (targetPosition: Vector3) => boolean;
  49044. /**
  49045. * The name of the behavior
  49046. */
  49047. get name(): string;
  49048. /**
  49049. * Initializes the behavior
  49050. */
  49051. init(): void;
  49052. private _tmpVector;
  49053. private _alternatePickedPoint;
  49054. private _worldDragAxis;
  49055. private _targetPosition;
  49056. private _attachedToElement;
  49057. /**
  49058. * Attaches the drag behavior the passed in mesh
  49059. * @param ownerNode The mesh that will be dragged around once attached
  49060. * @param predicate Predicate to use for pick filtering
  49061. */
  49062. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  49063. /**
  49064. * Force relase the drag action by code.
  49065. */
  49066. releaseDrag(): void;
  49067. private _startDragRay;
  49068. private _lastPointerRay;
  49069. /**
  49070. * Simulates the start of a pointer drag event on the behavior
  49071. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  49072. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  49073. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  49074. */
  49075. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49076. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49077. private _dragDelta;
  49078. protected _moveDrag(ray: Ray): void;
  49079. private _pickWithRayOnDragPlane;
  49080. private _pointA;
  49081. private _pointC;
  49082. private _localAxis;
  49083. private _lookAt;
  49084. private _updateDragPlanePosition;
  49085. /**
  49086. * Detaches the behavior from the mesh
  49087. */
  49088. detach(): void;
  49089. }
  49090. }
  49091. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  49092. import { Mesh } from "babylonjs/Meshes/mesh";
  49093. import { Behavior } from "babylonjs/Behaviors/behavior";
  49094. /**
  49095. * A behavior that when attached to a mesh will allow the mesh to be scaled
  49096. */
  49097. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  49098. private _dragBehaviorA;
  49099. private _dragBehaviorB;
  49100. private _startDistance;
  49101. private _initialScale;
  49102. private _targetScale;
  49103. private _ownerNode;
  49104. private _sceneRenderObserver;
  49105. /**
  49106. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  49107. */
  49108. constructor();
  49109. /**
  49110. * The name of the behavior
  49111. */
  49112. get name(): string;
  49113. /**
  49114. * Initializes the behavior
  49115. */
  49116. init(): void;
  49117. private _getCurrentDistance;
  49118. /**
  49119. * Attaches the scale behavior the passed in mesh
  49120. * @param ownerNode The mesh that will be scaled around once attached
  49121. */
  49122. attach(ownerNode: Mesh): void;
  49123. /**
  49124. * Detaches the behavior from the mesh
  49125. */
  49126. detach(): void;
  49127. }
  49128. }
  49129. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  49130. import { Behavior } from "babylonjs/Behaviors/behavior";
  49131. import { Mesh } from "babylonjs/Meshes/mesh";
  49132. import { Observable } from "babylonjs/Misc/observable";
  49133. /**
  49134. * 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
  49135. */
  49136. export class SixDofDragBehavior implements Behavior<Mesh> {
  49137. private static _virtualScene;
  49138. private _ownerNode;
  49139. private _sceneRenderObserver;
  49140. private _scene;
  49141. private _targetPosition;
  49142. private _virtualOriginMesh;
  49143. private _virtualDragMesh;
  49144. private _pointerObserver;
  49145. private _moving;
  49146. private _startingOrientation;
  49147. private _attachedToElement;
  49148. /**
  49149. * 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)
  49150. */
  49151. private zDragFactor;
  49152. /**
  49153. * If the object should rotate to face the drag origin
  49154. */
  49155. rotateDraggedObject: boolean;
  49156. /**
  49157. * If the behavior is currently in a dragging state
  49158. */
  49159. dragging: boolean;
  49160. /**
  49161. * 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)
  49162. */
  49163. dragDeltaRatio: number;
  49164. /**
  49165. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  49166. */
  49167. currentDraggingPointerID: number;
  49168. /**
  49169. * If camera controls should be detached during the drag
  49170. */
  49171. detachCameraControls: boolean;
  49172. /**
  49173. * Fires each time a drag starts
  49174. */
  49175. onDragStartObservable: Observable<{}>;
  49176. /**
  49177. * Fires each time a drag happens
  49178. */
  49179. onDragObservable: Observable<void>;
  49180. /**
  49181. * Fires each time a drag ends (eg. mouse release after drag)
  49182. */
  49183. onDragEndObservable: Observable<{}>;
  49184. /**
  49185. * 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
  49186. */
  49187. constructor();
  49188. /**
  49189. * The name of the behavior
  49190. */
  49191. get name(): string;
  49192. /**
  49193. * Initializes the behavior
  49194. */
  49195. init(): void;
  49196. /**
  49197. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  49198. */
  49199. private get _pointerCamera();
  49200. /**
  49201. * Attaches the scale behavior the passed in mesh
  49202. * @param ownerNode The mesh that will be scaled around once attached
  49203. */
  49204. attach(ownerNode: Mesh): void;
  49205. /**
  49206. * Detaches the behavior from the mesh
  49207. */
  49208. detach(): void;
  49209. }
  49210. }
  49211. declare module "babylonjs/Behaviors/Meshes/index" {
  49212. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  49213. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  49214. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  49215. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49216. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49217. }
  49218. declare module "babylonjs/Behaviors/index" {
  49219. export * from "babylonjs/Behaviors/behavior";
  49220. export * from "babylonjs/Behaviors/Cameras/index";
  49221. export * from "babylonjs/Behaviors/Meshes/index";
  49222. }
  49223. declare module "babylonjs/Bones/boneIKController" {
  49224. import { Bone } from "babylonjs/Bones/bone";
  49225. import { Vector3 } from "babylonjs/Maths/math.vector";
  49226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49227. import { Nullable } from "babylonjs/types";
  49228. /**
  49229. * Class used to apply inverse kinematics to bones
  49230. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  49231. */
  49232. export class BoneIKController {
  49233. private static _tmpVecs;
  49234. private static _tmpQuat;
  49235. private static _tmpMats;
  49236. /**
  49237. * Gets or sets the target mesh
  49238. */
  49239. targetMesh: AbstractMesh;
  49240. /** Gets or sets the mesh used as pole */
  49241. poleTargetMesh: AbstractMesh;
  49242. /**
  49243. * Gets or sets the bone used as pole
  49244. */
  49245. poleTargetBone: Nullable<Bone>;
  49246. /**
  49247. * Gets or sets the target position
  49248. */
  49249. targetPosition: Vector3;
  49250. /**
  49251. * Gets or sets the pole target position
  49252. */
  49253. poleTargetPosition: Vector3;
  49254. /**
  49255. * Gets or sets the pole target local offset
  49256. */
  49257. poleTargetLocalOffset: Vector3;
  49258. /**
  49259. * Gets or sets the pole angle
  49260. */
  49261. poleAngle: number;
  49262. /**
  49263. * Gets or sets the mesh associated with the controller
  49264. */
  49265. mesh: AbstractMesh;
  49266. /**
  49267. * 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)
  49268. */
  49269. slerpAmount: number;
  49270. private _bone1Quat;
  49271. private _bone1Mat;
  49272. private _bone2Ang;
  49273. private _bone1;
  49274. private _bone2;
  49275. private _bone1Length;
  49276. private _bone2Length;
  49277. private _maxAngle;
  49278. private _maxReach;
  49279. private _rightHandedSystem;
  49280. private _bendAxis;
  49281. private _slerping;
  49282. private _adjustRoll;
  49283. /**
  49284. * Gets or sets maximum allowed angle
  49285. */
  49286. get maxAngle(): number;
  49287. set maxAngle(value: number);
  49288. /**
  49289. * Creates a new BoneIKController
  49290. * @param mesh defines the mesh to control
  49291. * @param bone defines the bone to control
  49292. * @param options defines options to set up the controller
  49293. */
  49294. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  49295. targetMesh?: AbstractMesh;
  49296. poleTargetMesh?: AbstractMesh;
  49297. poleTargetBone?: Bone;
  49298. poleTargetLocalOffset?: Vector3;
  49299. poleAngle?: number;
  49300. bendAxis?: Vector3;
  49301. maxAngle?: number;
  49302. slerpAmount?: number;
  49303. });
  49304. private _setMaxAngle;
  49305. /**
  49306. * Force the controller to update the bones
  49307. */
  49308. update(): void;
  49309. }
  49310. }
  49311. declare module "babylonjs/Bones/boneLookController" {
  49312. import { Vector3 } from "babylonjs/Maths/math.vector";
  49313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49314. import { Bone } from "babylonjs/Bones/bone";
  49315. import { Space } from "babylonjs/Maths/math.axis";
  49316. /**
  49317. * Class used to make a bone look toward a point in space
  49318. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  49319. */
  49320. export class BoneLookController {
  49321. private static _tmpVecs;
  49322. private static _tmpQuat;
  49323. private static _tmpMats;
  49324. /**
  49325. * The target Vector3 that the bone will look at
  49326. */
  49327. target: Vector3;
  49328. /**
  49329. * The mesh that the bone is attached to
  49330. */
  49331. mesh: AbstractMesh;
  49332. /**
  49333. * The bone that will be looking to the target
  49334. */
  49335. bone: Bone;
  49336. /**
  49337. * The up axis of the coordinate system that is used when the bone is rotated
  49338. */
  49339. upAxis: Vector3;
  49340. /**
  49341. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  49342. */
  49343. upAxisSpace: Space;
  49344. /**
  49345. * Used to make an adjustment to the yaw of the bone
  49346. */
  49347. adjustYaw: number;
  49348. /**
  49349. * Used to make an adjustment to the pitch of the bone
  49350. */
  49351. adjustPitch: number;
  49352. /**
  49353. * Used to make an adjustment to the roll of the bone
  49354. */
  49355. adjustRoll: number;
  49356. /**
  49357. * 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)
  49358. */
  49359. slerpAmount: number;
  49360. private _minYaw;
  49361. private _maxYaw;
  49362. private _minPitch;
  49363. private _maxPitch;
  49364. private _minYawSin;
  49365. private _minYawCos;
  49366. private _maxYawSin;
  49367. private _maxYawCos;
  49368. private _midYawConstraint;
  49369. private _minPitchTan;
  49370. private _maxPitchTan;
  49371. private _boneQuat;
  49372. private _slerping;
  49373. private _transformYawPitch;
  49374. private _transformYawPitchInv;
  49375. private _firstFrameSkipped;
  49376. private _yawRange;
  49377. private _fowardAxis;
  49378. /**
  49379. * Gets or sets the minimum yaw angle that the bone can look to
  49380. */
  49381. get minYaw(): number;
  49382. set minYaw(value: number);
  49383. /**
  49384. * Gets or sets the maximum yaw angle that the bone can look to
  49385. */
  49386. get maxYaw(): number;
  49387. set maxYaw(value: number);
  49388. /**
  49389. * Gets or sets the minimum pitch angle that the bone can look to
  49390. */
  49391. get minPitch(): number;
  49392. set minPitch(value: number);
  49393. /**
  49394. * Gets or sets the maximum pitch angle that the bone can look to
  49395. */
  49396. get maxPitch(): number;
  49397. set maxPitch(value: number);
  49398. /**
  49399. * Create a BoneLookController
  49400. * @param mesh the mesh that the bone belongs to
  49401. * @param bone the bone that will be looking to the target
  49402. * @param target the target Vector3 to look at
  49403. * @param options optional settings:
  49404. * * maxYaw: the maximum angle the bone will yaw to
  49405. * * minYaw: the minimum angle the bone will yaw to
  49406. * * maxPitch: the maximum angle the bone will pitch to
  49407. * * minPitch: the minimum angle the bone will yaw to
  49408. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  49409. * * upAxis: the up axis of the coordinate system
  49410. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  49411. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  49412. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  49413. * * adjustYaw: used to make an adjustment to the yaw of the bone
  49414. * * adjustPitch: used to make an adjustment to the pitch of the bone
  49415. * * adjustRoll: used to make an adjustment to the roll of the bone
  49416. **/
  49417. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  49418. maxYaw?: number;
  49419. minYaw?: number;
  49420. maxPitch?: number;
  49421. minPitch?: number;
  49422. slerpAmount?: number;
  49423. upAxis?: Vector3;
  49424. upAxisSpace?: Space;
  49425. yawAxis?: Vector3;
  49426. pitchAxis?: Vector3;
  49427. adjustYaw?: number;
  49428. adjustPitch?: number;
  49429. adjustRoll?: number;
  49430. });
  49431. /**
  49432. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  49433. */
  49434. update(): void;
  49435. private _getAngleDiff;
  49436. private _getAngleBetween;
  49437. private _isAngleBetween;
  49438. }
  49439. }
  49440. declare module "babylonjs/Bones/index" {
  49441. export * from "babylonjs/Bones/bone";
  49442. export * from "babylonjs/Bones/boneIKController";
  49443. export * from "babylonjs/Bones/boneLookController";
  49444. export * from "babylonjs/Bones/skeleton";
  49445. }
  49446. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  49447. import { Nullable } from "babylonjs/types";
  49448. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49449. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49450. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49451. /**
  49452. * Manage the gamepad inputs to control an arc rotate camera.
  49453. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49454. */
  49455. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  49456. /**
  49457. * Defines the camera the input is attached to.
  49458. */
  49459. camera: ArcRotateCamera;
  49460. /**
  49461. * Defines the gamepad the input is gathering event from.
  49462. */
  49463. gamepad: Nullable<Gamepad>;
  49464. /**
  49465. * Defines the gamepad rotation sensiblity.
  49466. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49467. */
  49468. gamepadRotationSensibility: number;
  49469. /**
  49470. * Defines the gamepad move sensiblity.
  49471. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49472. */
  49473. gamepadMoveSensibility: number;
  49474. private _yAxisScale;
  49475. /**
  49476. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49477. */
  49478. get invertYAxis(): boolean;
  49479. set invertYAxis(value: boolean);
  49480. private _onGamepadConnectedObserver;
  49481. private _onGamepadDisconnectedObserver;
  49482. /**
  49483. * Attach the input controls to a specific dom element to get the input from.
  49484. */
  49485. attachControl(): void;
  49486. /**
  49487. * Detach the current controls from the specified dom element.
  49488. */
  49489. detachControl(): void;
  49490. /**
  49491. * Update the current camera state depending on the inputs that have been used this frame.
  49492. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49493. */
  49494. checkInputs(): void;
  49495. /**
  49496. * Gets the class name of the current intput.
  49497. * @returns the class name
  49498. */
  49499. getClassName(): string;
  49500. /**
  49501. * Get the friendly name associated with the input class.
  49502. * @returns the input friendly name
  49503. */
  49504. getSimpleName(): string;
  49505. }
  49506. }
  49507. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  49508. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49509. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49510. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  49511. interface ArcRotateCameraInputsManager {
  49512. /**
  49513. * Add orientation input support to the input manager.
  49514. * @returns the current input manager
  49515. */
  49516. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  49517. }
  49518. }
  49519. /**
  49520. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  49521. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49522. */
  49523. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  49524. /**
  49525. * Defines the camera the input is attached to.
  49526. */
  49527. camera: ArcRotateCamera;
  49528. /**
  49529. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  49530. */
  49531. alphaCorrection: number;
  49532. /**
  49533. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  49534. */
  49535. gammaCorrection: number;
  49536. private _alpha;
  49537. private _gamma;
  49538. private _dirty;
  49539. private _deviceOrientationHandler;
  49540. /**
  49541. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  49542. */
  49543. constructor();
  49544. /**
  49545. * Attach the input controls to a specific dom element to get the input from.
  49546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49547. */
  49548. attachControl(noPreventDefault?: boolean): void;
  49549. /** @hidden */
  49550. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  49551. /**
  49552. * Update the current camera state depending on the inputs that have been used this frame.
  49553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49554. */
  49555. checkInputs(): void;
  49556. /**
  49557. * Detach the current controls from the specified dom element.
  49558. */
  49559. detachControl(): void;
  49560. /**
  49561. * Gets the class name of the current intput.
  49562. * @returns the class name
  49563. */
  49564. getClassName(): string;
  49565. /**
  49566. * Get the friendly name associated with the input class.
  49567. * @returns the input friendly name
  49568. */
  49569. getSimpleName(): string;
  49570. }
  49571. }
  49572. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  49573. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49574. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49575. /**
  49576. * Listen to mouse events to control the camera.
  49577. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49578. */
  49579. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  49580. /**
  49581. * Defines the camera the input is attached to.
  49582. */
  49583. camera: FlyCamera;
  49584. /**
  49585. * Defines if touch is enabled. (Default is true.)
  49586. */
  49587. touchEnabled: boolean;
  49588. /**
  49589. * Defines the buttons associated with the input to handle camera rotation.
  49590. */
  49591. buttons: number[];
  49592. /**
  49593. * Assign buttons for Yaw control.
  49594. */
  49595. buttonsYaw: number[];
  49596. /**
  49597. * Assign buttons for Pitch control.
  49598. */
  49599. buttonsPitch: number[];
  49600. /**
  49601. * Assign buttons for Roll control.
  49602. */
  49603. buttonsRoll: number[];
  49604. /**
  49605. * Detect if any button is being pressed while mouse is moved.
  49606. * -1 = Mouse locked.
  49607. * 0 = Left button.
  49608. * 1 = Middle Button.
  49609. * 2 = Right Button.
  49610. */
  49611. activeButton: number;
  49612. /**
  49613. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  49614. * Higher values reduce its sensitivity.
  49615. */
  49616. angularSensibility: number;
  49617. private _observer;
  49618. private _rollObserver;
  49619. private previousPosition;
  49620. private noPreventDefault;
  49621. private element;
  49622. /**
  49623. * Listen to mouse events to control the camera.
  49624. * @param touchEnabled Define if touch is enabled. (Default is true.)
  49625. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49626. */
  49627. constructor(touchEnabled?: boolean);
  49628. /**
  49629. * Attach the mouse control to the HTML DOM element.
  49630. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  49631. */
  49632. attachControl(noPreventDefault?: boolean): void;
  49633. /**
  49634. * Detach the current controls from the specified dom element.
  49635. */
  49636. detachControl(): void;
  49637. /**
  49638. * Gets the class name of the current input.
  49639. * @returns the class name.
  49640. */
  49641. getClassName(): string;
  49642. /**
  49643. * Get the friendly name associated with the input class.
  49644. * @returns the input's friendly name.
  49645. */
  49646. getSimpleName(): string;
  49647. private _pointerInput;
  49648. private _onMouseMove;
  49649. /**
  49650. * Rotate camera by mouse offset.
  49651. */
  49652. private rotateCamera;
  49653. }
  49654. }
  49655. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  49656. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49657. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49658. /**
  49659. * Default Inputs manager for the FlyCamera.
  49660. * It groups all the default supported inputs for ease of use.
  49661. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49662. */
  49663. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49664. /**
  49665. * Instantiates a new FlyCameraInputsManager.
  49666. * @param camera Defines the camera the inputs belong to.
  49667. */
  49668. constructor(camera: FlyCamera);
  49669. /**
  49670. * Add keyboard input support to the input manager.
  49671. * @returns the new FlyCameraKeyboardMoveInput().
  49672. */
  49673. addKeyboard(): FlyCameraInputsManager;
  49674. /**
  49675. * Add mouse input support to the input manager.
  49676. * @param touchEnabled Enable touch screen support.
  49677. * @returns the new FlyCameraMouseInput().
  49678. */
  49679. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49680. }
  49681. }
  49682. declare module "babylonjs/Cameras/flyCamera" {
  49683. import { Scene } from "babylonjs/scene";
  49684. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49686. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49687. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49688. /**
  49689. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49690. * such as in a 3D Space Shooter or a Flight Simulator.
  49691. */
  49692. export class FlyCamera extends TargetCamera {
  49693. /**
  49694. * Define the collision ellipsoid of the camera.
  49695. * This is helpful for simulating a camera body, like a player's body.
  49696. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49697. */
  49698. ellipsoid: Vector3;
  49699. /**
  49700. * Define an offset for the position of the ellipsoid around the camera.
  49701. * This can be helpful if the camera is attached away from the player's body center,
  49702. * such as at its head.
  49703. */
  49704. ellipsoidOffset: Vector3;
  49705. /**
  49706. * Enable or disable collisions of the camera with the rest of the scene objects.
  49707. */
  49708. checkCollisions: boolean;
  49709. /**
  49710. * Enable or disable gravity on the camera.
  49711. */
  49712. applyGravity: boolean;
  49713. /**
  49714. * Define the current direction the camera is moving to.
  49715. */
  49716. cameraDirection: Vector3;
  49717. /**
  49718. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49719. * This overrides and empties cameraRotation.
  49720. */
  49721. rotationQuaternion: Quaternion;
  49722. /**
  49723. * Track Roll to maintain the wanted Rolling when looking around.
  49724. */
  49725. _trackRoll: number;
  49726. /**
  49727. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49728. */
  49729. rollCorrect: number;
  49730. /**
  49731. * Mimic a banked turn, Rolling the camera when Yawing.
  49732. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49733. */
  49734. bankedTurn: boolean;
  49735. /**
  49736. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49737. */
  49738. bankedTurnLimit: number;
  49739. /**
  49740. * Value of 0 disables the banked Roll.
  49741. * Value of 1 is equal to the Yaw angle in radians.
  49742. */
  49743. bankedTurnMultiplier: number;
  49744. /**
  49745. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49746. */
  49747. inputs: FlyCameraInputsManager;
  49748. /**
  49749. * Gets the input sensibility for mouse input.
  49750. * Higher values reduce sensitivity.
  49751. */
  49752. get angularSensibility(): number;
  49753. /**
  49754. * Sets the input sensibility for a mouse input.
  49755. * Higher values reduce sensitivity.
  49756. */
  49757. set angularSensibility(value: number);
  49758. /**
  49759. * Get the keys for camera movement forward.
  49760. */
  49761. get keysForward(): number[];
  49762. /**
  49763. * Set the keys for camera movement forward.
  49764. */
  49765. set keysForward(value: number[]);
  49766. /**
  49767. * Get the keys for camera movement backward.
  49768. */
  49769. get keysBackward(): number[];
  49770. set keysBackward(value: number[]);
  49771. /**
  49772. * Get the keys for camera movement up.
  49773. */
  49774. get keysUp(): number[];
  49775. /**
  49776. * Set the keys for camera movement up.
  49777. */
  49778. set keysUp(value: number[]);
  49779. /**
  49780. * Get the keys for camera movement down.
  49781. */
  49782. get keysDown(): number[];
  49783. /**
  49784. * Set the keys for camera movement down.
  49785. */
  49786. set keysDown(value: number[]);
  49787. /**
  49788. * Get the keys for camera movement left.
  49789. */
  49790. get keysLeft(): number[];
  49791. /**
  49792. * Set the keys for camera movement left.
  49793. */
  49794. set keysLeft(value: number[]);
  49795. /**
  49796. * Set the keys for camera movement right.
  49797. */
  49798. get keysRight(): number[];
  49799. /**
  49800. * Set the keys for camera movement right.
  49801. */
  49802. set keysRight(value: number[]);
  49803. /**
  49804. * Event raised when the camera collides with a mesh in the scene.
  49805. */
  49806. onCollide: (collidedMesh: AbstractMesh) => void;
  49807. private _collider;
  49808. private _needMoveForGravity;
  49809. private _oldPosition;
  49810. private _diffPosition;
  49811. private _newPosition;
  49812. /** @hidden */
  49813. _localDirection: Vector3;
  49814. /** @hidden */
  49815. _transformedDirection: Vector3;
  49816. /**
  49817. * Instantiates a FlyCamera.
  49818. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49819. * such as in a 3D Space Shooter or a Flight Simulator.
  49820. * @param name Define the name of the camera in the scene.
  49821. * @param position Define the starting position of the camera in the scene.
  49822. * @param scene Define the scene the camera belongs to.
  49823. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49824. */
  49825. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49826. /**
  49827. * Attach the input controls to a specific dom element to get the input from.
  49828. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49829. */
  49830. attachControl(noPreventDefault?: boolean): void;
  49831. /**
  49832. * Detach a control from the HTML DOM element.
  49833. * The camera will stop reacting to that input.
  49834. */
  49835. detachControl(): void;
  49836. private _collisionMask;
  49837. /**
  49838. * Get the mask that the camera ignores in collision events.
  49839. */
  49840. get collisionMask(): number;
  49841. /**
  49842. * Set the mask that the camera ignores in collision events.
  49843. */
  49844. set collisionMask(mask: number);
  49845. /** @hidden */
  49846. _collideWithWorld(displacement: Vector3): void;
  49847. /** @hidden */
  49848. private _onCollisionPositionChange;
  49849. /** @hidden */
  49850. _checkInputs(): void;
  49851. /** @hidden */
  49852. _decideIfNeedsToMove(): boolean;
  49853. /** @hidden */
  49854. _updatePosition(): void;
  49855. /**
  49856. * Restore the Roll to its target value at the rate specified.
  49857. * @param rate - Higher means slower restoring.
  49858. * @hidden
  49859. */
  49860. restoreRoll(rate: number): void;
  49861. /**
  49862. * Destroy the camera and release the current resources held by it.
  49863. */
  49864. dispose(): void;
  49865. /**
  49866. * Get the current object class name.
  49867. * @returns the class name.
  49868. */
  49869. getClassName(): string;
  49870. }
  49871. }
  49872. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49873. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49874. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49875. /**
  49876. * Listen to keyboard events to control the camera.
  49877. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49878. */
  49879. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49880. /**
  49881. * Defines the camera the input is attached to.
  49882. */
  49883. camera: FlyCamera;
  49884. /**
  49885. * The list of keyboard keys used to control the forward move of the camera.
  49886. */
  49887. keysForward: number[];
  49888. /**
  49889. * The list of keyboard keys used to control the backward move of the camera.
  49890. */
  49891. keysBackward: number[];
  49892. /**
  49893. * The list of keyboard keys used to control the forward move of the camera.
  49894. */
  49895. keysUp: number[];
  49896. /**
  49897. * The list of keyboard keys used to control the backward move of the camera.
  49898. */
  49899. keysDown: number[];
  49900. /**
  49901. * The list of keyboard keys used to control the right strafe move of the camera.
  49902. */
  49903. keysRight: number[];
  49904. /**
  49905. * The list of keyboard keys used to control the left strafe move of the camera.
  49906. */
  49907. keysLeft: number[];
  49908. private _keys;
  49909. private _onCanvasBlurObserver;
  49910. private _onKeyboardObserver;
  49911. private _engine;
  49912. private _scene;
  49913. /**
  49914. * Attach the input controls to a specific dom element to get the input from.
  49915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49916. */
  49917. attachControl(noPreventDefault?: boolean): void;
  49918. /**
  49919. * Detach the current controls from the specified dom element.
  49920. */
  49921. detachControl(): void;
  49922. /**
  49923. * Gets the class name of the current intput.
  49924. * @returns the class name
  49925. */
  49926. getClassName(): string;
  49927. /** @hidden */
  49928. _onLostFocus(e: FocusEvent): void;
  49929. /**
  49930. * Get the friendly name associated with the input class.
  49931. * @returns the input friendly name
  49932. */
  49933. getSimpleName(): string;
  49934. /**
  49935. * Update the current camera state depending on the inputs that have been used this frame.
  49936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49937. */
  49938. checkInputs(): void;
  49939. }
  49940. }
  49941. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49942. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49943. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49944. /**
  49945. * Manage the mouse wheel inputs to control a follow camera.
  49946. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49947. */
  49948. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49949. /**
  49950. * Defines the camera the input is attached to.
  49951. */
  49952. camera: FollowCamera;
  49953. /**
  49954. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49955. */
  49956. axisControlRadius: boolean;
  49957. /**
  49958. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49959. */
  49960. axisControlHeight: boolean;
  49961. /**
  49962. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49963. */
  49964. axisControlRotation: boolean;
  49965. /**
  49966. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49967. * relation to mouseWheel events.
  49968. */
  49969. wheelPrecision: number;
  49970. /**
  49971. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49972. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49973. */
  49974. wheelDeltaPercentage: number;
  49975. private _wheel;
  49976. private _observer;
  49977. /**
  49978. * Attach the input controls to a specific dom element to get the input from.
  49979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49980. */
  49981. attachControl(noPreventDefault?: boolean): void;
  49982. /**
  49983. * Detach the current controls from the specified dom element.
  49984. */
  49985. detachControl(): void;
  49986. /**
  49987. * Gets the class name of the current intput.
  49988. * @returns the class name
  49989. */
  49990. getClassName(): string;
  49991. /**
  49992. * Get the friendly name associated with the input class.
  49993. * @returns the input friendly name
  49994. */
  49995. getSimpleName(): string;
  49996. }
  49997. }
  49998. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49999. import { Nullable } from "babylonjs/types";
  50000. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50001. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  50002. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  50003. /**
  50004. * Manage the pointers inputs to control an follow camera.
  50005. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50006. */
  50007. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  50008. /**
  50009. * Defines the camera the input is attached to.
  50010. */
  50011. camera: FollowCamera;
  50012. /**
  50013. * Gets the class name of the current input.
  50014. * @returns the class name
  50015. */
  50016. getClassName(): string;
  50017. /**
  50018. * Defines the pointer angular sensibility along the X axis or how fast is
  50019. * the camera rotating.
  50020. * A negative number will reverse the axis direction.
  50021. */
  50022. angularSensibilityX: number;
  50023. /**
  50024. * Defines the pointer angular sensibility along the Y axis or how fast is
  50025. * the camera rotating.
  50026. * A negative number will reverse the axis direction.
  50027. */
  50028. angularSensibilityY: number;
  50029. /**
  50030. * Defines the pointer pinch precision or how fast is the camera zooming.
  50031. * A negative number will reverse the axis direction.
  50032. */
  50033. pinchPrecision: number;
  50034. /**
  50035. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50036. * from 0.
  50037. * It defines the percentage of current camera.radius to use as delta when
  50038. * pinch zoom is used.
  50039. */
  50040. pinchDeltaPercentage: number;
  50041. /**
  50042. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  50043. */
  50044. axisXControlRadius: boolean;
  50045. /**
  50046. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  50047. */
  50048. axisXControlHeight: boolean;
  50049. /**
  50050. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  50051. */
  50052. axisXControlRotation: boolean;
  50053. /**
  50054. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  50055. */
  50056. axisYControlRadius: boolean;
  50057. /**
  50058. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  50059. */
  50060. axisYControlHeight: boolean;
  50061. /**
  50062. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  50063. */
  50064. axisYControlRotation: boolean;
  50065. /**
  50066. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  50067. */
  50068. axisPinchControlRadius: boolean;
  50069. /**
  50070. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  50071. */
  50072. axisPinchControlHeight: boolean;
  50073. /**
  50074. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  50075. */
  50076. axisPinchControlRotation: boolean;
  50077. /**
  50078. * Log error messages if basic misconfiguration has occurred.
  50079. */
  50080. warningEnable: boolean;
  50081. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50082. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50083. private _warningCounter;
  50084. private _warning;
  50085. }
  50086. }
  50087. declare module "babylonjs/Cameras/followCameraInputsManager" {
  50088. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  50089. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50090. /**
  50091. * Default Inputs manager for the FollowCamera.
  50092. * It groups all the default supported inputs for ease of use.
  50093. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50094. */
  50095. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  50096. /**
  50097. * Instantiates a new FollowCameraInputsManager.
  50098. * @param camera Defines the camera the inputs belong to
  50099. */
  50100. constructor(camera: FollowCamera);
  50101. /**
  50102. * Add keyboard input support to the input manager.
  50103. * @returns the current input manager
  50104. */
  50105. addKeyboard(): FollowCameraInputsManager;
  50106. /**
  50107. * Add mouse wheel input support to the input manager.
  50108. * @returns the current input manager
  50109. */
  50110. addMouseWheel(): FollowCameraInputsManager;
  50111. /**
  50112. * Add pointers input support to the input manager.
  50113. * @returns the current input manager
  50114. */
  50115. addPointers(): FollowCameraInputsManager;
  50116. /**
  50117. * Add orientation input support to the input manager.
  50118. * @returns the current input manager
  50119. */
  50120. addVRDeviceOrientation(): FollowCameraInputsManager;
  50121. }
  50122. }
  50123. declare module "babylonjs/Cameras/followCamera" {
  50124. import { Nullable } from "babylonjs/types";
  50125. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  50126. import { Scene } from "babylonjs/scene";
  50127. import { Vector3 } from "babylonjs/Maths/math.vector";
  50128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50129. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  50130. /**
  50131. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  50132. * an arc rotate version arcFollowCamera are available.
  50133. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50134. */
  50135. export class FollowCamera extends TargetCamera {
  50136. /**
  50137. * Distance the follow camera should follow an object at
  50138. */
  50139. radius: number;
  50140. /**
  50141. * Minimum allowed distance of the camera to the axis of rotation
  50142. * (The camera can not get closer).
  50143. * This can help limiting how the Camera is able to move in the scene.
  50144. */
  50145. lowerRadiusLimit: Nullable<number>;
  50146. /**
  50147. * Maximum allowed distance of the camera to the axis of rotation
  50148. * (The camera can not get further).
  50149. * This can help limiting how the Camera is able to move in the scene.
  50150. */
  50151. upperRadiusLimit: Nullable<number>;
  50152. /**
  50153. * Define a rotation offset between the camera and the object it follows
  50154. */
  50155. rotationOffset: number;
  50156. /**
  50157. * Minimum allowed angle to camera position relative to target object.
  50158. * This can help limiting how the Camera is able to move in the scene.
  50159. */
  50160. lowerRotationOffsetLimit: Nullable<number>;
  50161. /**
  50162. * Maximum allowed angle to camera position relative to target object.
  50163. * This can help limiting how the Camera is able to move in the scene.
  50164. */
  50165. upperRotationOffsetLimit: Nullable<number>;
  50166. /**
  50167. * Define a height offset between the camera and the object it follows.
  50168. * It can help following an object from the top (like a car chaing a plane)
  50169. */
  50170. heightOffset: number;
  50171. /**
  50172. * Minimum allowed height of camera position relative to target object.
  50173. * This can help limiting how the Camera is able to move in the scene.
  50174. */
  50175. lowerHeightOffsetLimit: Nullable<number>;
  50176. /**
  50177. * Maximum allowed height of camera position relative to target object.
  50178. * This can help limiting how the Camera is able to move in the scene.
  50179. */
  50180. upperHeightOffsetLimit: Nullable<number>;
  50181. /**
  50182. * Define how fast the camera can accelerate to follow it s target.
  50183. */
  50184. cameraAcceleration: number;
  50185. /**
  50186. * Define the speed limit of the camera following an object.
  50187. */
  50188. maxCameraSpeed: number;
  50189. /**
  50190. * Define the target of the camera.
  50191. */
  50192. lockedTarget: Nullable<AbstractMesh>;
  50193. /**
  50194. * Defines the input associated with the camera.
  50195. */
  50196. inputs: FollowCameraInputsManager;
  50197. /**
  50198. * Instantiates the follow camera.
  50199. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50200. * @param name Define the name of the camera in the scene
  50201. * @param position Define the position of the camera
  50202. * @param scene Define the scene the camera belong to
  50203. * @param lockedTarget Define the target of the camera
  50204. */
  50205. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  50206. private _follow;
  50207. /**
  50208. * Attach the input controls to a specific dom element to get the input from.
  50209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50210. */
  50211. attachControl(noPreventDefault?: boolean): void;
  50212. /**
  50213. * Detach the current controls from the specified dom element.
  50214. */
  50215. detachControl(): void;
  50216. /** @hidden */
  50217. _checkInputs(): void;
  50218. private _checkLimits;
  50219. /**
  50220. * Gets the camera class name.
  50221. * @returns the class name
  50222. */
  50223. getClassName(): string;
  50224. }
  50225. /**
  50226. * Arc Rotate version of the follow camera.
  50227. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  50228. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50229. */
  50230. export class ArcFollowCamera extends TargetCamera {
  50231. /** The longitudinal angle of the camera */
  50232. alpha: number;
  50233. /** The latitudinal angle of the camera */
  50234. beta: number;
  50235. /** The radius of the camera from its target */
  50236. radius: number;
  50237. private _cartesianCoordinates;
  50238. /** Define the camera target (the mesh it should follow) */
  50239. private _meshTarget;
  50240. /**
  50241. * Instantiates a new ArcFollowCamera
  50242. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50243. * @param name Define the name of the camera
  50244. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  50245. * @param beta Define the rotation angle of the camera around the elevation axis
  50246. * @param radius Define the radius of the camera from its target point
  50247. * @param target Define the target of the camera
  50248. * @param scene Define the scene the camera belongs to
  50249. */
  50250. constructor(name: string,
  50251. /** The longitudinal angle of the camera */
  50252. alpha: number,
  50253. /** The latitudinal angle of the camera */
  50254. beta: number,
  50255. /** The radius of the camera from its target */
  50256. radius: number,
  50257. /** Define the camera target (the mesh it should follow) */
  50258. target: Nullable<AbstractMesh>, scene: Scene);
  50259. private _follow;
  50260. /** @hidden */
  50261. _checkInputs(): void;
  50262. /**
  50263. * Returns the class name of the object.
  50264. * It is mostly used internally for serialization purposes.
  50265. */
  50266. getClassName(): string;
  50267. }
  50268. }
  50269. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  50270. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50271. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50272. /**
  50273. * Manage the keyboard inputs to control the movement of a follow camera.
  50274. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50275. */
  50276. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  50277. /**
  50278. * Defines the camera the input is attached to.
  50279. */
  50280. camera: FollowCamera;
  50281. /**
  50282. * Defines the list of key codes associated with the up action (increase heightOffset)
  50283. */
  50284. keysHeightOffsetIncr: number[];
  50285. /**
  50286. * Defines the list of key codes associated with the down action (decrease heightOffset)
  50287. */
  50288. keysHeightOffsetDecr: number[];
  50289. /**
  50290. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  50291. */
  50292. keysHeightOffsetModifierAlt: boolean;
  50293. /**
  50294. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  50295. */
  50296. keysHeightOffsetModifierCtrl: boolean;
  50297. /**
  50298. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  50299. */
  50300. keysHeightOffsetModifierShift: boolean;
  50301. /**
  50302. * Defines the list of key codes associated with the left action (increase rotationOffset)
  50303. */
  50304. keysRotationOffsetIncr: number[];
  50305. /**
  50306. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  50307. */
  50308. keysRotationOffsetDecr: number[];
  50309. /**
  50310. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  50311. */
  50312. keysRotationOffsetModifierAlt: boolean;
  50313. /**
  50314. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  50315. */
  50316. keysRotationOffsetModifierCtrl: boolean;
  50317. /**
  50318. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  50319. */
  50320. keysRotationOffsetModifierShift: boolean;
  50321. /**
  50322. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  50323. */
  50324. keysRadiusIncr: number[];
  50325. /**
  50326. * Defines the list of key codes associated with the zoom-out action (increase radius)
  50327. */
  50328. keysRadiusDecr: number[];
  50329. /**
  50330. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  50331. */
  50332. keysRadiusModifierAlt: boolean;
  50333. /**
  50334. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  50335. */
  50336. keysRadiusModifierCtrl: boolean;
  50337. /**
  50338. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  50339. */
  50340. keysRadiusModifierShift: boolean;
  50341. /**
  50342. * Defines the rate of change of heightOffset.
  50343. */
  50344. heightSensibility: number;
  50345. /**
  50346. * Defines the rate of change of rotationOffset.
  50347. */
  50348. rotationSensibility: number;
  50349. /**
  50350. * Defines the rate of change of radius.
  50351. */
  50352. radiusSensibility: number;
  50353. private _keys;
  50354. private _ctrlPressed;
  50355. private _altPressed;
  50356. private _shiftPressed;
  50357. private _onCanvasBlurObserver;
  50358. private _onKeyboardObserver;
  50359. private _engine;
  50360. private _scene;
  50361. /**
  50362. * Attach the input controls to a specific dom element to get the input from.
  50363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50364. */
  50365. attachControl(noPreventDefault?: boolean): void;
  50366. /**
  50367. * Detach the current controls from the specified dom element.
  50368. */
  50369. detachControl(): void;
  50370. /**
  50371. * Update the current camera state depending on the inputs that have been used this frame.
  50372. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50373. */
  50374. checkInputs(): void;
  50375. /**
  50376. * Gets the class name of the current input.
  50377. * @returns the class name
  50378. */
  50379. getClassName(): string;
  50380. /**
  50381. * Get the friendly name associated with the input class.
  50382. * @returns the input friendly name
  50383. */
  50384. getSimpleName(): string;
  50385. /**
  50386. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50387. * allow modification of the heightOffset value.
  50388. */
  50389. private _modifierHeightOffset;
  50390. /**
  50391. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50392. * allow modification of the rotationOffset value.
  50393. */
  50394. private _modifierRotationOffset;
  50395. /**
  50396. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50397. * allow modification of the radius value.
  50398. */
  50399. private _modifierRadius;
  50400. }
  50401. }
  50402. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  50403. import { Nullable } from "babylonjs/types";
  50404. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50405. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50406. import { Observable } from "babylonjs/Misc/observable";
  50407. module "babylonjs/Cameras/freeCameraInputsManager" {
  50408. interface FreeCameraInputsManager {
  50409. /**
  50410. * @hidden
  50411. */
  50412. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  50413. /**
  50414. * Add orientation input support to the input manager.
  50415. * @returns the current input manager
  50416. */
  50417. addDeviceOrientation(): FreeCameraInputsManager;
  50418. }
  50419. }
  50420. /**
  50421. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  50422. * Screen rotation is taken into account.
  50423. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50424. */
  50425. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  50426. private _camera;
  50427. private _screenOrientationAngle;
  50428. private _constantTranform;
  50429. private _screenQuaternion;
  50430. private _alpha;
  50431. private _beta;
  50432. private _gamma;
  50433. /**
  50434. * Can be used to detect if a device orientation sensor is available on a device
  50435. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  50436. * @returns a promise that will resolve on orientation change
  50437. */
  50438. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  50439. /**
  50440. * @hidden
  50441. */
  50442. _onDeviceOrientationChangedObservable: Observable<void>;
  50443. /**
  50444. * Instantiates a new input
  50445. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50446. */
  50447. constructor();
  50448. /**
  50449. * Define the camera controlled by the input.
  50450. */
  50451. get camera(): FreeCamera;
  50452. set camera(camera: FreeCamera);
  50453. /**
  50454. * Attach the input controls to a specific dom element to get the input from.
  50455. */
  50456. attachControl(): void;
  50457. private _orientationChanged;
  50458. private _deviceOrientation;
  50459. /**
  50460. * Detach the current controls from the specified dom element.
  50461. */
  50462. detachControl(): void;
  50463. /**
  50464. * Update the current camera state depending on the inputs that have been used this frame.
  50465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50466. */
  50467. checkInputs(): void;
  50468. /**
  50469. * Gets the class name of the current intput.
  50470. * @returns the class name
  50471. */
  50472. getClassName(): string;
  50473. /**
  50474. * Get the friendly name associated with the input class.
  50475. * @returns the input friendly name
  50476. */
  50477. getSimpleName(): string;
  50478. }
  50479. }
  50480. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  50481. import { Nullable } from "babylonjs/types";
  50482. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50483. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50484. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50485. /**
  50486. * Manage the gamepad inputs to control a free camera.
  50487. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50488. */
  50489. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  50490. /**
  50491. * Define the camera the input is attached to.
  50492. */
  50493. camera: FreeCamera;
  50494. /**
  50495. * Define the Gamepad controlling the input
  50496. */
  50497. gamepad: Nullable<Gamepad>;
  50498. /**
  50499. * Defines the gamepad rotation sensiblity.
  50500. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50501. */
  50502. gamepadAngularSensibility: number;
  50503. /**
  50504. * Defines the gamepad move sensiblity.
  50505. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50506. */
  50507. gamepadMoveSensibility: number;
  50508. private _yAxisScale;
  50509. /**
  50510. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50511. */
  50512. get invertYAxis(): boolean;
  50513. set invertYAxis(value: boolean);
  50514. private _onGamepadConnectedObserver;
  50515. private _onGamepadDisconnectedObserver;
  50516. private _cameraTransform;
  50517. private _deltaTransform;
  50518. private _vector3;
  50519. private _vector2;
  50520. /**
  50521. * Attach the input controls to a specific dom element to get the input from.
  50522. */
  50523. attachControl(): void;
  50524. /**
  50525. * Detach the current controls from the specified dom element.
  50526. */
  50527. detachControl(): void;
  50528. /**
  50529. * Update the current camera state depending on the inputs that have been used this frame.
  50530. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50531. */
  50532. checkInputs(): void;
  50533. /**
  50534. * Gets the class name of the current intput.
  50535. * @returns the class name
  50536. */
  50537. getClassName(): string;
  50538. /**
  50539. * Get the friendly name associated with the input class.
  50540. * @returns the input friendly name
  50541. */
  50542. getSimpleName(): string;
  50543. }
  50544. }
  50545. declare module "babylonjs/Misc/virtualJoystick" {
  50546. import { Nullable } from "babylonjs/types";
  50547. import { Vector3 } from "babylonjs/Maths/math.vector";
  50548. /**
  50549. * Defines the potential axis of a Joystick
  50550. */
  50551. export enum JoystickAxis {
  50552. /** X axis */
  50553. X = 0,
  50554. /** Y axis */
  50555. Y = 1,
  50556. /** Z axis */
  50557. Z = 2
  50558. }
  50559. /**
  50560. * Represents the different customization options available
  50561. * for VirtualJoystick
  50562. */
  50563. interface VirtualJoystickCustomizations {
  50564. /**
  50565. * Size of the joystick's puck
  50566. */
  50567. puckSize: number;
  50568. /**
  50569. * Size of the joystick's container
  50570. */
  50571. containerSize: number;
  50572. /**
  50573. * Color of the joystick && puck
  50574. */
  50575. color: string;
  50576. /**
  50577. * Image URL for the joystick's puck
  50578. */
  50579. puckImage?: string;
  50580. /**
  50581. * Image URL for the joystick's container
  50582. */
  50583. containerImage?: string;
  50584. /**
  50585. * Defines the unmoving position of the joystick container
  50586. */
  50587. position?: {
  50588. x: number;
  50589. y: number;
  50590. };
  50591. /**
  50592. * Defines whether or not the joystick container is always visible
  50593. */
  50594. alwaysVisible: boolean;
  50595. /**
  50596. * Defines whether or not to limit the movement of the puck to the joystick's container
  50597. */
  50598. limitToContainer: boolean;
  50599. }
  50600. /**
  50601. * Class used to define virtual joystick (used in touch mode)
  50602. */
  50603. export class VirtualJoystick {
  50604. /**
  50605. * Gets or sets a boolean indicating that left and right values must be inverted
  50606. */
  50607. reverseLeftRight: boolean;
  50608. /**
  50609. * Gets or sets a boolean indicating that up and down values must be inverted
  50610. */
  50611. reverseUpDown: boolean;
  50612. /**
  50613. * Gets the offset value for the position (ie. the change of the position value)
  50614. */
  50615. deltaPosition: Vector3;
  50616. /**
  50617. * Gets a boolean indicating if the virtual joystick was pressed
  50618. */
  50619. pressed: boolean;
  50620. /**
  50621. * Canvas the virtual joystick will render onto, default z-index of this is 5
  50622. */
  50623. static Canvas: Nullable<HTMLCanvasElement>;
  50624. /**
  50625. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  50626. */
  50627. limitToContainer: boolean;
  50628. private static _globalJoystickIndex;
  50629. private static _alwaysVisibleSticks;
  50630. private static vjCanvasContext;
  50631. private static vjCanvasWidth;
  50632. private static vjCanvasHeight;
  50633. private static halfWidth;
  50634. private static _GetDefaultOptions;
  50635. private _action;
  50636. private _axisTargetedByLeftAndRight;
  50637. private _axisTargetedByUpAndDown;
  50638. private _joystickSensibility;
  50639. private _inversedSensibility;
  50640. private _joystickPointerID;
  50641. private _joystickColor;
  50642. private _joystickPointerPos;
  50643. private _joystickPreviousPointerPos;
  50644. private _joystickPointerStartPos;
  50645. private _deltaJoystickVector;
  50646. private _leftJoystick;
  50647. private _touches;
  50648. private _joystickPosition;
  50649. private _alwaysVisible;
  50650. private _puckImage;
  50651. private _containerImage;
  50652. private _joystickPuckSize;
  50653. private _joystickContainerSize;
  50654. private _clearPuckSize;
  50655. private _clearContainerSize;
  50656. private _clearPuckSizeOffset;
  50657. private _clearContainerSizeOffset;
  50658. private _onPointerDownHandlerRef;
  50659. private _onPointerMoveHandlerRef;
  50660. private _onPointerUpHandlerRef;
  50661. private _onResize;
  50662. /**
  50663. * Creates a new virtual joystick
  50664. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50665. * @param customizations Defines the options we want to customize the VirtualJoystick
  50666. */
  50667. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50668. /**
  50669. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50670. * @param newJoystickSensibility defines the new sensibility
  50671. */
  50672. setJoystickSensibility(newJoystickSensibility: number): void;
  50673. private _onPointerDown;
  50674. private _onPointerMove;
  50675. private _onPointerUp;
  50676. /**
  50677. * Change the color of the virtual joystick
  50678. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50679. */
  50680. setJoystickColor(newColor: string): void;
  50681. /**
  50682. * Size of the joystick's container
  50683. */
  50684. set containerSize(newSize: number);
  50685. get containerSize(): number;
  50686. /**
  50687. * Size of the joystick's puck
  50688. */
  50689. set puckSize(newSize: number);
  50690. get puckSize(): number;
  50691. /**
  50692. * Clears the set position of the joystick
  50693. */
  50694. clearPosition(): void;
  50695. /**
  50696. * Defines whether or not the joystick container is always visible
  50697. */
  50698. set alwaysVisible(value: boolean);
  50699. get alwaysVisible(): boolean;
  50700. /**
  50701. * Sets the constant position of the Joystick container
  50702. * @param x X axis coordinate
  50703. * @param y Y axis coordinate
  50704. */
  50705. setPosition(x: number, y: number): void;
  50706. /**
  50707. * Defines a callback to call when the joystick is touched
  50708. * @param action defines the callback
  50709. */
  50710. setActionOnTouch(action: () => any): void;
  50711. /**
  50712. * Defines which axis you'd like to control for left & right
  50713. * @param axis defines the axis to use
  50714. */
  50715. setAxisForLeftRight(axis: JoystickAxis): void;
  50716. /**
  50717. * Defines which axis you'd like to control for up & down
  50718. * @param axis defines the axis to use
  50719. */
  50720. setAxisForUpDown(axis: JoystickAxis): void;
  50721. /**
  50722. * Clears the canvas from the previous puck / container draw
  50723. */
  50724. private _clearPreviousDraw;
  50725. /**
  50726. * Loads `urlPath` to be used for the container's image
  50727. * @param urlPath defines the urlPath of an image to use
  50728. */
  50729. setContainerImage(urlPath: string): void;
  50730. /**
  50731. * Loads `urlPath` to be used for the puck's image
  50732. * @param urlPath defines the urlPath of an image to use
  50733. */
  50734. setPuckImage(urlPath: string): void;
  50735. /**
  50736. * Draws the Virtual Joystick's container
  50737. */
  50738. private _drawContainer;
  50739. /**
  50740. * Draws the Virtual Joystick's puck
  50741. */
  50742. private _drawPuck;
  50743. private _drawVirtualJoystick;
  50744. /**
  50745. * Release internal HTML canvas
  50746. */
  50747. releaseCanvas(): void;
  50748. }
  50749. }
  50750. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50751. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50752. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50753. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50754. module "babylonjs/Cameras/freeCameraInputsManager" {
  50755. interface FreeCameraInputsManager {
  50756. /**
  50757. * Add virtual joystick input support to the input manager.
  50758. * @returns the current input manager
  50759. */
  50760. addVirtualJoystick(): FreeCameraInputsManager;
  50761. }
  50762. }
  50763. /**
  50764. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50765. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50766. */
  50767. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50768. /**
  50769. * Defines the camera the input is attached to.
  50770. */
  50771. camera: FreeCamera;
  50772. private _leftjoystick;
  50773. private _rightjoystick;
  50774. /**
  50775. * Gets the left stick of the virtual joystick.
  50776. * @returns The virtual Joystick
  50777. */
  50778. getLeftJoystick(): VirtualJoystick;
  50779. /**
  50780. * Gets the right stick of the virtual joystick.
  50781. * @returns The virtual Joystick
  50782. */
  50783. getRightJoystick(): VirtualJoystick;
  50784. /**
  50785. * Update the current camera state depending on the inputs that have been used this frame.
  50786. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50787. */
  50788. checkInputs(): void;
  50789. /**
  50790. * Attach the input controls to a specific dom element to get the input from.
  50791. */
  50792. attachControl(): void;
  50793. /**
  50794. * Detach the current controls from the specified dom element.
  50795. */
  50796. detachControl(): void;
  50797. /**
  50798. * Gets the class name of the current intput.
  50799. * @returns the class name
  50800. */
  50801. getClassName(): string;
  50802. /**
  50803. * Get the friendly name associated with the input class.
  50804. * @returns the input friendly name
  50805. */
  50806. getSimpleName(): string;
  50807. }
  50808. }
  50809. declare module "babylonjs/Cameras/Inputs/index" {
  50810. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50811. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50812. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50813. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50814. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50815. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50816. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50817. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50818. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50819. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50820. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50821. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50822. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50823. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50824. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  50825. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50826. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50827. }
  50828. declare module "babylonjs/Cameras/touchCamera" {
  50829. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50830. import { Scene } from "babylonjs/scene";
  50831. import { Vector3 } from "babylonjs/Maths/math.vector";
  50832. /**
  50833. * This represents a FPS type of camera controlled by touch.
  50834. * This is like a universal camera minus the Gamepad controls.
  50835. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50836. */
  50837. export class TouchCamera extends FreeCamera {
  50838. /**
  50839. * Defines the touch sensibility for rotation.
  50840. * The higher the faster.
  50841. */
  50842. get touchAngularSensibility(): number;
  50843. set touchAngularSensibility(value: number);
  50844. /**
  50845. * Defines the touch sensibility for move.
  50846. * The higher the faster.
  50847. */
  50848. get touchMoveSensibility(): number;
  50849. set touchMoveSensibility(value: number);
  50850. /**
  50851. * Instantiates a new touch camera.
  50852. * This represents a FPS type of camera controlled by touch.
  50853. * This is like a universal camera minus the Gamepad controls.
  50854. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50855. * @param name Define the name of the camera in the scene
  50856. * @param position Define the start position of the camera in the scene
  50857. * @param scene Define the scene the camera belongs to
  50858. */
  50859. constructor(name: string, position: Vector3, scene: Scene);
  50860. /**
  50861. * Gets the current object class name.
  50862. * @return the class name
  50863. */
  50864. getClassName(): string;
  50865. /** @hidden */
  50866. _setupInputs(): void;
  50867. }
  50868. }
  50869. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50870. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50871. import { Scene } from "babylonjs/scene";
  50872. import { Vector3 } from "babylonjs/Maths/math.vector";
  50873. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50874. import { Axis } from "babylonjs/Maths/math.axis";
  50875. /**
  50876. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50877. * being tilted forward or back and left or right.
  50878. */
  50879. export class DeviceOrientationCamera extends FreeCamera {
  50880. private _initialQuaternion;
  50881. private _quaternionCache;
  50882. private _tmpDragQuaternion;
  50883. private _disablePointerInputWhenUsingDeviceOrientation;
  50884. /**
  50885. * Creates a new device orientation camera
  50886. * @param name The name of the camera
  50887. * @param position The start position camera
  50888. * @param scene The scene the camera belongs to
  50889. */
  50890. constructor(name: string, position: Vector3, scene: Scene);
  50891. /**
  50892. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50893. */
  50894. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50895. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50896. private _dragFactor;
  50897. /**
  50898. * Enabled turning on the y axis when the orientation sensor is active
  50899. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50900. */
  50901. enableHorizontalDragging(dragFactor?: number): void;
  50902. /**
  50903. * Gets the current instance class name ("DeviceOrientationCamera").
  50904. * This helps avoiding instanceof at run time.
  50905. * @returns the class name
  50906. */
  50907. getClassName(): string;
  50908. /**
  50909. * @hidden
  50910. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50911. */
  50912. _checkInputs(): void;
  50913. /**
  50914. * Reset the camera to its default orientation on the specified axis only.
  50915. * @param axis The axis to reset
  50916. */
  50917. resetToCurrentRotation(axis?: Axis): void;
  50918. }
  50919. }
  50920. declare module "babylonjs/Gamepads/xboxGamepad" {
  50921. import { Observable } from "babylonjs/Misc/observable";
  50922. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50923. /**
  50924. * Defines supported buttons for XBox360 compatible gamepads
  50925. */
  50926. export enum Xbox360Button {
  50927. /** A */
  50928. A = 0,
  50929. /** B */
  50930. B = 1,
  50931. /** X */
  50932. X = 2,
  50933. /** Y */
  50934. Y = 3,
  50935. /** Left button */
  50936. LB = 4,
  50937. /** Right button */
  50938. RB = 5,
  50939. /** Back */
  50940. Back = 8,
  50941. /** Start */
  50942. Start = 9,
  50943. /** Left stick */
  50944. LeftStick = 10,
  50945. /** Right stick */
  50946. RightStick = 11
  50947. }
  50948. /** Defines values for XBox360 DPad */
  50949. export enum Xbox360Dpad {
  50950. /** Up */
  50951. Up = 12,
  50952. /** Down */
  50953. Down = 13,
  50954. /** Left */
  50955. Left = 14,
  50956. /** Right */
  50957. Right = 15
  50958. }
  50959. /**
  50960. * Defines a XBox360 gamepad
  50961. */
  50962. export class Xbox360Pad extends Gamepad {
  50963. private _leftTrigger;
  50964. private _rightTrigger;
  50965. private _onlefttriggerchanged;
  50966. private _onrighttriggerchanged;
  50967. private _onbuttondown;
  50968. private _onbuttonup;
  50969. private _ondpaddown;
  50970. private _ondpadup;
  50971. /** Observable raised when a button is pressed */
  50972. onButtonDownObservable: Observable<Xbox360Button>;
  50973. /** Observable raised when a button is released */
  50974. onButtonUpObservable: Observable<Xbox360Button>;
  50975. /** Observable raised when a pad is pressed */
  50976. onPadDownObservable: Observable<Xbox360Dpad>;
  50977. /** Observable raised when a pad is released */
  50978. onPadUpObservable: Observable<Xbox360Dpad>;
  50979. private _buttonA;
  50980. private _buttonB;
  50981. private _buttonX;
  50982. private _buttonY;
  50983. private _buttonBack;
  50984. private _buttonStart;
  50985. private _buttonLB;
  50986. private _buttonRB;
  50987. private _buttonLeftStick;
  50988. private _buttonRightStick;
  50989. private _dPadUp;
  50990. private _dPadDown;
  50991. private _dPadLeft;
  50992. private _dPadRight;
  50993. private _isXboxOnePad;
  50994. /**
  50995. * Creates a new XBox360 gamepad object
  50996. * @param id defines the id of this gamepad
  50997. * @param index defines its index
  50998. * @param gamepad defines the internal HTML gamepad object
  50999. * @param xboxOne defines if it is a XBox One gamepad
  51000. */
  51001. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  51002. /**
  51003. * Defines the callback to call when left trigger is pressed
  51004. * @param callback defines the callback to use
  51005. */
  51006. onlefttriggerchanged(callback: (value: number) => void): void;
  51007. /**
  51008. * Defines the callback to call when right trigger is pressed
  51009. * @param callback defines the callback to use
  51010. */
  51011. onrighttriggerchanged(callback: (value: number) => void): void;
  51012. /**
  51013. * Gets the left trigger value
  51014. */
  51015. get leftTrigger(): number;
  51016. /**
  51017. * Sets the left trigger value
  51018. */
  51019. set leftTrigger(newValue: number);
  51020. /**
  51021. * Gets the right trigger value
  51022. */
  51023. get rightTrigger(): number;
  51024. /**
  51025. * Sets the right trigger value
  51026. */
  51027. set rightTrigger(newValue: number);
  51028. /**
  51029. * Defines the callback to call when a button is pressed
  51030. * @param callback defines the callback to use
  51031. */
  51032. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  51033. /**
  51034. * Defines the callback to call when a button is released
  51035. * @param callback defines the callback to use
  51036. */
  51037. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  51038. /**
  51039. * Defines the callback to call when a pad is pressed
  51040. * @param callback defines the callback to use
  51041. */
  51042. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  51043. /**
  51044. * Defines the callback to call when a pad is released
  51045. * @param callback defines the callback to use
  51046. */
  51047. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  51048. private _setButtonValue;
  51049. private _setDPadValue;
  51050. /**
  51051. * Gets the value of the `A` button
  51052. */
  51053. get buttonA(): number;
  51054. /**
  51055. * Sets the value of the `A` button
  51056. */
  51057. set buttonA(value: number);
  51058. /**
  51059. * Gets the value of the `B` button
  51060. */
  51061. get buttonB(): number;
  51062. /**
  51063. * Sets the value of the `B` button
  51064. */
  51065. set buttonB(value: number);
  51066. /**
  51067. * Gets the value of the `X` button
  51068. */
  51069. get buttonX(): number;
  51070. /**
  51071. * Sets the value of the `X` button
  51072. */
  51073. set buttonX(value: number);
  51074. /**
  51075. * Gets the value of the `Y` button
  51076. */
  51077. get buttonY(): number;
  51078. /**
  51079. * Sets the value of the `Y` button
  51080. */
  51081. set buttonY(value: number);
  51082. /**
  51083. * Gets the value of the `Start` button
  51084. */
  51085. get buttonStart(): number;
  51086. /**
  51087. * Sets the value of the `Start` button
  51088. */
  51089. set buttonStart(value: number);
  51090. /**
  51091. * Gets the value of the `Back` button
  51092. */
  51093. get buttonBack(): number;
  51094. /**
  51095. * Sets the value of the `Back` button
  51096. */
  51097. set buttonBack(value: number);
  51098. /**
  51099. * Gets the value of the `Left` button
  51100. */
  51101. get buttonLB(): number;
  51102. /**
  51103. * Sets the value of the `Left` button
  51104. */
  51105. set buttonLB(value: number);
  51106. /**
  51107. * Gets the value of the `Right` button
  51108. */
  51109. get buttonRB(): number;
  51110. /**
  51111. * Sets the value of the `Right` button
  51112. */
  51113. set buttonRB(value: number);
  51114. /**
  51115. * Gets the value of the Left joystick
  51116. */
  51117. get buttonLeftStick(): number;
  51118. /**
  51119. * Sets the value of the Left joystick
  51120. */
  51121. set buttonLeftStick(value: number);
  51122. /**
  51123. * Gets the value of the Right joystick
  51124. */
  51125. get buttonRightStick(): number;
  51126. /**
  51127. * Sets the value of the Right joystick
  51128. */
  51129. set buttonRightStick(value: number);
  51130. /**
  51131. * Gets the value of D-pad up
  51132. */
  51133. get dPadUp(): number;
  51134. /**
  51135. * Sets the value of D-pad up
  51136. */
  51137. set dPadUp(value: number);
  51138. /**
  51139. * Gets the value of D-pad down
  51140. */
  51141. get dPadDown(): number;
  51142. /**
  51143. * Sets the value of D-pad down
  51144. */
  51145. set dPadDown(value: number);
  51146. /**
  51147. * Gets the value of D-pad left
  51148. */
  51149. get dPadLeft(): number;
  51150. /**
  51151. * Sets the value of D-pad left
  51152. */
  51153. set dPadLeft(value: number);
  51154. /**
  51155. * Gets the value of D-pad right
  51156. */
  51157. get dPadRight(): number;
  51158. /**
  51159. * Sets the value of D-pad right
  51160. */
  51161. set dPadRight(value: number);
  51162. /**
  51163. * Force the gamepad to synchronize with device values
  51164. */
  51165. update(): void;
  51166. /**
  51167. * Disposes the gamepad
  51168. */
  51169. dispose(): void;
  51170. }
  51171. }
  51172. declare module "babylonjs/Gamepads/dualShockGamepad" {
  51173. import { Observable } from "babylonjs/Misc/observable";
  51174. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51175. /**
  51176. * Defines supported buttons for DualShock compatible gamepads
  51177. */
  51178. export enum DualShockButton {
  51179. /** Cross */
  51180. Cross = 0,
  51181. /** Circle */
  51182. Circle = 1,
  51183. /** Square */
  51184. Square = 2,
  51185. /** Triangle */
  51186. Triangle = 3,
  51187. /** L1 */
  51188. L1 = 4,
  51189. /** R1 */
  51190. R1 = 5,
  51191. /** Share */
  51192. Share = 8,
  51193. /** Options */
  51194. Options = 9,
  51195. /** Left stick */
  51196. LeftStick = 10,
  51197. /** Right stick */
  51198. RightStick = 11
  51199. }
  51200. /** Defines values for DualShock DPad */
  51201. export enum DualShockDpad {
  51202. /** Up */
  51203. Up = 12,
  51204. /** Down */
  51205. Down = 13,
  51206. /** Left */
  51207. Left = 14,
  51208. /** Right */
  51209. Right = 15
  51210. }
  51211. /**
  51212. * Defines a DualShock gamepad
  51213. */
  51214. export class DualShockPad extends Gamepad {
  51215. private _leftTrigger;
  51216. private _rightTrigger;
  51217. private _onlefttriggerchanged;
  51218. private _onrighttriggerchanged;
  51219. private _onbuttondown;
  51220. private _onbuttonup;
  51221. private _ondpaddown;
  51222. private _ondpadup;
  51223. /** Observable raised when a button is pressed */
  51224. onButtonDownObservable: Observable<DualShockButton>;
  51225. /** Observable raised when a button is released */
  51226. onButtonUpObservable: Observable<DualShockButton>;
  51227. /** Observable raised when a pad is pressed */
  51228. onPadDownObservable: Observable<DualShockDpad>;
  51229. /** Observable raised when a pad is released */
  51230. onPadUpObservable: Observable<DualShockDpad>;
  51231. private _buttonCross;
  51232. private _buttonCircle;
  51233. private _buttonSquare;
  51234. private _buttonTriangle;
  51235. private _buttonShare;
  51236. private _buttonOptions;
  51237. private _buttonL1;
  51238. private _buttonR1;
  51239. private _buttonLeftStick;
  51240. private _buttonRightStick;
  51241. private _dPadUp;
  51242. private _dPadDown;
  51243. private _dPadLeft;
  51244. private _dPadRight;
  51245. /**
  51246. * Creates a new DualShock gamepad object
  51247. * @param id defines the id of this gamepad
  51248. * @param index defines its index
  51249. * @param gamepad defines the internal HTML gamepad object
  51250. */
  51251. constructor(id: string, index: number, gamepad: any);
  51252. /**
  51253. * Defines the callback to call when left trigger is pressed
  51254. * @param callback defines the callback to use
  51255. */
  51256. onlefttriggerchanged(callback: (value: number) => void): void;
  51257. /**
  51258. * Defines the callback to call when right trigger is pressed
  51259. * @param callback defines the callback to use
  51260. */
  51261. onrighttriggerchanged(callback: (value: number) => void): void;
  51262. /**
  51263. * Gets the left trigger value
  51264. */
  51265. get leftTrigger(): number;
  51266. /**
  51267. * Sets the left trigger value
  51268. */
  51269. set leftTrigger(newValue: number);
  51270. /**
  51271. * Gets the right trigger value
  51272. */
  51273. get rightTrigger(): number;
  51274. /**
  51275. * Sets the right trigger value
  51276. */
  51277. set rightTrigger(newValue: number);
  51278. /**
  51279. * Defines the callback to call when a button is pressed
  51280. * @param callback defines the callback to use
  51281. */
  51282. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  51283. /**
  51284. * Defines the callback to call when a button is released
  51285. * @param callback defines the callback to use
  51286. */
  51287. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  51288. /**
  51289. * Defines the callback to call when a pad is pressed
  51290. * @param callback defines the callback to use
  51291. */
  51292. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  51293. /**
  51294. * Defines the callback to call when a pad is released
  51295. * @param callback defines the callback to use
  51296. */
  51297. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  51298. private _setButtonValue;
  51299. private _setDPadValue;
  51300. /**
  51301. * Gets the value of the `Cross` button
  51302. */
  51303. get buttonCross(): number;
  51304. /**
  51305. * Sets the value of the `Cross` button
  51306. */
  51307. set buttonCross(value: number);
  51308. /**
  51309. * Gets the value of the `Circle` button
  51310. */
  51311. get buttonCircle(): number;
  51312. /**
  51313. * Sets the value of the `Circle` button
  51314. */
  51315. set buttonCircle(value: number);
  51316. /**
  51317. * Gets the value of the `Square` button
  51318. */
  51319. get buttonSquare(): number;
  51320. /**
  51321. * Sets the value of the `Square` button
  51322. */
  51323. set buttonSquare(value: number);
  51324. /**
  51325. * Gets the value of the `Triangle` button
  51326. */
  51327. get buttonTriangle(): number;
  51328. /**
  51329. * Sets the value of the `Triangle` button
  51330. */
  51331. set buttonTriangle(value: number);
  51332. /**
  51333. * Gets the value of the `Options` button
  51334. */
  51335. get buttonOptions(): number;
  51336. /**
  51337. * Sets the value of the `Options` button
  51338. */
  51339. set buttonOptions(value: number);
  51340. /**
  51341. * Gets the value of the `Share` button
  51342. */
  51343. get buttonShare(): number;
  51344. /**
  51345. * Sets the value of the `Share` button
  51346. */
  51347. set buttonShare(value: number);
  51348. /**
  51349. * Gets the value of the `L1` button
  51350. */
  51351. get buttonL1(): number;
  51352. /**
  51353. * Sets the value of the `L1` button
  51354. */
  51355. set buttonL1(value: number);
  51356. /**
  51357. * Gets the value of the `R1` button
  51358. */
  51359. get buttonR1(): number;
  51360. /**
  51361. * Sets the value of the `R1` button
  51362. */
  51363. set buttonR1(value: number);
  51364. /**
  51365. * Gets the value of the Left joystick
  51366. */
  51367. get buttonLeftStick(): number;
  51368. /**
  51369. * Sets the value of the Left joystick
  51370. */
  51371. set buttonLeftStick(value: number);
  51372. /**
  51373. * Gets the value of the Right joystick
  51374. */
  51375. get buttonRightStick(): number;
  51376. /**
  51377. * Sets the value of the Right joystick
  51378. */
  51379. set buttonRightStick(value: number);
  51380. /**
  51381. * Gets the value of D-pad up
  51382. */
  51383. get dPadUp(): number;
  51384. /**
  51385. * Sets the value of D-pad up
  51386. */
  51387. set dPadUp(value: number);
  51388. /**
  51389. * Gets the value of D-pad down
  51390. */
  51391. get dPadDown(): number;
  51392. /**
  51393. * Sets the value of D-pad down
  51394. */
  51395. set dPadDown(value: number);
  51396. /**
  51397. * Gets the value of D-pad left
  51398. */
  51399. get dPadLeft(): number;
  51400. /**
  51401. * Sets the value of D-pad left
  51402. */
  51403. set dPadLeft(value: number);
  51404. /**
  51405. * Gets the value of D-pad right
  51406. */
  51407. get dPadRight(): number;
  51408. /**
  51409. * Sets the value of D-pad right
  51410. */
  51411. set dPadRight(value: number);
  51412. /**
  51413. * Force the gamepad to synchronize with device values
  51414. */
  51415. update(): void;
  51416. /**
  51417. * Disposes the gamepad
  51418. */
  51419. dispose(): void;
  51420. }
  51421. }
  51422. declare module "babylonjs/Gamepads/gamepadManager" {
  51423. import { Observable } from "babylonjs/Misc/observable";
  51424. import { Nullable } from "babylonjs/types";
  51425. import { Scene } from "babylonjs/scene";
  51426. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51427. /**
  51428. * Manager for handling gamepads
  51429. */
  51430. export class GamepadManager {
  51431. private _scene?;
  51432. private _babylonGamepads;
  51433. private _oneGamepadConnected;
  51434. /** @hidden */
  51435. _isMonitoring: boolean;
  51436. private _gamepadEventSupported;
  51437. private _gamepadSupport?;
  51438. /**
  51439. * observable to be triggered when the gamepad controller has been connected
  51440. */
  51441. onGamepadConnectedObservable: Observable<Gamepad>;
  51442. /**
  51443. * observable to be triggered when the gamepad controller has been disconnected
  51444. */
  51445. onGamepadDisconnectedObservable: Observable<Gamepad>;
  51446. private _onGamepadConnectedEvent;
  51447. private _onGamepadDisconnectedEvent;
  51448. /**
  51449. * Initializes the gamepad manager
  51450. * @param _scene BabylonJS scene
  51451. */
  51452. constructor(_scene?: Scene | undefined);
  51453. /**
  51454. * The gamepads in the game pad manager
  51455. */
  51456. get gamepads(): Gamepad[];
  51457. /**
  51458. * Get the gamepad controllers based on type
  51459. * @param type The type of gamepad controller
  51460. * @returns Nullable gamepad
  51461. */
  51462. getGamepadByType(type?: number): Nullable<Gamepad>;
  51463. /**
  51464. * Disposes the gamepad manager
  51465. */
  51466. dispose(): void;
  51467. private _addNewGamepad;
  51468. private _startMonitoringGamepads;
  51469. private _stopMonitoringGamepads;
  51470. /** @hidden */
  51471. _checkGamepadsStatus(): void;
  51472. private _updateGamepadObjects;
  51473. }
  51474. }
  51475. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  51476. import { Nullable } from "babylonjs/types";
  51477. import { Scene } from "babylonjs/scene";
  51478. import { ISceneComponent } from "babylonjs/sceneComponent";
  51479. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  51480. module "babylonjs/scene" {
  51481. interface Scene {
  51482. /** @hidden */
  51483. _gamepadManager: Nullable<GamepadManager>;
  51484. /**
  51485. * Gets the gamepad manager associated with the scene
  51486. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  51487. */
  51488. gamepadManager: GamepadManager;
  51489. }
  51490. }
  51491. module "babylonjs/Cameras/freeCameraInputsManager" {
  51492. /**
  51493. * Interface representing a free camera inputs manager
  51494. */
  51495. interface FreeCameraInputsManager {
  51496. /**
  51497. * Adds gamepad input support to the FreeCameraInputsManager.
  51498. * @returns the FreeCameraInputsManager
  51499. */
  51500. addGamepad(): FreeCameraInputsManager;
  51501. }
  51502. }
  51503. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51504. /**
  51505. * Interface representing an arc rotate camera inputs manager
  51506. */
  51507. interface ArcRotateCameraInputsManager {
  51508. /**
  51509. * Adds gamepad input support to the ArcRotateCamera InputManager.
  51510. * @returns the camera inputs manager
  51511. */
  51512. addGamepad(): ArcRotateCameraInputsManager;
  51513. }
  51514. }
  51515. /**
  51516. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  51517. */
  51518. export class GamepadSystemSceneComponent implements ISceneComponent {
  51519. /**
  51520. * The component name helpfull to identify the component in the list of scene components.
  51521. */
  51522. readonly name: string;
  51523. /**
  51524. * The scene the component belongs to.
  51525. */
  51526. scene: Scene;
  51527. /**
  51528. * Creates a new instance of the component for the given scene
  51529. * @param scene Defines the scene to register the component in
  51530. */
  51531. constructor(scene: Scene);
  51532. /**
  51533. * Registers the component in a given scene
  51534. */
  51535. register(): void;
  51536. /**
  51537. * Rebuilds the elements related to this component in case of
  51538. * context lost for instance.
  51539. */
  51540. rebuild(): void;
  51541. /**
  51542. * Disposes the component and the associated ressources
  51543. */
  51544. dispose(): void;
  51545. private _beforeCameraUpdate;
  51546. }
  51547. }
  51548. declare module "babylonjs/Cameras/universalCamera" {
  51549. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  51550. import { Scene } from "babylonjs/scene";
  51551. import { Vector3 } from "babylonjs/Maths/math.vector";
  51552. import "babylonjs/Gamepads/gamepadSceneComponent";
  51553. /**
  51554. * 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,
  51555. * which still works and will still be found in many Playgrounds.
  51556. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51557. */
  51558. export class UniversalCamera extends TouchCamera {
  51559. /**
  51560. * Defines the gamepad rotation sensiblity.
  51561. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51562. */
  51563. get gamepadAngularSensibility(): number;
  51564. set gamepadAngularSensibility(value: number);
  51565. /**
  51566. * Defines the gamepad move sensiblity.
  51567. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51568. */
  51569. get gamepadMoveSensibility(): number;
  51570. set gamepadMoveSensibility(value: number);
  51571. /**
  51572. * 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,
  51573. * which still works and will still be found in many Playgrounds.
  51574. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51575. * @param name Define the name of the camera in the scene
  51576. * @param position Define the start position of the camera in the scene
  51577. * @param scene Define the scene the camera belongs to
  51578. */
  51579. constructor(name: string, position: Vector3, scene: Scene);
  51580. /**
  51581. * Gets the current object class name.
  51582. * @return the class name
  51583. */
  51584. getClassName(): string;
  51585. }
  51586. }
  51587. declare module "babylonjs/Cameras/gamepadCamera" {
  51588. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51589. import { Scene } from "babylonjs/scene";
  51590. import { Vector3 } from "babylonjs/Maths/math.vector";
  51591. /**
  51592. * This represents a FPS type of camera. This is only here for back compat purpose.
  51593. * Please use the UniversalCamera instead as both are identical.
  51594. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51595. */
  51596. export class GamepadCamera extends UniversalCamera {
  51597. /**
  51598. * Instantiates a new Gamepad Camera
  51599. * This represents a FPS type of camera. This is only here for back compat purpose.
  51600. * Please use the UniversalCamera instead as both are identical.
  51601. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51602. * @param name Define the name of the camera in the scene
  51603. * @param position Define the start position of the camera in the scene
  51604. * @param scene Define the scene the camera belongs to
  51605. */
  51606. constructor(name: string, position: Vector3, scene: Scene);
  51607. /**
  51608. * Gets the current object class name.
  51609. * @return the class name
  51610. */
  51611. getClassName(): string;
  51612. }
  51613. }
  51614. declare module "babylonjs/Shaders/pass.fragment" {
  51615. /** @hidden */
  51616. export var passPixelShader: {
  51617. name: string;
  51618. shader: string;
  51619. };
  51620. }
  51621. declare module "babylonjs/Shaders/passCube.fragment" {
  51622. /** @hidden */
  51623. export var passCubePixelShader: {
  51624. name: string;
  51625. shader: string;
  51626. };
  51627. }
  51628. declare module "babylonjs/PostProcesses/passPostProcess" {
  51629. import { Nullable } from "babylonjs/types";
  51630. import { Camera } from "babylonjs/Cameras/camera";
  51631. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51632. import { Engine } from "babylonjs/Engines/engine";
  51633. import "babylonjs/Shaders/pass.fragment";
  51634. import "babylonjs/Shaders/passCube.fragment";
  51635. import { Scene } from "babylonjs/scene";
  51636. /**
  51637. * PassPostProcess which produces an output the same as it's input
  51638. */
  51639. export class PassPostProcess extends PostProcess {
  51640. /**
  51641. * Gets a string identifying the name of the class
  51642. * @returns "PassPostProcess" string
  51643. */
  51644. getClassName(): string;
  51645. /**
  51646. * Creates the PassPostProcess
  51647. * @param name The name of the effect.
  51648. * @param options The required width/height ratio to downsize to before computing the render pass.
  51649. * @param camera The camera to apply the render pass to.
  51650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51651. * @param engine The engine which the post process will be applied. (default: current engine)
  51652. * @param reusable If the post process can be reused on the same frame. (default: false)
  51653. * @param textureType The type of texture to be used when performing the post processing.
  51654. * @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)
  51655. */
  51656. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51657. /** @hidden */
  51658. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51659. }
  51660. /**
  51661. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51662. */
  51663. export class PassCubePostProcess extends PostProcess {
  51664. private _face;
  51665. /**
  51666. * Gets or sets the cube face to display.
  51667. * * 0 is +X
  51668. * * 1 is -X
  51669. * * 2 is +Y
  51670. * * 3 is -Y
  51671. * * 4 is +Z
  51672. * * 5 is -Z
  51673. */
  51674. get face(): number;
  51675. set face(value: number);
  51676. /**
  51677. * Gets a string identifying the name of the class
  51678. * @returns "PassCubePostProcess" string
  51679. */
  51680. getClassName(): string;
  51681. /**
  51682. * Creates the PassCubePostProcess
  51683. * @param name The name of the effect.
  51684. * @param options The required width/height ratio to downsize to before computing the render pass.
  51685. * @param camera The camera to apply the render pass to.
  51686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51687. * @param engine The engine which the post process will be applied. (default: current engine)
  51688. * @param reusable If the post process can be reused on the same frame. (default: false)
  51689. * @param textureType The type of texture to be used when performing the post processing.
  51690. * @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)
  51691. */
  51692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51693. /** @hidden */
  51694. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51695. }
  51696. }
  51697. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51698. /** @hidden */
  51699. export var anaglyphPixelShader: {
  51700. name: string;
  51701. shader: string;
  51702. };
  51703. }
  51704. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51705. import { Engine } from "babylonjs/Engines/engine";
  51706. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51707. import { Camera } from "babylonjs/Cameras/camera";
  51708. import "babylonjs/Shaders/anaglyph.fragment";
  51709. /**
  51710. * Postprocess used to generate anaglyphic rendering
  51711. */
  51712. export class AnaglyphPostProcess extends PostProcess {
  51713. private _passedProcess;
  51714. /**
  51715. * Gets a string identifying the name of the class
  51716. * @returns "AnaglyphPostProcess" string
  51717. */
  51718. getClassName(): string;
  51719. /**
  51720. * Creates a new AnaglyphPostProcess
  51721. * @param name defines postprocess name
  51722. * @param options defines creation options or target ratio scale
  51723. * @param rigCameras defines cameras using this postprocess
  51724. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51725. * @param engine defines hosting engine
  51726. * @param reusable defines if the postprocess will be reused multiple times per frame
  51727. */
  51728. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51729. }
  51730. }
  51731. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51732. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51733. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51734. import { Scene } from "babylonjs/scene";
  51735. import { Vector3 } from "babylonjs/Maths/math.vector";
  51736. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51737. /**
  51738. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51739. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51740. */
  51741. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51742. /**
  51743. * Creates a new AnaglyphArcRotateCamera
  51744. * @param name defines camera name
  51745. * @param alpha defines alpha angle (in radians)
  51746. * @param beta defines beta angle (in radians)
  51747. * @param radius defines radius
  51748. * @param target defines camera target
  51749. * @param interaxialDistance defines distance between each color axis
  51750. * @param scene defines the hosting scene
  51751. */
  51752. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51753. /**
  51754. * Gets camera class name
  51755. * @returns AnaglyphArcRotateCamera
  51756. */
  51757. getClassName(): string;
  51758. }
  51759. }
  51760. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51761. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51762. import { Scene } from "babylonjs/scene";
  51763. import { Vector3 } from "babylonjs/Maths/math.vector";
  51764. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51765. /**
  51766. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51767. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51768. */
  51769. export class AnaglyphFreeCamera extends FreeCamera {
  51770. /**
  51771. * Creates a new AnaglyphFreeCamera
  51772. * @param name defines camera name
  51773. * @param position defines initial position
  51774. * @param interaxialDistance defines distance between each color axis
  51775. * @param scene defines the hosting scene
  51776. */
  51777. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51778. /**
  51779. * Gets camera class name
  51780. * @returns AnaglyphFreeCamera
  51781. */
  51782. getClassName(): string;
  51783. }
  51784. }
  51785. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51786. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51787. import { Scene } from "babylonjs/scene";
  51788. import { Vector3 } from "babylonjs/Maths/math.vector";
  51789. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51790. /**
  51791. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51792. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51793. */
  51794. export class AnaglyphGamepadCamera extends GamepadCamera {
  51795. /**
  51796. * Creates a new AnaglyphGamepadCamera
  51797. * @param name defines camera name
  51798. * @param position defines initial position
  51799. * @param interaxialDistance defines distance between each color axis
  51800. * @param scene defines the hosting scene
  51801. */
  51802. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51803. /**
  51804. * Gets camera class name
  51805. * @returns AnaglyphGamepadCamera
  51806. */
  51807. getClassName(): string;
  51808. }
  51809. }
  51810. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51811. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51812. import { Scene } from "babylonjs/scene";
  51813. import { Vector3 } from "babylonjs/Maths/math.vector";
  51814. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51815. /**
  51816. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51817. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51818. */
  51819. export class AnaglyphUniversalCamera extends UniversalCamera {
  51820. /**
  51821. * Creates a new AnaglyphUniversalCamera
  51822. * @param name defines camera name
  51823. * @param position defines initial position
  51824. * @param interaxialDistance defines distance between each color axis
  51825. * @param scene defines the hosting scene
  51826. */
  51827. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51828. /**
  51829. * Gets camera class name
  51830. * @returns AnaglyphUniversalCamera
  51831. */
  51832. getClassName(): string;
  51833. }
  51834. }
  51835. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51836. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51837. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51838. import { Scene } from "babylonjs/scene";
  51839. import { Vector3 } from "babylonjs/Maths/math.vector";
  51840. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51841. /**
  51842. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51843. * @see https://doc.babylonjs.com/features/cameras
  51844. */
  51845. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51846. /**
  51847. * Creates a new StereoscopicArcRotateCamera
  51848. * @param name defines camera name
  51849. * @param alpha defines alpha angle (in radians)
  51850. * @param beta defines beta angle (in radians)
  51851. * @param radius defines radius
  51852. * @param target defines camera target
  51853. * @param interaxialDistance defines distance between each color axis
  51854. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51855. * @param scene defines the hosting scene
  51856. */
  51857. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51858. /**
  51859. * Gets camera class name
  51860. * @returns StereoscopicArcRotateCamera
  51861. */
  51862. getClassName(): string;
  51863. }
  51864. }
  51865. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51866. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51867. import { Scene } from "babylonjs/scene";
  51868. import { Vector3 } from "babylonjs/Maths/math.vector";
  51869. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51870. /**
  51871. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51872. * @see https://doc.babylonjs.com/features/cameras
  51873. */
  51874. export class StereoscopicFreeCamera extends FreeCamera {
  51875. /**
  51876. * Creates a new StereoscopicFreeCamera
  51877. * @param name defines camera name
  51878. * @param position defines initial position
  51879. * @param interaxialDistance defines distance between each color axis
  51880. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51881. * @param scene defines the hosting scene
  51882. */
  51883. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51884. /**
  51885. * Gets camera class name
  51886. * @returns StereoscopicFreeCamera
  51887. */
  51888. getClassName(): string;
  51889. }
  51890. }
  51891. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51892. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51893. import { Scene } from "babylonjs/scene";
  51894. import { Vector3 } from "babylonjs/Maths/math.vector";
  51895. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51896. /**
  51897. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51898. * @see https://doc.babylonjs.com/features/cameras
  51899. */
  51900. export class StereoscopicGamepadCamera extends GamepadCamera {
  51901. /**
  51902. * Creates a new StereoscopicGamepadCamera
  51903. * @param name defines camera name
  51904. * @param position defines initial position
  51905. * @param interaxialDistance defines distance between each color axis
  51906. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51907. * @param scene defines the hosting scene
  51908. */
  51909. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51910. /**
  51911. * Gets camera class name
  51912. * @returns StereoscopicGamepadCamera
  51913. */
  51914. getClassName(): string;
  51915. }
  51916. }
  51917. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51918. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51919. import { Scene } from "babylonjs/scene";
  51920. import { Vector3 } from "babylonjs/Maths/math.vector";
  51921. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51922. /**
  51923. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51924. * @see https://doc.babylonjs.com/features/cameras
  51925. */
  51926. export class StereoscopicUniversalCamera extends UniversalCamera {
  51927. /**
  51928. * Creates a new StereoscopicUniversalCamera
  51929. * @param name defines camera name
  51930. * @param position defines initial position
  51931. * @param interaxialDistance defines distance between each color axis
  51932. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51933. * @param scene defines the hosting scene
  51934. */
  51935. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51936. /**
  51937. * Gets camera class name
  51938. * @returns StereoscopicUniversalCamera
  51939. */
  51940. getClassName(): string;
  51941. }
  51942. }
  51943. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51944. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51945. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51946. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51947. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51948. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51949. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51950. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51951. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51952. }
  51953. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51954. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51955. import { Scene } from "babylonjs/scene";
  51956. import { Vector3 } from "babylonjs/Maths/math.vector";
  51957. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51958. /**
  51959. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51960. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51961. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51962. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51963. */
  51964. export class VirtualJoysticksCamera extends FreeCamera {
  51965. /**
  51966. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51967. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51968. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51969. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51970. * @param name Define the name of the camera in the scene
  51971. * @param position Define the start position of the camera in the scene
  51972. * @param scene Define the scene the camera belongs to
  51973. */
  51974. constructor(name: string, position: Vector3, scene: Scene);
  51975. /**
  51976. * Gets the current object class name.
  51977. * @return the class name
  51978. */
  51979. getClassName(): string;
  51980. }
  51981. }
  51982. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51983. import { Matrix } from "babylonjs/Maths/math.vector";
  51984. /**
  51985. * This represents all the required metrics to create a VR camera.
  51986. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51987. */
  51988. export class VRCameraMetrics {
  51989. /**
  51990. * Define the horizontal resolution off the screen.
  51991. */
  51992. hResolution: number;
  51993. /**
  51994. * Define the vertical resolution off the screen.
  51995. */
  51996. vResolution: number;
  51997. /**
  51998. * Define the horizontal screen size.
  51999. */
  52000. hScreenSize: number;
  52001. /**
  52002. * Define the vertical screen size.
  52003. */
  52004. vScreenSize: number;
  52005. /**
  52006. * Define the vertical screen center position.
  52007. */
  52008. vScreenCenter: number;
  52009. /**
  52010. * Define the distance of the eyes to the screen.
  52011. */
  52012. eyeToScreenDistance: number;
  52013. /**
  52014. * Define the distance between both lenses
  52015. */
  52016. lensSeparationDistance: number;
  52017. /**
  52018. * Define the distance between both viewer's eyes.
  52019. */
  52020. interpupillaryDistance: number;
  52021. /**
  52022. * Define the distortion factor of the VR postprocess.
  52023. * Please, touch with care.
  52024. */
  52025. distortionK: number[];
  52026. /**
  52027. * Define the chromatic aberration correction factors for the VR post process.
  52028. */
  52029. chromaAbCorrection: number[];
  52030. /**
  52031. * Define the scale factor of the post process.
  52032. * The smaller the better but the slower.
  52033. */
  52034. postProcessScaleFactor: number;
  52035. /**
  52036. * Define an offset for the lens center.
  52037. */
  52038. lensCenterOffset: number;
  52039. /**
  52040. * Define if the current vr camera should compensate the distortion of the lense or not.
  52041. */
  52042. compensateDistortion: boolean;
  52043. /**
  52044. * Defines if multiview should be enabled when rendering (Default: false)
  52045. */
  52046. multiviewEnabled: boolean;
  52047. /**
  52048. * Gets the rendering aspect ratio based on the provided resolutions.
  52049. */
  52050. get aspectRatio(): number;
  52051. /**
  52052. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  52053. */
  52054. get aspectRatioFov(): number;
  52055. /**
  52056. * @hidden
  52057. */
  52058. get leftHMatrix(): Matrix;
  52059. /**
  52060. * @hidden
  52061. */
  52062. get rightHMatrix(): Matrix;
  52063. /**
  52064. * @hidden
  52065. */
  52066. get leftPreViewMatrix(): Matrix;
  52067. /**
  52068. * @hidden
  52069. */
  52070. get rightPreViewMatrix(): Matrix;
  52071. /**
  52072. * Get the default VRMetrics based on the most generic setup.
  52073. * @returns the default vr metrics
  52074. */
  52075. static GetDefault(): VRCameraMetrics;
  52076. }
  52077. }
  52078. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  52079. /** @hidden */
  52080. export var vrDistortionCorrectionPixelShader: {
  52081. name: string;
  52082. shader: string;
  52083. };
  52084. }
  52085. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  52086. import { Camera } from "babylonjs/Cameras/camera";
  52087. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52088. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52089. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  52090. /**
  52091. * VRDistortionCorrectionPostProcess used for mobile VR
  52092. */
  52093. export class VRDistortionCorrectionPostProcess extends PostProcess {
  52094. private _isRightEye;
  52095. private _distortionFactors;
  52096. private _postProcessScaleFactor;
  52097. private _lensCenterOffset;
  52098. private _scaleIn;
  52099. private _scaleFactor;
  52100. private _lensCenter;
  52101. /**
  52102. * Gets a string identifying the name of the class
  52103. * @returns "VRDistortionCorrectionPostProcess" string
  52104. */
  52105. getClassName(): string;
  52106. /**
  52107. * Initializes the VRDistortionCorrectionPostProcess
  52108. * @param name The name of the effect.
  52109. * @param camera The camera to apply the render pass to.
  52110. * @param isRightEye If this is for the right eye distortion
  52111. * @param vrMetrics All the required metrics for the VR camera
  52112. */
  52113. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  52114. }
  52115. }
  52116. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  52117. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  52118. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52119. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52120. import { Scene } from "babylonjs/scene";
  52121. import { Vector3 } from "babylonjs/Maths/math.vector";
  52122. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  52123. import "babylonjs/Cameras/RigModes/vrRigMode";
  52124. /**
  52125. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  52126. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52127. */
  52128. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  52129. /**
  52130. * Creates a new VRDeviceOrientationArcRotateCamera
  52131. * @param name defines camera name
  52132. * @param alpha defines the camera rotation along the logitudinal axis
  52133. * @param beta defines the camera rotation along the latitudinal axis
  52134. * @param radius defines the camera distance from its target
  52135. * @param target defines the camera target
  52136. * @param scene defines the scene the camera belongs to
  52137. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52138. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52139. */
  52140. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52141. /**
  52142. * Gets camera class name
  52143. * @returns VRDeviceOrientationArcRotateCamera
  52144. */
  52145. getClassName(): string;
  52146. }
  52147. }
  52148. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  52149. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  52150. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52151. import { Scene } from "babylonjs/scene";
  52152. import { Vector3 } from "babylonjs/Maths/math.vector";
  52153. import "babylonjs/Cameras/RigModes/vrRigMode";
  52154. /**
  52155. * Camera used to simulate VR rendering (based on FreeCamera)
  52156. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52157. */
  52158. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  52159. /**
  52160. * Creates a new VRDeviceOrientationFreeCamera
  52161. * @param name defines camera name
  52162. * @param position defines the start position of the camera
  52163. * @param scene defines the scene the camera belongs to
  52164. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52165. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52166. */
  52167. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52168. /**
  52169. * Gets camera class name
  52170. * @returns VRDeviceOrientationFreeCamera
  52171. */
  52172. getClassName(): string;
  52173. }
  52174. }
  52175. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  52176. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52177. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52178. import { Scene } from "babylonjs/scene";
  52179. import { Vector3 } from "babylonjs/Maths/math.vector";
  52180. import "babylonjs/Gamepads/gamepadSceneComponent";
  52181. /**
  52182. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  52183. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52184. */
  52185. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  52186. /**
  52187. * Creates a new VRDeviceOrientationGamepadCamera
  52188. * @param name defines camera name
  52189. * @param position defines the start position of the camera
  52190. * @param scene defines the scene the camera belongs to
  52191. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52192. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52193. */
  52194. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52195. /**
  52196. * Gets camera class name
  52197. * @returns VRDeviceOrientationGamepadCamera
  52198. */
  52199. getClassName(): string;
  52200. }
  52201. }
  52202. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  52203. import { Scene } from "babylonjs/scene";
  52204. import { Texture } from "babylonjs/Materials/Textures/texture";
  52205. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52206. /**
  52207. * A class extending Texture allowing drawing on a texture
  52208. * @see https://doc.babylonjs.com/how_to/dynamictexture
  52209. */
  52210. export class DynamicTexture extends Texture {
  52211. private _generateMipMaps;
  52212. private _canvas;
  52213. private _context;
  52214. /**
  52215. * Creates a DynamicTexture
  52216. * @param name defines the name of the texture
  52217. * @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
  52218. * @param scene defines the scene where you want the texture
  52219. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  52220. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52221. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  52222. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  52223. */
  52224. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  52225. /**
  52226. * Get the current class name of the texture useful for serialization or dynamic coding.
  52227. * @returns "DynamicTexture"
  52228. */
  52229. getClassName(): string;
  52230. /**
  52231. * Gets the current state of canRescale
  52232. */
  52233. get canRescale(): boolean;
  52234. private _recreate;
  52235. /**
  52236. * Scales the texture
  52237. * @param ratio the scale factor to apply to both width and height
  52238. */
  52239. scale(ratio: number): void;
  52240. /**
  52241. * Resizes the texture
  52242. * @param width the new width
  52243. * @param height the new height
  52244. */
  52245. scaleTo(width: number, height: number): void;
  52246. /**
  52247. * Gets the context of the canvas used by the texture
  52248. * @returns the canvas context of the dynamic texture
  52249. */
  52250. getContext(): CanvasRenderingContext2D;
  52251. /**
  52252. * Clears the texture
  52253. */
  52254. clear(): void;
  52255. /**
  52256. * Updates the texture
  52257. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52258. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  52259. */
  52260. update(invertY?: boolean, premulAlpha?: boolean): void;
  52261. /**
  52262. * Draws text onto the texture
  52263. * @param text defines the text to be drawn
  52264. * @param x defines the placement of the text from the left
  52265. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  52266. * @param font defines the font to be used with font-style, font-size, font-name
  52267. * @param color defines the color used for the text
  52268. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  52269. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52270. * @param update defines whether texture is immediately update (default is true)
  52271. */
  52272. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  52273. /**
  52274. * Clones the texture
  52275. * @returns the clone of the texture.
  52276. */
  52277. clone(): DynamicTexture;
  52278. /**
  52279. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  52280. * @returns a serialized dynamic texture object
  52281. */
  52282. serialize(): any;
  52283. private _IsCanvasElement;
  52284. /** @hidden */
  52285. _rebuild(): void;
  52286. }
  52287. }
  52288. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  52289. import { Scene } from "babylonjs/scene";
  52290. import { Color3 } from "babylonjs/Maths/math.color";
  52291. import { Mesh } from "babylonjs/Meshes/mesh";
  52292. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52293. import { Nullable } from "babylonjs/types";
  52294. /**
  52295. * Class containing static functions to help procedurally build meshes
  52296. */
  52297. export class GroundBuilder {
  52298. /**
  52299. * Creates a ground mesh
  52300. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52301. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52303. * @param name defines the name of the mesh
  52304. * @param options defines the options used to create the mesh
  52305. * @param scene defines the hosting scene
  52306. * @returns the ground mesh
  52307. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52308. */
  52309. static CreateGround(name: string, options: {
  52310. width?: number;
  52311. height?: number;
  52312. subdivisions?: number;
  52313. subdivisionsX?: number;
  52314. subdivisionsY?: number;
  52315. updatable?: boolean;
  52316. }, scene: any): Mesh;
  52317. /**
  52318. * Creates a tiled ground mesh
  52319. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52320. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52321. * * 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
  52322. * * 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
  52323. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52324. * @param name defines the name of the mesh
  52325. * @param options defines the options used to create the mesh
  52326. * @param scene defines the hosting scene
  52327. * @returns the tiled ground mesh
  52328. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52329. */
  52330. static CreateTiledGround(name: string, options: {
  52331. xmin: number;
  52332. zmin: number;
  52333. xmax: number;
  52334. zmax: number;
  52335. subdivisions?: {
  52336. w: number;
  52337. h: number;
  52338. };
  52339. precision?: {
  52340. w: number;
  52341. h: number;
  52342. };
  52343. updatable?: boolean;
  52344. }, scene?: Nullable<Scene>): Mesh;
  52345. /**
  52346. * Creates a ground mesh from a height map
  52347. * * The parameter `url` sets the URL of the height map image resource.
  52348. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52349. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52350. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52351. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52352. * * 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.
  52353. * * 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).
  52354. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52356. * @param name defines the name of the mesh
  52357. * @param url defines the url to the height map
  52358. * @param options defines the options used to create the mesh
  52359. * @param scene defines the hosting scene
  52360. * @returns the ground mesh
  52361. * @see https://doc.babylonjs.com/babylon101/height_map
  52362. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52363. */
  52364. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52365. width?: number;
  52366. height?: number;
  52367. subdivisions?: number;
  52368. minHeight?: number;
  52369. maxHeight?: number;
  52370. colorFilter?: Color3;
  52371. alphaFilter?: number;
  52372. updatable?: boolean;
  52373. onReady?: (mesh: GroundMesh) => void;
  52374. }, scene?: Nullable<Scene>): GroundMesh;
  52375. }
  52376. }
  52377. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  52378. import { Vector4 } from "babylonjs/Maths/math.vector";
  52379. import { Mesh } from "babylonjs/Meshes/mesh";
  52380. /**
  52381. * Class containing static functions to help procedurally build meshes
  52382. */
  52383. export class TorusBuilder {
  52384. /**
  52385. * Creates a torus mesh
  52386. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52387. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52388. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52392. * @param name defines the name of the mesh
  52393. * @param options defines the options used to create the mesh
  52394. * @param scene defines the hosting scene
  52395. * @returns the torus mesh
  52396. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52397. */
  52398. static CreateTorus(name: string, options: {
  52399. diameter?: number;
  52400. thickness?: number;
  52401. tessellation?: number;
  52402. updatable?: boolean;
  52403. sideOrientation?: number;
  52404. frontUVs?: Vector4;
  52405. backUVs?: Vector4;
  52406. }, scene: any): Mesh;
  52407. }
  52408. }
  52409. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  52410. import { Vector4 } from "babylonjs/Maths/math.vector";
  52411. import { Color4 } from "babylonjs/Maths/math.color";
  52412. import { Mesh } from "babylonjs/Meshes/mesh";
  52413. /**
  52414. * Class containing static functions to help procedurally build meshes
  52415. */
  52416. export class CylinderBuilder {
  52417. /**
  52418. * Creates a cylinder or a cone mesh
  52419. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52420. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52421. * * 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.
  52422. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52423. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52424. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52425. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52426. * * 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).
  52427. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52428. * * 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).
  52429. * * 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
  52430. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52431. * * 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
  52432. * * 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.
  52433. * * If `enclose` is false, a ring surface is one element.
  52434. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52435. * * 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
  52436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52439. * @param name defines the name of the mesh
  52440. * @param options defines the options used to create the mesh
  52441. * @param scene defines the hosting scene
  52442. * @returns the cylinder mesh
  52443. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52444. */
  52445. static CreateCylinder(name: string, options: {
  52446. height?: number;
  52447. diameterTop?: number;
  52448. diameterBottom?: number;
  52449. diameter?: number;
  52450. tessellation?: number;
  52451. subdivisions?: number;
  52452. arc?: number;
  52453. faceColors?: Color4[];
  52454. faceUV?: Vector4[];
  52455. updatable?: boolean;
  52456. hasRings?: boolean;
  52457. enclose?: boolean;
  52458. cap?: number;
  52459. sideOrientation?: number;
  52460. frontUVs?: Vector4;
  52461. backUVs?: Vector4;
  52462. }, scene: any): Mesh;
  52463. }
  52464. }
  52465. declare module "babylonjs/XR/webXRTypes" {
  52466. import { Nullable } from "babylonjs/types";
  52467. import { IDisposable } from "babylonjs/scene";
  52468. /**
  52469. * States of the webXR experience
  52470. */
  52471. export enum WebXRState {
  52472. /**
  52473. * Transitioning to being in XR mode
  52474. */
  52475. ENTERING_XR = 0,
  52476. /**
  52477. * Transitioning to non XR mode
  52478. */
  52479. EXITING_XR = 1,
  52480. /**
  52481. * In XR mode and presenting
  52482. */
  52483. IN_XR = 2,
  52484. /**
  52485. * Not entered XR mode
  52486. */
  52487. NOT_IN_XR = 3
  52488. }
  52489. /**
  52490. * The state of the XR camera's tracking
  52491. */
  52492. export enum WebXRTrackingState {
  52493. /**
  52494. * No transformation received, device is not being tracked
  52495. */
  52496. NOT_TRACKING = 0,
  52497. /**
  52498. * Tracking lost - using emulated position
  52499. */
  52500. TRACKING_LOST = 1,
  52501. /**
  52502. * Transformation tracking works normally
  52503. */
  52504. TRACKING = 2
  52505. }
  52506. /**
  52507. * Abstraction of the XR render target
  52508. */
  52509. export interface WebXRRenderTarget extends IDisposable {
  52510. /**
  52511. * xrpresent context of the canvas which can be used to display/mirror xr content
  52512. */
  52513. canvasContext: WebGLRenderingContext;
  52514. /**
  52515. * xr layer for the canvas
  52516. */
  52517. xrLayer: Nullable<XRWebGLLayer>;
  52518. /**
  52519. * Initializes the xr layer for the session
  52520. * @param xrSession xr session
  52521. * @returns a promise that will resolve once the XR Layer has been created
  52522. */
  52523. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52524. }
  52525. }
  52526. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  52527. import { Nullable } from "babylonjs/types";
  52528. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52529. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52530. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52531. import { Observable } from "babylonjs/Misc/observable";
  52532. /**
  52533. * COnfiguration object for WebXR output canvas
  52534. */
  52535. export class WebXRManagedOutputCanvasOptions {
  52536. /**
  52537. * An optional canvas in case you wish to create it yourself and provide it here.
  52538. * If not provided, a new canvas will be created
  52539. */
  52540. canvasElement?: HTMLCanvasElement;
  52541. /**
  52542. * Options for this XR Layer output
  52543. */
  52544. canvasOptions?: XRWebGLLayerInit;
  52545. /**
  52546. * CSS styling for a newly created canvas (if not provided)
  52547. */
  52548. newCanvasCssStyle?: string;
  52549. /**
  52550. * Get the default values of the configuration object
  52551. * @param engine defines the engine to use (can be null)
  52552. * @returns default values of this configuration object
  52553. */
  52554. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  52555. }
  52556. /**
  52557. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  52558. */
  52559. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  52560. private _options;
  52561. private _canvas;
  52562. private _engine;
  52563. private _originalCanvasSize;
  52564. /**
  52565. * Rendering context of the canvas which can be used to display/mirror xr content
  52566. */
  52567. canvasContext: WebGLRenderingContext;
  52568. /**
  52569. * xr layer for the canvas
  52570. */
  52571. xrLayer: Nullable<XRWebGLLayer>;
  52572. /**
  52573. * Obseervers registered here will be triggered when the xr layer was initialized
  52574. */
  52575. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  52576. /**
  52577. * Initializes the canvas to be added/removed upon entering/exiting xr
  52578. * @param _xrSessionManager The XR Session manager
  52579. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  52580. */
  52581. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  52582. /**
  52583. * Disposes of the object
  52584. */
  52585. dispose(): void;
  52586. /**
  52587. * Initializes the xr layer for the session
  52588. * @param xrSession xr session
  52589. * @returns a promise that will resolve once the XR Layer has been created
  52590. */
  52591. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52592. private _addCanvas;
  52593. private _removeCanvas;
  52594. private _setCanvasSize;
  52595. private _setManagedOutputCanvas;
  52596. }
  52597. }
  52598. declare module "babylonjs/XR/webXRSessionManager" {
  52599. import { Observable } from "babylonjs/Misc/observable";
  52600. import { Nullable } from "babylonjs/types";
  52601. import { IDisposable, Scene } from "babylonjs/scene";
  52602. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52603. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52604. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  52605. /**
  52606. * Manages an XRSession to work with Babylon's engine
  52607. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  52608. */
  52609. export class WebXRSessionManager implements IDisposable {
  52610. /** The scene which the session should be created for */
  52611. scene: Scene;
  52612. private _referenceSpace;
  52613. private _rttProvider;
  52614. private _sessionEnded;
  52615. private _xrNavigator;
  52616. private baseLayer;
  52617. /**
  52618. * The base reference space from which the session started. good if you want to reset your
  52619. * reference space
  52620. */
  52621. baseReferenceSpace: XRReferenceSpace;
  52622. /**
  52623. * Current XR frame
  52624. */
  52625. currentFrame: Nullable<XRFrame>;
  52626. /** WebXR timestamp updated every frame */
  52627. currentTimestamp: number;
  52628. /**
  52629. * Used just in case of a failure to initialize an immersive session.
  52630. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  52631. */
  52632. defaultHeightCompensation: number;
  52633. /**
  52634. * Fires every time a new xrFrame arrives which can be used to update the camera
  52635. */
  52636. onXRFrameObservable: Observable<XRFrame>;
  52637. /**
  52638. * Fires when the reference space changed
  52639. */
  52640. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52641. /**
  52642. * Fires when the xr session is ended either by the device or manually done
  52643. */
  52644. onXRSessionEnded: Observable<any>;
  52645. /**
  52646. * Fires when the xr session is ended either by the device or manually done
  52647. */
  52648. onXRSessionInit: Observable<XRSession>;
  52649. /**
  52650. * Underlying xr session
  52651. */
  52652. session: XRSession;
  52653. /**
  52654. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52655. * or get the offset the player is currently at.
  52656. */
  52657. viewerReferenceSpace: XRReferenceSpace;
  52658. /**
  52659. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52660. * @param scene The scene which the session should be created for
  52661. */
  52662. constructor(
  52663. /** The scene which the session should be created for */
  52664. scene: Scene);
  52665. /**
  52666. * The current reference space used in this session. This reference space can constantly change!
  52667. * It is mainly used to offset the camera's position.
  52668. */
  52669. get referenceSpace(): XRReferenceSpace;
  52670. /**
  52671. * Set a new reference space and triggers the observable
  52672. */
  52673. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52674. /**
  52675. * Disposes of the session manager
  52676. */
  52677. dispose(): void;
  52678. /**
  52679. * Stops the xrSession and restores the render loop
  52680. * @returns Promise which resolves after it exits XR
  52681. */
  52682. exitXRAsync(): Promise<void>;
  52683. /**
  52684. * Gets the correct render target texture to be rendered this frame for this eye
  52685. * @param eye the eye for which to get the render target
  52686. * @returns the render target for the specified eye
  52687. */
  52688. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52689. /**
  52690. * Creates a WebXRRenderTarget object for the XR session
  52691. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52692. * @param options optional options to provide when creating a new render target
  52693. * @returns a WebXR render target to which the session can render
  52694. */
  52695. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52696. /**
  52697. * Initializes the manager
  52698. * After initialization enterXR can be called to start an XR session
  52699. * @returns Promise which resolves after it is initialized
  52700. */
  52701. initializeAsync(): Promise<void>;
  52702. /**
  52703. * Initializes an xr session
  52704. * @param xrSessionMode mode to initialize
  52705. * @param xrSessionInit defines optional and required values to pass to the session builder
  52706. * @returns a promise which will resolve once the session has been initialized
  52707. */
  52708. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52709. /**
  52710. * Checks if a session would be supported for the creation options specified
  52711. * @param sessionMode session mode to check if supported eg. immersive-vr
  52712. * @returns A Promise that resolves to true if supported and false if not
  52713. */
  52714. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52715. /**
  52716. * Resets the reference space to the one started the session
  52717. */
  52718. resetReferenceSpace(): void;
  52719. /**
  52720. * Starts rendering to the xr layer
  52721. */
  52722. runXRRenderLoop(): void;
  52723. /**
  52724. * Sets the reference space on the xr session
  52725. * @param referenceSpaceType space to set
  52726. * @returns a promise that will resolve once the reference space has been set
  52727. */
  52728. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52729. /**
  52730. * Updates the render state of the session
  52731. * @param state state to set
  52732. * @returns a promise that resolves once the render state has been updated
  52733. */
  52734. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52735. /**
  52736. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52737. * @param sessionMode defines the session to test
  52738. * @returns a promise with boolean as final value
  52739. */
  52740. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52741. private _createRenderTargetTexture;
  52742. }
  52743. }
  52744. declare module "babylonjs/XR/webXRCamera" {
  52745. import { Vector3 } from "babylonjs/Maths/math.vector";
  52746. import { Scene } from "babylonjs/scene";
  52747. import { Camera } from "babylonjs/Cameras/camera";
  52748. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52749. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52750. import { Observable } from "babylonjs/Misc/observable";
  52751. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52752. /**
  52753. * WebXR Camera which holds the views for the xrSession
  52754. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52755. */
  52756. export class WebXRCamera extends FreeCamera {
  52757. private _xrSessionManager;
  52758. private _firstFrame;
  52759. private _referenceQuaternion;
  52760. private _referencedPosition;
  52761. private _xrInvPositionCache;
  52762. private _xrInvQuaternionCache;
  52763. private _trackingState;
  52764. /**
  52765. * Observable raised before camera teleportation
  52766. */
  52767. onBeforeCameraTeleport: Observable<Vector3>;
  52768. /**
  52769. * Observable raised after camera teleportation
  52770. */
  52771. onAfterCameraTeleport: Observable<Vector3>;
  52772. /**
  52773. * Notifies when the camera's tracking state has changed.
  52774. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52775. */
  52776. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52777. /**
  52778. * Should position compensation execute on first frame.
  52779. * This is used when copying the position from a native (non XR) camera
  52780. */
  52781. compensateOnFirstFrame: boolean;
  52782. /**
  52783. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52784. * @param name the name of the camera
  52785. * @param scene the scene to add the camera to
  52786. * @param _xrSessionManager a constructed xr session manager
  52787. */
  52788. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52789. /**
  52790. * Get the current XR tracking state of the camera
  52791. */
  52792. get trackingState(): WebXRTrackingState;
  52793. private _setTrackingState;
  52794. /**
  52795. * Return the user's height, unrelated to the current ground.
  52796. * This will be the y position of this camera, when ground level is 0.
  52797. */
  52798. get realWorldHeight(): number;
  52799. /** @hidden */
  52800. _updateForDualEyeDebugging(): void;
  52801. /**
  52802. * Sets this camera's transformation based on a non-vr camera
  52803. * @param otherCamera the non-vr camera to copy the transformation from
  52804. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52805. */
  52806. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52807. /**
  52808. * Gets the current instance class name ("WebXRCamera").
  52809. * @returns the class name
  52810. */
  52811. getClassName(): string;
  52812. private _rotate180;
  52813. private _updateFromXRSession;
  52814. private _updateNumberOfRigCameras;
  52815. private _updateReferenceSpace;
  52816. private _updateReferenceSpaceOffset;
  52817. }
  52818. }
  52819. declare module "babylonjs/XR/webXRFeaturesManager" {
  52820. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52821. import { IDisposable } from "babylonjs/scene";
  52822. /**
  52823. * Defining the interface required for a (webxr) feature
  52824. */
  52825. export interface IWebXRFeature extends IDisposable {
  52826. /**
  52827. * Is this feature attached
  52828. */
  52829. attached: boolean;
  52830. /**
  52831. * Should auto-attach be disabled?
  52832. */
  52833. disableAutoAttach: boolean;
  52834. /**
  52835. * Attach the feature to the session
  52836. * Will usually be called by the features manager
  52837. *
  52838. * @param force should attachment be forced (even when already attached)
  52839. * @returns true if successful.
  52840. */
  52841. attach(force?: boolean): boolean;
  52842. /**
  52843. * Detach the feature from the session
  52844. * Will usually be called by the features manager
  52845. *
  52846. * @returns true if successful.
  52847. */
  52848. detach(): boolean;
  52849. /**
  52850. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52851. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52852. *
  52853. * @returns whether or not the feature is compatible in this environment
  52854. */
  52855. isCompatible(): boolean;
  52856. /**
  52857. * Was this feature disposed;
  52858. */
  52859. isDisposed: boolean;
  52860. /**
  52861. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52862. */
  52863. xrNativeFeatureName?: string;
  52864. /**
  52865. * A list of (Babylon WebXR) features this feature depends on
  52866. */
  52867. dependsOn?: string[];
  52868. }
  52869. /**
  52870. * A list of the currently available features without referencing them
  52871. */
  52872. export class WebXRFeatureName {
  52873. /**
  52874. * The name of the anchor system feature
  52875. */
  52876. static readonly ANCHOR_SYSTEM: string;
  52877. /**
  52878. * The name of the background remover feature
  52879. */
  52880. static readonly BACKGROUND_REMOVER: string;
  52881. /**
  52882. * The name of the hit test feature
  52883. */
  52884. static readonly HIT_TEST: string;
  52885. /**
  52886. * physics impostors for xr controllers feature
  52887. */
  52888. static readonly PHYSICS_CONTROLLERS: string;
  52889. /**
  52890. * The name of the plane detection feature
  52891. */
  52892. static readonly PLANE_DETECTION: string;
  52893. /**
  52894. * The name of the pointer selection feature
  52895. */
  52896. static readonly POINTER_SELECTION: string;
  52897. /**
  52898. * The name of the teleportation feature
  52899. */
  52900. static readonly TELEPORTATION: string;
  52901. /**
  52902. * The name of the feature points feature.
  52903. */
  52904. static readonly FEATURE_POINTS: string;
  52905. /**
  52906. * The name of the hand tracking feature.
  52907. */
  52908. static readonly HAND_TRACKING: string;
  52909. }
  52910. /**
  52911. * Defining the constructor of a feature. Used to register the modules.
  52912. */
  52913. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52914. /**
  52915. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52916. * It is mainly used in AR sessions.
  52917. *
  52918. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52919. */
  52920. export class WebXRFeaturesManager implements IDisposable {
  52921. private _xrSessionManager;
  52922. private static readonly _AvailableFeatures;
  52923. private _features;
  52924. /**
  52925. * constructs a new features manages.
  52926. *
  52927. * @param _xrSessionManager an instance of WebXRSessionManager
  52928. */
  52929. constructor(_xrSessionManager: WebXRSessionManager);
  52930. /**
  52931. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52932. * Mainly used internally.
  52933. *
  52934. * @param featureName the name of the feature to register
  52935. * @param constructorFunction the function used to construct the module
  52936. * @param version the (babylon) version of the module
  52937. * @param stable is that a stable version of this module
  52938. */
  52939. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52940. /**
  52941. * Returns a constructor of a specific feature.
  52942. *
  52943. * @param featureName the name of the feature to construct
  52944. * @param version the version of the feature to load
  52945. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52946. * @param options optional options provided to the module.
  52947. * @returns a function that, when called, will return a new instance of this feature
  52948. */
  52949. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52950. /**
  52951. * Can be used to return the list of features currently registered
  52952. *
  52953. * @returns an Array of available features
  52954. */
  52955. static GetAvailableFeatures(): string[];
  52956. /**
  52957. * Gets the versions available for a specific feature
  52958. * @param featureName the name of the feature
  52959. * @returns an array with the available versions
  52960. */
  52961. static GetAvailableVersions(featureName: string): string[];
  52962. /**
  52963. * Return the latest unstable version of this feature
  52964. * @param featureName the name of the feature to search
  52965. * @returns the version number. if not found will return -1
  52966. */
  52967. static GetLatestVersionOfFeature(featureName: string): number;
  52968. /**
  52969. * Return the latest stable version of this feature
  52970. * @param featureName the name of the feature to search
  52971. * @returns the version number. if not found will return -1
  52972. */
  52973. static GetStableVersionOfFeature(featureName: string): number;
  52974. /**
  52975. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52976. * Can be used during a session to start a feature
  52977. * @param featureName the name of feature to attach
  52978. */
  52979. attachFeature(featureName: string): void;
  52980. /**
  52981. * Can be used inside a session or when the session ends to detach a specific feature
  52982. * @param featureName the name of the feature to detach
  52983. */
  52984. detachFeature(featureName: string): void;
  52985. /**
  52986. * Used to disable an already-enabled feature
  52987. * The feature will be disposed and will be recreated once enabled.
  52988. * @param featureName the feature to disable
  52989. * @returns true if disable was successful
  52990. */
  52991. disableFeature(featureName: string | {
  52992. Name: string;
  52993. }): boolean;
  52994. /**
  52995. * dispose this features manager
  52996. */
  52997. dispose(): void;
  52998. /**
  52999. * 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.
  53000. * 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.
  53001. *
  53002. * @param featureName the name of the feature to load or the class of the feature
  53003. * @param version optional version to load. if not provided the latest version will be enabled
  53004. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  53005. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  53006. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  53007. * @returns a new constructed feature or throws an error if feature not found.
  53008. */
  53009. enableFeature(featureName: string | {
  53010. Name: string;
  53011. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  53012. /**
  53013. * get the implementation of an enabled feature.
  53014. * @param featureName the name of the feature to load
  53015. * @returns the feature class, if found
  53016. */
  53017. getEnabledFeature(featureName: string): IWebXRFeature;
  53018. /**
  53019. * Get the list of enabled features
  53020. * @returns an array of enabled features
  53021. */
  53022. getEnabledFeatures(): string[];
  53023. /**
  53024. * This function will exten the session creation configuration object with enabled features.
  53025. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53026. * according to the defined "required" variable, provided during enableFeature call
  53027. * @param xrSessionInit the xr Session init object to extend
  53028. *
  53029. * @returns an extended XRSessionInit object
  53030. */
  53031. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  53032. }
  53033. }
  53034. declare module "babylonjs/XR/webXRExperienceHelper" {
  53035. import { Observable } from "babylonjs/Misc/observable";
  53036. import { IDisposable, Scene } from "babylonjs/scene";
  53037. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53038. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53039. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  53040. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  53041. /**
  53042. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53043. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53044. */
  53045. export class WebXRExperienceHelper implements IDisposable {
  53046. private scene;
  53047. private _nonVRCamera;
  53048. private _originalSceneAutoClear;
  53049. private _supported;
  53050. /**
  53051. * Camera used to render xr content
  53052. */
  53053. camera: WebXRCamera;
  53054. /** A features manager for this xr session */
  53055. featuresManager: WebXRFeaturesManager;
  53056. /**
  53057. * Observers registered here will be triggered after the camera's initial transformation is set
  53058. * This can be used to set a different ground level or an extra rotation.
  53059. *
  53060. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53061. * to the position set after this observable is done executing.
  53062. */
  53063. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53064. /**
  53065. * Fires when the state of the experience helper has changed
  53066. */
  53067. onStateChangedObservable: Observable<WebXRState>;
  53068. /** Session manager used to keep track of xr session */
  53069. sessionManager: WebXRSessionManager;
  53070. /**
  53071. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53072. */
  53073. state: WebXRState;
  53074. /**
  53075. * Creates a WebXRExperienceHelper
  53076. * @param scene The scene the helper should be created in
  53077. */
  53078. private constructor();
  53079. /**
  53080. * Creates the experience helper
  53081. * @param scene the scene to attach the experience helper to
  53082. * @returns a promise for the experience helper
  53083. */
  53084. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53085. /**
  53086. * Disposes of the experience helper
  53087. */
  53088. dispose(): void;
  53089. /**
  53090. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53091. * @param sessionMode options for the XR session
  53092. * @param referenceSpaceType frame of reference of the XR session
  53093. * @param renderTarget the output canvas that will be used to enter XR mode
  53094. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53095. * @returns promise that resolves after xr mode has entered
  53096. */
  53097. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53098. /**
  53099. * Exits XR mode and returns the scene to its original state
  53100. * @returns promise that resolves after xr mode has exited
  53101. */
  53102. exitXRAsync(): Promise<void>;
  53103. private _nonXRToXRCamera;
  53104. private _setState;
  53105. }
  53106. }
  53107. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  53108. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53109. import { Observable } from "babylonjs/Misc/observable";
  53110. import { IDisposable } from "babylonjs/scene";
  53111. /**
  53112. * X-Y values for axes in WebXR
  53113. */
  53114. export interface IWebXRMotionControllerAxesValue {
  53115. /**
  53116. * The value of the x axis
  53117. */
  53118. x: number;
  53119. /**
  53120. * The value of the y-axis
  53121. */
  53122. y: number;
  53123. }
  53124. /**
  53125. * changed / previous values for the values of this component
  53126. */
  53127. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53128. /**
  53129. * current (this frame) value
  53130. */
  53131. current: T;
  53132. /**
  53133. * previous (last change) value
  53134. */
  53135. previous: T;
  53136. }
  53137. /**
  53138. * Represents changes in the component between current frame and last values recorded
  53139. */
  53140. export interface IWebXRMotionControllerComponentChanges {
  53141. /**
  53142. * will be populated with previous and current values if axes changed
  53143. */
  53144. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  53145. /**
  53146. * will be populated with previous and current values if pressed changed
  53147. */
  53148. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53149. /**
  53150. * will be populated with previous and current values if touched changed
  53151. */
  53152. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53153. /**
  53154. * will be populated with previous and current values if value changed
  53155. */
  53156. value?: IWebXRMotionControllerComponentChangesValues<number>;
  53157. }
  53158. /**
  53159. * This class represents a single component (for example button or thumbstick) of a motion controller
  53160. */
  53161. export class WebXRControllerComponent implements IDisposable {
  53162. /**
  53163. * the id of this component
  53164. */
  53165. id: string;
  53166. /**
  53167. * the type of the component
  53168. */
  53169. type: MotionControllerComponentType;
  53170. private _buttonIndex;
  53171. private _axesIndices;
  53172. private _axes;
  53173. private _changes;
  53174. private _currentValue;
  53175. private _hasChanges;
  53176. private _pressed;
  53177. private _touched;
  53178. /**
  53179. * button component type
  53180. */
  53181. static BUTTON_TYPE: MotionControllerComponentType;
  53182. /**
  53183. * squeeze component type
  53184. */
  53185. static SQUEEZE_TYPE: MotionControllerComponentType;
  53186. /**
  53187. * Thumbstick component type
  53188. */
  53189. static THUMBSTICK_TYPE: MotionControllerComponentType;
  53190. /**
  53191. * Touchpad component type
  53192. */
  53193. static TOUCHPAD_TYPE: MotionControllerComponentType;
  53194. /**
  53195. * trigger component type
  53196. */
  53197. static TRIGGER_TYPE: MotionControllerComponentType;
  53198. /**
  53199. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  53200. * the axes data changes
  53201. */
  53202. onAxisValueChangedObservable: Observable<{
  53203. x: number;
  53204. y: number;
  53205. }>;
  53206. /**
  53207. * Observers registered here will be triggered when the state of a button changes
  53208. * State change is either pressed / touched / value
  53209. */
  53210. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  53211. /**
  53212. * Creates a new component for a motion controller.
  53213. * It is created by the motion controller itself
  53214. *
  53215. * @param id the id of this component
  53216. * @param type the type of the component
  53217. * @param _buttonIndex index in the buttons array of the gamepad
  53218. * @param _axesIndices indices of the values in the axes array of the gamepad
  53219. */
  53220. constructor(
  53221. /**
  53222. * the id of this component
  53223. */
  53224. id: string,
  53225. /**
  53226. * the type of the component
  53227. */
  53228. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  53229. /**
  53230. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  53231. */
  53232. get axes(): IWebXRMotionControllerAxesValue;
  53233. /**
  53234. * Get the changes. Elements will be populated only if they changed with their previous and current value
  53235. */
  53236. get changes(): IWebXRMotionControllerComponentChanges;
  53237. /**
  53238. * Return whether or not the component changed the last frame
  53239. */
  53240. get hasChanges(): boolean;
  53241. /**
  53242. * is the button currently pressed
  53243. */
  53244. get pressed(): boolean;
  53245. /**
  53246. * is the button currently touched
  53247. */
  53248. get touched(): boolean;
  53249. /**
  53250. * Get the current value of this component
  53251. */
  53252. get value(): number;
  53253. /**
  53254. * Dispose this component
  53255. */
  53256. dispose(): void;
  53257. /**
  53258. * Are there axes correlating to this component
  53259. * @return true is axes data is available
  53260. */
  53261. isAxes(): boolean;
  53262. /**
  53263. * Is this component a button (hence - pressable)
  53264. * @returns true if can be pressed
  53265. */
  53266. isButton(): boolean;
  53267. /**
  53268. * update this component using the gamepad object it is in. Called on every frame
  53269. * @param nativeController the native gamepad controller object
  53270. */
  53271. update(nativeController: IMinimalMotionControllerObject): void;
  53272. }
  53273. }
  53274. declare module "babylonjs/Loading/sceneLoader" {
  53275. import { Observable } from "babylonjs/Misc/observable";
  53276. import { Nullable } from "babylonjs/types";
  53277. import { Scene } from "babylonjs/scene";
  53278. import { Engine } from "babylonjs/Engines/engine";
  53279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53280. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  53281. import { AssetContainer } from "babylonjs/assetContainer";
  53282. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53283. import { Skeleton } from "babylonjs/Bones/skeleton";
  53284. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  53285. import { WebRequest } from "babylonjs/Misc/webRequest";
  53286. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53287. import { Geometry } from "babylonjs/Meshes/geometry";
  53288. import { Light } from "babylonjs/Lights/light";
  53289. /**
  53290. * Type used for the success callback of ImportMesh
  53291. */
  53292. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  53293. /**
  53294. * Interface used for the result of ImportMeshAsync
  53295. */
  53296. export interface ISceneLoaderAsyncResult {
  53297. /**
  53298. * The array of loaded meshes
  53299. */
  53300. readonly meshes: AbstractMesh[];
  53301. /**
  53302. * The array of loaded particle systems
  53303. */
  53304. readonly particleSystems: IParticleSystem[];
  53305. /**
  53306. * The array of loaded skeletons
  53307. */
  53308. readonly skeletons: Skeleton[];
  53309. /**
  53310. * The array of loaded animation groups
  53311. */
  53312. readonly animationGroups: AnimationGroup[];
  53313. /**
  53314. * The array of loaded transform nodes
  53315. */
  53316. readonly transformNodes: TransformNode[];
  53317. /**
  53318. * The array of loaded geometries
  53319. */
  53320. readonly geometries: Geometry[];
  53321. /**
  53322. * The array of loaded lights
  53323. */
  53324. readonly lights: Light[];
  53325. }
  53326. /**
  53327. * Interface used to represent data loading progression
  53328. */
  53329. export interface ISceneLoaderProgressEvent {
  53330. /**
  53331. * Defines if data length to load can be evaluated
  53332. */
  53333. readonly lengthComputable: boolean;
  53334. /**
  53335. * Defines the loaded data length
  53336. */
  53337. readonly loaded: number;
  53338. /**
  53339. * Defines the data length to load
  53340. */
  53341. readonly total: number;
  53342. }
  53343. /**
  53344. * Interface used by SceneLoader plugins to define supported file extensions
  53345. */
  53346. export interface ISceneLoaderPluginExtensions {
  53347. /**
  53348. * Defines the list of supported extensions
  53349. */
  53350. [extension: string]: {
  53351. isBinary: boolean;
  53352. };
  53353. }
  53354. /**
  53355. * Interface used by SceneLoader plugin factory
  53356. */
  53357. export interface ISceneLoaderPluginFactory {
  53358. /**
  53359. * Defines the name of the factory
  53360. */
  53361. name: string;
  53362. /**
  53363. * Function called to create a new plugin
  53364. * @return the new plugin
  53365. */
  53366. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  53367. /**
  53368. * The callback that returns true if the data can be directly loaded.
  53369. * @param data string containing the file data
  53370. * @returns if the data can be loaded directly
  53371. */
  53372. canDirectLoad?(data: string): boolean;
  53373. }
  53374. /**
  53375. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  53376. */
  53377. export interface ISceneLoaderPluginBase {
  53378. /**
  53379. * The friendly name of this plugin.
  53380. */
  53381. name: string;
  53382. /**
  53383. * The file extensions supported by this plugin.
  53384. */
  53385. extensions: string | ISceneLoaderPluginExtensions;
  53386. /**
  53387. * The callback called when loading from a url.
  53388. * @param scene scene loading this url
  53389. * @param url url to load
  53390. * @param onSuccess callback called when the file successfully loads
  53391. * @param onProgress callback called while file is loading (if the server supports this mode)
  53392. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  53393. * @param onError callback called when the file fails to load
  53394. * @returns a file request object
  53395. */
  53396. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53397. /**
  53398. * The callback called when loading from a file object.
  53399. * @param scene scene loading this file
  53400. * @param file defines the file to load
  53401. * @param onSuccess defines the callback to call when data is loaded
  53402. * @param onProgress defines the callback to call during loading process
  53403. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  53404. * @param onError defines the callback to call when an error occurs
  53405. * @returns a file request object
  53406. */
  53407. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53408. /**
  53409. * The callback that returns true if the data can be directly loaded.
  53410. * @param data string containing the file data
  53411. * @returns if the data can be loaded directly
  53412. */
  53413. canDirectLoad?(data: string): boolean;
  53414. /**
  53415. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  53416. * @param scene scene loading this data
  53417. * @param data string containing the data
  53418. * @returns data to pass to the plugin
  53419. */
  53420. directLoad?(scene: Scene, data: string): any;
  53421. /**
  53422. * The callback that allows custom handling of the root url based on the response url.
  53423. * @param rootUrl the original root url
  53424. * @param responseURL the response url if available
  53425. * @returns the new root url
  53426. */
  53427. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  53428. }
  53429. /**
  53430. * Interface used to define a SceneLoader plugin
  53431. */
  53432. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  53433. /**
  53434. * Import meshes into a scene.
  53435. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53436. * @param scene The scene to import into
  53437. * @param data The data to import
  53438. * @param rootUrl The root url for scene and resources
  53439. * @param meshes The meshes array to import into
  53440. * @param particleSystems The particle systems array to import into
  53441. * @param skeletons The skeletons array to import into
  53442. * @param onError The callback when import fails
  53443. * @returns True if successful or false otherwise
  53444. */
  53445. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  53446. /**
  53447. * Load into a scene.
  53448. * @param scene The scene to load into
  53449. * @param data The data to import
  53450. * @param rootUrl The root url for scene and resources
  53451. * @param onError The callback when import fails
  53452. * @returns True if successful or false otherwise
  53453. */
  53454. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  53455. /**
  53456. * Load into an asset container.
  53457. * @param scene The scene to load into
  53458. * @param data The data to import
  53459. * @param rootUrl The root url for scene and resources
  53460. * @param onError The callback when import fails
  53461. * @returns The loaded asset container
  53462. */
  53463. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  53464. }
  53465. /**
  53466. * Interface used to define an async SceneLoader plugin
  53467. */
  53468. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  53469. /**
  53470. * Import meshes into a scene.
  53471. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53472. * @param scene The scene to import into
  53473. * @param data The data to import
  53474. * @param rootUrl The root url for scene and resources
  53475. * @param onProgress The callback when the load progresses
  53476. * @param fileName Defines the name of the file to load
  53477. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  53478. */
  53479. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  53480. /**
  53481. * Load into a scene.
  53482. * @param scene The scene to load into
  53483. * @param data The data to import
  53484. * @param rootUrl The root url for scene and resources
  53485. * @param onProgress The callback when the load progresses
  53486. * @param fileName Defines the name of the file to load
  53487. * @returns Nothing
  53488. */
  53489. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  53490. /**
  53491. * Load into an asset container.
  53492. * @param scene The scene to load into
  53493. * @param data The data to import
  53494. * @param rootUrl The root url for scene and resources
  53495. * @param onProgress The callback when the load progresses
  53496. * @param fileName Defines the name of the file to load
  53497. * @returns The loaded asset container
  53498. */
  53499. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  53500. }
  53501. /**
  53502. * Mode that determines how to handle old animation groups before loading new ones.
  53503. */
  53504. export enum SceneLoaderAnimationGroupLoadingMode {
  53505. /**
  53506. * Reset all old animations to initial state then dispose them.
  53507. */
  53508. Clean = 0,
  53509. /**
  53510. * Stop all old animations.
  53511. */
  53512. Stop = 1,
  53513. /**
  53514. * Restart old animations from first frame.
  53515. */
  53516. Sync = 2,
  53517. /**
  53518. * Old animations remains untouched.
  53519. */
  53520. NoSync = 3
  53521. }
  53522. /**
  53523. * Defines a plugin registered by the SceneLoader
  53524. */
  53525. interface IRegisteredPlugin {
  53526. /**
  53527. * Defines the plugin to use
  53528. */
  53529. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53530. /**
  53531. * Defines if the plugin supports binary data
  53532. */
  53533. isBinary: boolean;
  53534. }
  53535. /**
  53536. * Class used to load scene from various file formats using registered plugins
  53537. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  53538. */
  53539. export class SceneLoader {
  53540. /**
  53541. * No logging while loading
  53542. */
  53543. static readonly NO_LOGGING: number;
  53544. /**
  53545. * Minimal logging while loading
  53546. */
  53547. static readonly MINIMAL_LOGGING: number;
  53548. /**
  53549. * Summary logging while loading
  53550. */
  53551. static readonly SUMMARY_LOGGING: number;
  53552. /**
  53553. * Detailled logging while loading
  53554. */
  53555. static readonly DETAILED_LOGGING: number;
  53556. /**
  53557. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53558. */
  53559. static get ForceFullSceneLoadingForIncremental(): boolean;
  53560. static set ForceFullSceneLoadingForIncremental(value: boolean);
  53561. /**
  53562. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53563. */
  53564. static get ShowLoadingScreen(): boolean;
  53565. static set ShowLoadingScreen(value: boolean);
  53566. /**
  53567. * Defines the current logging level (while loading the scene)
  53568. * @ignorenaming
  53569. */
  53570. static get loggingLevel(): number;
  53571. static set loggingLevel(value: number);
  53572. /**
  53573. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53574. */
  53575. static get CleanBoneMatrixWeights(): boolean;
  53576. static set CleanBoneMatrixWeights(value: boolean);
  53577. /**
  53578. * Event raised when a plugin is used to load a scene
  53579. */
  53580. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53581. private static _registeredPlugins;
  53582. private static _showingLoadingScreen;
  53583. /**
  53584. * Gets the default plugin (used to load Babylon files)
  53585. * @returns the .babylon plugin
  53586. */
  53587. static GetDefaultPlugin(): IRegisteredPlugin;
  53588. private static _GetPluginForExtension;
  53589. private static _GetPluginForDirectLoad;
  53590. private static _GetPluginForFilename;
  53591. private static _GetDirectLoad;
  53592. private static _LoadData;
  53593. private static _GetFileInfo;
  53594. /**
  53595. * Gets a plugin that can load the given extension
  53596. * @param extension defines the extension to load
  53597. * @returns a plugin or null if none works
  53598. */
  53599. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53600. /**
  53601. * Gets a boolean indicating that the given extension can be loaded
  53602. * @param extension defines the extension to load
  53603. * @returns true if the extension is supported
  53604. */
  53605. static IsPluginForExtensionAvailable(extension: string): boolean;
  53606. /**
  53607. * Adds a new plugin to the list of registered plugins
  53608. * @param plugin defines the plugin to add
  53609. */
  53610. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  53611. /**
  53612. * Import meshes into a scene
  53613. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53614. * @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)
  53615. * @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)
  53616. * @param scene the instance of BABYLON.Scene to append to
  53617. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  53618. * @param onProgress a callback with a progress event for each file being loaded
  53619. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53620. * @param pluginExtension the extension used to determine the plugin
  53621. * @returns The loaded plugin
  53622. */
  53623. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53624. /**
  53625. * Import meshes into a scene
  53626. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53627. * @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)
  53628. * @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)
  53629. * @param scene the instance of BABYLON.Scene to append to
  53630. * @param onProgress a callback with a progress event for each file being loaded
  53631. * @param pluginExtension the extension used to determine the plugin
  53632. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53633. */
  53634. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  53635. /**
  53636. * Load a scene
  53637. * @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)
  53638. * @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)
  53639. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53640. * @param onSuccess a callback with the scene when import succeeds
  53641. * @param onProgress a callback with a progress event for each file being loaded
  53642. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53643. * @param pluginExtension the extension used to determine the plugin
  53644. * @returns The loaded plugin
  53645. */
  53646. 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>;
  53647. /**
  53648. * Load a scene
  53649. * @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)
  53650. * @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)
  53651. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53652. * @param onProgress a callback with a progress event for each file being loaded
  53653. * @param pluginExtension the extension used to determine the plugin
  53654. * @returns The loaded scene
  53655. */
  53656. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53657. /**
  53658. * Append a scene
  53659. * @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)
  53660. * @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)
  53661. * @param scene is the instance of BABYLON.Scene to append to
  53662. * @param onSuccess a callback with the scene when import succeeds
  53663. * @param onProgress a callback with a progress event for each file being loaded
  53664. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53665. * @param pluginExtension the extension used to determine the plugin
  53666. * @returns The loaded plugin
  53667. */
  53668. 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>;
  53669. /**
  53670. * Append a scene
  53671. * @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)
  53672. * @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)
  53673. * @param scene is the instance of BABYLON.Scene to append to
  53674. * @param onProgress a callback with a progress event for each file being loaded
  53675. * @param pluginExtension the extension used to determine the plugin
  53676. * @returns The given scene
  53677. */
  53678. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53679. /**
  53680. * Load a scene into an asset container
  53681. * @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)
  53682. * @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)
  53683. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53684. * @param onSuccess a callback with the scene when import succeeds
  53685. * @param onProgress a callback with a progress event for each file being loaded
  53686. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53687. * @param pluginExtension the extension used to determine the plugin
  53688. * @returns The loaded plugin
  53689. */
  53690. 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>;
  53691. /**
  53692. * Load a scene into an asset container
  53693. * @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)
  53694. * @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)
  53695. * @param scene is the instance of Scene to append to
  53696. * @param onProgress a callback with a progress event for each file being loaded
  53697. * @param pluginExtension the extension used to determine the plugin
  53698. * @returns The loaded asset container
  53699. */
  53700. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53701. /**
  53702. * Import animations from a file into a scene
  53703. * @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)
  53704. * @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)
  53705. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53706. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53707. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53708. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53709. * @param onSuccess a callback with the scene when import succeeds
  53710. * @param onProgress a callback with a progress event for each file being loaded
  53711. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53712. * @param pluginExtension the extension used to determine the plugin
  53713. */
  53714. 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;
  53715. /**
  53716. * Import animations from a file into a scene
  53717. * @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)
  53718. * @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)
  53719. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53720. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53721. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53722. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53723. * @param onSuccess a callback with the scene when import succeeds
  53724. * @param onProgress a callback with a progress event for each file being loaded
  53725. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53726. * @param pluginExtension the extension used to determine the plugin
  53727. * @returns the updated scene with imported animations
  53728. */
  53729. 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>;
  53730. }
  53731. }
  53732. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53733. import { IDisposable, Scene } from "babylonjs/scene";
  53734. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53735. import { Observable } from "babylonjs/Misc/observable";
  53736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53737. import { Nullable } from "babylonjs/types";
  53738. /**
  53739. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53740. */
  53741. export type MotionControllerHandedness = "none" | "left" | "right";
  53742. /**
  53743. * The type of components available in motion controllers.
  53744. * This is not the name of the component.
  53745. */
  53746. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53747. /**
  53748. * The state of a controller component
  53749. */
  53750. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53751. /**
  53752. * The schema of motion controller layout.
  53753. * No object will be initialized using this interface
  53754. * This is used just to define the profile.
  53755. */
  53756. export interface IMotionControllerLayout {
  53757. /**
  53758. * Path to load the assets. Usually relative to the base path
  53759. */
  53760. assetPath: string;
  53761. /**
  53762. * Available components (unsorted)
  53763. */
  53764. components: {
  53765. /**
  53766. * A map of component Ids
  53767. */
  53768. [componentId: string]: {
  53769. /**
  53770. * The type of input the component outputs
  53771. */
  53772. type: MotionControllerComponentType;
  53773. /**
  53774. * The indices of this component in the gamepad object
  53775. */
  53776. gamepadIndices: {
  53777. /**
  53778. * Index of button
  53779. */
  53780. button?: number;
  53781. /**
  53782. * If available, index of x-axis
  53783. */
  53784. xAxis?: number;
  53785. /**
  53786. * If available, index of y-axis
  53787. */
  53788. yAxis?: number;
  53789. };
  53790. /**
  53791. * The mesh's root node name
  53792. */
  53793. rootNodeName: string;
  53794. /**
  53795. * Animation definitions for this model
  53796. */
  53797. visualResponses: {
  53798. [stateKey: string]: {
  53799. /**
  53800. * What property will be animated
  53801. */
  53802. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53803. /**
  53804. * What states influence this visual response
  53805. */
  53806. states: MotionControllerComponentStateType[];
  53807. /**
  53808. * Type of animation - movement or visibility
  53809. */
  53810. valueNodeProperty: "transform" | "visibility";
  53811. /**
  53812. * Base node name to move. Its position will be calculated according to the min and max nodes
  53813. */
  53814. valueNodeName?: string;
  53815. /**
  53816. * Minimum movement node
  53817. */
  53818. minNodeName?: string;
  53819. /**
  53820. * Max movement node
  53821. */
  53822. maxNodeName?: string;
  53823. };
  53824. };
  53825. /**
  53826. * If touch enabled, what is the name of node to display user feedback
  53827. */
  53828. touchPointNodeName?: string;
  53829. };
  53830. };
  53831. /**
  53832. * Is it xr standard mapping or not
  53833. */
  53834. gamepadMapping: "" | "xr-standard";
  53835. /**
  53836. * Base root node of this entire model
  53837. */
  53838. rootNodeName: string;
  53839. /**
  53840. * Defines the main button component id
  53841. */
  53842. selectComponentId: string;
  53843. }
  53844. /**
  53845. * A definition for the layout map in the input profile
  53846. */
  53847. export interface IMotionControllerLayoutMap {
  53848. /**
  53849. * Layouts with handedness type as a key
  53850. */
  53851. [handedness: string]: IMotionControllerLayout;
  53852. }
  53853. /**
  53854. * The XR Input profile schema
  53855. * Profiles can be found here:
  53856. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53857. */
  53858. export interface IMotionControllerProfile {
  53859. /**
  53860. * fallback profiles for this profileId
  53861. */
  53862. fallbackProfileIds: string[];
  53863. /**
  53864. * The layout map, with handedness as key
  53865. */
  53866. layouts: IMotionControllerLayoutMap;
  53867. /**
  53868. * The id of this profile
  53869. * correlates to the profile(s) in the xrInput.profiles array
  53870. */
  53871. profileId: string;
  53872. }
  53873. /**
  53874. * A helper-interface for the 3 meshes needed for controller button animation
  53875. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53876. */
  53877. export interface IMotionControllerButtonMeshMap {
  53878. /**
  53879. * the mesh that defines the pressed value mesh position.
  53880. * This is used to find the max-position of this button
  53881. */
  53882. pressedMesh: AbstractMesh;
  53883. /**
  53884. * the mesh that defines the unpressed value mesh position.
  53885. * This is used to find the min (or initial) position of this button
  53886. */
  53887. unpressedMesh: AbstractMesh;
  53888. /**
  53889. * The mesh that will be changed when value changes
  53890. */
  53891. valueMesh: AbstractMesh;
  53892. }
  53893. /**
  53894. * A helper-interface for the 3 meshes needed for controller axis animation.
  53895. * This will be expanded when touchpad animations are fully supported
  53896. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53897. */
  53898. export interface IMotionControllerMeshMap {
  53899. /**
  53900. * the mesh that defines the maximum value mesh position.
  53901. */
  53902. maxMesh?: AbstractMesh;
  53903. /**
  53904. * the mesh that defines the minimum value mesh position.
  53905. */
  53906. minMesh?: AbstractMesh;
  53907. /**
  53908. * The mesh that will be changed when axis value changes
  53909. */
  53910. valueMesh?: AbstractMesh;
  53911. }
  53912. /**
  53913. * The elements needed for change-detection of the gamepad objects in motion controllers
  53914. */
  53915. export interface IMinimalMotionControllerObject {
  53916. /**
  53917. * Available axes of this controller
  53918. */
  53919. axes: number[];
  53920. /**
  53921. * An array of available buttons
  53922. */
  53923. buttons: Array<{
  53924. /**
  53925. * Value of the button/trigger
  53926. */
  53927. value: number;
  53928. /**
  53929. * If the button/trigger is currently touched
  53930. */
  53931. touched: boolean;
  53932. /**
  53933. * If the button/trigger is currently pressed
  53934. */
  53935. pressed: boolean;
  53936. }>;
  53937. /**
  53938. * EXPERIMENTAL haptic support.
  53939. */
  53940. hapticActuators?: Array<{
  53941. pulse: (value: number, duration: number) => Promise<boolean>;
  53942. }>;
  53943. }
  53944. /**
  53945. * An Abstract Motion controller
  53946. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53947. * Each component has an observable to check for changes in value and state
  53948. */
  53949. export abstract class WebXRAbstractMotionController implements IDisposable {
  53950. protected scene: Scene;
  53951. protected layout: IMotionControllerLayout;
  53952. /**
  53953. * The gamepad object correlating to this controller
  53954. */
  53955. gamepadObject: IMinimalMotionControllerObject;
  53956. /**
  53957. * handedness (left/right/none) of this controller
  53958. */
  53959. handedness: MotionControllerHandedness;
  53960. private _initComponent;
  53961. private _modelReady;
  53962. /**
  53963. * A map of components (WebXRControllerComponent) in this motion controller
  53964. * Components have a ComponentType and can also have both button and axis definitions
  53965. */
  53966. readonly components: {
  53967. [id: string]: WebXRControllerComponent;
  53968. };
  53969. /**
  53970. * Disable the model's animation. Can be set at any time.
  53971. */
  53972. disableAnimation: boolean;
  53973. /**
  53974. * Observers registered here will be triggered when the model of this controller is done loading
  53975. */
  53976. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53977. /**
  53978. * The profile id of this motion controller
  53979. */
  53980. abstract profileId: string;
  53981. /**
  53982. * The root mesh of the model. It is null if the model was not yet initialized
  53983. */
  53984. rootMesh: Nullable<AbstractMesh>;
  53985. /**
  53986. * constructs a new abstract motion controller
  53987. * @param scene the scene to which the model of the controller will be added
  53988. * @param layout The profile layout to load
  53989. * @param gamepadObject The gamepad object correlating to this controller
  53990. * @param handedness handedness (left/right/none) of this controller
  53991. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53992. */
  53993. constructor(scene: Scene, layout: IMotionControllerLayout,
  53994. /**
  53995. * The gamepad object correlating to this controller
  53996. */
  53997. gamepadObject: IMinimalMotionControllerObject,
  53998. /**
  53999. * handedness (left/right/none) of this controller
  54000. */
  54001. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  54002. /**
  54003. * Dispose this controller, the model mesh and all its components
  54004. */
  54005. dispose(): void;
  54006. /**
  54007. * Returns all components of specific type
  54008. * @param type the type to search for
  54009. * @return an array of components with this type
  54010. */
  54011. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  54012. /**
  54013. * get a component based an its component id as defined in layout.components
  54014. * @param id the id of the component
  54015. * @returns the component correlates to the id or undefined if not found
  54016. */
  54017. getComponent(id: string): WebXRControllerComponent;
  54018. /**
  54019. * Get the list of components available in this motion controller
  54020. * @returns an array of strings correlating to available components
  54021. */
  54022. getComponentIds(): string[];
  54023. /**
  54024. * Get the first component of specific type
  54025. * @param type type of component to find
  54026. * @return a controller component or null if not found
  54027. */
  54028. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54029. /**
  54030. * Get the main (Select) component of this controller as defined in the layout
  54031. * @returns the main component of this controller
  54032. */
  54033. getMainComponent(): WebXRControllerComponent;
  54034. /**
  54035. * Loads the model correlating to this controller
  54036. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54037. * @returns A promise fulfilled with the result of the model loading
  54038. */
  54039. loadModel(): Promise<boolean>;
  54040. /**
  54041. * Update this model using the current XRFrame
  54042. * @param xrFrame the current xr frame to use and update the model
  54043. */
  54044. updateFromXRFrame(xrFrame: XRFrame): void;
  54045. /**
  54046. * Backwards compatibility due to a deeply-integrated typo
  54047. */
  54048. get handness(): XREye;
  54049. /**
  54050. * Pulse (vibrate) this controller
  54051. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54052. * Consecutive calls to this function will cancel the last pulse call
  54053. *
  54054. * @param value the strength of the pulse in 0.0...1.0 range
  54055. * @param duration Duration of the pulse in milliseconds
  54056. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54057. * @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
  54058. */
  54059. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54060. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54061. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54062. /**
  54063. * Moves the axis on the controller mesh based on its current state
  54064. * @param axis the index of the axis
  54065. * @param axisValue the value of the axis which determines the meshes new position
  54066. * @hidden
  54067. */
  54068. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54069. /**
  54070. * Update the model itself with the current frame data
  54071. * @param xrFrame the frame to use for updating the model mesh
  54072. */
  54073. protected updateModel(xrFrame: XRFrame): void;
  54074. /**
  54075. * Get the filename and path for this controller's model
  54076. * @returns a map of filename and path
  54077. */
  54078. protected abstract _getFilenameAndPath(): {
  54079. filename: string;
  54080. path: string;
  54081. };
  54082. /**
  54083. * This function is called before the mesh is loaded. It checks for loading constraints.
  54084. * For example, this function can check if the GLB loader is available
  54085. * If this function returns false, the generic controller will be loaded instead
  54086. * @returns Is the client ready to load the mesh
  54087. */
  54088. protected abstract _getModelLoadingConstraints(): boolean;
  54089. /**
  54090. * This function will be called after the model was successfully loaded and can be used
  54091. * for mesh transformations before it is available for the user
  54092. * @param meshes the loaded meshes
  54093. */
  54094. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54095. /**
  54096. * Set the root mesh for this controller. Important for the WebXR controller class
  54097. * @param meshes the loaded meshes
  54098. */
  54099. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54100. /**
  54101. * A function executed each frame that updates the mesh (if needed)
  54102. * @param xrFrame the current xrFrame
  54103. */
  54104. protected abstract _updateModel(xrFrame: XRFrame): void;
  54105. private _getGenericFilenameAndPath;
  54106. private _getGenericParentMesh;
  54107. }
  54108. }
  54109. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  54110. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54112. import { Scene } from "babylonjs/scene";
  54113. /**
  54114. * A generic trigger-only motion controller for WebXR
  54115. */
  54116. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54117. /**
  54118. * Static version of the profile id of this controller
  54119. */
  54120. static ProfileId: string;
  54121. profileId: string;
  54122. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54123. protected _getFilenameAndPath(): {
  54124. filename: string;
  54125. path: string;
  54126. };
  54127. protected _getModelLoadingConstraints(): boolean;
  54128. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54129. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54130. protected _updateModel(): void;
  54131. }
  54132. }
  54133. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  54134. import { Vector4 } from "babylonjs/Maths/math.vector";
  54135. import { Mesh } from "babylonjs/Meshes/mesh";
  54136. import { Scene } from "babylonjs/scene";
  54137. import { Nullable } from "babylonjs/types";
  54138. /**
  54139. * Class containing static functions to help procedurally build meshes
  54140. */
  54141. export class SphereBuilder {
  54142. /**
  54143. * Creates a sphere mesh
  54144. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54145. * * 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`)
  54146. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54147. * * 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
  54148. * * 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)
  54149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54152. * @param name defines the name of the mesh
  54153. * @param options defines the options used to create the mesh
  54154. * @param scene defines the hosting scene
  54155. * @returns the sphere mesh
  54156. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54157. */
  54158. static CreateSphere(name: string, options: {
  54159. segments?: number;
  54160. diameter?: number;
  54161. diameterX?: number;
  54162. diameterY?: number;
  54163. diameterZ?: number;
  54164. arc?: number;
  54165. slice?: number;
  54166. sideOrientation?: number;
  54167. frontUVs?: Vector4;
  54168. backUVs?: Vector4;
  54169. updatable?: boolean;
  54170. }, scene?: Nullable<Scene>): Mesh;
  54171. }
  54172. }
  54173. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  54174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54175. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54176. import { Scene } from "babylonjs/scene";
  54177. /**
  54178. * A profiled motion controller has its profile loaded from an online repository.
  54179. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  54180. */
  54181. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  54182. private _repositoryUrl;
  54183. private _buttonMeshMapping;
  54184. private _touchDots;
  54185. /**
  54186. * The profile ID of this controller. Will be populated when the controller initializes.
  54187. */
  54188. profileId: string;
  54189. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  54190. dispose(): void;
  54191. protected _getFilenameAndPath(): {
  54192. filename: string;
  54193. path: string;
  54194. };
  54195. protected _getModelLoadingConstraints(): boolean;
  54196. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  54197. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54198. protected _updateModel(_xrFrame: XRFrame): void;
  54199. }
  54200. }
  54201. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  54202. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54203. import { Scene } from "babylonjs/scene";
  54204. /**
  54205. * A construction function type to create a new controller based on an xrInput object
  54206. */
  54207. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  54208. /**
  54209. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  54210. *
  54211. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  54212. * it should be replaced with auto-loaded controllers.
  54213. *
  54214. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  54215. */
  54216. export class WebXRMotionControllerManager {
  54217. private static _AvailableControllers;
  54218. private static _Fallbacks;
  54219. private static _ProfileLoadingPromises;
  54220. private static _ProfilesList;
  54221. /**
  54222. * The base URL of the online controller repository. Can be changed at any time.
  54223. */
  54224. static BaseRepositoryUrl: string;
  54225. /**
  54226. * Which repository gets priority - local or online
  54227. */
  54228. static PrioritizeOnlineRepository: boolean;
  54229. /**
  54230. * Use the online repository, or use only locally-defined controllers
  54231. */
  54232. static UseOnlineRepository: boolean;
  54233. /**
  54234. * Clear the cache used for profile loading and reload when requested again
  54235. */
  54236. static ClearProfilesCache(): void;
  54237. /**
  54238. * Register the default fallbacks.
  54239. * This function is called automatically when this file is imported.
  54240. */
  54241. static DefaultFallbacks(): void;
  54242. /**
  54243. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  54244. * @param profileId the profile to which a fallback needs to be found
  54245. * @return an array with corresponding fallback profiles
  54246. */
  54247. static FindFallbackWithProfileId(profileId: string): string[];
  54248. /**
  54249. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  54250. * The order of search:
  54251. *
  54252. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  54253. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54254. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  54255. * 4) return the generic trigger controller if none were found
  54256. *
  54257. * @param xrInput the xrInput to which a new controller is initialized
  54258. * @param scene the scene to which the model will be added
  54259. * @param forceProfile force a certain profile for this controller
  54260. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  54261. */
  54262. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  54263. /**
  54264. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  54265. *
  54266. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  54267. *
  54268. * @param type the profile type to register
  54269. * @param constructFunction the function to be called when loading this profile
  54270. */
  54271. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  54272. /**
  54273. * Register a fallback to a specific profile.
  54274. * @param profileId the profileId that will receive the fallbacks
  54275. * @param fallbacks A list of fallback profiles
  54276. */
  54277. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  54278. /**
  54279. * Will update the list of profiles available in the repository
  54280. * @return a promise that resolves to a map of profiles available online
  54281. */
  54282. static UpdateProfilesList(): Promise<{
  54283. [profile: string]: string;
  54284. }>;
  54285. private static _LoadProfileFromRepository;
  54286. private static _LoadProfilesFromAvailableControllers;
  54287. }
  54288. }
  54289. declare module "babylonjs/XR/webXRInputSource" {
  54290. import { Observable } from "babylonjs/Misc/observable";
  54291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54292. import { Ray } from "babylonjs/Culling/ray";
  54293. import { Scene } from "babylonjs/scene";
  54294. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54295. /**
  54296. * Configuration options for the WebXR controller creation
  54297. */
  54298. export interface IWebXRControllerOptions {
  54299. /**
  54300. * Should the controller mesh be animated when a user interacts with it
  54301. * The pressed buttons / thumbstick and touchpad animations will be disabled
  54302. */
  54303. disableMotionControllerAnimation?: boolean;
  54304. /**
  54305. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  54306. */
  54307. doNotLoadControllerMesh?: boolean;
  54308. /**
  54309. * Force a specific controller type for this controller.
  54310. * This can be used when creating your own profile or when testing different controllers
  54311. */
  54312. forceControllerProfile?: string;
  54313. /**
  54314. * Defines a rendering group ID for meshes that will be loaded.
  54315. * This is for the default controllers only.
  54316. */
  54317. renderingGroupId?: number;
  54318. }
  54319. /**
  54320. * Represents an XR controller
  54321. */
  54322. export class WebXRInputSource {
  54323. private _scene;
  54324. /** The underlying input source for the controller */
  54325. inputSource: XRInputSource;
  54326. private _options;
  54327. private _tmpVector;
  54328. private _uniqueId;
  54329. private _disposed;
  54330. /**
  54331. * 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
  54332. */
  54333. grip?: AbstractMesh;
  54334. /**
  54335. * If available, this is the gamepad object related to this controller.
  54336. * Using this object it is possible to get click events and trackpad changes of the
  54337. * webxr controller that is currently being used.
  54338. */
  54339. motionController?: WebXRAbstractMotionController;
  54340. /**
  54341. * Event that fires when the controller is removed/disposed.
  54342. * The object provided as event data is this controller, after associated assets were disposed.
  54343. * uniqueId is still available.
  54344. */
  54345. onDisposeObservable: Observable<WebXRInputSource>;
  54346. /**
  54347. * Will be triggered when the mesh associated with the motion controller is done loading.
  54348. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  54349. * A shortened version of controller -> motion controller -> on mesh loaded.
  54350. */
  54351. onMeshLoadedObservable: Observable<AbstractMesh>;
  54352. /**
  54353. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  54354. */
  54355. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  54356. /**
  54357. * Pointer which can be used to select objects or attach a visible laser to
  54358. */
  54359. pointer: AbstractMesh;
  54360. /**
  54361. * Creates the input source object
  54362. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  54363. * @param _scene the scene which the controller should be associated to
  54364. * @param inputSource the underlying input source for the controller
  54365. * @param _options options for this controller creation
  54366. */
  54367. constructor(_scene: Scene,
  54368. /** The underlying input source for the controller */
  54369. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  54370. /**
  54371. * Get this controllers unique id
  54372. */
  54373. get uniqueId(): string;
  54374. /**
  54375. * Disposes of the object
  54376. */
  54377. dispose(): void;
  54378. /**
  54379. * Gets a world space ray coming from the pointer or grip
  54380. * @param result the resulting ray
  54381. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  54382. */
  54383. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  54384. /**
  54385. * Updates the controller pose based on the given XRFrame
  54386. * @param xrFrame xr frame to update the pose with
  54387. * @param referenceSpace reference space to use
  54388. */
  54389. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  54390. }
  54391. }
  54392. declare module "babylonjs/XR/webXRInput" {
  54393. import { Observable } from "babylonjs/Misc/observable";
  54394. import { IDisposable } from "babylonjs/scene";
  54395. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  54396. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54397. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54398. /**
  54399. * The schema for initialization options of the XR Input class
  54400. */
  54401. export interface IWebXRInputOptions {
  54402. /**
  54403. * If set to true no model will be automatically loaded
  54404. */
  54405. doNotLoadControllerMeshes?: boolean;
  54406. /**
  54407. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  54408. * If not found, the xr input profile data will be used.
  54409. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  54410. */
  54411. forceInputProfile?: string;
  54412. /**
  54413. * Do not send a request to the controller repository to load the profile.
  54414. *
  54415. * Instead, use the controllers available in babylon itself.
  54416. */
  54417. disableOnlineControllerRepository?: boolean;
  54418. /**
  54419. * A custom URL for the controllers repository
  54420. */
  54421. customControllersRepositoryURL?: string;
  54422. /**
  54423. * Should the controller model's components not move according to the user input
  54424. */
  54425. disableControllerAnimation?: boolean;
  54426. /**
  54427. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  54428. */
  54429. controllerOptions?: IWebXRControllerOptions;
  54430. }
  54431. /**
  54432. * XR input used to track XR inputs such as controllers/rays
  54433. */
  54434. export class WebXRInput implements IDisposable {
  54435. /**
  54436. * the xr session manager for this session
  54437. */
  54438. xrSessionManager: WebXRSessionManager;
  54439. /**
  54440. * the WebXR camera for this session. Mainly used for teleportation
  54441. */
  54442. xrCamera: WebXRCamera;
  54443. private readonly options;
  54444. /**
  54445. * XR controllers being tracked
  54446. */
  54447. controllers: Array<WebXRInputSource>;
  54448. private _frameObserver;
  54449. private _sessionEndedObserver;
  54450. private _sessionInitObserver;
  54451. /**
  54452. * Event when a controller has been connected/added
  54453. */
  54454. onControllerAddedObservable: Observable<WebXRInputSource>;
  54455. /**
  54456. * Event when a controller has been removed/disconnected
  54457. */
  54458. onControllerRemovedObservable: Observable<WebXRInputSource>;
  54459. /**
  54460. * Initializes the WebXRInput
  54461. * @param xrSessionManager the xr session manager for this session
  54462. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  54463. * @param options = initialization options for this xr input
  54464. */
  54465. constructor(
  54466. /**
  54467. * the xr session manager for this session
  54468. */
  54469. xrSessionManager: WebXRSessionManager,
  54470. /**
  54471. * the WebXR camera for this session. Mainly used for teleportation
  54472. */
  54473. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  54474. private _onInputSourcesChange;
  54475. private _addAndRemoveControllers;
  54476. /**
  54477. * Disposes of the object
  54478. */
  54479. dispose(): void;
  54480. }
  54481. }
  54482. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  54483. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54484. import { Observable, EventState } from "babylonjs/Misc/observable";
  54485. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54486. /**
  54487. * This is the base class for all WebXR features.
  54488. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  54489. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  54490. */
  54491. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  54492. protected _xrSessionManager: WebXRSessionManager;
  54493. private _attached;
  54494. private _removeOnDetach;
  54495. /**
  54496. * Is this feature disposed?
  54497. */
  54498. isDisposed: boolean;
  54499. /**
  54500. * Should auto-attach be disabled?
  54501. */
  54502. disableAutoAttach: boolean;
  54503. /**
  54504. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  54505. */
  54506. xrNativeFeatureName: string;
  54507. /**
  54508. * Construct a new (abstract) WebXR feature
  54509. * @param _xrSessionManager the xr session manager for this feature
  54510. */
  54511. constructor(_xrSessionManager: WebXRSessionManager);
  54512. /**
  54513. * Is this feature attached
  54514. */
  54515. get attached(): boolean;
  54516. /**
  54517. * attach this feature
  54518. *
  54519. * @param force should attachment be forced (even when already attached)
  54520. * @returns true if successful, false is failed or already attached
  54521. */
  54522. attach(force?: boolean): boolean;
  54523. /**
  54524. * detach this feature.
  54525. *
  54526. * @returns true if successful, false if failed or already detached
  54527. */
  54528. detach(): boolean;
  54529. /**
  54530. * Dispose this feature and all of the resources attached
  54531. */
  54532. dispose(): void;
  54533. /**
  54534. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54535. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54536. *
  54537. * @returns whether or not the feature is compatible in this environment
  54538. */
  54539. isCompatible(): boolean;
  54540. /**
  54541. * This is used to register callbacks that will automatically be removed when detach is called.
  54542. * @param observable the observable to which the observer will be attached
  54543. * @param callback the callback to register
  54544. */
  54545. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  54546. /**
  54547. * Code in this function will be executed on each xrFrame received from the browser.
  54548. * This function will not execute after the feature is detached.
  54549. * @param _xrFrame the current frame
  54550. */
  54551. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  54552. }
  54553. }
  54554. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  54555. import { IDisposable, Scene } from "babylonjs/scene";
  54556. import { Nullable } from "babylonjs/types";
  54557. import { Observable } from "babylonjs/Misc/observable";
  54558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54559. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  54560. import { Camera } from "babylonjs/Cameras/camera";
  54561. /**
  54562. * Renders a layer on top of an existing scene
  54563. */
  54564. export class UtilityLayerRenderer implements IDisposable {
  54565. /** the original scene that will be rendered on top of */
  54566. originalScene: Scene;
  54567. private _pointerCaptures;
  54568. private _lastPointerEvents;
  54569. private static _DefaultUtilityLayer;
  54570. private static _DefaultKeepDepthUtilityLayer;
  54571. private _sharedGizmoLight;
  54572. private _renderCamera;
  54573. /**
  54574. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  54575. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  54576. * @returns the camera that is used when rendering the utility layer
  54577. */
  54578. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  54579. /**
  54580. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  54581. * @param cam the camera that should be used when rendering the utility layer
  54582. */
  54583. setRenderCamera(cam: Nullable<Camera>): void;
  54584. /**
  54585. * @hidden
  54586. * Light which used by gizmos to get light shading
  54587. */
  54588. _getSharedGizmoLight(): HemisphericLight;
  54589. /**
  54590. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  54591. */
  54592. pickUtilitySceneFirst: boolean;
  54593. /**
  54594. * 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)
  54595. */
  54596. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  54597. /**
  54598. * 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)
  54599. */
  54600. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  54601. /**
  54602. * The scene that is rendered on top of the original scene
  54603. */
  54604. utilityLayerScene: Scene;
  54605. /**
  54606. * If the utility layer should automatically be rendered on top of existing scene
  54607. */
  54608. shouldRender: boolean;
  54609. /**
  54610. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  54611. */
  54612. onlyCheckPointerDownEvents: boolean;
  54613. /**
  54614. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  54615. */
  54616. processAllEvents: boolean;
  54617. /**
  54618. * Observable raised when the pointer move from the utility layer scene to the main scene
  54619. */
  54620. onPointerOutObservable: Observable<number>;
  54621. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  54622. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  54623. private _afterRenderObserver;
  54624. private _sceneDisposeObserver;
  54625. private _originalPointerObserver;
  54626. /**
  54627. * Instantiates a UtilityLayerRenderer
  54628. * @param originalScene the original scene that will be rendered on top of
  54629. * @param handleEvents boolean indicating if the utility layer should handle events
  54630. */
  54631. constructor(
  54632. /** the original scene that will be rendered on top of */
  54633. originalScene: Scene, handleEvents?: boolean);
  54634. private _notifyObservers;
  54635. /**
  54636. * Renders the utility layers scene on top of the original scene
  54637. */
  54638. render(): void;
  54639. /**
  54640. * Disposes of the renderer
  54641. */
  54642. dispose(): void;
  54643. private _updateCamera;
  54644. }
  54645. }
  54646. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  54647. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54649. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54650. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  54651. import { Scene } from "babylonjs/scene";
  54652. import { Nullable } from "babylonjs/types";
  54653. import { Color3 } from "babylonjs/Maths/math.color";
  54654. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54655. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54656. /**
  54657. * Options interface for the pointer selection module
  54658. */
  54659. export interface IWebXRControllerPointerSelectionOptions {
  54660. /**
  54661. * if provided, this scene will be used to render meshes.
  54662. */
  54663. customUtilityLayerScene?: Scene;
  54664. /**
  54665. * 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)
  54666. * If not disabled, the last picked point will be used to execute a pointer up event
  54667. * If disabled, pointer up event will be triggered right after the pointer down event.
  54668. * Used in screen and gaze target ray mode only
  54669. */
  54670. disablePointerUpOnTouchOut: boolean;
  54671. /**
  54672. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54673. */
  54674. forceGazeMode: boolean;
  54675. /**
  54676. * 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
  54677. * to start a new countdown to the pointer down event.
  54678. * Defaults to 1.
  54679. */
  54680. gazeModePointerMovedFactor?: number;
  54681. /**
  54682. * Different button type to use instead of the main component
  54683. */
  54684. overrideButtonId?: string;
  54685. /**
  54686. * use this rendering group id for the meshes (optional)
  54687. */
  54688. renderingGroupId?: number;
  54689. /**
  54690. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54691. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54692. * 3000 means 3 seconds between pointing at something and selecting it
  54693. */
  54694. timeToSelect?: number;
  54695. /**
  54696. * Should meshes created here be added to a utility layer or the main scene
  54697. */
  54698. useUtilityLayer?: boolean;
  54699. /**
  54700. * Optional WebXR camera to be used for gaze selection
  54701. */
  54702. gazeCamera?: WebXRCamera;
  54703. /**
  54704. * the xr input to use with this pointer selection
  54705. */
  54706. xrInput: WebXRInput;
  54707. /**
  54708. * Should the scene pointerX and pointerY update be disabled
  54709. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54710. * Disable in VR, if not needed.
  54711. * The first rig camera (left eye) will be used to calculate the projection
  54712. */
  54713. disableScenePointerVectorUpdate: boolean;
  54714. /**
  54715. * Enable pointer selection on all controllers instead of switching between them
  54716. */
  54717. enablePointerSelectionOnAllControllers?: boolean;
  54718. /**
  54719. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54720. * If switch is enabled, it will still allow the user to switch between the different controllers
  54721. */
  54722. preferredHandedness?: XRHandedness;
  54723. /**
  54724. * Disable switching the pointer selection from one controller to the other.
  54725. * 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
  54726. */
  54727. disableSwitchOnClick?: boolean;
  54728. /**
  54729. * The maximum distance of the pointer selection feature. Defaults to 100.
  54730. */
  54731. maxPointerDistance?: number;
  54732. }
  54733. /**
  54734. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54735. */
  54736. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54737. private readonly _options;
  54738. private static _idCounter;
  54739. private _attachController;
  54740. private _controllers;
  54741. private _scene;
  54742. private _tmpVectorForPickCompare;
  54743. private _attachedController;
  54744. /**
  54745. * The module's name
  54746. */
  54747. static readonly Name: string;
  54748. /**
  54749. * The (Babylon) version of this module.
  54750. * This is an integer representing the implementation version.
  54751. * This number does not correspond to the WebXR specs version
  54752. */
  54753. static readonly Version: number;
  54754. /**
  54755. * Disable lighting on the laser pointer (so it will always be visible)
  54756. */
  54757. disablePointerLighting: boolean;
  54758. /**
  54759. * Disable lighting on the selection mesh (so it will always be visible)
  54760. */
  54761. disableSelectionMeshLighting: boolean;
  54762. /**
  54763. * Should the laser pointer be displayed
  54764. */
  54765. displayLaserPointer: boolean;
  54766. /**
  54767. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54768. */
  54769. displaySelectionMesh: boolean;
  54770. /**
  54771. * This color will be set to the laser pointer when selection is triggered
  54772. */
  54773. laserPointerPickedColor: Color3;
  54774. /**
  54775. * Default color of the laser pointer
  54776. */
  54777. laserPointerDefaultColor: Color3;
  54778. /**
  54779. * default color of the selection ring
  54780. */
  54781. selectionMeshDefaultColor: Color3;
  54782. /**
  54783. * This color will be applied to the selection ring when selection is triggered
  54784. */
  54785. selectionMeshPickedColor: Color3;
  54786. /**
  54787. * Optional filter to be used for ray selection. This predicate shares behavior with
  54788. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54789. */
  54790. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54791. /**
  54792. * constructs a new background remover module
  54793. * @param _xrSessionManager the session manager for this module
  54794. * @param _options read-only options to be used in this module
  54795. */
  54796. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54797. /**
  54798. * attach this feature
  54799. * Will usually be called by the features manager
  54800. *
  54801. * @returns true if successful.
  54802. */
  54803. attach(): boolean;
  54804. /**
  54805. * detach this feature.
  54806. * Will usually be called by the features manager
  54807. *
  54808. * @returns true if successful.
  54809. */
  54810. detach(): boolean;
  54811. /**
  54812. * Will get the mesh under a specific pointer.
  54813. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54814. * @param controllerId the controllerId to check
  54815. * @returns The mesh under pointer or null if no mesh is under the pointer
  54816. */
  54817. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54818. /**
  54819. * Get the xr controller that correlates to the pointer id in the pointer event
  54820. *
  54821. * @param id the pointer id to search for
  54822. * @returns the controller that correlates to this id or null if not found
  54823. */
  54824. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54825. private _identityMatrix;
  54826. private _screenCoordinatesRef;
  54827. private _viewportRef;
  54828. protected _onXRFrame(_xrFrame: XRFrame): void;
  54829. private _attachGazeMode;
  54830. private _attachScreenRayMode;
  54831. private _attachTrackedPointerRayMode;
  54832. private _convertNormalToDirectionOfRay;
  54833. private _detachController;
  54834. private _generateNewMeshPair;
  54835. private _pickingMoved;
  54836. private _updatePointerDistance;
  54837. /** @hidden */
  54838. get lasterPointerDefaultColor(): Color3;
  54839. }
  54840. }
  54841. declare module "babylonjs/XR/webXREnterExitUI" {
  54842. import { Nullable } from "babylonjs/types";
  54843. import { Observable } from "babylonjs/Misc/observable";
  54844. import { IDisposable, Scene } from "babylonjs/scene";
  54845. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54846. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54847. /**
  54848. * Button which can be used to enter a different mode of XR
  54849. */
  54850. export class WebXREnterExitUIButton {
  54851. /** button element */
  54852. element: HTMLElement;
  54853. /** XR initialization options for the button */
  54854. sessionMode: XRSessionMode;
  54855. /** Reference space type */
  54856. referenceSpaceType: XRReferenceSpaceType;
  54857. /**
  54858. * Creates a WebXREnterExitUIButton
  54859. * @param element button element
  54860. * @param sessionMode XR initialization session mode
  54861. * @param referenceSpaceType the type of reference space to be used
  54862. */
  54863. constructor(
  54864. /** button element */
  54865. element: HTMLElement,
  54866. /** XR initialization options for the button */
  54867. sessionMode: XRSessionMode,
  54868. /** Reference space type */
  54869. referenceSpaceType: XRReferenceSpaceType);
  54870. /**
  54871. * Extendable function which can be used to update the button's visuals when the state changes
  54872. * @param activeButton the current active button in the UI
  54873. */
  54874. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54875. }
  54876. /**
  54877. * Options to create the webXR UI
  54878. */
  54879. export class WebXREnterExitUIOptions {
  54880. /**
  54881. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54882. */
  54883. customButtons?: Array<WebXREnterExitUIButton>;
  54884. /**
  54885. * A reference space type to use when creating the default button.
  54886. * Default is local-floor
  54887. */
  54888. referenceSpaceType?: XRReferenceSpaceType;
  54889. /**
  54890. * Context to enter xr with
  54891. */
  54892. renderTarget?: Nullable<WebXRRenderTarget>;
  54893. /**
  54894. * A session mode to use when creating the default button.
  54895. * Default is immersive-vr
  54896. */
  54897. sessionMode?: XRSessionMode;
  54898. /**
  54899. * A list of optional features to init the session with
  54900. */
  54901. optionalFeatures?: string[];
  54902. /**
  54903. * A list of optional features to init the session with
  54904. */
  54905. requiredFeatures?: string[];
  54906. /**
  54907. * If defined, this function will be executed if the UI encounters an error when entering XR
  54908. */
  54909. onError?: (error: any) => void;
  54910. }
  54911. /**
  54912. * UI to allow the user to enter/exit XR mode
  54913. */
  54914. export class WebXREnterExitUI implements IDisposable {
  54915. private scene;
  54916. /** version of the options passed to this UI */
  54917. options: WebXREnterExitUIOptions;
  54918. private _activeButton;
  54919. private _buttons;
  54920. /**
  54921. * The HTML Div Element to which buttons are added.
  54922. */
  54923. readonly overlay: HTMLDivElement;
  54924. /**
  54925. * Fired every time the active button is changed.
  54926. *
  54927. * When xr is entered via a button that launches xr that button will be the callback parameter
  54928. *
  54929. * When exiting xr the callback parameter will be null)
  54930. */
  54931. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54932. /**
  54933. *
  54934. * @param scene babylon scene object to use
  54935. * @param options (read-only) version of the options passed to this UI
  54936. */
  54937. private constructor();
  54938. /**
  54939. * Creates UI to allow the user to enter/exit XR mode
  54940. * @param scene the scene to add the ui to
  54941. * @param helper the xr experience helper to enter/exit xr with
  54942. * @param options options to configure the UI
  54943. * @returns the created ui
  54944. */
  54945. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54946. /**
  54947. * Disposes of the XR UI component
  54948. */
  54949. dispose(): void;
  54950. private _updateButtons;
  54951. }
  54952. }
  54953. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54954. import { Vector3 } from "babylonjs/Maths/math.vector";
  54955. import { Color4 } from "babylonjs/Maths/math.color";
  54956. import { Nullable } from "babylonjs/types";
  54957. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54958. import { Scene } from "babylonjs/scene";
  54959. /**
  54960. * Class containing static functions to help procedurally build meshes
  54961. */
  54962. export class LinesBuilder {
  54963. /**
  54964. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54965. * * 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
  54966. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54967. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54968. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54969. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54970. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54971. * * 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
  54972. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54973. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54975. * @param name defines the name of the new line system
  54976. * @param options defines the options used to create the line system
  54977. * @param scene defines the hosting scene
  54978. * @returns a new line system mesh
  54979. */
  54980. static CreateLineSystem(name: string, options: {
  54981. lines: Vector3[][];
  54982. updatable?: boolean;
  54983. instance?: Nullable<LinesMesh>;
  54984. colors?: Nullable<Color4[][]>;
  54985. useVertexAlpha?: boolean;
  54986. }, scene: Nullable<Scene>): LinesMesh;
  54987. /**
  54988. * Creates a line mesh
  54989. * 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
  54990. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54991. * * The parameter `points` is an array successive Vector3
  54992. * * 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
  54993. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54994. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54995. * * When updating an instance, remember that only point positions can change, not the number of points
  54996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54997. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54998. * @param name defines the name of the new line system
  54999. * @param options defines the options used to create the line system
  55000. * @param scene defines the hosting scene
  55001. * @returns a new line mesh
  55002. */
  55003. static CreateLines(name: string, options: {
  55004. points: Vector3[];
  55005. updatable?: boolean;
  55006. instance?: Nullable<LinesMesh>;
  55007. colors?: Color4[];
  55008. useVertexAlpha?: boolean;
  55009. }, scene?: Nullable<Scene>): LinesMesh;
  55010. /**
  55011. * Creates a dashed line mesh
  55012. * * 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
  55013. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55014. * * The parameter `points` is an array successive Vector3
  55015. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55016. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55017. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55018. * * 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
  55019. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55020. * * When updating an instance, remember that only point positions can change, not the number of points
  55021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55022. * @param name defines the name of the mesh
  55023. * @param options defines the options used to create the mesh
  55024. * @param scene defines the hosting scene
  55025. * @returns the dashed line mesh
  55026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55027. */
  55028. static CreateDashedLines(name: string, options: {
  55029. points: Vector3[];
  55030. dashSize?: number;
  55031. gapSize?: number;
  55032. dashNb?: number;
  55033. updatable?: boolean;
  55034. instance?: LinesMesh;
  55035. useVertexAlpha?: boolean;
  55036. }, scene?: Nullable<Scene>): LinesMesh;
  55037. }
  55038. }
  55039. declare module "babylonjs/Misc/timer" {
  55040. import { Observable, Observer } from "babylonjs/Misc/observable";
  55041. import { Nullable } from "babylonjs/types";
  55042. import { IDisposable } from "babylonjs/scene";
  55043. /**
  55044. * Construction options for a timer
  55045. */
  55046. export interface ITimerOptions<T> {
  55047. /**
  55048. * Time-to-end
  55049. */
  55050. timeout: number;
  55051. /**
  55052. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55053. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55054. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55055. */
  55056. contextObservable: Observable<T>;
  55057. /**
  55058. * Optional parameters when adding an observer to the observable
  55059. */
  55060. observableParameters?: {
  55061. mask?: number;
  55062. insertFirst?: boolean;
  55063. scope?: any;
  55064. };
  55065. /**
  55066. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55067. */
  55068. breakCondition?: (data?: ITimerData<T>) => boolean;
  55069. /**
  55070. * Will be triggered when the time condition has met
  55071. */
  55072. onEnded?: (data: ITimerData<any>) => void;
  55073. /**
  55074. * Will be triggered when the break condition has met (prematurely ended)
  55075. */
  55076. onAborted?: (data: ITimerData<any>) => void;
  55077. /**
  55078. * Optional function to execute on each tick (or count)
  55079. */
  55080. onTick?: (data: ITimerData<any>) => void;
  55081. }
  55082. /**
  55083. * An interface defining the data sent by the timer
  55084. */
  55085. export interface ITimerData<T> {
  55086. /**
  55087. * When did it start
  55088. */
  55089. startTime: number;
  55090. /**
  55091. * Time now
  55092. */
  55093. currentTime: number;
  55094. /**
  55095. * Time passed since started
  55096. */
  55097. deltaTime: number;
  55098. /**
  55099. * How much is completed, in [0.0...1.0].
  55100. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55101. */
  55102. completeRate: number;
  55103. /**
  55104. * What the registered observable sent in the last count
  55105. */
  55106. payload: T;
  55107. }
  55108. /**
  55109. * The current state of the timer
  55110. */
  55111. export enum TimerState {
  55112. /**
  55113. * Timer initialized, not yet started
  55114. */
  55115. INIT = 0,
  55116. /**
  55117. * Timer started and counting
  55118. */
  55119. STARTED = 1,
  55120. /**
  55121. * Timer ended (whether aborted or time reached)
  55122. */
  55123. ENDED = 2
  55124. }
  55125. /**
  55126. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55127. *
  55128. * @param options options with which to initialize this timer
  55129. */
  55130. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55131. /**
  55132. * An advanced implementation of a timer class
  55133. */
  55134. export class AdvancedTimer<T = any> implements IDisposable {
  55135. /**
  55136. * Will notify each time the timer calculates the remaining time
  55137. */
  55138. onEachCountObservable: Observable<ITimerData<T>>;
  55139. /**
  55140. * Will trigger when the timer was aborted due to the break condition
  55141. */
  55142. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55143. /**
  55144. * Will trigger when the timer ended successfully
  55145. */
  55146. onTimerEndedObservable: Observable<ITimerData<T>>;
  55147. /**
  55148. * Will trigger when the timer state has changed
  55149. */
  55150. onStateChangedObservable: Observable<TimerState>;
  55151. private _observer;
  55152. private _contextObservable;
  55153. private _observableParameters;
  55154. private _startTime;
  55155. private _timer;
  55156. private _state;
  55157. private _breakCondition;
  55158. private _timeToEnd;
  55159. private _breakOnNextTick;
  55160. /**
  55161. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55162. * @param options construction options for this advanced timer
  55163. */
  55164. constructor(options: ITimerOptions<T>);
  55165. /**
  55166. * set a breaking condition for this timer. Default is to never break during count
  55167. * @param predicate the new break condition. Returns true to break, false otherwise
  55168. */
  55169. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55170. /**
  55171. * Reset ALL associated observables in this advanced timer
  55172. */
  55173. clearObservables(): void;
  55174. /**
  55175. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55176. *
  55177. * @param timeToEnd how much time to measure until timer ended
  55178. */
  55179. start(timeToEnd?: number): void;
  55180. /**
  55181. * Will force a stop on the next tick.
  55182. */
  55183. stop(): void;
  55184. /**
  55185. * Dispose this timer, clearing all resources
  55186. */
  55187. dispose(): void;
  55188. private _setState;
  55189. private _tick;
  55190. private _stop;
  55191. }
  55192. }
  55193. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  55194. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  55195. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55196. import { Nullable } from "babylonjs/types";
  55197. import { WebXRInput } from "babylonjs/XR/webXRInput";
  55198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55199. import { Vector3 } from "babylonjs/Maths/math.vector";
  55200. import { Material } from "babylonjs/Materials/material";
  55201. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  55202. import { Scene } from "babylonjs/scene";
  55203. /**
  55204. * The options container for the teleportation module
  55205. */
  55206. export interface IWebXRTeleportationOptions {
  55207. /**
  55208. * if provided, this scene will be used to render meshes.
  55209. */
  55210. customUtilityLayerScene?: Scene;
  55211. /**
  55212. * Values to configure the default target mesh
  55213. */
  55214. defaultTargetMeshOptions?: {
  55215. /**
  55216. * Fill color of the teleportation area
  55217. */
  55218. teleportationFillColor?: string;
  55219. /**
  55220. * Border color for the teleportation area
  55221. */
  55222. teleportationBorderColor?: string;
  55223. /**
  55224. * Disable the mesh's animation sequence
  55225. */
  55226. disableAnimation?: boolean;
  55227. /**
  55228. * Disable lighting on the material or the ring and arrow
  55229. */
  55230. disableLighting?: boolean;
  55231. /**
  55232. * Override the default material of the torus and arrow
  55233. */
  55234. torusArrowMaterial?: Material;
  55235. };
  55236. /**
  55237. * A list of meshes to use as floor meshes.
  55238. * Meshes can be added and removed after initializing the feature using the
  55239. * addFloorMesh and removeFloorMesh functions
  55240. * If empty, rotation will still work
  55241. */
  55242. floorMeshes?: AbstractMesh[];
  55243. /**
  55244. * use this rendering group id for the meshes (optional)
  55245. */
  55246. renderingGroupId?: number;
  55247. /**
  55248. * Should teleportation move only to snap points
  55249. */
  55250. snapPointsOnly?: boolean;
  55251. /**
  55252. * An array of points to which the teleportation will snap to.
  55253. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  55254. */
  55255. snapPositions?: Vector3[];
  55256. /**
  55257. * How close should the teleportation ray be in order to snap to position.
  55258. * Default to 0.8 units (meters)
  55259. */
  55260. snapToPositionRadius?: number;
  55261. /**
  55262. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  55263. * If you want to support rotation, make sure your mesh has a direction indicator.
  55264. *
  55265. * When left untouched, the default mesh will be initialized.
  55266. */
  55267. teleportationTargetMesh?: AbstractMesh;
  55268. /**
  55269. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  55270. */
  55271. timeToTeleport?: number;
  55272. /**
  55273. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  55274. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  55275. */
  55276. useMainComponentOnly?: boolean;
  55277. /**
  55278. * Should meshes created here be added to a utility layer or the main scene
  55279. */
  55280. useUtilityLayer?: boolean;
  55281. /**
  55282. * Babylon XR Input class for controller
  55283. */
  55284. xrInput: WebXRInput;
  55285. /**
  55286. * Meshes that the teleportation ray cannot go through
  55287. */
  55288. pickBlockerMeshes?: AbstractMesh[];
  55289. /**
  55290. * Should teleport work only on a specific hand?
  55291. */
  55292. forceHandedness?: XRHandedness;
  55293. /**
  55294. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  55295. */
  55296. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  55297. }
  55298. /**
  55299. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  55300. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  55301. * the input of the attached controllers.
  55302. */
  55303. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  55304. private _options;
  55305. private _controllers;
  55306. private _currentTeleportationControllerId;
  55307. private _floorMeshes;
  55308. private _quadraticBezierCurve;
  55309. private _selectionFeature;
  55310. private _snapToPositions;
  55311. private _snappedToPoint;
  55312. private _teleportationRingMaterial?;
  55313. private _tmpRay;
  55314. private _tmpVector;
  55315. private _tmpQuaternion;
  55316. /**
  55317. * The module's name
  55318. */
  55319. static readonly Name: string;
  55320. /**
  55321. * The (Babylon) version of this module.
  55322. * This is an integer representing the implementation version.
  55323. * This number does not correspond to the webxr specs version
  55324. */
  55325. static readonly Version: number;
  55326. /**
  55327. * Is movement backwards enabled
  55328. */
  55329. backwardsMovementEnabled: boolean;
  55330. /**
  55331. * Distance to travel when moving backwards
  55332. */
  55333. backwardsTeleportationDistance: number;
  55334. /**
  55335. * The distance from the user to the inspection point in the direction of the controller
  55336. * A higher number will allow the user to move further
  55337. * defaults to 5 (meters, in xr units)
  55338. */
  55339. parabolicCheckRadius: number;
  55340. /**
  55341. * Should the module support parabolic ray on top of direct ray
  55342. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  55343. * Very helpful when moving between floors / different heights
  55344. */
  55345. parabolicRayEnabled: boolean;
  55346. /**
  55347. * The second type of ray - straight line.
  55348. * Should it be enabled or should the parabolic line be the only one.
  55349. */
  55350. straightRayEnabled: boolean;
  55351. /**
  55352. * How much rotation should be applied when rotating right and left
  55353. */
  55354. rotationAngle: number;
  55355. private _rotationEnabled;
  55356. /**
  55357. * Is rotation enabled when moving forward?
  55358. * Disabling this feature will prevent the user from deciding the direction when teleporting
  55359. */
  55360. get rotationEnabled(): boolean;
  55361. /**
  55362. * Sets wether rotation is enabled or not
  55363. * @param enabled is rotation enabled when teleportation is shown
  55364. */
  55365. set rotationEnabled(enabled: boolean);
  55366. /**
  55367. * Exposes the currently set teleportation target mesh.
  55368. */
  55369. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  55370. /**
  55371. * constructs a new anchor system
  55372. * @param _xrSessionManager an instance of WebXRSessionManager
  55373. * @param _options configuration object for this feature
  55374. */
  55375. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  55376. /**
  55377. * Get the snapPointsOnly flag
  55378. */
  55379. get snapPointsOnly(): boolean;
  55380. /**
  55381. * Sets the snapPointsOnly flag
  55382. * @param snapToPoints should teleportation be exclusively to snap points
  55383. */
  55384. set snapPointsOnly(snapToPoints: boolean);
  55385. /**
  55386. * Add a new mesh to the floor meshes array
  55387. * @param mesh the mesh to use as floor mesh
  55388. */
  55389. addFloorMesh(mesh: AbstractMesh): void;
  55390. /**
  55391. * Add a new snap-to point to fix teleportation to this position
  55392. * @param newSnapPoint The new Snap-To point
  55393. */
  55394. addSnapPoint(newSnapPoint: Vector3): void;
  55395. attach(): boolean;
  55396. detach(): boolean;
  55397. dispose(): void;
  55398. /**
  55399. * Remove a mesh from the floor meshes array
  55400. * @param mesh the mesh to remove
  55401. */
  55402. removeFloorMesh(mesh: AbstractMesh): void;
  55403. /**
  55404. * Remove a mesh from the floor meshes array using its name
  55405. * @param name the mesh name to remove
  55406. */
  55407. removeFloorMeshByName(name: string): void;
  55408. /**
  55409. * 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
  55410. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  55411. * @returns was the point found and removed or not
  55412. */
  55413. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55414. /**
  55415. * This function sets a selection feature that will be disabled when
  55416. * the forward ray is shown and will be reattached when hidden.
  55417. * This is used to remove the selection rays when moving.
  55418. * @param selectionFeature the feature to disable when forward movement is enabled
  55419. */
  55420. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55421. protected _onXRFrame(_xrFrame: XRFrame): void;
  55422. private _attachController;
  55423. private _createDefaultTargetMesh;
  55424. private _detachController;
  55425. private _findClosestSnapPointWithRadius;
  55426. private _setTargetMeshPosition;
  55427. private _setTargetMeshVisibility;
  55428. private _showParabolicPath;
  55429. private _teleportForward;
  55430. }
  55431. }
  55432. declare module "babylonjs/XR/webXRDefaultExperience" {
  55433. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  55434. import { Scene } from "babylonjs/scene";
  55435. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  55436. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  55437. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55438. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  55439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55440. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55441. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  55442. /**
  55443. * Options for the default xr helper
  55444. */
  55445. export class WebXRDefaultExperienceOptions {
  55446. /**
  55447. * Enable or disable default UI to enter XR
  55448. */
  55449. disableDefaultUI?: boolean;
  55450. /**
  55451. * Should teleportation not initialize. defaults to false.
  55452. */
  55453. disableTeleportation?: boolean;
  55454. /**
  55455. * Floor meshes that will be used for teleport
  55456. */
  55457. floorMeshes?: Array<AbstractMesh>;
  55458. /**
  55459. * If set to true, the first frame will not be used to reset position
  55460. * The first frame is mainly used when copying transformation from the old camera
  55461. * Mainly used in AR
  55462. */
  55463. ignoreNativeCameraTransformation?: boolean;
  55464. /**
  55465. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  55466. */
  55467. inputOptions?: IWebXRInputOptions;
  55468. /**
  55469. * optional configuration for the output canvas
  55470. */
  55471. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  55472. /**
  55473. * optional UI options. This can be used among other to change session mode and reference space type
  55474. */
  55475. uiOptions?: WebXREnterExitUIOptions;
  55476. /**
  55477. * When loading teleportation and pointer select, use stable versions instead of latest.
  55478. */
  55479. useStablePlugins?: boolean;
  55480. /**
  55481. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  55482. */
  55483. renderingGroupId?: number;
  55484. /**
  55485. * A list of optional features to init the session with
  55486. * If set to true, all features we support will be added
  55487. */
  55488. optionalFeatures?: boolean | string[];
  55489. }
  55490. /**
  55491. * Default experience which provides a similar setup to the previous webVRExperience
  55492. */
  55493. export class WebXRDefaultExperience {
  55494. /**
  55495. * Base experience
  55496. */
  55497. baseExperience: WebXRExperienceHelper;
  55498. /**
  55499. * Enables ui for entering/exiting xr
  55500. */
  55501. enterExitUI: WebXREnterExitUI;
  55502. /**
  55503. * Input experience extension
  55504. */
  55505. input: WebXRInput;
  55506. /**
  55507. * Enables laser pointer and selection
  55508. */
  55509. pointerSelection: WebXRControllerPointerSelection;
  55510. /**
  55511. * Default target xr should render to
  55512. */
  55513. renderTarget: WebXRRenderTarget;
  55514. /**
  55515. * Enables teleportation
  55516. */
  55517. teleportation: WebXRMotionControllerTeleportation;
  55518. private constructor();
  55519. /**
  55520. * Creates the default xr experience
  55521. * @param scene scene
  55522. * @param options options for basic configuration
  55523. * @returns resulting WebXRDefaultExperience
  55524. */
  55525. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55526. /**
  55527. * DIsposes of the experience helper
  55528. */
  55529. dispose(): void;
  55530. }
  55531. }
  55532. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  55533. import { Observable } from "babylonjs/Misc/observable";
  55534. import { Nullable } from "babylonjs/types";
  55535. import { Camera } from "babylonjs/Cameras/camera";
  55536. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55537. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55538. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  55539. import { Scene } from "babylonjs/scene";
  55540. import { Vector3 } from "babylonjs/Maths/math.vector";
  55541. import { Color3 } from "babylonjs/Maths/math.color";
  55542. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55544. import { Mesh } from "babylonjs/Meshes/mesh";
  55545. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  55546. import { EasingFunction } from "babylonjs/Animations/easing";
  55547. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55548. import "babylonjs/Meshes/Builders/groundBuilder";
  55549. import "babylonjs/Meshes/Builders/torusBuilder";
  55550. import "babylonjs/Meshes/Builders/cylinderBuilder";
  55551. import "babylonjs/Gamepads/gamepadSceneComponent";
  55552. import "babylonjs/Animations/animatable";
  55553. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  55554. /**
  55555. * Options to modify the vr teleportation behavior.
  55556. */
  55557. export interface VRTeleportationOptions {
  55558. /**
  55559. * The name of the mesh which should be used as the teleportation floor. (default: null)
  55560. */
  55561. floorMeshName?: string;
  55562. /**
  55563. * A list of meshes to be used as the teleportation floor. (default: empty)
  55564. */
  55565. floorMeshes?: Mesh[];
  55566. /**
  55567. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  55568. */
  55569. teleportationMode?: number;
  55570. /**
  55571. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  55572. */
  55573. teleportationTime?: number;
  55574. /**
  55575. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  55576. */
  55577. teleportationSpeed?: number;
  55578. /**
  55579. * The easing function used in the animation or null for Linear. (default CircleEase)
  55580. */
  55581. easingFunction?: EasingFunction;
  55582. }
  55583. /**
  55584. * Options to modify the vr experience helper's behavior.
  55585. */
  55586. export interface VRExperienceHelperOptions extends WebVROptions {
  55587. /**
  55588. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  55589. */
  55590. createDeviceOrientationCamera?: boolean;
  55591. /**
  55592. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  55593. */
  55594. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  55595. /**
  55596. * Uses the main button on the controller to toggle the laser casted. (default: true)
  55597. */
  55598. laserToggle?: boolean;
  55599. /**
  55600. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  55601. */
  55602. floorMeshes?: Mesh[];
  55603. /**
  55604. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  55605. */
  55606. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  55607. /**
  55608. * Defines if WebXR should be used instead of WebVR (if available)
  55609. */
  55610. useXR?: boolean;
  55611. }
  55612. /**
  55613. * Event containing information after VR has been entered
  55614. */
  55615. export class OnAfterEnteringVRObservableEvent {
  55616. /**
  55617. * If entering vr was successful
  55618. */
  55619. success: boolean;
  55620. }
  55621. /**
  55622. * Helps to quickly add VR support to an existing scene.
  55623. * See https://doc.babylonjs.com/how_to/webvr_helper
  55624. */
  55625. export class VRExperienceHelper {
  55626. /** Options to modify the vr experience helper's behavior. */
  55627. webVROptions: VRExperienceHelperOptions;
  55628. private _scene;
  55629. private _position;
  55630. private _btnVR;
  55631. private _btnVRDisplayed;
  55632. private _webVRsupported;
  55633. private _webVRready;
  55634. private _webVRrequesting;
  55635. private _webVRpresenting;
  55636. private _hasEnteredVR;
  55637. private _fullscreenVRpresenting;
  55638. private _inputElement;
  55639. private _webVRCamera;
  55640. private _vrDeviceOrientationCamera;
  55641. private _deviceOrientationCamera;
  55642. private _existingCamera;
  55643. private _onKeyDown;
  55644. private _onVrDisplayPresentChange;
  55645. private _onVRDisplayChanged;
  55646. private _onVRRequestPresentStart;
  55647. private _onVRRequestPresentComplete;
  55648. /**
  55649. * 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)
  55650. */
  55651. enableGazeEvenWhenNoPointerLock: boolean;
  55652. /**
  55653. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  55654. */
  55655. exitVROnDoubleTap: boolean;
  55656. /**
  55657. * Observable raised right before entering VR.
  55658. */
  55659. onEnteringVRObservable: Observable<VRExperienceHelper>;
  55660. /**
  55661. * Observable raised when entering VR has completed.
  55662. */
  55663. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  55664. /**
  55665. * Observable raised when exiting VR.
  55666. */
  55667. onExitingVRObservable: Observable<VRExperienceHelper>;
  55668. /**
  55669. * Observable raised when controller mesh is loaded.
  55670. */
  55671. onControllerMeshLoadedObservable: Observable<WebVRController>;
  55672. /** Return this.onEnteringVRObservable
  55673. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  55674. */
  55675. get onEnteringVR(): Observable<VRExperienceHelper>;
  55676. /** Return this.onExitingVRObservable
  55677. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  55678. */
  55679. get onExitingVR(): Observable<VRExperienceHelper>;
  55680. /** Return this.onControllerMeshLoadedObservable
  55681. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  55682. */
  55683. get onControllerMeshLoaded(): Observable<WebVRController>;
  55684. private _rayLength;
  55685. private _useCustomVRButton;
  55686. private _teleportationRequested;
  55687. private _teleportActive;
  55688. private _floorMeshName;
  55689. private _floorMeshesCollection;
  55690. private _teleportationMode;
  55691. private _teleportationTime;
  55692. private _teleportationSpeed;
  55693. private _teleportationEasing;
  55694. private _rotationAllowed;
  55695. private _teleportBackwardsVector;
  55696. private _teleportationTarget;
  55697. private _isDefaultTeleportationTarget;
  55698. private _postProcessMove;
  55699. private _teleportationFillColor;
  55700. private _teleportationBorderColor;
  55701. private _rotationAngle;
  55702. private _haloCenter;
  55703. private _cameraGazer;
  55704. private _padSensibilityUp;
  55705. private _padSensibilityDown;
  55706. private _leftController;
  55707. private _rightController;
  55708. private _gazeColor;
  55709. private _laserColor;
  55710. private _pickedLaserColor;
  55711. private _pickedGazeColor;
  55712. /**
  55713. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55714. */
  55715. onNewMeshSelected: Observable<AbstractMesh>;
  55716. /**
  55717. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55718. * This observable will provide the mesh and the controller used to select the mesh
  55719. */
  55720. onMeshSelectedWithController: Observable<{
  55721. mesh: AbstractMesh;
  55722. controller: WebVRController;
  55723. }>;
  55724. /**
  55725. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55726. */
  55727. onNewMeshPicked: Observable<PickingInfo>;
  55728. private _circleEase;
  55729. /**
  55730. * Observable raised before camera teleportation
  55731. */
  55732. onBeforeCameraTeleport: Observable<Vector3>;
  55733. /**
  55734. * Observable raised after camera teleportation
  55735. */
  55736. onAfterCameraTeleport: Observable<Vector3>;
  55737. /**
  55738. * Observable raised when current selected mesh gets unselected
  55739. */
  55740. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55741. private _raySelectionPredicate;
  55742. /**
  55743. * To be optionaly changed by user to define custom ray selection
  55744. */
  55745. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55746. /**
  55747. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55748. */
  55749. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55750. /**
  55751. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55752. */
  55753. teleportationEnabled: boolean;
  55754. private _defaultHeight;
  55755. private _teleportationInitialized;
  55756. private _interactionsEnabled;
  55757. private _interactionsRequested;
  55758. private _displayGaze;
  55759. private _displayLaserPointer;
  55760. /**
  55761. * The mesh used to display where the user is going to teleport.
  55762. */
  55763. get teleportationTarget(): Mesh;
  55764. /**
  55765. * Sets the mesh to be used to display where the user is going to teleport.
  55766. */
  55767. set teleportationTarget(value: Mesh);
  55768. /**
  55769. * 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
  55770. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55771. * See https://doc.babylonjs.com/resources/baking_transformations
  55772. */
  55773. get gazeTrackerMesh(): Mesh;
  55774. set gazeTrackerMesh(value: Mesh);
  55775. /**
  55776. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55777. */
  55778. updateGazeTrackerScale: boolean;
  55779. /**
  55780. * If the gaze trackers color should be updated when selecting meshes
  55781. */
  55782. updateGazeTrackerColor: boolean;
  55783. /**
  55784. * If the controller laser color should be updated when selecting meshes
  55785. */
  55786. updateControllerLaserColor: boolean;
  55787. /**
  55788. * The gaze tracking mesh corresponding to the left controller
  55789. */
  55790. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55791. /**
  55792. * The gaze tracking mesh corresponding to the right controller
  55793. */
  55794. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55795. /**
  55796. * If the ray of the gaze should be displayed.
  55797. */
  55798. get displayGaze(): boolean;
  55799. /**
  55800. * Sets if the ray of the gaze should be displayed.
  55801. */
  55802. set displayGaze(value: boolean);
  55803. /**
  55804. * If the ray of the LaserPointer should be displayed.
  55805. */
  55806. get displayLaserPointer(): boolean;
  55807. /**
  55808. * Sets if the ray of the LaserPointer should be displayed.
  55809. */
  55810. set displayLaserPointer(value: boolean);
  55811. /**
  55812. * The deviceOrientationCamera used as the camera when not in VR.
  55813. */
  55814. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55815. /**
  55816. * Based on the current WebVR support, returns the current VR camera used.
  55817. */
  55818. get currentVRCamera(): Nullable<Camera>;
  55819. /**
  55820. * The webVRCamera which is used when in VR.
  55821. */
  55822. get webVRCamera(): WebVRFreeCamera;
  55823. /**
  55824. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55825. */
  55826. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55827. /**
  55828. * The html button that is used to trigger entering into VR.
  55829. */
  55830. get vrButton(): Nullable<HTMLButtonElement>;
  55831. private get _teleportationRequestInitiated();
  55832. /**
  55833. * Defines whether or not Pointer lock should be requested when switching to
  55834. * full screen.
  55835. */
  55836. requestPointerLockOnFullScreen: boolean;
  55837. /**
  55838. * If asking to force XR, this will be populated with the default xr experience
  55839. */
  55840. xr: WebXRDefaultExperience;
  55841. /**
  55842. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55843. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55844. */
  55845. xrTestDone: boolean;
  55846. /**
  55847. * Instantiates a VRExperienceHelper.
  55848. * Helps to quickly add VR support to an existing scene.
  55849. * @param scene The scene the VRExperienceHelper belongs to.
  55850. * @param webVROptions Options to modify the vr experience helper's behavior.
  55851. */
  55852. constructor(scene: Scene,
  55853. /** Options to modify the vr experience helper's behavior. */
  55854. webVROptions?: VRExperienceHelperOptions);
  55855. private completeVRInit;
  55856. private _onDefaultMeshLoaded;
  55857. private _onResize;
  55858. private _onFullscreenChange;
  55859. /**
  55860. * Gets a value indicating if we are currently in VR mode.
  55861. */
  55862. get isInVRMode(): boolean;
  55863. private onVrDisplayPresentChange;
  55864. private onVRDisplayChanged;
  55865. private moveButtonToBottomRight;
  55866. private displayVRButton;
  55867. private updateButtonVisibility;
  55868. private _cachedAngularSensibility;
  55869. /**
  55870. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55871. * Otherwise, will use the fullscreen API.
  55872. */
  55873. enterVR(): void;
  55874. /**
  55875. * Attempt to exit VR, or fullscreen.
  55876. */
  55877. exitVR(): void;
  55878. /**
  55879. * The position of the vr experience helper.
  55880. */
  55881. get position(): Vector3;
  55882. /**
  55883. * Sets the position of the vr experience helper.
  55884. */
  55885. set position(value: Vector3);
  55886. /**
  55887. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55888. */
  55889. enableInteractions(): void;
  55890. private get _noControllerIsActive();
  55891. private beforeRender;
  55892. private _isTeleportationFloor;
  55893. /**
  55894. * Adds a floor mesh to be used for teleportation.
  55895. * @param floorMesh the mesh to be used for teleportation.
  55896. */
  55897. addFloorMesh(floorMesh: Mesh): void;
  55898. /**
  55899. * Removes a floor mesh from being used for teleportation.
  55900. * @param floorMesh the mesh to be removed.
  55901. */
  55902. removeFloorMesh(floorMesh: Mesh): void;
  55903. /**
  55904. * Enables interactions and teleportation using the VR controllers and gaze.
  55905. * @param vrTeleportationOptions options to modify teleportation behavior.
  55906. */
  55907. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55908. private _onNewGamepadConnected;
  55909. private _tryEnableInteractionOnController;
  55910. private _onNewGamepadDisconnected;
  55911. private _enableInteractionOnController;
  55912. private _checkTeleportWithRay;
  55913. private _checkRotate;
  55914. private _checkTeleportBackwards;
  55915. private _enableTeleportationOnController;
  55916. private _createTeleportationCircles;
  55917. private _displayTeleportationTarget;
  55918. private _hideTeleportationTarget;
  55919. private _rotateCamera;
  55920. private _moveTeleportationSelectorTo;
  55921. private _workingVector;
  55922. private _workingQuaternion;
  55923. private _workingMatrix;
  55924. /**
  55925. * Time Constant Teleportation Mode
  55926. */
  55927. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55928. /**
  55929. * Speed Constant Teleportation Mode
  55930. */
  55931. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55932. /**
  55933. * Teleports the users feet to the desired location
  55934. * @param location The location where the user's feet should be placed
  55935. */
  55936. teleportCamera(location: Vector3): void;
  55937. private _convertNormalToDirectionOfRay;
  55938. private _castRayAndSelectObject;
  55939. private _notifySelectedMeshUnselected;
  55940. /**
  55941. * Permanently set new colors for the laser pointer
  55942. * @param color the new laser color
  55943. * @param pickedColor the new laser color when picked mesh detected
  55944. */
  55945. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55946. /**
  55947. * Set lighting enabled / disabled on the laser pointer of both controllers
  55948. * @param enabled should the lighting be enabled on the laser pointer
  55949. */
  55950. setLaserLightingState(enabled?: boolean): void;
  55951. /**
  55952. * Permanently set new colors for the gaze pointer
  55953. * @param color the new gaze color
  55954. * @param pickedColor the new gaze color when picked mesh detected
  55955. */
  55956. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55957. /**
  55958. * Sets the color of the laser ray from the vr controllers.
  55959. * @param color new color for the ray.
  55960. */
  55961. changeLaserColor(color: Color3): void;
  55962. /**
  55963. * Sets the color of the ray from the vr headsets gaze.
  55964. * @param color new color for the ray.
  55965. */
  55966. changeGazeColor(color: Color3): void;
  55967. /**
  55968. * Exits VR and disposes of the vr experience helper
  55969. */
  55970. dispose(): void;
  55971. /**
  55972. * Gets the name of the VRExperienceHelper class
  55973. * @returns "VRExperienceHelper"
  55974. */
  55975. getClassName(): string;
  55976. }
  55977. }
  55978. declare module "babylonjs/Cameras/VR/index" {
  55979. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55980. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55981. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55982. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55983. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55984. export * from "babylonjs/Cameras/VR/webVRCamera";
  55985. }
  55986. declare module "babylonjs/Cameras/RigModes/index" {
  55987. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55988. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55989. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55990. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55991. }
  55992. declare module "babylonjs/Cameras/index" {
  55993. export * from "babylonjs/Cameras/Inputs/index";
  55994. export * from "babylonjs/Cameras/cameraInputsManager";
  55995. export * from "babylonjs/Cameras/camera";
  55996. export * from "babylonjs/Cameras/targetCamera";
  55997. export * from "babylonjs/Cameras/freeCamera";
  55998. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55999. export * from "babylonjs/Cameras/touchCamera";
  56000. export * from "babylonjs/Cameras/arcRotateCamera";
  56001. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  56002. export * from "babylonjs/Cameras/deviceOrientationCamera";
  56003. export * from "babylonjs/Cameras/flyCamera";
  56004. export * from "babylonjs/Cameras/flyCameraInputsManager";
  56005. export * from "babylonjs/Cameras/followCamera";
  56006. export * from "babylonjs/Cameras/followCameraInputsManager";
  56007. export * from "babylonjs/Cameras/gamepadCamera";
  56008. export * from "babylonjs/Cameras/Stereoscopic/index";
  56009. export * from "babylonjs/Cameras/universalCamera";
  56010. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  56011. export * from "babylonjs/Cameras/VR/index";
  56012. export * from "babylonjs/Cameras/RigModes/index";
  56013. }
  56014. declare module "babylonjs/Collisions/index" {
  56015. export * from "babylonjs/Collisions/collider";
  56016. export * from "babylonjs/Collisions/collisionCoordinator";
  56017. export * from "babylonjs/Collisions/pickingInfo";
  56018. export * from "babylonjs/Collisions/intersectionInfo";
  56019. export * from "babylonjs/Collisions/meshCollisionData";
  56020. }
  56021. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  56022. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  56023. import { Vector3 } from "babylonjs/Maths/math.vector";
  56024. import { Ray } from "babylonjs/Culling/ray";
  56025. import { Plane } from "babylonjs/Maths/math.plane";
  56026. /**
  56027. * Contains an array of blocks representing the octree
  56028. */
  56029. export interface IOctreeContainer<T> {
  56030. /**
  56031. * Blocks within the octree
  56032. */
  56033. blocks: Array<OctreeBlock<T>>;
  56034. }
  56035. /**
  56036. * Class used to store a cell in an octree
  56037. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56038. */
  56039. export class OctreeBlock<T> {
  56040. /**
  56041. * Gets the content of the current block
  56042. */
  56043. entries: T[];
  56044. /**
  56045. * Gets the list of block children
  56046. */
  56047. blocks: Array<OctreeBlock<T>>;
  56048. private _depth;
  56049. private _maxDepth;
  56050. private _capacity;
  56051. private _minPoint;
  56052. private _maxPoint;
  56053. private _boundingVectors;
  56054. private _creationFunc;
  56055. /**
  56056. * Creates a new block
  56057. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56058. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56059. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56060. * @param depth defines the current depth of this block in the octree
  56061. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56062. * @param creationFunc defines a callback to call when an element is added to the block
  56063. */
  56064. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56065. /**
  56066. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56067. */
  56068. get capacity(): number;
  56069. /**
  56070. * Gets the minimum vector (in world space) of the block's bounding box
  56071. */
  56072. get minPoint(): Vector3;
  56073. /**
  56074. * Gets the maximum vector (in world space) of the block's bounding box
  56075. */
  56076. get maxPoint(): Vector3;
  56077. /**
  56078. * Add a new element to this block
  56079. * @param entry defines the element to add
  56080. */
  56081. addEntry(entry: T): void;
  56082. /**
  56083. * Remove an element from this block
  56084. * @param entry defines the element to remove
  56085. */
  56086. removeEntry(entry: T): void;
  56087. /**
  56088. * Add an array of elements to this block
  56089. * @param entries defines the array of elements to add
  56090. */
  56091. addEntries(entries: T[]): void;
  56092. /**
  56093. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56094. * @param frustumPlanes defines the frustum planes to test
  56095. * @param selection defines the array to store current content if selection is positive
  56096. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56097. */
  56098. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56099. /**
  56100. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56101. * @param sphereCenter defines the bounding sphere center
  56102. * @param sphereRadius defines the bounding sphere radius
  56103. * @param selection defines the array to store current content if selection is positive
  56104. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56105. */
  56106. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56107. /**
  56108. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56109. * @param ray defines the ray to test with
  56110. * @param selection defines the array to store current content if selection is positive
  56111. */
  56112. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56113. /**
  56114. * Subdivide the content into child blocks (this block will then be empty)
  56115. */
  56116. createInnerBlocks(): void;
  56117. /**
  56118. * @hidden
  56119. */
  56120. 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;
  56121. }
  56122. }
  56123. declare module "babylonjs/Culling/Octrees/octree" {
  56124. import { SmartArray } from "babylonjs/Misc/smartArray";
  56125. import { Vector3 } from "babylonjs/Maths/math.vector";
  56126. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56128. import { Ray } from "babylonjs/Culling/ray";
  56129. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  56130. import { Plane } from "babylonjs/Maths/math.plane";
  56131. /**
  56132. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56133. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56134. */
  56135. export class Octree<T> {
  56136. /** 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.) */
  56137. maxDepth: number;
  56138. /**
  56139. * Blocks within the octree containing objects
  56140. */
  56141. blocks: Array<OctreeBlock<T>>;
  56142. /**
  56143. * Content stored in the octree
  56144. */
  56145. dynamicContent: T[];
  56146. private _maxBlockCapacity;
  56147. private _selectionContent;
  56148. private _creationFunc;
  56149. /**
  56150. * Creates a octree
  56151. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56152. * @param creationFunc function to be used to instatiate the octree
  56153. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56154. * @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.)
  56155. */
  56156. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56157. /** 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.) */
  56158. maxDepth?: number);
  56159. /**
  56160. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56161. * @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);
  56162. * @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);
  56163. * @param entries meshes to be added to the octree blocks
  56164. */
  56165. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56166. /**
  56167. * Adds a mesh to the octree
  56168. * @param entry Mesh to add to the octree
  56169. */
  56170. addMesh(entry: T): void;
  56171. /**
  56172. * Remove an element from the octree
  56173. * @param entry defines the element to remove
  56174. */
  56175. removeMesh(entry: T): void;
  56176. /**
  56177. * Selects an array of meshes within the frustum
  56178. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56179. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56180. * @returns array of meshes within the frustum
  56181. */
  56182. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56183. /**
  56184. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56185. * @param sphereCenter defines the bounding sphere center
  56186. * @param sphereRadius defines the bounding sphere radius
  56187. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56188. * @returns an array of objects that intersect the sphere
  56189. */
  56190. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56191. /**
  56192. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56193. * @param ray defines the ray to test with
  56194. * @returns array of intersected objects
  56195. */
  56196. intersectsRay(ray: Ray): SmartArray<T>;
  56197. /**
  56198. * Adds a mesh into the octree block if it intersects the block
  56199. */
  56200. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56201. /**
  56202. * Adds a submesh into the octree block if it intersects the block
  56203. */
  56204. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56205. }
  56206. }
  56207. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  56208. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  56209. import { Scene } from "babylonjs/scene";
  56210. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56212. import { Ray } from "babylonjs/Culling/ray";
  56213. import { Octree } from "babylonjs/Culling/Octrees/octree";
  56214. import { Collider } from "babylonjs/Collisions/collider";
  56215. module "babylonjs/scene" {
  56216. interface Scene {
  56217. /**
  56218. * @hidden
  56219. * Backing Filed
  56220. */
  56221. _selectionOctree: Octree<AbstractMesh>;
  56222. /**
  56223. * Gets the octree used to boost mesh selection (picking)
  56224. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56225. */
  56226. selectionOctree: Octree<AbstractMesh>;
  56227. /**
  56228. * Creates or updates the octree used to boost selection (picking)
  56229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56230. * @param maxCapacity defines the maximum capacity per leaf
  56231. * @param maxDepth defines the maximum depth of the octree
  56232. * @returns an octree of AbstractMesh
  56233. */
  56234. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56235. }
  56236. }
  56237. module "babylonjs/Meshes/abstractMesh" {
  56238. interface AbstractMesh {
  56239. /**
  56240. * @hidden
  56241. * Backing Field
  56242. */
  56243. _submeshesOctree: Octree<SubMesh>;
  56244. /**
  56245. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56246. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56247. * @param maxCapacity defines the maximum size of each block (64 by default)
  56248. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56249. * @returns the new octree
  56250. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56251. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56252. */
  56253. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56254. }
  56255. }
  56256. /**
  56257. * Defines the octree scene component responsible to manage any octrees
  56258. * in a given scene.
  56259. */
  56260. export class OctreeSceneComponent {
  56261. /**
  56262. * The component name help to identify the component in the list of scene components.
  56263. */
  56264. readonly name: string;
  56265. /**
  56266. * The scene the component belongs to.
  56267. */
  56268. scene: Scene;
  56269. /**
  56270. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56271. */
  56272. readonly checksIsEnabled: boolean;
  56273. /**
  56274. * Creates a new instance of the component for the given scene
  56275. * @param scene Defines the scene to register the component in
  56276. */
  56277. constructor(scene: Scene);
  56278. /**
  56279. * Registers the component in a given scene
  56280. */
  56281. register(): void;
  56282. /**
  56283. * Return the list of active meshes
  56284. * @returns the list of active meshes
  56285. */
  56286. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56287. /**
  56288. * Return the list of active sub meshes
  56289. * @param mesh The mesh to get the candidates sub meshes from
  56290. * @returns the list of active sub meshes
  56291. */
  56292. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56293. private _tempRay;
  56294. /**
  56295. * Return the list of sub meshes intersecting with a given local ray
  56296. * @param mesh defines the mesh to find the submesh for
  56297. * @param localRay defines the ray in local space
  56298. * @returns the list of intersecting sub meshes
  56299. */
  56300. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56301. /**
  56302. * Return the list of sub meshes colliding with a collider
  56303. * @param mesh defines the mesh to find the submesh for
  56304. * @param collider defines the collider to evaluate the collision against
  56305. * @returns the list of colliding sub meshes
  56306. */
  56307. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56308. /**
  56309. * Rebuilds the elements related to this component in case of
  56310. * context lost for instance.
  56311. */
  56312. rebuild(): void;
  56313. /**
  56314. * Disposes the component and the associated ressources.
  56315. */
  56316. dispose(): void;
  56317. }
  56318. }
  56319. declare module "babylonjs/Culling/Octrees/index" {
  56320. export * from "babylonjs/Culling/Octrees/octree";
  56321. export * from "babylonjs/Culling/Octrees/octreeBlock";
  56322. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  56323. }
  56324. declare module "babylonjs/Culling/index" {
  56325. export * from "babylonjs/Culling/boundingBox";
  56326. export * from "babylonjs/Culling/boundingInfo";
  56327. export * from "babylonjs/Culling/boundingSphere";
  56328. export * from "babylonjs/Culling/Octrees/index";
  56329. export * from "babylonjs/Culling/ray";
  56330. }
  56331. declare module "babylonjs/Gizmos/gizmo" {
  56332. import { Observer } from "babylonjs/Misc/observable";
  56333. import { Nullable } from "babylonjs/types";
  56334. import { IDisposable } from "babylonjs/scene";
  56335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56336. import { Mesh } from "babylonjs/Meshes/mesh";
  56337. import { Node } from "babylonjs/node";
  56338. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56339. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56340. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  56341. /**
  56342. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  56343. */
  56344. export interface GizmoAxisCache {
  56345. /** Mesh used to runder the Gizmo */
  56346. gizmoMeshes: Mesh[];
  56347. /** Mesh used to detect user interaction with Gizmo */
  56348. colliderMeshes: Mesh[];
  56349. /** Material used to inicate color of gizmo mesh */
  56350. material: StandardMaterial;
  56351. /** Material used to inicate hover state of the Gizmo */
  56352. hoverMaterial: StandardMaterial;
  56353. /** Material used to inicate disabled state of the Gizmo */
  56354. disableMaterial: StandardMaterial;
  56355. /** Used to indicate Active state of the Gizmo */
  56356. active: boolean;
  56357. }
  56358. /**
  56359. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  56360. */
  56361. export class Gizmo implements IDisposable {
  56362. /** The utility layer the gizmo will be added to */
  56363. gizmoLayer: UtilityLayerRenderer;
  56364. /**
  56365. * The root mesh of the gizmo
  56366. */
  56367. _rootMesh: Mesh;
  56368. private _attachedMesh;
  56369. private _attachedNode;
  56370. /**
  56371. * Ratio for the scale of the gizmo (Default: 1)
  56372. */
  56373. protected _scaleRatio: number;
  56374. /**
  56375. * boolean updated by pointermove when a gizmo mesh is hovered
  56376. */
  56377. protected _isHovered: boolean;
  56378. /**
  56379. * Ratio for the scale of the gizmo (Default: 1)
  56380. */
  56381. set scaleRatio(value: number);
  56382. get scaleRatio(): number;
  56383. /**
  56384. * True when the mouse pointer is hovered a gizmo mesh
  56385. */
  56386. get isHovered(): boolean;
  56387. /**
  56388. * If a custom mesh has been set (Default: false)
  56389. */
  56390. protected _customMeshSet: boolean;
  56391. /**
  56392. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  56393. * * When set, interactions will be enabled
  56394. */
  56395. get attachedMesh(): Nullable<AbstractMesh>;
  56396. set attachedMesh(value: Nullable<AbstractMesh>);
  56397. /**
  56398. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  56399. * * When set, interactions will be enabled
  56400. */
  56401. get attachedNode(): Nullable<Node>;
  56402. set attachedNode(value: Nullable<Node>);
  56403. /**
  56404. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56405. * @param mesh The mesh to replace the default mesh of the gizmo
  56406. */
  56407. setCustomMesh(mesh: Mesh): void;
  56408. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56409. /**
  56410. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56411. */
  56412. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56413. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56414. /**
  56415. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56416. */
  56417. updateGizmoPositionToMatchAttachedMesh: boolean;
  56418. /**
  56419. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56420. */
  56421. updateScale: boolean;
  56422. protected _interactionsEnabled: boolean;
  56423. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56424. private _beforeRenderObserver;
  56425. private _tempQuaternion;
  56426. private _tempVector;
  56427. private _tempVector2;
  56428. private _tempMatrix1;
  56429. private _tempMatrix2;
  56430. private _rightHandtoLeftHandMatrix;
  56431. /**
  56432. * Creates a gizmo
  56433. * @param gizmoLayer The utility layer the gizmo will be added to
  56434. */
  56435. constructor(
  56436. /** The utility layer the gizmo will be added to */
  56437. gizmoLayer?: UtilityLayerRenderer);
  56438. /**
  56439. * Updates the gizmo to match the attached mesh's position/rotation
  56440. */
  56441. protected _update(): void;
  56442. /**
  56443. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56444. * @param value Node, TransformNode or mesh
  56445. */
  56446. protected _matrixChanged(): void;
  56447. /**
  56448. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  56449. * @param gizmoLayer The utility layer the gizmo will be added to
  56450. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  56451. * @returns {Observer<PointerInfo>} pointerObserver
  56452. */
  56453. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  56454. /**
  56455. * Disposes of the gizmo
  56456. */
  56457. dispose(): void;
  56458. }
  56459. }
  56460. declare module "babylonjs/Gizmos/planeDragGizmo" {
  56461. import { Observable } from "babylonjs/Misc/observable";
  56462. import { Nullable } from "babylonjs/types";
  56463. import { Vector3 } from "babylonjs/Maths/math.vector";
  56464. import { Color3 } from "babylonjs/Maths/math.color";
  56465. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56466. import { Node } from "babylonjs/node";
  56467. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56468. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56469. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56470. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56471. import { Scene } from "babylonjs/scene";
  56472. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56473. /**
  56474. * Single plane drag gizmo
  56475. */
  56476. export class PlaneDragGizmo extends Gizmo {
  56477. /**
  56478. * Drag behavior responsible for the gizmos dragging interactions
  56479. */
  56480. dragBehavior: PointerDragBehavior;
  56481. private _pointerObserver;
  56482. /**
  56483. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56484. */
  56485. snapDistance: number;
  56486. /**
  56487. * Event that fires each time the gizmo snaps to a new location.
  56488. * * snapDistance is the the change in distance
  56489. */
  56490. onSnapObservable: Observable<{
  56491. snapDistance: number;
  56492. }>;
  56493. private _gizmoMesh;
  56494. private _coloredMaterial;
  56495. private _hoverMaterial;
  56496. private _disableMaterial;
  56497. private _isEnabled;
  56498. private _parent;
  56499. private _dragging;
  56500. /** @hidden */
  56501. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56502. /**
  56503. * Creates a PlaneDragGizmo
  56504. * @param gizmoLayer The utility layer the gizmo will be added to
  56505. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56506. * @param color The color of the gizmo
  56507. */
  56508. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56509. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56510. /**
  56511. * If the gizmo is enabled
  56512. */
  56513. set isEnabled(value: boolean);
  56514. get isEnabled(): boolean;
  56515. /**
  56516. * Disposes of the gizmo
  56517. */
  56518. dispose(): void;
  56519. }
  56520. }
  56521. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56522. import { Observable } from "babylonjs/Misc/observable";
  56523. import { Nullable } from "babylonjs/types";
  56524. import { Vector3 } from "babylonjs/Maths/math.vector";
  56525. import { Color3 } from "babylonjs/Maths/math.color";
  56526. import "babylonjs/Meshes/Builders/linesBuilder";
  56527. import { Node } from "babylonjs/node";
  56528. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56529. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56530. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56531. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56532. /**
  56533. * Single plane rotation gizmo
  56534. */
  56535. export class PlaneRotationGizmo extends Gizmo {
  56536. /**
  56537. * Drag behavior responsible for the gizmos dragging interactions
  56538. */
  56539. dragBehavior: PointerDragBehavior;
  56540. private _pointerObserver;
  56541. /**
  56542. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56543. */
  56544. snapDistance: number;
  56545. /**
  56546. * Event that fires each time the gizmo snaps to a new location.
  56547. * * snapDistance is the the change in distance
  56548. */
  56549. onSnapObservable: Observable<{
  56550. snapDistance: number;
  56551. }>;
  56552. private _isEnabled;
  56553. private _parent;
  56554. private _coloredMaterial;
  56555. private _hoverMaterial;
  56556. private _disableMaterial;
  56557. private _gizmoMesh;
  56558. private _rotationCircle;
  56559. private _dragging;
  56560. private static _CircleConstants;
  56561. /**
  56562. * Creates a PlaneRotationGizmo
  56563. * @param gizmoLayer The utility layer the gizmo will be added to
  56564. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56565. * @param color The color of the gizmo
  56566. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56567. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56568. * @param thickness display gizmo axis thickness
  56569. */
  56570. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56571. /** Create Geometry for Gizmo */
  56572. private _createGizmoMesh;
  56573. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56574. private setupRotationCircle;
  56575. private updateRotationPath;
  56576. private updateRotationCircle;
  56577. /**
  56578. * If the gizmo is enabled
  56579. */
  56580. set isEnabled(value: boolean);
  56581. get isEnabled(): boolean;
  56582. /**
  56583. * Disposes of the gizmo
  56584. */
  56585. dispose(): void;
  56586. }
  56587. }
  56588. declare module "babylonjs/Gizmos/rotationGizmo" {
  56589. import { Observable } from "babylonjs/Misc/observable";
  56590. import { Nullable } from "babylonjs/types";
  56591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56592. import { Mesh } from "babylonjs/Meshes/mesh";
  56593. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56594. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56595. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56596. import { Node } from "babylonjs/node";
  56597. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56598. /**
  56599. * Gizmo that enables rotating a mesh along 3 axis
  56600. */
  56601. export class RotationGizmo extends Gizmo {
  56602. /**
  56603. * Internal gizmo used for interactions on the x axis
  56604. */
  56605. xGizmo: PlaneRotationGizmo;
  56606. /**
  56607. * Internal gizmo used for interactions on the y axis
  56608. */
  56609. yGizmo: PlaneRotationGizmo;
  56610. /**
  56611. * Internal gizmo used for interactions on the z axis
  56612. */
  56613. zGizmo: PlaneRotationGizmo;
  56614. /** Fires an event when any of it's sub gizmos are dragged */
  56615. onDragStartObservable: Observable<unknown>;
  56616. /** Fires an event when any of it's sub gizmos are released from dragging */
  56617. onDragEndObservable: Observable<unknown>;
  56618. private _meshAttached;
  56619. private _nodeAttached;
  56620. private _observables;
  56621. /** Node Caching for quick lookup */
  56622. private _gizmoAxisCache;
  56623. get attachedMesh(): Nullable<AbstractMesh>;
  56624. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56625. get attachedNode(): Nullable<Node>;
  56626. set attachedNode(node: Nullable<Node>);
  56627. protected _checkBillboardTransform(): void;
  56628. /**
  56629. * True when the mouse pointer is hovering a gizmo mesh
  56630. */
  56631. get isHovered(): boolean;
  56632. /**
  56633. * Creates a RotationGizmo
  56634. * @param gizmoLayer The utility layer the gizmo will be added to
  56635. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56636. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56637. * @param thickness display gizmo axis thickness
  56638. */
  56639. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  56640. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56641. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56642. /**
  56643. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56644. */
  56645. set snapDistance(value: number);
  56646. get snapDistance(): number;
  56647. /**
  56648. * Ratio for the scale of the gizmo (Default: 1)
  56649. */
  56650. set scaleRatio(value: number);
  56651. get scaleRatio(): number;
  56652. /**
  56653. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56654. * @param mesh Axis gizmo mesh
  56655. * @param cache Gizmo axis definition used for reactive gizmo UI
  56656. */
  56657. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56658. /**
  56659. * Disposes of the gizmo
  56660. */
  56661. dispose(): void;
  56662. /**
  56663. * CustomMeshes are not supported by this gizmo
  56664. * @param mesh The mesh to replace the default mesh of the gizmo
  56665. */
  56666. setCustomMesh(mesh: Mesh): void;
  56667. }
  56668. }
  56669. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  56670. import { Scene } from "babylonjs/scene";
  56671. import { Vector4 } from "babylonjs/Maths/math.vector";
  56672. import { Color4 } from "babylonjs/Maths/math.color";
  56673. import { Mesh } from "babylonjs/Meshes/mesh";
  56674. import { Nullable } from "babylonjs/types";
  56675. /**
  56676. * Class containing static functions to help procedurally build meshes
  56677. */
  56678. export class PolyhedronBuilder {
  56679. /**
  56680. * Creates a polyhedron mesh
  56681. * * 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
  56682. * * The parameter `size` (positive float, default 1) sets the polygon size
  56683. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56684. * * 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`
  56685. * * 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
  56686. * * 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)`)
  56687. * * 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
  56688. * * 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
  56689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56692. * @param name defines the name of the mesh
  56693. * @param options defines the options used to create the mesh
  56694. * @param scene defines the hosting scene
  56695. * @returns the polyhedron mesh
  56696. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56697. */
  56698. static CreatePolyhedron(name: string, options: {
  56699. type?: number;
  56700. size?: number;
  56701. sizeX?: number;
  56702. sizeY?: number;
  56703. sizeZ?: number;
  56704. custom?: any;
  56705. faceUV?: Vector4[];
  56706. faceColors?: Color4[];
  56707. flat?: boolean;
  56708. updatable?: boolean;
  56709. sideOrientation?: number;
  56710. frontUVs?: Vector4;
  56711. backUVs?: Vector4;
  56712. }, scene?: Nullable<Scene>): Mesh;
  56713. }
  56714. }
  56715. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56716. import { Nullable } from "babylonjs/types";
  56717. import { Scene } from "babylonjs/scene";
  56718. import { Vector4 } from "babylonjs/Maths/math.vector";
  56719. import { Color4 } from "babylonjs/Maths/math.color";
  56720. import { Mesh } from "babylonjs/Meshes/mesh";
  56721. /**
  56722. * Class containing static functions to help procedurally build meshes
  56723. */
  56724. export class BoxBuilder {
  56725. /**
  56726. * Creates a box mesh
  56727. * * The parameter `size` sets the size (float) of each box side (default 1)
  56728. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56729. * * 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)
  56730. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56734. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56735. * @param name defines the name of the mesh
  56736. * @param options defines the options used to create the mesh
  56737. * @param scene defines the hosting scene
  56738. * @returns the box mesh
  56739. */
  56740. static CreateBox(name: string, options: {
  56741. size?: number;
  56742. width?: number;
  56743. height?: number;
  56744. depth?: number;
  56745. faceUV?: Vector4[];
  56746. faceColors?: Color4[];
  56747. sideOrientation?: number;
  56748. frontUVs?: Vector4;
  56749. backUVs?: Vector4;
  56750. wrap?: boolean;
  56751. topBaseAt?: number;
  56752. bottomBaseAt?: number;
  56753. updatable?: boolean;
  56754. }, scene?: Nullable<Scene>): Mesh;
  56755. }
  56756. }
  56757. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  56758. import { Observable } from "babylonjs/Misc/observable";
  56759. import { Nullable } from "babylonjs/types";
  56760. import { Vector3 } from "babylonjs/Maths/math.vector";
  56761. import { Node } from "babylonjs/node";
  56762. import { Mesh } from "babylonjs/Meshes/mesh";
  56763. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56764. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56765. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56766. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56767. import { Color3 } from "babylonjs/Maths/math.color";
  56768. /**
  56769. * Single axis scale gizmo
  56770. */
  56771. export class AxisScaleGizmo extends Gizmo {
  56772. /**
  56773. * Drag behavior responsible for the gizmos dragging interactions
  56774. */
  56775. dragBehavior: PointerDragBehavior;
  56776. private _pointerObserver;
  56777. /**
  56778. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56779. */
  56780. snapDistance: number;
  56781. /**
  56782. * Event that fires each time the gizmo snaps to a new location.
  56783. * * snapDistance is the the change in distance
  56784. */
  56785. onSnapObservable: Observable<{
  56786. snapDistance: number;
  56787. }>;
  56788. /**
  56789. * If the scaling operation should be done on all axis (default: false)
  56790. */
  56791. uniformScaling: boolean;
  56792. /**
  56793. * Custom sensitivity value for the drag strength
  56794. */
  56795. sensitivity: number;
  56796. private _isEnabled;
  56797. private _parent;
  56798. private _gizmoMesh;
  56799. private _coloredMaterial;
  56800. private _hoverMaterial;
  56801. private _disableMaterial;
  56802. private _dragging;
  56803. private _tmpVector;
  56804. private _tmpMatrix;
  56805. private _tmpMatrix2;
  56806. /**
  56807. * Creates an AxisScaleGizmo
  56808. * @param gizmoLayer The utility layer the gizmo will be added to
  56809. * @param dragAxis The axis which the gizmo will be able to scale on
  56810. * @param color The color of the gizmo
  56811. * @param thickness display gizmo axis thickness
  56812. */
  56813. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56814. /** Create Geometry for Gizmo */
  56815. private _createGizmoMesh;
  56816. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56817. /**
  56818. * If the gizmo is enabled
  56819. */
  56820. set isEnabled(value: boolean);
  56821. get isEnabled(): boolean;
  56822. /**
  56823. * Disposes of the gizmo
  56824. */
  56825. dispose(): void;
  56826. /**
  56827. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56828. * @param mesh The mesh to replace the default mesh of the gizmo
  56829. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56830. */
  56831. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56832. }
  56833. }
  56834. declare module "babylonjs/Gizmos/scaleGizmo" {
  56835. import { Observable } from "babylonjs/Misc/observable";
  56836. import { Nullable } from "babylonjs/types";
  56837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56838. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56839. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  56840. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56841. import { Mesh } from "babylonjs/Meshes/mesh";
  56842. import { Node } from "babylonjs/node";
  56843. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56844. /**
  56845. * Gizmo that enables scaling a mesh along 3 axis
  56846. */
  56847. export class ScaleGizmo extends Gizmo {
  56848. /**
  56849. * Internal gizmo used for interactions on the x axis
  56850. */
  56851. xGizmo: AxisScaleGizmo;
  56852. /**
  56853. * Internal gizmo used for interactions on the y axis
  56854. */
  56855. yGizmo: AxisScaleGizmo;
  56856. /**
  56857. * Internal gizmo used for interactions on the z axis
  56858. */
  56859. zGizmo: AxisScaleGizmo;
  56860. /**
  56861. * Internal gizmo used to scale all axis equally
  56862. */
  56863. uniformScaleGizmo: AxisScaleGizmo;
  56864. private _meshAttached;
  56865. private _nodeAttached;
  56866. private _snapDistance;
  56867. private _uniformScalingMesh;
  56868. private _octahedron;
  56869. private _sensitivity;
  56870. private _coloredMaterial;
  56871. private _hoverMaterial;
  56872. private _disableMaterial;
  56873. private _observables;
  56874. /** Node Caching for quick lookup */
  56875. private _gizmoAxisCache;
  56876. /** Fires an event when any of it's sub gizmos are dragged */
  56877. onDragStartObservable: Observable<unknown>;
  56878. /** Fires an event when any of it's sub gizmos are released from dragging */
  56879. onDragEndObservable: Observable<unknown>;
  56880. get attachedMesh(): Nullable<AbstractMesh>;
  56881. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56882. get attachedNode(): Nullable<Node>;
  56883. set attachedNode(node: Nullable<Node>);
  56884. /**
  56885. * True when the mouse pointer is hovering a gizmo mesh
  56886. */
  56887. get isHovered(): boolean;
  56888. /**
  56889. * Creates a ScaleGizmo
  56890. * @param gizmoLayer The utility layer the gizmo will be added to
  56891. * @param thickness display gizmo axis thickness
  56892. */
  56893. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  56894. /** Create Geometry for Gizmo */
  56895. private _createUniformScaleMesh;
  56896. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56897. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56898. /**
  56899. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56900. */
  56901. set snapDistance(value: number);
  56902. get snapDistance(): number;
  56903. /**
  56904. * Ratio for the scale of the gizmo (Default: 1)
  56905. */
  56906. set scaleRatio(value: number);
  56907. get scaleRatio(): number;
  56908. /**
  56909. * Sensitivity factor for dragging (Default: 1)
  56910. */
  56911. set sensitivity(value: number);
  56912. get sensitivity(): number;
  56913. /**
  56914. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56915. * @param mesh Axis gizmo mesh
  56916. * @param cache Gizmo axis definition used for reactive gizmo UI
  56917. */
  56918. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56919. /**
  56920. * Disposes of the gizmo
  56921. */
  56922. dispose(): void;
  56923. }
  56924. }
  56925. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56926. import { Observable } from "babylonjs/Misc/observable";
  56927. import { Nullable } from "babylonjs/types";
  56928. import { Vector3 } from "babylonjs/Maths/math.vector";
  56929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56930. import { Mesh } from "babylonjs/Meshes/mesh";
  56931. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56932. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56933. import { Color3 } from "babylonjs/Maths/math.color";
  56934. import "babylonjs/Meshes/Builders/boxBuilder";
  56935. /**
  56936. * Bounding box gizmo
  56937. */
  56938. export class BoundingBoxGizmo extends Gizmo {
  56939. private _lineBoundingBox;
  56940. private _rotateSpheresParent;
  56941. private _scaleBoxesParent;
  56942. private _boundingDimensions;
  56943. private _renderObserver;
  56944. private _pointerObserver;
  56945. private _scaleDragSpeed;
  56946. private _tmpQuaternion;
  56947. private _tmpVector;
  56948. private _tmpRotationMatrix;
  56949. /**
  56950. * 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)
  56951. */
  56952. ignoreChildren: boolean;
  56953. /**
  56954. * 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)
  56955. */
  56956. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56957. /**
  56958. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56959. */
  56960. rotationSphereSize: number;
  56961. /**
  56962. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56963. */
  56964. scaleBoxSize: number;
  56965. /**
  56966. * 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)
  56967. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  56968. */
  56969. fixedDragMeshScreenSize: boolean;
  56970. /**
  56971. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  56972. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  56973. */
  56974. fixedDragMeshBoundsSize: boolean;
  56975. /**
  56976. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56977. */
  56978. fixedDragMeshScreenSizeDistanceFactor: number;
  56979. /**
  56980. * Fired when a rotation sphere or scale box is dragged
  56981. */
  56982. onDragStartObservable: Observable<{}>;
  56983. /**
  56984. * Fired when a scale box is dragged
  56985. */
  56986. onScaleBoxDragObservable: Observable<{}>;
  56987. /**
  56988. * Fired when a scale box drag is ended
  56989. */
  56990. onScaleBoxDragEndObservable: Observable<{}>;
  56991. /**
  56992. * Fired when a rotation sphere is dragged
  56993. */
  56994. onRotationSphereDragObservable: Observable<{}>;
  56995. /**
  56996. * Fired when a rotation sphere drag is ended
  56997. */
  56998. onRotationSphereDragEndObservable: Observable<{}>;
  56999. /**
  57000. * 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)
  57001. */
  57002. scalePivot: Nullable<Vector3>;
  57003. /**
  57004. * Mesh used as a pivot to rotate the attached node
  57005. */
  57006. private _anchorMesh;
  57007. private _existingMeshScale;
  57008. private _dragMesh;
  57009. private pointerDragBehavior;
  57010. private coloredMaterial;
  57011. private hoverColoredMaterial;
  57012. /**
  57013. * Sets the color of the bounding box gizmo
  57014. * @param color the color to set
  57015. */
  57016. setColor(color: Color3): void;
  57017. /**
  57018. * Creates an BoundingBoxGizmo
  57019. * @param gizmoLayer The utility layer the gizmo will be added to
  57020. * @param color The color of the gizmo
  57021. */
  57022. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57023. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57024. private _selectNode;
  57025. /**
  57026. * Updates the bounding box information for the Gizmo
  57027. */
  57028. updateBoundingBox(): void;
  57029. private _updateRotationSpheres;
  57030. private _updateScaleBoxes;
  57031. /**
  57032. * Enables rotation on the specified axis and disables rotation on the others
  57033. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57034. */
  57035. setEnabledRotationAxis(axis: string): void;
  57036. /**
  57037. * Enables/disables scaling
  57038. * @param enable if scaling should be enabled
  57039. * @param homogeneousScaling defines if scaling should only be homogeneous
  57040. */
  57041. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57042. private _updateDummy;
  57043. /**
  57044. * Enables a pointer drag behavior on the bounding box of the gizmo
  57045. */
  57046. enableDragBehavior(): void;
  57047. /**
  57048. * Disposes of the gizmo
  57049. */
  57050. dispose(): void;
  57051. /**
  57052. * 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)
  57053. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57054. * @returns the bounding box mesh with the passed in mesh as a child
  57055. */
  57056. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57057. /**
  57058. * CustomMeshes are not supported by this gizmo
  57059. * @param mesh The mesh to replace the default mesh of the gizmo
  57060. */
  57061. setCustomMesh(mesh: Mesh): void;
  57062. }
  57063. }
  57064. declare module "babylonjs/Gizmos/gizmoManager" {
  57065. import { Observable } from "babylonjs/Misc/observable";
  57066. import { Nullable } from "babylonjs/types";
  57067. import { Scene, IDisposable } from "babylonjs/scene";
  57068. import { Node } from "babylonjs/node";
  57069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57070. import { Mesh } from "babylonjs/Meshes/mesh";
  57071. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57072. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  57073. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  57074. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  57075. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  57076. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  57077. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  57078. /**
  57079. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57080. */
  57081. export class GizmoManager implements IDisposable {
  57082. private scene;
  57083. /**
  57084. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57085. */
  57086. gizmos: {
  57087. positionGizmo: Nullable<PositionGizmo>;
  57088. rotationGizmo: Nullable<RotationGizmo>;
  57089. scaleGizmo: Nullable<ScaleGizmo>;
  57090. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57091. };
  57092. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57093. clearGizmoOnEmptyPointerEvent: boolean;
  57094. /** Fires an event when the manager is attached to a mesh */
  57095. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57096. /** Fires an event when the manager is attached to a node */
  57097. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57098. private _gizmosEnabled;
  57099. private _pointerObservers;
  57100. private _attachedMesh;
  57101. private _attachedNode;
  57102. private _boundingBoxColor;
  57103. private _defaultUtilityLayer;
  57104. private _defaultKeepDepthUtilityLayer;
  57105. private _thickness;
  57106. /** Node Caching for quick lookup */
  57107. private _gizmoAxisCache;
  57108. /**
  57109. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57110. */
  57111. boundingBoxDragBehavior: SixDofDragBehavior;
  57112. /**
  57113. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57114. */
  57115. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57116. /**
  57117. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57118. */
  57119. attachableNodes: Nullable<Array<Node>>;
  57120. /**
  57121. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57122. */
  57123. usePointerToAttachGizmos: boolean;
  57124. /**
  57125. * Utility layer that the bounding box gizmo belongs to
  57126. */
  57127. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57128. /**
  57129. * Utility layer that all gizmos besides bounding box belong to
  57130. */
  57131. get utilityLayer(): UtilityLayerRenderer;
  57132. /**
  57133. * True when the mouse pointer is hovering a gizmo mesh
  57134. */
  57135. get isHovered(): boolean;
  57136. /**
  57137. * Instatiates a gizmo manager
  57138. * @param scene the scene to overlay the gizmos on top of
  57139. * @param thickness display gizmo axis thickness
  57140. * @param utilityLayer the layer where gizmos are rendered
  57141. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57142. */
  57143. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57144. /**
  57145. * Subscribes to pointer down events, for attaching and detaching mesh
  57146. * @param scene The sceme layer the observer will be added to
  57147. */
  57148. private _attachToMeshPointerObserver;
  57149. /**
  57150. * Attaches a set of gizmos to the specified mesh
  57151. * @param mesh The mesh the gizmo's should be attached to
  57152. */
  57153. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57154. /**
  57155. * Attaches a set of gizmos to the specified node
  57156. * @param node The node the gizmo's should be attached to
  57157. */
  57158. attachToNode(node: Nullable<Node>): void;
  57159. /**
  57160. * If the position gizmo is enabled
  57161. */
  57162. set positionGizmoEnabled(value: boolean);
  57163. get positionGizmoEnabled(): boolean;
  57164. /**
  57165. * If the rotation gizmo is enabled
  57166. */
  57167. set rotationGizmoEnabled(value: boolean);
  57168. get rotationGizmoEnabled(): boolean;
  57169. /**
  57170. * If the scale gizmo is enabled
  57171. */
  57172. set scaleGizmoEnabled(value: boolean);
  57173. get scaleGizmoEnabled(): boolean;
  57174. /**
  57175. * If the boundingBox gizmo is enabled
  57176. */
  57177. set boundingBoxGizmoEnabled(value: boolean);
  57178. get boundingBoxGizmoEnabled(): boolean;
  57179. /**
  57180. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57181. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57182. */
  57183. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57184. /**
  57185. * Disposes of the gizmo manager
  57186. */
  57187. dispose(): void;
  57188. }
  57189. }
  57190. declare module "babylonjs/Gizmos/positionGizmo" {
  57191. import { Observable } from "babylonjs/Misc/observable";
  57192. import { Nullable } from "babylonjs/types";
  57193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57194. import { Node } from "babylonjs/node";
  57195. import { Mesh } from "babylonjs/Meshes/mesh";
  57196. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  57197. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  57198. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  57199. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57200. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  57201. /**
  57202. * Gizmo that enables dragging a mesh along 3 axis
  57203. */
  57204. export class PositionGizmo extends Gizmo {
  57205. /**
  57206. * Internal gizmo used for interactions on the x axis
  57207. */
  57208. xGizmo: AxisDragGizmo;
  57209. /**
  57210. * Internal gizmo used for interactions on the y axis
  57211. */
  57212. yGizmo: AxisDragGizmo;
  57213. /**
  57214. * Internal gizmo used for interactions on the z axis
  57215. */
  57216. zGizmo: AxisDragGizmo;
  57217. /**
  57218. * Internal gizmo used for interactions on the yz plane
  57219. */
  57220. xPlaneGizmo: PlaneDragGizmo;
  57221. /**
  57222. * Internal gizmo used for interactions on the xz plane
  57223. */
  57224. yPlaneGizmo: PlaneDragGizmo;
  57225. /**
  57226. * Internal gizmo used for interactions on the xy plane
  57227. */
  57228. zPlaneGizmo: PlaneDragGizmo;
  57229. /**
  57230. * private variables
  57231. */
  57232. private _meshAttached;
  57233. private _nodeAttached;
  57234. private _snapDistance;
  57235. private _observables;
  57236. /** Node Caching for quick lookup */
  57237. private _gizmoAxisCache;
  57238. /** Fires an event when any of it's sub gizmos are dragged */
  57239. onDragStartObservable: Observable<unknown>;
  57240. /** Fires an event when any of it's sub gizmos are released from dragging */
  57241. onDragEndObservable: Observable<unknown>;
  57242. /**
  57243. * If set to true, planar drag is enabled
  57244. */
  57245. private _planarGizmoEnabled;
  57246. get attachedMesh(): Nullable<AbstractMesh>;
  57247. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57248. get attachedNode(): Nullable<Node>;
  57249. set attachedNode(node: Nullable<Node>);
  57250. /**
  57251. * True when the mouse pointer is hovering a gizmo mesh
  57252. */
  57253. get isHovered(): boolean;
  57254. /**
  57255. * Creates a PositionGizmo
  57256. * @param gizmoLayer The utility layer the gizmo will be added to
  57257. @param thickness display gizmo axis thickness
  57258. */
  57259. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57260. /**
  57261. * If the planar drag gizmo is enabled
  57262. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57263. */
  57264. set planarGizmoEnabled(value: boolean);
  57265. get planarGizmoEnabled(): boolean;
  57266. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57267. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57268. /**
  57269. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57270. */
  57271. set snapDistance(value: number);
  57272. get snapDistance(): number;
  57273. /**
  57274. * Ratio for the scale of the gizmo (Default: 1)
  57275. */
  57276. set scaleRatio(value: number);
  57277. get scaleRatio(): number;
  57278. /**
  57279. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57280. * @param mesh Axis gizmo mesh
  57281. * @param cache Gizmo axis definition used for reactive gizmo UI
  57282. */
  57283. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57284. /**
  57285. * Disposes of the gizmo
  57286. */
  57287. dispose(): void;
  57288. /**
  57289. * CustomMeshes are not supported by this gizmo
  57290. * @param mesh The mesh to replace the default mesh of the gizmo
  57291. */
  57292. setCustomMesh(mesh: Mesh): void;
  57293. }
  57294. }
  57295. declare module "babylonjs/Gizmos/axisDragGizmo" {
  57296. import { Observable } from "babylonjs/Misc/observable";
  57297. import { Nullable } from "babylonjs/types";
  57298. import { Vector3 } from "babylonjs/Maths/math.vector";
  57299. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57300. import { Node } from "babylonjs/node";
  57301. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  57302. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  57303. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57304. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  57305. import { Scene } from "babylonjs/scene";
  57306. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  57307. import { Color3 } from "babylonjs/Maths/math.color";
  57308. /**
  57309. * Single axis drag gizmo
  57310. */
  57311. export class AxisDragGizmo extends Gizmo {
  57312. /**
  57313. * Drag behavior responsible for the gizmos dragging interactions
  57314. */
  57315. dragBehavior: PointerDragBehavior;
  57316. private _pointerObserver;
  57317. /**
  57318. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57319. */
  57320. snapDistance: number;
  57321. /**
  57322. * Event that fires each time the gizmo snaps to a new location.
  57323. * * snapDistance is the the change in distance
  57324. */
  57325. onSnapObservable: Observable<{
  57326. snapDistance: number;
  57327. }>;
  57328. private _isEnabled;
  57329. private _parent;
  57330. private _gizmoMesh;
  57331. private _coloredMaterial;
  57332. private _hoverMaterial;
  57333. private _disableMaterial;
  57334. private _dragging;
  57335. /** @hidden */
  57336. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57337. /** @hidden */
  57338. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57339. /**
  57340. * Creates an AxisDragGizmo
  57341. * @param gizmoLayer The utility layer the gizmo will be added to
  57342. * @param dragAxis The axis which the gizmo will be able to drag on
  57343. * @param color The color of the gizmo
  57344. * @param thickness display gizmo axis thickness
  57345. */
  57346. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57347. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57348. /**
  57349. * If the gizmo is enabled
  57350. */
  57351. set isEnabled(value: boolean);
  57352. get isEnabled(): boolean;
  57353. /**
  57354. * Disposes of the gizmo
  57355. */
  57356. dispose(): void;
  57357. }
  57358. }
  57359. declare module "babylonjs/Debug/axesViewer" {
  57360. import { Vector3 } from "babylonjs/Maths/math.vector";
  57361. import { Nullable } from "babylonjs/types";
  57362. import { Scene } from "babylonjs/scene";
  57363. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57364. /**
  57365. * The Axes viewer will show 3 axes in a specific point in space
  57366. */
  57367. export class AxesViewer {
  57368. private _xAxis;
  57369. private _yAxis;
  57370. private _zAxis;
  57371. private _scaleLinesFactor;
  57372. private _instanced;
  57373. /**
  57374. * Gets the hosting scene
  57375. */
  57376. scene: Nullable<Scene>;
  57377. /**
  57378. * Gets or sets a number used to scale line length
  57379. */
  57380. scaleLines: number;
  57381. /** Gets the node hierarchy used to render x-axis */
  57382. get xAxis(): TransformNode;
  57383. /** Gets the node hierarchy used to render y-axis */
  57384. get yAxis(): TransformNode;
  57385. /** Gets the node hierarchy used to render z-axis */
  57386. get zAxis(): TransformNode;
  57387. /**
  57388. * Creates a new AxesViewer
  57389. * @param scene defines the hosting scene
  57390. * @param scaleLines defines a number used to scale line length (1 by default)
  57391. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57392. * @param xAxis defines the node hierarchy used to render the x-axis
  57393. * @param yAxis defines the node hierarchy used to render the y-axis
  57394. * @param zAxis defines the node hierarchy used to render the z-axis
  57395. */
  57396. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57397. /**
  57398. * Force the viewer to update
  57399. * @param position defines the position of the viewer
  57400. * @param xaxis defines the x axis of the viewer
  57401. * @param yaxis defines the y axis of the viewer
  57402. * @param zaxis defines the z axis of the viewer
  57403. */
  57404. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57405. /**
  57406. * Creates an instance of this axes viewer.
  57407. * @returns a new axes viewer with instanced meshes
  57408. */
  57409. createInstance(): AxesViewer;
  57410. /** Releases resources */
  57411. dispose(): void;
  57412. private static _SetRenderingGroupId;
  57413. }
  57414. }
  57415. declare module "babylonjs/Debug/boneAxesViewer" {
  57416. import { Nullable } from "babylonjs/types";
  57417. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  57418. import { Vector3 } from "babylonjs/Maths/math.vector";
  57419. import { Mesh } from "babylonjs/Meshes/mesh";
  57420. import { Bone } from "babylonjs/Bones/bone";
  57421. import { Scene } from "babylonjs/scene";
  57422. /**
  57423. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57424. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57425. */
  57426. export class BoneAxesViewer extends AxesViewer {
  57427. /**
  57428. * Gets or sets the target mesh where to display the axes viewer
  57429. */
  57430. mesh: Nullable<Mesh>;
  57431. /**
  57432. * Gets or sets the target bone where to display the axes viewer
  57433. */
  57434. bone: Nullable<Bone>;
  57435. /** Gets current position */
  57436. pos: Vector3;
  57437. /** Gets direction of X axis */
  57438. xaxis: Vector3;
  57439. /** Gets direction of Y axis */
  57440. yaxis: Vector3;
  57441. /** Gets direction of Z axis */
  57442. zaxis: Vector3;
  57443. /**
  57444. * Creates a new BoneAxesViewer
  57445. * @param scene defines the hosting scene
  57446. * @param bone defines the target bone
  57447. * @param mesh defines the target mesh
  57448. * @param scaleLines defines a scaling factor for line length (1 by default)
  57449. */
  57450. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  57451. /**
  57452. * Force the viewer to update
  57453. */
  57454. update(): void;
  57455. /** Releases resources */
  57456. dispose(): void;
  57457. }
  57458. }
  57459. declare module "babylonjs/Debug/debugLayer" {
  57460. import { Scene } from "babylonjs/scene";
  57461. /**
  57462. * Interface used to define scene explorer extensibility option
  57463. */
  57464. export interface IExplorerExtensibilityOption {
  57465. /**
  57466. * Define the option label
  57467. */
  57468. label: string;
  57469. /**
  57470. * Defines the action to execute on click
  57471. */
  57472. action: (entity: any) => void;
  57473. }
  57474. /**
  57475. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  57476. */
  57477. export interface IExplorerExtensibilityGroup {
  57478. /**
  57479. * Defines a predicate to test if a given type mut be extended
  57480. */
  57481. predicate: (entity: any) => boolean;
  57482. /**
  57483. * Gets the list of options added to a type
  57484. */
  57485. entries: IExplorerExtensibilityOption[];
  57486. }
  57487. /**
  57488. * Interface used to define the options to use to create the Inspector
  57489. */
  57490. export interface IInspectorOptions {
  57491. /**
  57492. * Display in overlay mode (default: false)
  57493. */
  57494. overlay?: boolean;
  57495. /**
  57496. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  57497. */
  57498. globalRoot?: HTMLElement;
  57499. /**
  57500. * Display the Scene explorer
  57501. */
  57502. showExplorer?: boolean;
  57503. /**
  57504. * Display the property inspector
  57505. */
  57506. showInspector?: boolean;
  57507. /**
  57508. * Display in embed mode (both panes on the right)
  57509. */
  57510. embedMode?: boolean;
  57511. /**
  57512. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  57513. */
  57514. handleResize?: boolean;
  57515. /**
  57516. * Allow the panes to popup (default: true)
  57517. */
  57518. enablePopup?: boolean;
  57519. /**
  57520. * Allow the panes to be closed by users (default: true)
  57521. */
  57522. enableClose?: boolean;
  57523. /**
  57524. * Optional list of extensibility entries
  57525. */
  57526. explorerExtensibility?: IExplorerExtensibilityGroup[];
  57527. /**
  57528. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  57529. */
  57530. inspectorURL?: string;
  57531. /**
  57532. * Optional initial tab (default to DebugLayerTab.Properties)
  57533. */
  57534. initialTab?: DebugLayerTab;
  57535. }
  57536. module "babylonjs/scene" {
  57537. interface Scene {
  57538. /**
  57539. * @hidden
  57540. * Backing field
  57541. */
  57542. _debugLayer: DebugLayer;
  57543. /**
  57544. * Gets the debug layer (aka Inspector) associated with the scene
  57545. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57546. */
  57547. debugLayer: DebugLayer;
  57548. }
  57549. }
  57550. /**
  57551. * Enum of inspector action tab
  57552. */
  57553. export enum DebugLayerTab {
  57554. /**
  57555. * Properties tag (default)
  57556. */
  57557. Properties = 0,
  57558. /**
  57559. * Debug tab
  57560. */
  57561. Debug = 1,
  57562. /**
  57563. * Statistics tab
  57564. */
  57565. Statistics = 2,
  57566. /**
  57567. * Tools tab
  57568. */
  57569. Tools = 3,
  57570. /**
  57571. * Settings tab
  57572. */
  57573. Settings = 4
  57574. }
  57575. /**
  57576. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57577. * what is happening in your scene
  57578. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57579. */
  57580. export class DebugLayer {
  57581. /**
  57582. * Define the url to get the inspector script from.
  57583. * By default it uses the babylonjs CDN.
  57584. * @ignoreNaming
  57585. */
  57586. static InspectorURL: string;
  57587. private _scene;
  57588. private BJSINSPECTOR;
  57589. private _onPropertyChangedObservable?;
  57590. /**
  57591. * Observable triggered when a property is changed through the inspector.
  57592. */
  57593. get onPropertyChangedObservable(): any;
  57594. /**
  57595. * Instantiates a new debug layer.
  57596. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57597. * what is happening in your scene
  57598. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57599. * @param scene Defines the scene to inspect
  57600. */
  57601. constructor(scene: Scene);
  57602. /** Creates the inspector window. */
  57603. private _createInspector;
  57604. /**
  57605. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  57606. * @param entity defines the entity to select
  57607. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  57608. */
  57609. select(entity: any, lineContainerTitles?: string | string[]): void;
  57610. /** Get the inspector from bundle or global */
  57611. private _getGlobalInspector;
  57612. /**
  57613. * Get if the inspector is visible or not.
  57614. * @returns true if visible otherwise, false
  57615. */
  57616. isVisible(): boolean;
  57617. /**
  57618. * Hide the inspector and close its window.
  57619. */
  57620. hide(): void;
  57621. /**
  57622. * Update the scene in the inspector
  57623. */
  57624. setAsActiveScene(): void;
  57625. /**
  57626. * Launch the debugLayer.
  57627. * @param config Define the configuration of the inspector
  57628. * @return a promise fulfilled when the debug layer is visible
  57629. */
  57630. show(config?: IInspectorOptions): Promise<DebugLayer>;
  57631. }
  57632. }
  57633. declare module "babylonjs/Debug/physicsViewer" {
  57634. import { Nullable } from "babylonjs/types";
  57635. import { Scene } from "babylonjs/scene";
  57636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57637. import { Mesh } from "babylonjs/Meshes/mesh";
  57638. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57639. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57640. /**
  57641. * Used to show the physics impostor around the specific mesh
  57642. */
  57643. export class PhysicsViewer {
  57644. /** @hidden */
  57645. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  57646. /** @hidden */
  57647. protected _meshes: Array<Nullable<AbstractMesh>>;
  57648. /** @hidden */
  57649. protected _scene: Nullable<Scene>;
  57650. /** @hidden */
  57651. protected _numMeshes: number;
  57652. /** @hidden */
  57653. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  57654. private _renderFunction;
  57655. private _utilityLayer;
  57656. private _debugBoxMesh;
  57657. private _debugSphereMesh;
  57658. private _debugCylinderMesh;
  57659. private _debugMaterial;
  57660. private _debugMeshMeshes;
  57661. /**
  57662. * Creates a new PhysicsViewer
  57663. * @param scene defines the hosting scene
  57664. */
  57665. constructor(scene: Scene);
  57666. /** @hidden */
  57667. protected _updateDebugMeshes(): void;
  57668. /**
  57669. * Renders a specified physic impostor
  57670. * @param impostor defines the impostor to render
  57671. * @param targetMesh defines the mesh represented by the impostor
  57672. * @returns the new debug mesh used to render the impostor
  57673. */
  57674. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  57675. /**
  57676. * Hides a specified physic impostor
  57677. * @param impostor defines the impostor to hide
  57678. */
  57679. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  57680. private _getDebugMaterial;
  57681. private _getDebugBoxMesh;
  57682. private _getDebugSphereMesh;
  57683. private _getDebugCylinderMesh;
  57684. private _getDebugMeshMesh;
  57685. private _getDebugMesh;
  57686. /** Releases all resources */
  57687. dispose(): void;
  57688. }
  57689. }
  57690. declare module "babylonjs/Debug/rayHelper" {
  57691. import { Nullable } from "babylonjs/types";
  57692. import { Ray } from "babylonjs/Culling/ray";
  57693. import { Vector3 } from "babylonjs/Maths/math.vector";
  57694. import { Color3 } from "babylonjs/Maths/math.color";
  57695. import { Scene } from "babylonjs/scene";
  57696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57697. import "babylonjs/Meshes/Builders/linesBuilder";
  57698. /**
  57699. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57700. * in order to better appreciate the issue one might have.
  57701. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57702. */
  57703. export class RayHelper {
  57704. /**
  57705. * Defines the ray we are currently tryin to visualize.
  57706. */
  57707. ray: Nullable<Ray>;
  57708. private _renderPoints;
  57709. private _renderLine;
  57710. private _renderFunction;
  57711. private _scene;
  57712. private _onAfterRenderObserver;
  57713. private _onAfterStepObserver;
  57714. private _attachedToMesh;
  57715. private _meshSpaceDirection;
  57716. private _meshSpaceOrigin;
  57717. /**
  57718. * Helper function to create a colored helper in a scene in one line.
  57719. * @param ray Defines the ray we are currently tryin to visualize
  57720. * @param scene Defines the scene the ray is used in
  57721. * @param color Defines the color we want to see the ray in
  57722. * @returns The newly created ray helper.
  57723. */
  57724. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  57725. /**
  57726. * Instantiate a new ray helper.
  57727. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57728. * in order to better appreciate the issue one might have.
  57729. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57730. * @param ray Defines the ray we are currently tryin to visualize
  57731. */
  57732. constructor(ray: Ray);
  57733. /**
  57734. * Shows the ray we are willing to debug.
  57735. * @param scene Defines the scene the ray needs to be rendered in
  57736. * @param color Defines the color the ray needs to be rendered in
  57737. */
  57738. show(scene: Scene, color?: Color3): void;
  57739. /**
  57740. * Hides the ray we are debugging.
  57741. */
  57742. hide(): void;
  57743. private _render;
  57744. /**
  57745. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  57746. * @param mesh Defines the mesh we want the helper attached to
  57747. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  57748. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  57749. * @param length Defines the length of the ray
  57750. */
  57751. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  57752. /**
  57753. * Detach the ray helper from the mesh it has previously been attached to.
  57754. */
  57755. detachFromMesh(): void;
  57756. private _updateToMesh;
  57757. /**
  57758. * Dispose the helper and release its associated resources.
  57759. */
  57760. dispose(): void;
  57761. }
  57762. }
  57763. declare module "babylonjs/Debug/ISkeletonViewer" {
  57764. import { Skeleton } from "babylonjs/Bones/skeleton";
  57765. import { Color3 } from "babylonjs/Maths/math.color";
  57766. /**
  57767. * Defines the options associated with the creation of a SkeletonViewer.
  57768. */
  57769. export interface ISkeletonViewerOptions {
  57770. /** Should the system pause animations before building the Viewer? */
  57771. pauseAnimations: boolean;
  57772. /** Should the system return the skeleton to rest before building? */
  57773. returnToRest: boolean;
  57774. /** public Display Mode of the Viewer */
  57775. displayMode: number;
  57776. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57777. displayOptions: ISkeletonViewerDisplayOptions;
  57778. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57779. computeBonesUsingShaders: boolean;
  57780. /** Flag ignore non weighted bones */
  57781. useAllBones: boolean;
  57782. }
  57783. /**
  57784. * Defines how to display the various bone meshes for the viewer.
  57785. */
  57786. export interface ISkeletonViewerDisplayOptions {
  57787. /** How far down to start tapering the bone spurs */
  57788. midStep?: number;
  57789. /** How big is the midStep? */
  57790. midStepFactor?: number;
  57791. /** Base for the Sphere Size */
  57792. sphereBaseSize?: number;
  57793. /** The ratio of the sphere to the longest bone in units */
  57794. sphereScaleUnit?: number;
  57795. /** Ratio for the Sphere Size */
  57796. sphereFactor?: number;
  57797. /** Whether a spur should attach its far end to the child bone position */
  57798. spurFollowsChild?: boolean;
  57799. /** Whether to show local axes or not */
  57800. showLocalAxes?: boolean;
  57801. /** Length of each local axis */
  57802. localAxesSize?: number;
  57803. }
  57804. /**
  57805. * Defines the constructor options for the BoneWeight Shader.
  57806. */
  57807. export interface IBoneWeightShaderOptions {
  57808. /** Skeleton to Map */
  57809. skeleton: Skeleton;
  57810. /** Colors for Uninfluenced bones */
  57811. colorBase?: Color3;
  57812. /** Colors for 0.0-0.25 Weight bones */
  57813. colorZero?: Color3;
  57814. /** Color for 0.25-0.5 Weight Influence */
  57815. colorQuarter?: Color3;
  57816. /** Color for 0.5-0.75 Weight Influence */
  57817. colorHalf?: Color3;
  57818. /** Color for 0.75-1 Weight Influence */
  57819. colorFull?: Color3;
  57820. /** Color for Zero Weight Influence */
  57821. targetBoneIndex?: number;
  57822. }
  57823. /**
  57824. * Simple structure of the gradient steps for the Color Map.
  57825. */
  57826. export interface ISkeletonMapShaderColorMapKnot {
  57827. /** Color of the Knot */
  57828. color: Color3;
  57829. /** Location of the Knot */
  57830. location: number;
  57831. }
  57832. /**
  57833. * Defines the constructor options for the SkeletonMap Shader.
  57834. */
  57835. export interface ISkeletonMapShaderOptions {
  57836. /** Skeleton to Map */
  57837. skeleton: Skeleton;
  57838. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  57839. colorMap?: ISkeletonMapShaderColorMapKnot[];
  57840. }
  57841. }
  57842. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57843. import { Nullable } from "babylonjs/types";
  57844. import { Scene } from "babylonjs/scene";
  57845. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57846. import { Color4 } from "babylonjs/Maths/math.color";
  57847. import { Mesh } from "babylonjs/Meshes/mesh";
  57848. /**
  57849. * Class containing static functions to help procedurally build meshes
  57850. */
  57851. export class RibbonBuilder {
  57852. /**
  57853. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57854. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57855. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57856. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57857. * * 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
  57858. * * 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
  57859. * * 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
  57860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57863. * * 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
  57864. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57865. * * 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
  57866. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57868. * @param name defines the name of the mesh
  57869. * @param options defines the options used to create the mesh
  57870. * @param scene defines the hosting scene
  57871. * @returns the ribbon mesh
  57872. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57873. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57874. */
  57875. static CreateRibbon(name: string, options: {
  57876. pathArray: Vector3[][];
  57877. closeArray?: boolean;
  57878. closePath?: boolean;
  57879. offset?: number;
  57880. updatable?: boolean;
  57881. sideOrientation?: number;
  57882. frontUVs?: Vector4;
  57883. backUVs?: Vector4;
  57884. instance?: Mesh;
  57885. invertUV?: boolean;
  57886. uvs?: Vector2[];
  57887. colors?: Color4[];
  57888. }, scene?: Nullable<Scene>): Mesh;
  57889. }
  57890. }
  57891. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57892. import { Nullable } from "babylonjs/types";
  57893. import { Scene } from "babylonjs/scene";
  57894. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57895. import { Mesh } from "babylonjs/Meshes/mesh";
  57896. /**
  57897. * Class containing static functions to help procedurally build meshes
  57898. */
  57899. export class ShapeBuilder {
  57900. /**
  57901. * 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.
  57902. * * 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.
  57903. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57904. * * 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.
  57905. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57906. * * 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
  57907. * * 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
  57908. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57911. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57913. * @param name defines the name of the mesh
  57914. * @param options defines the options used to create the mesh
  57915. * @param scene defines the hosting scene
  57916. * @returns the extruded shape mesh
  57917. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57919. */
  57920. static ExtrudeShape(name: string, options: {
  57921. shape: Vector3[];
  57922. path: Vector3[];
  57923. scale?: number;
  57924. rotation?: number;
  57925. cap?: number;
  57926. updatable?: boolean;
  57927. sideOrientation?: number;
  57928. frontUVs?: Vector4;
  57929. backUVs?: Vector4;
  57930. instance?: Mesh;
  57931. invertUV?: boolean;
  57932. }, scene?: Nullable<Scene>): Mesh;
  57933. /**
  57934. * Creates an custom extruded shape mesh.
  57935. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57936. * * 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.
  57937. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57938. * * 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
  57939. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57940. * * 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
  57941. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57942. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57943. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57944. * * 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
  57945. * * 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
  57946. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57948. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57951. * @param name defines the name of the mesh
  57952. * @param options defines the options used to create the mesh
  57953. * @param scene defines the hosting scene
  57954. * @returns the custom extruded shape mesh
  57955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57956. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57958. */
  57959. static ExtrudeShapeCustom(name: string, options: {
  57960. shape: Vector3[];
  57961. path: Vector3[];
  57962. scaleFunction?: any;
  57963. rotationFunction?: any;
  57964. ribbonCloseArray?: boolean;
  57965. ribbonClosePath?: boolean;
  57966. cap?: number;
  57967. updatable?: boolean;
  57968. sideOrientation?: number;
  57969. frontUVs?: Vector4;
  57970. backUVs?: Vector4;
  57971. instance?: Mesh;
  57972. invertUV?: boolean;
  57973. }, scene?: Nullable<Scene>): Mesh;
  57974. private static _ExtrudeShapeGeneric;
  57975. }
  57976. }
  57977. declare module "babylonjs/Debug/skeletonViewer" {
  57978. import { Color3 } from "babylonjs/Maths/math.color";
  57979. import { Scene } from "babylonjs/scene";
  57980. import { Nullable } from "babylonjs/types";
  57981. import { Skeleton } from "babylonjs/Bones/skeleton";
  57982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57983. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57984. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57985. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  57986. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  57987. /**
  57988. * Class used to render a debug view of a given skeleton
  57989. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  57990. */
  57991. export class SkeletonViewer {
  57992. /** defines the skeleton to render */
  57993. skeleton: Skeleton;
  57994. /** defines the mesh attached to the skeleton */
  57995. mesh: AbstractMesh;
  57996. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57997. autoUpdateBonesMatrices: boolean;
  57998. /** defines the rendering group id to use with the viewer */
  57999. renderingGroupId: number;
  58000. /** is the options for the viewer */
  58001. options: Partial<ISkeletonViewerOptions>;
  58002. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58003. static readonly DISPLAY_LINES: number;
  58004. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58005. static readonly DISPLAY_SPHERES: number;
  58006. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58007. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58008. /** public static method to create a BoneWeight Shader
  58009. * @param options The constructor options
  58010. * @param scene The scene that the shader is scoped to
  58011. * @returns The created ShaderMaterial
  58012. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58013. */
  58014. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58015. /** public static method to create a BoneWeight Shader
  58016. * @param options The constructor options
  58017. * @param scene The scene that the shader is scoped to
  58018. * @returns The created ShaderMaterial
  58019. */
  58020. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58021. /** private static method to create a BoneWeight Shader
  58022. * @param size The size of the buffer to create (usually the bone count)
  58023. * @param colorMap The gradient data to generate
  58024. * @param scene The scene that the shader is scoped to
  58025. * @returns an Array of floats from the color gradient values
  58026. */
  58027. private static _CreateBoneMapColorBuffer;
  58028. /** If SkeletonViewer scene scope. */
  58029. private _scene;
  58030. /** Gets or sets the color used to render the skeleton */
  58031. color: Color3;
  58032. /** Array of the points of the skeleton fo the line view. */
  58033. private _debugLines;
  58034. /** The SkeletonViewers Mesh. */
  58035. private _debugMesh;
  58036. /** The local axes Meshes. */
  58037. private _localAxes;
  58038. /** If SkeletonViewer is enabled. */
  58039. private _isEnabled;
  58040. /** If SkeletonViewer is ready. */
  58041. private _ready;
  58042. /** SkeletonViewer render observable. */
  58043. private _obs;
  58044. /** The Utility Layer to render the gizmos in. */
  58045. private _utilityLayer;
  58046. private _boneIndices;
  58047. /** Gets the Scene. */
  58048. get scene(): Scene;
  58049. /** Gets the utilityLayer. */
  58050. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58051. /** Checks Ready Status. */
  58052. get isReady(): Boolean;
  58053. /** Sets Ready Status. */
  58054. set ready(value: boolean);
  58055. /** Gets the debugMesh */
  58056. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58057. /** Sets the debugMesh */
  58058. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58059. /** Gets the displayMode */
  58060. get displayMode(): number;
  58061. /** Sets the displayMode */
  58062. set displayMode(value: number);
  58063. /**
  58064. * Creates a new SkeletonViewer
  58065. * @param skeleton defines the skeleton to render
  58066. * @param mesh defines the mesh attached to the skeleton
  58067. * @param scene defines the hosting scene
  58068. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58069. * @param renderingGroupId defines the rendering group id to use with the viewer
  58070. * @param options All of the extra constructor options for the SkeletonViewer
  58071. */
  58072. constructor(
  58073. /** defines the skeleton to render */
  58074. skeleton: Skeleton,
  58075. /** defines the mesh attached to the skeleton */
  58076. mesh: AbstractMesh,
  58077. /** The Scene scope*/
  58078. scene: Scene,
  58079. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58080. autoUpdateBonesMatrices?: boolean,
  58081. /** defines the rendering group id to use with the viewer */
  58082. renderingGroupId?: number,
  58083. /** is the options for the viewer */
  58084. options?: Partial<ISkeletonViewerOptions>);
  58085. /** The Dynamic bindings for the update functions */
  58086. private _bindObs;
  58087. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58088. update(): void;
  58089. /** Gets or sets a boolean indicating if the viewer is enabled */
  58090. set isEnabled(value: boolean);
  58091. get isEnabled(): boolean;
  58092. private _getBonePosition;
  58093. private _getLinesForBonesWithLength;
  58094. private _getLinesForBonesNoLength;
  58095. /** function to revert the mesh and scene back to the initial state. */
  58096. private _revert;
  58097. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58098. private _getAbsoluteBindPoseToRef;
  58099. /** function to build and bind sphere joint points and spur bone representations. */
  58100. private _buildSpheresAndSpurs;
  58101. private _buildLocalAxes;
  58102. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58103. private _displayLinesUpdate;
  58104. /** Changes the displayMode of the skeleton viewer
  58105. * @param mode The displayMode numerical value
  58106. */
  58107. changeDisplayMode(mode: number): void;
  58108. /** Sets a display option of the skeleton viewer
  58109. *
  58110. * | Option | Type | Default | Description |
  58111. * | ---------------- | ------- | ------- | ----------- |
  58112. * | 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`. |
  58113. * | 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`. |
  58114. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58115. * | 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`. |
  58116. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58117. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58118. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58119. *
  58120. * @param option String of the option name
  58121. * @param value The numerical option value
  58122. */
  58123. changeDisplayOptions(option: string, value: number): void;
  58124. /** Release associated resources */
  58125. dispose(): void;
  58126. }
  58127. }
  58128. declare module "babylonjs/Debug/index" {
  58129. export * from "babylonjs/Debug/axesViewer";
  58130. export * from "babylonjs/Debug/boneAxesViewer";
  58131. export * from "babylonjs/Debug/debugLayer";
  58132. export * from "babylonjs/Debug/physicsViewer";
  58133. export * from "babylonjs/Debug/rayHelper";
  58134. export * from "babylonjs/Debug/skeletonViewer";
  58135. export * from "babylonjs/Debug/ISkeletonViewer";
  58136. }
  58137. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  58138. /**
  58139. * Enum for Device Types
  58140. */
  58141. export enum DeviceType {
  58142. /** Generic */
  58143. Generic = 0,
  58144. /** Keyboard */
  58145. Keyboard = 1,
  58146. /** Mouse */
  58147. Mouse = 2,
  58148. /** Touch Pointers */
  58149. Touch = 3,
  58150. /** PS4 Dual Shock */
  58151. DualShock = 4,
  58152. /** Xbox */
  58153. Xbox = 5,
  58154. /** Switch Controller */
  58155. Switch = 6
  58156. }
  58157. /**
  58158. * Enum for All Pointers (Touch/Mouse)
  58159. */
  58160. export enum PointerInput {
  58161. /** Horizontal Axis */
  58162. Horizontal = 0,
  58163. /** Vertical Axis */
  58164. Vertical = 1,
  58165. /** Left Click or Touch */
  58166. LeftClick = 2,
  58167. /** Middle Click */
  58168. MiddleClick = 3,
  58169. /** Right Click */
  58170. RightClick = 4,
  58171. /** Browser Back */
  58172. BrowserBack = 5,
  58173. /** Browser Forward */
  58174. BrowserForward = 6
  58175. }
  58176. /**
  58177. * Enum for Dual Shock Gamepad
  58178. */
  58179. export enum DualShockInput {
  58180. /** Cross */
  58181. Cross = 0,
  58182. /** Circle */
  58183. Circle = 1,
  58184. /** Square */
  58185. Square = 2,
  58186. /** Triangle */
  58187. Triangle = 3,
  58188. /** L1 */
  58189. L1 = 4,
  58190. /** R1 */
  58191. R1 = 5,
  58192. /** L2 */
  58193. L2 = 6,
  58194. /** R2 */
  58195. R2 = 7,
  58196. /** Share */
  58197. Share = 8,
  58198. /** Options */
  58199. Options = 9,
  58200. /** L3 */
  58201. L3 = 10,
  58202. /** R3 */
  58203. R3 = 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. /** TouchPad */
  58215. TouchPad = 17,
  58216. /** LStickXAxis */
  58217. LStickXAxis = 18,
  58218. /** LStickYAxis */
  58219. LStickYAxis = 19,
  58220. /** RStickXAxis */
  58221. RStickXAxis = 20,
  58222. /** RStickYAxis */
  58223. RStickYAxis = 21
  58224. }
  58225. /**
  58226. * Enum for Xbox Gamepad
  58227. */
  58228. export enum XboxInput {
  58229. /** A */
  58230. A = 0,
  58231. /** B */
  58232. B = 1,
  58233. /** X */
  58234. X = 2,
  58235. /** Y */
  58236. Y = 3,
  58237. /** LB */
  58238. LB = 4,
  58239. /** RB */
  58240. RB = 5,
  58241. /** LT */
  58242. LT = 6,
  58243. /** RT */
  58244. RT = 7,
  58245. /** Back */
  58246. Back = 8,
  58247. /** Start */
  58248. Start = 9,
  58249. /** LS */
  58250. LS = 10,
  58251. /** RS */
  58252. RS = 11,
  58253. /** DPadUp */
  58254. DPadUp = 12,
  58255. /** DPadDown */
  58256. DPadDown = 13,
  58257. /** DPadLeft */
  58258. DPadLeft = 14,
  58259. /** DRight */
  58260. DPadRight = 15,
  58261. /** Home */
  58262. Home = 16,
  58263. /** LStickXAxis */
  58264. LStickXAxis = 17,
  58265. /** LStickYAxis */
  58266. LStickYAxis = 18,
  58267. /** RStickXAxis */
  58268. RStickXAxis = 19,
  58269. /** RStickYAxis */
  58270. RStickYAxis = 20
  58271. }
  58272. /**
  58273. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58274. */
  58275. export enum SwitchInput {
  58276. /** B */
  58277. B = 0,
  58278. /** A */
  58279. A = 1,
  58280. /** Y */
  58281. Y = 2,
  58282. /** X */
  58283. X = 3,
  58284. /** L */
  58285. L = 4,
  58286. /** R */
  58287. R = 5,
  58288. /** ZL */
  58289. ZL = 6,
  58290. /** ZR */
  58291. ZR = 7,
  58292. /** Minus */
  58293. Minus = 8,
  58294. /** Plus */
  58295. Plus = 9,
  58296. /** LS */
  58297. LS = 10,
  58298. /** RS */
  58299. RS = 11,
  58300. /** DPadUp */
  58301. DPadUp = 12,
  58302. /** DPadDown */
  58303. DPadDown = 13,
  58304. /** DPadLeft */
  58305. DPadLeft = 14,
  58306. /** DRight */
  58307. DPadRight = 15,
  58308. /** Home */
  58309. Home = 16,
  58310. /** Capture */
  58311. Capture = 17,
  58312. /** LStickXAxis */
  58313. LStickXAxis = 18,
  58314. /** LStickYAxis */
  58315. LStickYAxis = 19,
  58316. /** RStickXAxis */
  58317. RStickXAxis = 20,
  58318. /** RStickYAxis */
  58319. RStickYAxis = 21
  58320. }
  58321. }
  58322. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  58323. import { Engine } from "babylonjs/Engines/engine";
  58324. import { IDisposable } from "babylonjs/scene";
  58325. import { Nullable } from "babylonjs/types";
  58326. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58327. /**
  58328. * This class will take all inputs from Keyboard, Pointer, and
  58329. * any Gamepads and provide a polling system that all devices
  58330. * will use. This class assumes that there will only be one
  58331. * pointer device and one keyboard.
  58332. */
  58333. export class DeviceInputSystem implements IDisposable {
  58334. /**
  58335. * Returns onDeviceConnected callback property
  58336. * @returns Callback with function to execute when a device is connected
  58337. */
  58338. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58339. /**
  58340. * Sets callback function when a device is connected and executes against all connected devices
  58341. * @param callback Function to execute when a device is connected
  58342. */
  58343. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58344. /**
  58345. * Callback to be triggered when a device is disconnected
  58346. */
  58347. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58348. /**
  58349. * Callback to be triggered when event driven input is updated
  58350. */
  58351. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58352. private _inputs;
  58353. private _gamepads;
  58354. private _keyboardActive;
  58355. private _pointerActive;
  58356. private _elementToAttachTo;
  58357. private _keyboardDownEvent;
  58358. private _keyboardUpEvent;
  58359. private _pointerMoveEvent;
  58360. private _pointerDownEvent;
  58361. private _pointerUpEvent;
  58362. private _gamepadConnectedEvent;
  58363. private _gamepadDisconnectedEvent;
  58364. private _onDeviceConnected;
  58365. private static _MAX_KEYCODES;
  58366. private static _MAX_POINTER_INPUTS;
  58367. private constructor();
  58368. /**
  58369. * Creates a new DeviceInputSystem instance
  58370. * @param engine Engine to pull input element from
  58371. * @returns The new instance
  58372. */
  58373. static Create(engine: Engine): DeviceInputSystem;
  58374. /**
  58375. * Checks for current device input value, given an id and input index
  58376. * @param deviceName Id of connected device
  58377. * @param inputIndex Index of device input
  58378. * @returns Current value of input
  58379. */
  58380. /**
  58381. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58382. * @param deviceType Enum specifiying device type
  58383. * @param deviceSlot "Slot" or index that device is referenced in
  58384. * @param inputIndex Id of input to be checked
  58385. * @returns Current value of input
  58386. */
  58387. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58388. /**
  58389. * Dispose of all the eventlisteners
  58390. */
  58391. dispose(): void;
  58392. /**
  58393. * Checks for existing connections to devices and register them, if necessary
  58394. * Currently handles gamepads and mouse
  58395. */
  58396. private _checkForConnectedDevices;
  58397. /**
  58398. * Add a gamepad to the DeviceInputSystem
  58399. * @param gamepad A single DOM Gamepad object
  58400. */
  58401. private _addGamePad;
  58402. /**
  58403. * Add pointer device to DeviceInputSystem
  58404. * @param deviceType Type of Pointer to add
  58405. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58406. * @param currentX Current X at point of adding
  58407. * @param currentY Current Y at point of adding
  58408. */
  58409. private _addPointerDevice;
  58410. /**
  58411. * Add device and inputs to device array
  58412. * @param deviceType Enum specifiying device type
  58413. * @param deviceSlot "Slot" or index that device is referenced in
  58414. * @param numberOfInputs Number of input entries to create for given device
  58415. */
  58416. private _registerDevice;
  58417. /**
  58418. * Given a specific device name, remove that device from the device map
  58419. * @param deviceType Enum specifiying device type
  58420. * @param deviceSlot "Slot" or index that device is referenced in
  58421. */
  58422. private _unregisterDevice;
  58423. /**
  58424. * Handle all actions that come from keyboard interaction
  58425. */
  58426. private _handleKeyActions;
  58427. /**
  58428. * Handle all actions that come from pointer interaction
  58429. */
  58430. private _handlePointerActions;
  58431. /**
  58432. * Handle all actions that come from gamepad interaction
  58433. */
  58434. private _handleGamepadActions;
  58435. /**
  58436. * Update all non-event based devices with each frame
  58437. * @param deviceType Enum specifiying device type
  58438. * @param deviceSlot "Slot" or index that device is referenced in
  58439. * @param inputIndex Id of input to be checked
  58440. */
  58441. private _updateDevice;
  58442. /**
  58443. * Gets DeviceType from the device name
  58444. * @param deviceName Name of Device from DeviceInputSystem
  58445. * @returns DeviceType enum value
  58446. */
  58447. private _getGamepadDeviceType;
  58448. }
  58449. }
  58450. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  58451. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58452. /**
  58453. * Type to handle enforcement of inputs
  58454. */
  58455. 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;
  58456. }
  58457. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  58458. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  58459. import { Engine } from "babylonjs/Engines/engine";
  58460. import { IDisposable } from "babylonjs/scene";
  58461. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58462. import { Nullable } from "babylonjs/types";
  58463. import { Observable } from "babylonjs/Misc/observable";
  58464. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58465. /**
  58466. * Class that handles all input for a specific device
  58467. */
  58468. export class DeviceSource<T extends DeviceType> {
  58469. /** Type of device */
  58470. readonly deviceType: DeviceType;
  58471. /** "Slot" or index that device is referenced in */
  58472. readonly deviceSlot: number;
  58473. /**
  58474. * Observable to handle device input changes per device
  58475. */
  58476. readonly onInputChangedObservable: Observable<{
  58477. inputIndex: DeviceInput<T>;
  58478. previousState: Nullable<number>;
  58479. currentState: Nullable<number>;
  58480. }>;
  58481. private readonly _deviceInputSystem;
  58482. /**
  58483. * Default Constructor
  58484. * @param deviceInputSystem Reference to DeviceInputSystem
  58485. * @param deviceType Type of device
  58486. * @param deviceSlot "Slot" or index that device is referenced in
  58487. */
  58488. constructor(deviceInputSystem: DeviceInputSystem,
  58489. /** Type of device */
  58490. deviceType: DeviceType,
  58491. /** "Slot" or index that device is referenced in */
  58492. deviceSlot?: number);
  58493. /**
  58494. * Get input for specific input
  58495. * @param inputIndex index of specific input on device
  58496. * @returns Input value from DeviceInputSystem
  58497. */
  58498. getInput(inputIndex: DeviceInput<T>): number;
  58499. }
  58500. /**
  58501. * Class to keep track of devices
  58502. */
  58503. export class DeviceSourceManager implements IDisposable {
  58504. /**
  58505. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  58506. */
  58507. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  58508. /**
  58509. * Observable to be triggered when after a device is disconnected
  58510. */
  58511. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  58512. private readonly _devices;
  58513. private readonly _firstDevice;
  58514. private readonly _deviceInputSystem;
  58515. /**
  58516. * Default Constructor
  58517. * @param engine engine to pull input element from
  58518. */
  58519. constructor(engine: Engine);
  58520. /**
  58521. * Gets a DeviceSource, given a type and slot
  58522. * @param deviceType Enum specifying device type
  58523. * @param deviceSlot "Slot" or index that device is referenced in
  58524. * @returns DeviceSource object
  58525. */
  58526. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  58527. /**
  58528. * Gets an array of DeviceSource objects for a given device type
  58529. * @param deviceType Enum specifying device type
  58530. * @returns Array of DeviceSource objects
  58531. */
  58532. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  58533. /**
  58534. * Returns a read-only list of all available devices
  58535. * @returns Read-only array with active devices
  58536. */
  58537. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  58538. /**
  58539. * Dispose of DeviceInputSystem and other parts
  58540. */
  58541. dispose(): void;
  58542. /**
  58543. * Function to add device name to device list
  58544. * @param deviceType Enum specifying device type
  58545. * @param deviceSlot "Slot" or index that device is referenced in
  58546. */
  58547. private _addDevice;
  58548. /**
  58549. * Function to remove device name to device list
  58550. * @param deviceType Enum specifying device type
  58551. * @param deviceSlot "Slot" or index that device is referenced in
  58552. */
  58553. private _removeDevice;
  58554. /**
  58555. * Updates array storing first connected device of each type
  58556. * @param type Type of Device
  58557. */
  58558. private _updateFirstDevices;
  58559. }
  58560. }
  58561. declare module "babylonjs/DeviceInput/index" {
  58562. export * from "babylonjs/DeviceInput/deviceInputSystem";
  58563. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58564. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58565. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58566. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58567. }
  58568. declare module "babylonjs/Engines/nullEngine" {
  58569. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  58570. import { Engine } from "babylonjs/Engines/engine";
  58571. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58572. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58574. import { Effect } from "babylonjs/Materials/effect";
  58575. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58576. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58577. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  58578. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58579. /**
  58580. * Options to create the null engine
  58581. */
  58582. export class NullEngineOptions {
  58583. /**
  58584. * Render width (Default: 512)
  58585. */
  58586. renderWidth: number;
  58587. /**
  58588. * Render height (Default: 256)
  58589. */
  58590. renderHeight: number;
  58591. /**
  58592. * Texture size (Default: 512)
  58593. */
  58594. textureSize: number;
  58595. /**
  58596. * If delta time between frames should be constant
  58597. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58598. */
  58599. deterministicLockstep: boolean;
  58600. /**
  58601. * Maximum about of steps between frames (Default: 4)
  58602. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58603. */
  58604. lockstepMaxSteps: number;
  58605. /**
  58606. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  58607. */
  58608. useHighPrecisionMatrix?: boolean;
  58609. }
  58610. /**
  58611. * The null engine class provides support for headless version of babylon.js.
  58612. * This can be used in server side scenario or for testing purposes
  58613. */
  58614. export class NullEngine extends Engine {
  58615. private _options;
  58616. /**
  58617. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  58618. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58619. * @returns true if engine is in deterministic lock step mode
  58620. */
  58621. isDeterministicLockStep(): boolean;
  58622. /**
  58623. * Gets the max steps when engine is running in deterministic lock step
  58624. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58625. * @returns the max steps
  58626. */
  58627. getLockstepMaxSteps(): number;
  58628. /**
  58629. * Gets the current hardware scaling level.
  58630. * By default the hardware scaling level is computed from the window device ratio.
  58631. * 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.
  58632. * @returns a number indicating the current hardware scaling level
  58633. */
  58634. getHardwareScalingLevel(): number;
  58635. constructor(options?: NullEngineOptions);
  58636. /**
  58637. * Creates a vertex buffer
  58638. * @param vertices the data for the vertex buffer
  58639. * @returns the new WebGL static buffer
  58640. */
  58641. createVertexBuffer(vertices: FloatArray): DataBuffer;
  58642. /**
  58643. * Creates a new index buffer
  58644. * @param indices defines the content of the index buffer
  58645. * @param updatable defines if the index buffer must be updatable
  58646. * @returns a new webGL buffer
  58647. */
  58648. createIndexBuffer(indices: IndicesArray): DataBuffer;
  58649. /**
  58650. * Clear the current render buffer or the current render target (if any is set up)
  58651. * @param color defines the color to use
  58652. * @param backBuffer defines if the back buffer must be cleared
  58653. * @param depth defines if the depth buffer must be cleared
  58654. * @param stencil defines if the stencil buffer must be cleared
  58655. */
  58656. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58657. /**
  58658. * Gets the current render width
  58659. * @param useScreen defines if screen size must be used (or the current render target if any)
  58660. * @returns a number defining the current render width
  58661. */
  58662. getRenderWidth(useScreen?: boolean): number;
  58663. /**
  58664. * Gets the current render height
  58665. * @param useScreen defines if screen size must be used (or the current render target if any)
  58666. * @returns a number defining the current render height
  58667. */
  58668. getRenderHeight(useScreen?: boolean): number;
  58669. /**
  58670. * Set the WebGL's viewport
  58671. * @param viewport defines the viewport element to be used
  58672. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  58673. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  58674. */
  58675. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  58676. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  58677. /**
  58678. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  58679. * @param pipelineContext defines the pipeline context to use
  58680. * @param uniformsNames defines the list of uniform names
  58681. * @returns an array of webGL uniform locations
  58682. */
  58683. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  58684. /**
  58685. * Gets the lsit of active attributes for a given webGL program
  58686. * @param pipelineContext defines the pipeline context to use
  58687. * @param attributesNames defines the list of attribute names to get
  58688. * @returns an array of indices indicating the offset of each attribute
  58689. */
  58690. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58691. /**
  58692. * Binds an effect to the webGL context
  58693. * @param effect defines the effect to bind
  58694. */
  58695. bindSamplers(effect: Effect): void;
  58696. /**
  58697. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  58698. * @param effect defines the effect to activate
  58699. */
  58700. enableEffect(effect: Effect): void;
  58701. /**
  58702. * Set various states to the webGL context
  58703. * @param culling defines backface culling state
  58704. * @param zOffset defines the value to apply to zOffset (0 by default)
  58705. * @param force defines if states must be applied even if cache is up to date
  58706. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  58707. */
  58708. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58709. /**
  58710. * Set the value of an uniform to an array of int32
  58711. * @param uniform defines the webGL uniform location where to store the value
  58712. * @param array defines the array of int32 to store
  58713. * @returns true if value was set
  58714. */
  58715. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58716. /**
  58717. * Set the value of an uniform to an array of int32 (stored as vec2)
  58718. * @param uniform defines the webGL uniform location where to store the value
  58719. * @param array defines the array of int32 to store
  58720. * @returns true if value was set
  58721. */
  58722. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58723. /**
  58724. * Set the value of an uniform to an array of int32 (stored as vec3)
  58725. * @param uniform defines the webGL uniform location where to store the value
  58726. * @param array defines the array of int32 to store
  58727. * @returns true if value was set
  58728. */
  58729. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58730. /**
  58731. * Set the value of an uniform to an array of int32 (stored as vec4)
  58732. * @param uniform defines the webGL uniform location where to store the value
  58733. * @param array defines the array of int32 to store
  58734. * @returns true if value was set
  58735. */
  58736. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58737. /**
  58738. * Set the value of an uniform to an array of float32
  58739. * @param uniform defines the webGL uniform location where to store the value
  58740. * @param array defines the array of float32 to store
  58741. * @returns true if value was set
  58742. */
  58743. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58744. /**
  58745. * Set the value of an uniform to an array of float32 (stored as vec2)
  58746. * @param uniform defines the webGL uniform location where to store the value
  58747. * @param array defines the array of float32 to store
  58748. * @returns true if value was set
  58749. */
  58750. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58751. /**
  58752. * Set the value of an uniform to an array of float32 (stored as vec3)
  58753. * @param uniform defines the webGL uniform location where to store the value
  58754. * @param array defines the array of float32 to store
  58755. * @returns true if value was set
  58756. */
  58757. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58758. /**
  58759. * Set the value of an uniform to an array of float32 (stored as vec4)
  58760. * @param uniform defines the webGL uniform location where to store the value
  58761. * @param array defines the array of float32 to store
  58762. * @returns true if value was set
  58763. */
  58764. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58765. /**
  58766. * Set the value of an uniform to an array of number
  58767. * @param uniform defines the webGL uniform location where to store the value
  58768. * @param array defines the array of number to store
  58769. * @returns true if value was set
  58770. */
  58771. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58772. /**
  58773. * Set the value of an uniform to an array of number (stored as vec2)
  58774. * @param uniform defines the webGL uniform location where to store the value
  58775. * @param array defines the array of number to store
  58776. * @returns true if value was set
  58777. */
  58778. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58779. /**
  58780. * Set the value of an uniform to an array of number (stored as vec3)
  58781. * @param uniform defines the webGL uniform location where to store the value
  58782. * @param array defines the array of number to store
  58783. * @returns true if value was set
  58784. */
  58785. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58786. /**
  58787. * Set the value of an uniform to an array of number (stored as vec4)
  58788. * @param uniform defines the webGL uniform location where to store the value
  58789. * @param array defines the array of number to store
  58790. * @returns true if value was set
  58791. */
  58792. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58793. /**
  58794. * Set the value of an uniform to an array of float32 (stored as matrices)
  58795. * @param uniform defines the webGL uniform location where to store the value
  58796. * @param matrices defines the array of float32 to store
  58797. * @returns true if value was set
  58798. */
  58799. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58800. /**
  58801. * Set the value of an uniform to a matrix (3x3)
  58802. * @param uniform defines the webGL uniform location where to store the value
  58803. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  58804. * @returns true if value was set
  58805. */
  58806. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58807. /**
  58808. * Set the value of an uniform to a matrix (2x2)
  58809. * @param uniform defines the webGL uniform location where to store the value
  58810. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  58811. * @returns true if value was set
  58812. */
  58813. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58814. /**
  58815. * Set the value of an uniform to a number (float)
  58816. * @param uniform defines the webGL uniform location where to store the value
  58817. * @param value defines the float number to store
  58818. * @returns true if value was set
  58819. */
  58820. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58821. /**
  58822. * Set the value of an uniform to a vec2
  58823. * @param uniform defines the webGL uniform location where to store the value
  58824. * @param x defines the 1st component of the value
  58825. * @param y defines the 2nd component of the value
  58826. * @returns true if value was set
  58827. */
  58828. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58829. /**
  58830. * Set the value of an uniform to a vec3
  58831. * @param uniform defines the webGL uniform location where to store the value
  58832. * @param x defines the 1st component of the value
  58833. * @param y defines the 2nd component of the value
  58834. * @param z defines the 3rd component of the value
  58835. * @returns true if value was set
  58836. */
  58837. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58838. /**
  58839. * Set the value of an uniform to a boolean
  58840. * @param uniform defines the webGL uniform location where to store the value
  58841. * @param bool defines the boolean to store
  58842. * @returns true if value was set
  58843. */
  58844. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  58845. /**
  58846. * Set the value of an uniform to a vec4
  58847. * @param uniform defines the webGL uniform location where to store the value
  58848. * @param x defines the 1st component of the value
  58849. * @param y defines the 2nd component of the value
  58850. * @param z defines the 3rd component of the value
  58851. * @param w defines the 4th component of the value
  58852. * @returns true if value was set
  58853. */
  58854. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58855. /**
  58856. * Sets the current alpha mode
  58857. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  58858. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58859. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58860. */
  58861. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58862. /**
  58863. * Bind webGl buffers directly to the webGL context
  58864. * @param vertexBuffers defines the vertex buffer to bind
  58865. * @param indexBuffer defines the index buffer to bind
  58866. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  58867. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  58868. * @param effect defines the effect associated with the vertex buffer
  58869. */
  58870. bindBuffers(vertexBuffers: {
  58871. [key: string]: VertexBuffer;
  58872. }, indexBuffer: DataBuffer, effect: Effect): void;
  58873. /**
  58874. * Force the entire cache to be cleared
  58875. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  58876. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  58877. */
  58878. wipeCaches(bruteForce?: boolean): void;
  58879. /**
  58880. * Send a draw order
  58881. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  58882. * @param indexStart defines the starting index
  58883. * @param indexCount defines the number of index to draw
  58884. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58885. */
  58886. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  58887. /**
  58888. * Draw a list of indexed primitives
  58889. * @param fillMode defines the primitive to use
  58890. * @param indexStart defines the starting index
  58891. * @param indexCount defines the number of index to draw
  58892. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58893. */
  58894. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58895. /**
  58896. * Draw a list of unindexed primitives
  58897. * @param fillMode defines the primitive to use
  58898. * @param verticesStart defines the index of first vertex to draw
  58899. * @param verticesCount defines the count of vertices to draw
  58900. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58901. */
  58902. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58903. /** @hidden */
  58904. _createTexture(): WebGLTexture;
  58905. /** @hidden */
  58906. _releaseTexture(texture: InternalTexture): void;
  58907. /**
  58908. * Usually called from Texture.ts.
  58909. * Passed information to create a WebGLTexture
  58910. * @param urlArg defines a value which contains one of the following:
  58911. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58912. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58913. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58914. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58915. * @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)
  58916. * @param scene needed for loading to the correct scene
  58917. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58918. * @param onLoad optional callback to be called upon successful completion
  58919. * @param onError optional callback to be called upon failure
  58920. * @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
  58921. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58922. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58923. * @param forcedExtension defines the extension to use to pick the right loader
  58924. * @param mimeType defines an optional mime type
  58925. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58926. */
  58927. 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;
  58928. /**
  58929. * Creates a new render target texture
  58930. * @param size defines the size of the texture
  58931. * @param options defines the options used to create the texture
  58932. * @returns a new render target texture stored in an InternalTexture
  58933. */
  58934. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  58935. /**
  58936. * Update the sampling mode of a given texture
  58937. * @param samplingMode defines the required sampling mode
  58938. * @param texture defines the texture to update
  58939. */
  58940. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58941. /**
  58942. * Binds the frame buffer to the specified texture.
  58943. * @param texture The texture to render to or null for the default canvas
  58944. * @param faceIndex The face of the texture to render to in case of cube texture
  58945. * @param requiredWidth The width of the target to render to
  58946. * @param requiredHeight The height of the target to render to
  58947. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  58948. * @param lodLevel defines le lod level to bind to the frame buffer
  58949. */
  58950. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58951. /**
  58952. * Unbind the current render target texture from the webGL context
  58953. * @param texture defines the render target texture to unbind
  58954. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  58955. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  58956. */
  58957. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58958. /**
  58959. * Creates a dynamic vertex buffer
  58960. * @param vertices the data for the dynamic vertex buffer
  58961. * @returns the new WebGL dynamic buffer
  58962. */
  58963. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  58964. /**
  58965. * Update the content of a dynamic texture
  58966. * @param texture defines the texture to update
  58967. * @param canvas defines the canvas containing the source
  58968. * @param invertY defines if data must be stored with Y axis inverted
  58969. * @param premulAlpha defines if alpha is stored as premultiplied
  58970. * @param format defines the format of the data
  58971. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58972. */
  58973. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58974. /**
  58975. * Gets a boolean indicating if all created effects are ready
  58976. * @returns true if all effects are ready
  58977. */
  58978. areAllEffectsReady(): boolean;
  58979. /**
  58980. * @hidden
  58981. * Get the current error code of the webGL context
  58982. * @returns the error code
  58983. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  58984. */
  58985. getError(): number;
  58986. /** @hidden */
  58987. _getUnpackAlignement(): number;
  58988. /** @hidden */
  58989. _unpackFlipY(value: boolean): void;
  58990. /**
  58991. * Update a dynamic index buffer
  58992. * @param indexBuffer defines the target index buffer
  58993. * @param indices defines the data to update
  58994. * @param offset defines the offset in the target index buffer where update should start
  58995. */
  58996. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  58997. /**
  58998. * Updates a dynamic vertex buffer.
  58999. * @param vertexBuffer the vertex buffer to update
  59000. * @param vertices the data used to update the vertex buffer
  59001. * @param byteOffset the byte offset of the data (optional)
  59002. * @param byteLength the byte length of the data (optional)
  59003. */
  59004. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59005. /** @hidden */
  59006. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59007. /** @hidden */
  59008. _bindTexture(channel: number, texture: InternalTexture): void;
  59009. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59010. /**
  59011. * 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
  59012. */
  59013. releaseEffects(): void;
  59014. displayLoadingUI(): void;
  59015. hideLoadingUI(): void;
  59016. /** @hidden */
  59017. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59018. /** @hidden */
  59019. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59020. /** @hidden */
  59021. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59022. /** @hidden */
  59023. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59024. }
  59025. }
  59026. declare module "babylonjs/Instrumentation/timeToken" {
  59027. import { Nullable } from "babylonjs/types";
  59028. /**
  59029. * @hidden
  59030. **/
  59031. export class _TimeToken {
  59032. _startTimeQuery: Nullable<WebGLQuery>;
  59033. _endTimeQuery: Nullable<WebGLQuery>;
  59034. _timeElapsedQuery: Nullable<WebGLQuery>;
  59035. _timeElapsedQueryEnded: boolean;
  59036. }
  59037. }
  59038. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  59039. import { Nullable, int } from "babylonjs/types";
  59040. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  59041. /** @hidden */
  59042. export class _OcclusionDataStorage {
  59043. /** @hidden */
  59044. occlusionInternalRetryCounter: number;
  59045. /** @hidden */
  59046. isOcclusionQueryInProgress: boolean;
  59047. /** @hidden */
  59048. isOccluded: boolean;
  59049. /** @hidden */
  59050. occlusionRetryCount: number;
  59051. /** @hidden */
  59052. occlusionType: number;
  59053. /** @hidden */
  59054. occlusionQueryAlgorithmType: number;
  59055. }
  59056. module "babylonjs/Engines/engine" {
  59057. interface Engine {
  59058. /**
  59059. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59060. * @return the new query
  59061. */
  59062. createQuery(): WebGLQuery;
  59063. /**
  59064. * Delete and release a webGL query
  59065. * @param query defines the query to delete
  59066. * @return the current engine
  59067. */
  59068. deleteQuery(query: WebGLQuery): Engine;
  59069. /**
  59070. * Check if a given query has resolved and got its value
  59071. * @param query defines the query to check
  59072. * @returns true if the query got its value
  59073. */
  59074. isQueryResultAvailable(query: WebGLQuery): boolean;
  59075. /**
  59076. * Gets the value of a given query
  59077. * @param query defines the query to check
  59078. * @returns the value of the query
  59079. */
  59080. getQueryResult(query: WebGLQuery): number;
  59081. /**
  59082. * Initiates an occlusion query
  59083. * @param algorithmType defines the algorithm to use
  59084. * @param query defines the query to use
  59085. * @returns the current engine
  59086. * @see https://doc.babylonjs.com/features/occlusionquery
  59087. */
  59088. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59089. /**
  59090. * Ends an occlusion query
  59091. * @see https://doc.babylonjs.com/features/occlusionquery
  59092. * @param algorithmType defines the algorithm to use
  59093. * @returns the current engine
  59094. */
  59095. endOcclusionQuery(algorithmType: number): Engine;
  59096. /**
  59097. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59098. * Please note that only one query can be issued at a time
  59099. * @returns a time token used to track the time span
  59100. */
  59101. startTimeQuery(): Nullable<_TimeToken>;
  59102. /**
  59103. * Ends a time query
  59104. * @param token defines the token used to measure the time span
  59105. * @returns the time spent (in ns)
  59106. */
  59107. endTimeQuery(token: _TimeToken): int;
  59108. /** @hidden */
  59109. _currentNonTimestampToken: Nullable<_TimeToken>;
  59110. /** @hidden */
  59111. _createTimeQuery(): WebGLQuery;
  59112. /** @hidden */
  59113. _deleteTimeQuery(query: WebGLQuery): void;
  59114. /** @hidden */
  59115. _getGlAlgorithmType(algorithmType: number): number;
  59116. /** @hidden */
  59117. _getTimeQueryResult(query: WebGLQuery): any;
  59118. /** @hidden */
  59119. _getTimeQueryAvailability(query: WebGLQuery): any;
  59120. }
  59121. }
  59122. module "babylonjs/Meshes/abstractMesh" {
  59123. interface AbstractMesh {
  59124. /**
  59125. * Backing filed
  59126. * @hidden
  59127. */
  59128. __occlusionDataStorage: _OcclusionDataStorage;
  59129. /**
  59130. * Access property
  59131. * @hidden
  59132. */
  59133. _occlusionDataStorage: _OcclusionDataStorage;
  59134. /**
  59135. * 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.
  59136. * The default value is -1 which means don't break the query and wait till the result
  59137. * @see https://doc.babylonjs.com/features/occlusionquery
  59138. */
  59139. occlusionRetryCount: number;
  59140. /**
  59141. * 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:
  59142. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59143. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59144. * * 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.
  59145. * @see https://doc.babylonjs.com/features/occlusionquery
  59146. */
  59147. occlusionType: number;
  59148. /**
  59149. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59150. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59151. * * 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.
  59152. * @see https://doc.babylonjs.com/features/occlusionquery
  59153. */
  59154. occlusionQueryAlgorithmType: number;
  59155. /**
  59156. * 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
  59157. * @see https://doc.babylonjs.com/features/occlusionquery
  59158. */
  59159. isOccluded: boolean;
  59160. /**
  59161. * Flag to check the progress status of the query
  59162. * @see https://doc.babylonjs.com/features/occlusionquery
  59163. */
  59164. isOcclusionQueryInProgress: boolean;
  59165. }
  59166. }
  59167. }
  59168. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  59169. import { Nullable } from "babylonjs/types";
  59170. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59171. /** @hidden */
  59172. export var _forceTransformFeedbackToBundle: boolean;
  59173. module "babylonjs/Engines/engine" {
  59174. interface Engine {
  59175. /**
  59176. * Creates a webGL transform feedback object
  59177. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59178. * @returns the webGL transform feedback object
  59179. */
  59180. createTransformFeedback(): WebGLTransformFeedback;
  59181. /**
  59182. * Delete a webGL transform feedback object
  59183. * @param value defines the webGL transform feedback object to delete
  59184. */
  59185. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59186. /**
  59187. * Bind a webGL transform feedback object to the webgl context
  59188. * @param value defines the webGL transform feedback object to bind
  59189. */
  59190. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59191. /**
  59192. * Begins a transform feedback operation
  59193. * @param usePoints defines if points or triangles must be used
  59194. */
  59195. beginTransformFeedback(usePoints: boolean): void;
  59196. /**
  59197. * Ends a transform feedback operation
  59198. */
  59199. endTransformFeedback(): void;
  59200. /**
  59201. * Specify the varyings to use with transform feedback
  59202. * @param program defines the associated webGL program
  59203. * @param value defines the list of strings representing the varying names
  59204. */
  59205. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59206. /**
  59207. * Bind a webGL buffer for a transform feedback operation
  59208. * @param value defines the webGL buffer to bind
  59209. */
  59210. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59211. }
  59212. }
  59213. }
  59214. declare module "babylonjs/Engines/Extensions/engine.views" {
  59215. import { Camera } from "babylonjs/Cameras/camera";
  59216. import { Nullable } from "babylonjs/types";
  59217. /**
  59218. * Class used to define an additional view for the engine
  59219. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59220. */
  59221. export class EngineView {
  59222. /** Defines the canvas where to render the view */
  59223. target: HTMLCanvasElement;
  59224. /** Defines an optional camera used to render the view (will use active camera else) */
  59225. camera?: Camera;
  59226. }
  59227. module "babylonjs/Engines/engine" {
  59228. interface Engine {
  59229. /**
  59230. * Gets or sets the HTML element to use for attaching events
  59231. */
  59232. inputElement: Nullable<HTMLElement>;
  59233. /**
  59234. * Gets the current engine view
  59235. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59236. */
  59237. activeView: Nullable<EngineView>;
  59238. /** Gets or sets the list of views */
  59239. views: EngineView[];
  59240. /**
  59241. * Register a new child canvas
  59242. * @param canvas defines the canvas to register
  59243. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59244. * @returns the associated view
  59245. */
  59246. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59247. /**
  59248. * Remove a registered child canvas
  59249. * @param canvas defines the canvas to remove
  59250. * @returns the current engine
  59251. */
  59252. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59253. }
  59254. }
  59255. }
  59256. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  59257. import { Nullable } from "babylonjs/types";
  59258. module "babylonjs/Engines/engine" {
  59259. interface Engine {
  59260. /** @hidden */
  59261. _excludedCompressedTextures: string[];
  59262. /** @hidden */
  59263. _textureFormatInUse: string;
  59264. /**
  59265. * Gets the list of texture formats supported
  59266. */
  59267. readonly texturesSupported: Array<string>;
  59268. /**
  59269. * Gets the texture format in use
  59270. */
  59271. readonly textureFormatInUse: Nullable<string>;
  59272. /**
  59273. * Set the compressed texture extensions or file names to skip.
  59274. *
  59275. * @param skippedFiles defines the list of those texture files you want to skip
  59276. * Example: [".dds", ".env", "myfile.png"]
  59277. */
  59278. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59279. /**
  59280. * Set the compressed texture format to use, based on the formats you have, and the formats
  59281. * supported by the hardware / browser.
  59282. *
  59283. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59284. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59285. * to API arguments needed to compressed textures. This puts the burden on the container
  59286. * generator to house the arcane code for determining these for current & future formats.
  59287. *
  59288. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59289. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59290. *
  59291. * Note: The result of this call is not taken into account when a texture is base64.
  59292. *
  59293. * @param formatsAvailable defines the list of those format families you have created
  59294. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59295. *
  59296. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59297. * @returns The extension selected.
  59298. */
  59299. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59300. }
  59301. }
  59302. }
  59303. declare module "babylonjs/Engines/Extensions/index" {
  59304. export * from "babylonjs/Engines/Extensions/engine.alpha";
  59305. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  59306. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  59307. export * from "babylonjs/Engines/Extensions/engine.multiview";
  59308. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  59309. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59310. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  59311. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  59312. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  59313. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  59314. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59315. export * from "babylonjs/Engines/Extensions/engine.webVR";
  59316. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  59317. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  59318. export * from "babylonjs/Engines/Extensions/engine.views";
  59319. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  59320. import "babylonjs/Engines/Extensions/engine.textureSelector";
  59321. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  59322. }
  59323. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  59324. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59325. /** @hidden */
  59326. export var rgbdEncodePixelShader: {
  59327. name: string;
  59328. shader: string;
  59329. };
  59330. }
  59331. declare module "babylonjs/Misc/environmentTextureTools" {
  59332. import { Nullable } from "babylonjs/types";
  59333. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59334. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59336. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59337. import "babylonjs/Engines/Extensions/engine.readTexture";
  59338. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59339. import "babylonjs/Shaders/rgbdEncode.fragment";
  59340. import "babylonjs/Shaders/rgbdDecode.fragment";
  59341. /**
  59342. * Raw texture data and descriptor sufficient for WebGL texture upload
  59343. */
  59344. export interface EnvironmentTextureInfo {
  59345. /**
  59346. * Version of the environment map
  59347. */
  59348. version: number;
  59349. /**
  59350. * Width of image
  59351. */
  59352. width: number;
  59353. /**
  59354. * Irradiance information stored in the file.
  59355. */
  59356. irradiance: any;
  59357. /**
  59358. * Specular information stored in the file.
  59359. */
  59360. specular: any;
  59361. }
  59362. /**
  59363. * Defines One Image in the file. It requires only the position in the file
  59364. * as well as the length.
  59365. */
  59366. interface BufferImageData {
  59367. /**
  59368. * Length of the image data.
  59369. */
  59370. length: number;
  59371. /**
  59372. * Position of the data from the null terminator delimiting the end of the JSON.
  59373. */
  59374. position: number;
  59375. }
  59376. /**
  59377. * Defines the specular data enclosed in the file.
  59378. * This corresponds to the version 1 of the data.
  59379. */
  59380. export interface EnvironmentTextureSpecularInfoV1 {
  59381. /**
  59382. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59383. */
  59384. specularDataPosition?: number;
  59385. /**
  59386. * This contains all the images data needed to reconstruct the cubemap.
  59387. */
  59388. mipmaps: Array<BufferImageData>;
  59389. /**
  59390. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59391. */
  59392. lodGenerationScale: number;
  59393. }
  59394. /**
  59395. * Sets of helpers addressing the serialization and deserialization of environment texture
  59396. * stored in a BabylonJS env file.
  59397. * Those files are usually stored as .env files.
  59398. */
  59399. export class EnvironmentTextureTools {
  59400. /**
  59401. * Magic number identifying the env file.
  59402. */
  59403. private static _MagicBytes;
  59404. /**
  59405. * Gets the environment info from an env file.
  59406. * @param data The array buffer containing the .env bytes.
  59407. * @returns the environment file info (the json header) if successfully parsed.
  59408. */
  59409. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59410. /**
  59411. * Creates an environment texture from a loaded cube texture.
  59412. * @param texture defines the cube texture to convert in env file
  59413. * @return a promise containing the environment data if succesfull.
  59414. */
  59415. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59416. /**
  59417. * Creates a JSON representation of the spherical data.
  59418. * @param texture defines the texture containing the polynomials
  59419. * @return the JSON representation of the spherical info
  59420. */
  59421. private static _CreateEnvTextureIrradiance;
  59422. /**
  59423. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59424. * @param data the image data
  59425. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59426. * @return the views described by info providing access to the underlying buffer
  59427. */
  59428. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59429. /**
  59430. * Uploads the texture info contained in the env file to the GPU.
  59431. * @param texture defines the internal texture to upload to
  59432. * @param data defines the data to load
  59433. * @param info defines the texture info retrieved through the GetEnvInfo method
  59434. * @returns a promise
  59435. */
  59436. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59437. private static _OnImageReadyAsync;
  59438. /**
  59439. * Uploads the levels of image data to the GPU.
  59440. * @param texture defines the internal texture to upload to
  59441. * @param imageData defines the array buffer views of image data [mipmap][face]
  59442. * @returns a promise
  59443. */
  59444. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59445. /**
  59446. * Uploads spherical polynomials information to the texture.
  59447. * @param texture defines the texture we are trying to upload the information to
  59448. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59449. */
  59450. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59451. /** @hidden */
  59452. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59453. }
  59454. }
  59455. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  59456. /**
  59457. * Class used to inline functions in shader code
  59458. */
  59459. export class ShaderCodeInliner {
  59460. private static readonly _RegexpFindFunctionNameAndType;
  59461. private _sourceCode;
  59462. private _functionDescr;
  59463. private _numMaxIterations;
  59464. /** Gets or sets the token used to mark the functions to inline */
  59465. inlineToken: string;
  59466. /** Gets or sets the debug mode */
  59467. debug: boolean;
  59468. /** Gets the code after the inlining process */
  59469. get code(): string;
  59470. /**
  59471. * Initializes the inliner
  59472. * @param sourceCode shader code source to inline
  59473. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  59474. */
  59475. constructor(sourceCode: string, numMaxIterations?: number);
  59476. /**
  59477. * Start the processing of the shader code
  59478. */
  59479. processCode(): void;
  59480. private _collectFunctions;
  59481. private _processInlining;
  59482. private _extractBetweenMarkers;
  59483. private _skipWhitespaces;
  59484. private _removeComments;
  59485. private _replaceFunctionCallsByCode;
  59486. private _findBackward;
  59487. private _escapeRegExp;
  59488. private _replaceNames;
  59489. }
  59490. }
  59491. declare module "babylonjs/Engines/nativeEngine" {
  59492. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  59493. import { Engine } from "babylonjs/Engines/engine";
  59494. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  59495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59496. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59497. import { Effect } from "babylonjs/Materials/effect";
  59498. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59499. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  59500. import { IColor4Like } from "babylonjs/Maths/math.like";
  59501. import { Scene } from "babylonjs/scene";
  59502. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  59503. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  59504. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  59505. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  59506. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  59507. /**
  59508. * Container for accessors for natively-stored mesh data buffers.
  59509. */
  59510. class NativeDataBuffer extends DataBuffer {
  59511. /**
  59512. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59513. */
  59514. nativeIndexBuffer?: any;
  59515. /**
  59516. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59517. */
  59518. nativeVertexBuffer?: any;
  59519. }
  59520. /** @hidden */
  59521. class NativeTexture extends InternalTexture {
  59522. getInternalTexture(): InternalTexture;
  59523. getViewCount(): number;
  59524. }
  59525. /** @hidden */
  59526. export class NativeEngine extends Engine {
  59527. private readonly _native;
  59528. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59529. private readonly INVALID_HANDLE;
  59530. private _boundBuffersVertexArray;
  59531. private _currentDepthTest;
  59532. getHardwareScalingLevel(): number;
  59533. constructor();
  59534. dispose(): void;
  59535. /**
  59536. * Can be used to override the current requestAnimationFrame requester.
  59537. * @hidden
  59538. */
  59539. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59540. /**
  59541. * Override default engine behavior.
  59542. * @param color
  59543. * @param backBuffer
  59544. * @param depth
  59545. * @param stencil
  59546. */
  59547. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59548. /**
  59549. * Gets host document
  59550. * @returns the host document object
  59551. */
  59552. getHostDocument(): Nullable<Document>;
  59553. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59554. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59555. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59556. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59557. [key: string]: VertexBuffer;
  59558. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59559. bindBuffers(vertexBuffers: {
  59560. [key: string]: VertexBuffer;
  59561. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59562. recordVertexArrayObject(vertexBuffers: {
  59563. [key: string]: VertexBuffer;
  59564. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59565. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59566. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59567. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59568. /**
  59569. * Draw a list of indexed primitives
  59570. * @param fillMode defines the primitive to use
  59571. * @param indexStart defines the starting index
  59572. * @param indexCount defines the number of index to draw
  59573. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59574. */
  59575. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59576. /**
  59577. * Draw a list of unindexed primitives
  59578. * @param fillMode defines the primitive to use
  59579. * @param verticesStart defines the index of first vertex to draw
  59580. * @param verticesCount defines the count of vertices to draw
  59581. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59582. */
  59583. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59584. createPipelineContext(): IPipelineContext;
  59585. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59586. /** @hidden */
  59587. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59588. /** @hidden */
  59589. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59590. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59591. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59592. protected _setProgram(program: WebGLProgram): void;
  59593. _releaseEffect(effect: Effect): void;
  59594. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59595. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59596. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59597. bindSamplers(effect: Effect): void;
  59598. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  59599. getRenderWidth(useScreen?: boolean): number;
  59600. getRenderHeight(useScreen?: boolean): number;
  59601. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  59602. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59603. /**
  59604. * Set the z offset to apply to current rendering
  59605. * @param value defines the offset to apply
  59606. */
  59607. setZOffset(value: number): void;
  59608. /**
  59609. * Gets the current value of the zOffset
  59610. * @returns the current zOffset state
  59611. */
  59612. getZOffset(): number;
  59613. /**
  59614. * Enable or disable depth buffering
  59615. * @param enable defines the state to set
  59616. */
  59617. setDepthBuffer(enable: boolean): void;
  59618. /**
  59619. * Gets a boolean indicating if depth writing is enabled
  59620. * @returns the current depth writing state
  59621. */
  59622. getDepthWrite(): boolean;
  59623. setDepthFunctionToGreater(): void;
  59624. setDepthFunctionToGreaterOrEqual(): void;
  59625. setDepthFunctionToLess(): void;
  59626. setDepthFunctionToLessOrEqual(): void;
  59627. /**
  59628. * Enable or disable depth writing
  59629. * @param enable defines the state to set
  59630. */
  59631. setDepthWrite(enable: boolean): void;
  59632. /**
  59633. * Enable or disable color writing
  59634. * @param enable defines the state to set
  59635. */
  59636. setColorWrite(enable: boolean): void;
  59637. /**
  59638. * Gets a boolean indicating if color writing is enabled
  59639. * @returns the current color writing state
  59640. */
  59641. getColorWrite(): boolean;
  59642. /**
  59643. * Sets alpha constants used by some alpha blending modes
  59644. * @param r defines the red component
  59645. * @param g defines the green component
  59646. * @param b defines the blue component
  59647. * @param a defines the alpha component
  59648. */
  59649. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  59650. /**
  59651. * Sets the current alpha mode
  59652. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  59653. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59654. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59655. */
  59656. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59657. /**
  59658. * Gets the current alpha mode
  59659. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59660. * @returns the current alpha mode
  59661. */
  59662. getAlphaMode(): number;
  59663. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  59664. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59665. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59666. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59667. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59668. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59669. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59670. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59671. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59672. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59673. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59674. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59675. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59676. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59677. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59678. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59679. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59680. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59681. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59682. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59683. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  59684. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  59685. wipeCaches(bruteForce?: boolean): void;
  59686. _createTexture(): WebGLTexture;
  59687. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  59688. /**
  59689. * Update the content of a dynamic texture
  59690. * @param texture defines the texture to update
  59691. * @param canvas defines the canvas containing the source
  59692. * @param invertY defines if data must be stored with Y axis inverted
  59693. * @param premulAlpha defines if alpha is stored as premultiplied
  59694. * @param format defines the format of the data
  59695. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59696. */
  59697. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59698. /**
  59699. * Usually called from Texture.ts.
  59700. * Passed information to create a WebGLTexture
  59701. * @param url defines a value which contains one of the following:
  59702. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59703. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59704. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59705. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59706. * @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)
  59707. * @param scene needed for loading to the correct scene
  59708. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59709. * @param onLoad optional callback to be called upon successful completion
  59710. * @param onError optional callback to be called upon failure
  59711. * @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
  59712. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59713. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59714. * @param forcedExtension defines the extension to use to pick the right loader
  59715. * @param mimeType defines an optional mime type
  59716. * @param loaderOptions options to be passed to the loader
  59717. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59718. */
  59719. 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;
  59720. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  59721. _releaseFramebufferObjects(texture: InternalTexture): void;
  59722. /**
  59723. * Creates a cube texture
  59724. * @param rootUrl defines the url where the files to load is located
  59725. * @param scene defines the current scene
  59726. * @param files defines the list of files to load (1 per face)
  59727. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  59728. * @param onLoad defines an optional callback raised when the texture is loaded
  59729. * @param onError defines an optional callback raised if there is an issue to load the texture
  59730. * @param format defines the format of the data
  59731. * @param forcedExtension defines the extension to use to pick the right loader
  59732. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  59733. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59734. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59735. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  59736. * @returns the cube texture as an InternalTexture
  59737. */
  59738. 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;
  59739. createRenderTargetTexture(size: number | {
  59740. width: number;
  59741. height: number;
  59742. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  59743. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59744. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59745. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59746. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  59747. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  59748. /**
  59749. * Updates a dynamic vertex buffer.
  59750. * @param vertexBuffer the vertex buffer to update
  59751. * @param data the data used to update the vertex buffer
  59752. * @param byteOffset the byte offset of the data (optional)
  59753. * @param byteLength the byte length of the data (optional)
  59754. */
  59755. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  59756. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  59757. private _updateAnisotropicLevel;
  59758. private _getAddressMode;
  59759. /** @hidden */
  59760. _bindTexture(channel: number, texture: InternalTexture): void;
  59761. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  59762. releaseEffects(): void;
  59763. /** @hidden */
  59764. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59765. /** @hidden */
  59766. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59767. /** @hidden */
  59768. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59769. /** @hidden */
  59770. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59771. private _getNativeSamplingMode;
  59772. private _getNativeTextureFormat;
  59773. private _getNativeAlphaMode;
  59774. private _getNativeAttribType;
  59775. }
  59776. }
  59777. declare module "babylonjs/Engines/index" {
  59778. export * from "babylonjs/Engines/constants";
  59779. export * from "babylonjs/Engines/engineCapabilities";
  59780. export * from "babylonjs/Engines/instancingAttributeInfo";
  59781. export * from "babylonjs/Engines/thinEngine";
  59782. export * from "babylonjs/Engines/engine";
  59783. export * from "babylonjs/Engines/engineStore";
  59784. export * from "babylonjs/Engines/nullEngine";
  59785. export * from "babylonjs/Engines/Extensions/index";
  59786. export * from "babylonjs/Engines/IPipelineContext";
  59787. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  59788. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  59789. export * from "babylonjs/Engines/nativeEngine";
  59790. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  59791. export * from "babylonjs/Engines/performanceConfigurator";
  59792. }
  59793. declare module "babylonjs/Events/clipboardEvents" {
  59794. /**
  59795. * Gather the list of clipboard event types as constants.
  59796. */
  59797. export class ClipboardEventTypes {
  59798. /**
  59799. * The clipboard event is fired when a copy command is active (pressed).
  59800. */
  59801. static readonly COPY: number;
  59802. /**
  59803. * The clipboard event is fired when a cut command is active (pressed).
  59804. */
  59805. static readonly CUT: number;
  59806. /**
  59807. * The clipboard event is fired when a paste command is active (pressed).
  59808. */
  59809. static readonly PASTE: number;
  59810. }
  59811. /**
  59812. * This class is used to store clipboard related info for the onClipboardObservable event.
  59813. */
  59814. export class ClipboardInfo {
  59815. /**
  59816. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59817. */
  59818. type: number;
  59819. /**
  59820. * Defines the related dom event
  59821. */
  59822. event: ClipboardEvent;
  59823. /**
  59824. *Creates an instance of ClipboardInfo.
  59825. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  59826. * @param event Defines the related dom event
  59827. */
  59828. constructor(
  59829. /**
  59830. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59831. */
  59832. type: number,
  59833. /**
  59834. * Defines the related dom event
  59835. */
  59836. event: ClipboardEvent);
  59837. /**
  59838. * Get the clipboard event's type from the keycode.
  59839. * @param keyCode Defines the keyCode for the current keyboard event.
  59840. * @return {number}
  59841. */
  59842. static GetTypeFromCharacter(keyCode: number): number;
  59843. }
  59844. }
  59845. declare module "babylonjs/Events/index" {
  59846. export * from "babylonjs/Events/keyboardEvents";
  59847. export * from "babylonjs/Events/pointerEvents";
  59848. export * from "babylonjs/Events/clipboardEvents";
  59849. }
  59850. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  59851. import { Scene } from "babylonjs/scene";
  59852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59853. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59854. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59855. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59856. /**
  59857. * Google Daydream controller
  59858. */
  59859. export class DaydreamController extends WebVRController {
  59860. /**
  59861. * Base Url for the controller model.
  59862. */
  59863. static MODEL_BASE_URL: string;
  59864. /**
  59865. * File name for the controller model.
  59866. */
  59867. static MODEL_FILENAME: string;
  59868. /**
  59869. * Gamepad Id prefix used to identify Daydream Controller.
  59870. */
  59871. static readonly GAMEPAD_ID_PREFIX: string;
  59872. /**
  59873. * Creates a new DaydreamController from a gamepad
  59874. * @param vrGamepad the gamepad that the controller should be created from
  59875. */
  59876. constructor(vrGamepad: any);
  59877. /**
  59878. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59879. * @param scene scene in which to add meshes
  59880. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59881. */
  59882. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59883. /**
  59884. * Called once for each button that changed state since the last frame
  59885. * @param buttonIdx Which button index changed
  59886. * @param state New state of the button
  59887. * @param changes Which properties on the state changed since last frame
  59888. */
  59889. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59890. }
  59891. }
  59892. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  59893. import { Scene } from "babylonjs/scene";
  59894. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59895. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59896. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59897. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59898. /**
  59899. * Gear VR Controller
  59900. */
  59901. export class GearVRController extends WebVRController {
  59902. /**
  59903. * Base Url for the controller model.
  59904. */
  59905. static MODEL_BASE_URL: string;
  59906. /**
  59907. * File name for the controller model.
  59908. */
  59909. static MODEL_FILENAME: string;
  59910. /**
  59911. * Gamepad Id prefix used to identify this controller.
  59912. */
  59913. static readonly GAMEPAD_ID_PREFIX: string;
  59914. private readonly _buttonIndexToObservableNameMap;
  59915. /**
  59916. * Creates a new GearVRController from a gamepad
  59917. * @param vrGamepad the gamepad that the controller should be created from
  59918. */
  59919. constructor(vrGamepad: any);
  59920. /**
  59921. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59922. * @param scene scene in which to add meshes
  59923. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59924. */
  59925. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59926. /**
  59927. * Called once for each button that changed state since the last frame
  59928. * @param buttonIdx Which button index changed
  59929. * @param state New state of the button
  59930. * @param changes Which properties on the state changed since last frame
  59931. */
  59932. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59933. }
  59934. }
  59935. declare module "babylonjs/Gamepads/Controllers/genericController" {
  59936. import { Scene } from "babylonjs/scene";
  59937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59938. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59939. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59940. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59941. /**
  59942. * Generic Controller
  59943. */
  59944. export class GenericController extends WebVRController {
  59945. /**
  59946. * Base Url for the controller model.
  59947. */
  59948. static readonly MODEL_BASE_URL: string;
  59949. /**
  59950. * File name for the controller model.
  59951. */
  59952. static readonly MODEL_FILENAME: string;
  59953. /**
  59954. * Creates a new GenericController from a gamepad
  59955. * @param vrGamepad the gamepad that the controller should be created from
  59956. */
  59957. constructor(vrGamepad: any);
  59958. /**
  59959. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59960. * @param scene scene in which to add meshes
  59961. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59962. */
  59963. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59964. /**
  59965. * Called once for each button that changed state since the last frame
  59966. * @param buttonIdx Which button index changed
  59967. * @param state New state of the button
  59968. * @param changes Which properties on the state changed since last frame
  59969. */
  59970. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59971. }
  59972. }
  59973. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  59974. import { Observable } from "babylonjs/Misc/observable";
  59975. import { Scene } from "babylonjs/scene";
  59976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59977. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59978. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59979. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59980. /**
  59981. * Oculus Touch Controller
  59982. */
  59983. export class OculusTouchController extends WebVRController {
  59984. /**
  59985. * Base Url for the controller model.
  59986. */
  59987. static MODEL_BASE_URL: string;
  59988. /**
  59989. * File name for the left controller model.
  59990. */
  59991. static MODEL_LEFT_FILENAME: string;
  59992. /**
  59993. * File name for the right controller model.
  59994. */
  59995. static MODEL_RIGHT_FILENAME: string;
  59996. /**
  59997. * Base Url for the Quest controller model.
  59998. */
  59999. static QUEST_MODEL_BASE_URL: string;
  60000. /**
  60001. * @hidden
  60002. * If the controllers are running on a device that needs the updated Quest controller models
  60003. */
  60004. static _IsQuest: boolean;
  60005. /**
  60006. * Fired when the secondary trigger on this controller is modified
  60007. */
  60008. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60009. /**
  60010. * Fired when the thumb rest on this controller is modified
  60011. */
  60012. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60013. /**
  60014. * Creates a new OculusTouchController from a gamepad
  60015. * @param vrGamepad the gamepad that the controller should be created from
  60016. */
  60017. constructor(vrGamepad: any);
  60018. /**
  60019. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60020. * @param scene scene in which to add meshes
  60021. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60022. */
  60023. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60024. /**
  60025. * Fired when the A button on this controller is modified
  60026. */
  60027. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60028. /**
  60029. * Fired when the B button on this controller is modified
  60030. */
  60031. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60032. /**
  60033. * Fired when the X button on this controller is modified
  60034. */
  60035. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60036. /**
  60037. * Fired when the Y button on this controller is modified
  60038. */
  60039. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60040. /**
  60041. * Called once for each button that changed state since the last frame
  60042. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60043. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60044. * 2) secondary trigger (same)
  60045. * 3) A (right) X (left), touch, pressed = value
  60046. * 4) B / Y
  60047. * 5) thumb rest
  60048. * @param buttonIdx Which button index changed
  60049. * @param state New state of the button
  60050. * @param changes Which properties on the state changed since last frame
  60051. */
  60052. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60053. }
  60054. }
  60055. declare module "babylonjs/Gamepads/Controllers/viveController" {
  60056. import { Scene } from "babylonjs/scene";
  60057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60058. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  60059. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60060. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  60061. import { Observable } from "babylonjs/Misc/observable";
  60062. /**
  60063. * Vive Controller
  60064. */
  60065. export class ViveController extends WebVRController {
  60066. /**
  60067. * Base Url for the controller model.
  60068. */
  60069. static MODEL_BASE_URL: string;
  60070. /**
  60071. * File name for the controller model.
  60072. */
  60073. static MODEL_FILENAME: string;
  60074. /**
  60075. * Creates a new ViveController from a gamepad
  60076. * @param vrGamepad the gamepad that the controller should be created from
  60077. */
  60078. constructor(vrGamepad: any);
  60079. /**
  60080. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60081. * @param scene scene in which to add meshes
  60082. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60083. */
  60084. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60085. /**
  60086. * Fired when the left button on this controller is modified
  60087. */
  60088. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60089. /**
  60090. * Fired when the right button on this controller is modified
  60091. */
  60092. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60093. /**
  60094. * Fired when the menu button on this controller is modified
  60095. */
  60096. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60097. /**
  60098. * Called once for each button that changed state since the last frame
  60099. * Vive mapping:
  60100. * 0: touchpad
  60101. * 1: trigger
  60102. * 2: left AND right buttons
  60103. * 3: menu button
  60104. * @param buttonIdx Which button index changed
  60105. * @param state New state of the button
  60106. * @param changes Which properties on the state changed since last frame
  60107. */
  60108. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60109. }
  60110. }
  60111. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  60112. import { Observable } from "babylonjs/Misc/observable";
  60113. import { Scene } from "babylonjs/scene";
  60114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60115. import { Ray } from "babylonjs/Culling/ray";
  60116. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  60117. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60118. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  60119. /**
  60120. * Defines the WindowsMotionController object that the state of the windows motion controller
  60121. */
  60122. export class WindowsMotionController extends WebVRController {
  60123. /**
  60124. * The base url used to load the left and right controller models
  60125. */
  60126. static MODEL_BASE_URL: string;
  60127. /**
  60128. * The name of the left controller model file
  60129. */
  60130. static MODEL_LEFT_FILENAME: string;
  60131. /**
  60132. * The name of the right controller model file
  60133. */
  60134. static MODEL_RIGHT_FILENAME: string;
  60135. /**
  60136. * The controller name prefix for this controller type
  60137. */
  60138. static readonly GAMEPAD_ID_PREFIX: string;
  60139. /**
  60140. * The controller id pattern for this controller type
  60141. */
  60142. private static readonly GAMEPAD_ID_PATTERN;
  60143. private _loadedMeshInfo;
  60144. protected readonly _mapping: {
  60145. buttons: string[];
  60146. buttonMeshNames: {
  60147. trigger: string;
  60148. menu: string;
  60149. grip: string;
  60150. thumbstick: string;
  60151. trackpad: string;
  60152. };
  60153. buttonObservableNames: {
  60154. trigger: string;
  60155. menu: string;
  60156. grip: string;
  60157. thumbstick: string;
  60158. trackpad: string;
  60159. };
  60160. axisMeshNames: string[];
  60161. pointingPoseMeshName: string;
  60162. };
  60163. /**
  60164. * Fired when the trackpad on this controller is clicked
  60165. */
  60166. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60167. /**
  60168. * Fired when the trackpad on this controller is modified
  60169. */
  60170. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60171. /**
  60172. * The current x and y values of this controller's trackpad
  60173. */
  60174. trackpad: StickValues;
  60175. /**
  60176. * Creates a new WindowsMotionController from a gamepad
  60177. * @param vrGamepad the gamepad that the controller should be created from
  60178. */
  60179. constructor(vrGamepad: any);
  60180. /**
  60181. * Fired when the trigger on this controller is modified
  60182. */
  60183. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60184. /**
  60185. * Fired when the menu button on this controller is modified
  60186. */
  60187. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60188. /**
  60189. * Fired when the grip button on this controller is modified
  60190. */
  60191. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60192. /**
  60193. * Fired when the thumbstick button on this controller is modified
  60194. */
  60195. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60196. /**
  60197. * Fired when the touchpad button on this controller is modified
  60198. */
  60199. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60200. /**
  60201. * Fired when the touchpad values on this controller are modified
  60202. */
  60203. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60204. protected _updateTrackpad(): void;
  60205. /**
  60206. * Called once per frame by the engine.
  60207. */
  60208. update(): void;
  60209. /**
  60210. * Called once for each button that changed state since the last frame
  60211. * @param buttonIdx Which button index changed
  60212. * @param state New state of the button
  60213. * @param changes Which properties on the state changed since last frame
  60214. */
  60215. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60216. /**
  60217. * Moves the buttons on the controller mesh based on their current state
  60218. * @param buttonName the name of the button to move
  60219. * @param buttonValue the value of the button which determines the buttons new position
  60220. */
  60221. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60222. /**
  60223. * Moves the axis on the controller mesh based on its current state
  60224. * @param axis the index of the axis
  60225. * @param axisValue the value of the axis which determines the meshes new position
  60226. * @hidden
  60227. */
  60228. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60229. /**
  60230. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60231. * @param scene scene in which to add meshes
  60232. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60233. */
  60234. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60235. /**
  60236. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60237. * can be transformed by button presses and axes values, based on this._mapping.
  60238. *
  60239. * @param scene scene in which the meshes exist
  60240. * @param meshes list of meshes that make up the controller model to process
  60241. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60242. */
  60243. private processModel;
  60244. private createMeshInfo;
  60245. /**
  60246. * Gets the ray of the controller in the direction the controller is pointing
  60247. * @param length the length the resulting ray should be
  60248. * @returns a ray in the direction the controller is pointing
  60249. */
  60250. getForwardRay(length?: number): Ray;
  60251. /**
  60252. * Disposes of the controller
  60253. */
  60254. dispose(): void;
  60255. }
  60256. /**
  60257. * This class represents a new windows motion controller in XR.
  60258. */
  60259. export class XRWindowsMotionController extends WindowsMotionController {
  60260. /**
  60261. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60262. */
  60263. protected readonly _mapping: {
  60264. buttons: string[];
  60265. buttonMeshNames: {
  60266. trigger: string;
  60267. menu: string;
  60268. grip: string;
  60269. thumbstick: string;
  60270. trackpad: string;
  60271. };
  60272. buttonObservableNames: {
  60273. trigger: string;
  60274. menu: string;
  60275. grip: string;
  60276. thumbstick: string;
  60277. trackpad: string;
  60278. };
  60279. axisMeshNames: string[];
  60280. pointingPoseMeshName: string;
  60281. };
  60282. /**
  60283. * Construct a new XR-Based windows motion controller
  60284. *
  60285. * @param gamepadInfo the gamepad object from the browser
  60286. */
  60287. constructor(gamepadInfo: any);
  60288. /**
  60289. * holds the thumbstick values (X,Y)
  60290. */
  60291. thumbstickValues: StickValues;
  60292. /**
  60293. * Fired when the thumbstick on this controller is clicked
  60294. */
  60295. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60296. /**
  60297. * Fired when the thumbstick on this controller is modified
  60298. */
  60299. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60300. /**
  60301. * Fired when the touchpad button on this controller is modified
  60302. */
  60303. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60304. /**
  60305. * Fired when the touchpad values on this controller are modified
  60306. */
  60307. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60308. /**
  60309. * Fired when the thumbstick button on this controller is modified
  60310. * here to prevent breaking changes
  60311. */
  60312. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60313. /**
  60314. * updating the thumbstick(!) and not the trackpad.
  60315. * This is named this way due to the difference between WebVR and XR and to avoid
  60316. * changing the parent class.
  60317. */
  60318. protected _updateTrackpad(): void;
  60319. /**
  60320. * Disposes the class with joy
  60321. */
  60322. dispose(): void;
  60323. }
  60324. }
  60325. declare module "babylonjs/Gamepads/Controllers/index" {
  60326. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  60327. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  60328. export * from "babylonjs/Gamepads/Controllers/genericController";
  60329. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  60330. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60331. export * from "babylonjs/Gamepads/Controllers/viveController";
  60332. export * from "babylonjs/Gamepads/Controllers/webVRController";
  60333. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  60334. }
  60335. declare module "babylonjs/Gamepads/index" {
  60336. export * from "babylonjs/Gamepads/Controllers/index";
  60337. export * from "babylonjs/Gamepads/gamepad";
  60338. export * from "babylonjs/Gamepads/gamepadManager";
  60339. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  60340. export * from "babylonjs/Gamepads/xboxGamepad";
  60341. export * from "babylonjs/Gamepads/dualShockGamepad";
  60342. }
  60343. declare module "babylonjs/Lights/directionalLight" {
  60344. import { Camera } from "babylonjs/Cameras/camera";
  60345. import { Scene } from "babylonjs/scene";
  60346. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60348. import { Light } from "babylonjs/Lights/light";
  60349. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60350. import { Effect } from "babylonjs/Materials/effect";
  60351. /**
  60352. * A directional light is defined by a direction (what a surprise!).
  60353. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60354. * 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.
  60355. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60356. */
  60357. export class DirectionalLight extends ShadowLight {
  60358. private _shadowFrustumSize;
  60359. /**
  60360. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60361. */
  60362. get shadowFrustumSize(): number;
  60363. /**
  60364. * Specifies a fix frustum size for the shadow generation.
  60365. */
  60366. set shadowFrustumSize(value: number);
  60367. private _shadowOrthoScale;
  60368. /**
  60369. * Gets the shadow projection scale against the optimal computed one.
  60370. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60371. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60372. */
  60373. get shadowOrthoScale(): number;
  60374. /**
  60375. * Sets the shadow projection scale against the optimal computed one.
  60376. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60377. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60378. */
  60379. set shadowOrthoScale(value: number);
  60380. /**
  60381. * Automatically compute the projection matrix to best fit (including all the casters)
  60382. * on each frame.
  60383. */
  60384. autoUpdateExtends: boolean;
  60385. /**
  60386. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60387. * on each frame. autoUpdateExtends must be set to true for this to work
  60388. */
  60389. autoCalcShadowZBounds: boolean;
  60390. private _orthoLeft;
  60391. private _orthoRight;
  60392. private _orthoTop;
  60393. private _orthoBottom;
  60394. /**
  60395. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60396. * The directional light is emitted from everywhere in the given direction.
  60397. * It can cast shadows.
  60398. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60399. * @param name The friendly name of the light
  60400. * @param direction The direction of the light
  60401. * @param scene The scene the light belongs to
  60402. */
  60403. constructor(name: string, direction: Vector3, scene: Scene);
  60404. /**
  60405. * Returns the string "DirectionalLight".
  60406. * @return The class name
  60407. */
  60408. getClassName(): string;
  60409. /**
  60410. * Returns the integer 1.
  60411. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60412. */
  60413. getTypeID(): number;
  60414. /**
  60415. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60416. * Returns the DirectionalLight Shadow projection matrix.
  60417. */
  60418. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60419. /**
  60420. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60421. * Returns the DirectionalLight Shadow projection matrix.
  60422. */
  60423. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60424. /**
  60425. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60426. * Returns the DirectionalLight Shadow projection matrix.
  60427. */
  60428. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60429. protected _buildUniformLayout(): void;
  60430. /**
  60431. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60432. * @param effect The effect to update
  60433. * @param lightIndex The index of the light in the effect to update
  60434. * @returns The directional light
  60435. */
  60436. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60437. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60438. /**
  60439. * Gets the minZ used for shadow according to both the scene and the light.
  60440. *
  60441. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60442. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60443. * @param activeCamera The camera we are returning the min for
  60444. * @returns the depth min z
  60445. */
  60446. getDepthMinZ(activeCamera: Camera): number;
  60447. /**
  60448. * Gets the maxZ used for shadow according to both the scene and the light.
  60449. *
  60450. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60451. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60452. * @param activeCamera The camera we are returning the max for
  60453. * @returns the depth max z
  60454. */
  60455. getDepthMaxZ(activeCamera: Camera): number;
  60456. /**
  60457. * Prepares the list of defines specific to the light type.
  60458. * @param defines the list of defines
  60459. * @param lightIndex defines the index of the light for the effect
  60460. */
  60461. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60462. }
  60463. }
  60464. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  60465. import { Mesh } from "babylonjs/Meshes/mesh";
  60466. /**
  60467. * Class containing static functions to help procedurally build meshes
  60468. */
  60469. export class HemisphereBuilder {
  60470. /**
  60471. * Creates a hemisphere mesh
  60472. * @param name defines the name of the mesh
  60473. * @param options defines the options used to create the mesh
  60474. * @param scene defines the hosting scene
  60475. * @returns the hemisphere mesh
  60476. */
  60477. static CreateHemisphere(name: string, options: {
  60478. segments?: number;
  60479. diameter?: number;
  60480. sideOrientation?: number;
  60481. }, scene: any): Mesh;
  60482. }
  60483. }
  60484. declare module "babylonjs/Lights/spotLight" {
  60485. import { Nullable } from "babylonjs/types";
  60486. import { Scene } from "babylonjs/scene";
  60487. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60489. import { Effect } from "babylonjs/Materials/effect";
  60490. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60491. import { Light } from "babylonjs/Lights/light";
  60492. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60493. /**
  60494. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60495. * These values define a cone of light starting from the position, emitting toward the direction.
  60496. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60497. * and the exponent defines the speed of the decay of the light with distance (reach).
  60498. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60499. */
  60500. export class SpotLight extends ShadowLight {
  60501. private _angle;
  60502. private _innerAngle;
  60503. private _cosHalfAngle;
  60504. private _lightAngleScale;
  60505. private _lightAngleOffset;
  60506. /**
  60507. * Gets the cone angle of the spot light in Radians.
  60508. */
  60509. get angle(): number;
  60510. /**
  60511. * Sets the cone angle of the spot light in Radians.
  60512. */
  60513. set angle(value: number);
  60514. /**
  60515. * Only used in gltf falloff mode, this defines the angle where
  60516. * the directional falloff will start before cutting at angle which could be seen
  60517. * as outer angle.
  60518. */
  60519. get innerAngle(): number;
  60520. /**
  60521. * Only used in gltf falloff mode, this defines the angle where
  60522. * the directional falloff will start before cutting at angle which could be seen
  60523. * as outer angle.
  60524. */
  60525. set innerAngle(value: number);
  60526. private _shadowAngleScale;
  60527. /**
  60528. * Allows scaling the angle of the light for shadow generation only.
  60529. */
  60530. get shadowAngleScale(): number;
  60531. /**
  60532. * Allows scaling the angle of the light for shadow generation only.
  60533. */
  60534. set shadowAngleScale(value: number);
  60535. /**
  60536. * The light decay speed with the distance from the emission spot.
  60537. */
  60538. exponent: number;
  60539. private _projectionTextureMatrix;
  60540. /**
  60541. * Allows reading the projecton texture
  60542. */
  60543. get projectionTextureMatrix(): Matrix;
  60544. protected _projectionTextureLightNear: number;
  60545. /**
  60546. * Gets the near clip of the Spotlight for texture projection.
  60547. */
  60548. get projectionTextureLightNear(): number;
  60549. /**
  60550. * Sets the near clip of the Spotlight for texture projection.
  60551. */
  60552. set projectionTextureLightNear(value: number);
  60553. protected _projectionTextureLightFar: number;
  60554. /**
  60555. * Gets the far clip of the Spotlight for texture projection.
  60556. */
  60557. get projectionTextureLightFar(): number;
  60558. /**
  60559. * Sets the far clip of the Spotlight for texture projection.
  60560. */
  60561. set projectionTextureLightFar(value: number);
  60562. protected _projectionTextureUpDirection: Vector3;
  60563. /**
  60564. * Gets the Up vector of the Spotlight for texture projection.
  60565. */
  60566. get projectionTextureUpDirection(): Vector3;
  60567. /**
  60568. * Sets the Up vector of the Spotlight for texture projection.
  60569. */
  60570. set projectionTextureUpDirection(value: Vector3);
  60571. private _projectionTexture;
  60572. /**
  60573. * Gets the projection texture of the light.
  60574. */
  60575. get projectionTexture(): Nullable<BaseTexture>;
  60576. /**
  60577. * Sets the projection texture of the light.
  60578. */
  60579. set projectionTexture(value: Nullable<BaseTexture>);
  60580. private static _IsProceduralTexture;
  60581. private static _IsTexture;
  60582. private _projectionTextureViewLightDirty;
  60583. private _projectionTextureProjectionLightDirty;
  60584. private _projectionTextureDirty;
  60585. private _projectionTextureViewTargetVector;
  60586. private _projectionTextureViewLightMatrix;
  60587. private _projectionTextureProjectionLightMatrix;
  60588. private _projectionTextureScalingMatrix;
  60589. /**
  60590. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60591. * It can cast shadows.
  60592. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60593. * @param name The light friendly name
  60594. * @param position The position of the spot light in the scene
  60595. * @param direction The direction of the light in the scene
  60596. * @param angle The cone angle of the light in Radians
  60597. * @param exponent The light decay speed with the distance from the emission spot
  60598. * @param scene The scene the lights belongs to
  60599. */
  60600. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60601. /**
  60602. * Returns the string "SpotLight".
  60603. * @returns the class name
  60604. */
  60605. getClassName(): string;
  60606. /**
  60607. * Returns the integer 2.
  60608. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60609. */
  60610. getTypeID(): number;
  60611. /**
  60612. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60613. */
  60614. protected _setDirection(value: Vector3): void;
  60615. /**
  60616. * Overrides the position setter to recompute the projection texture view light Matrix.
  60617. */
  60618. protected _setPosition(value: Vector3): void;
  60619. /**
  60620. * 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.
  60621. * Returns the SpotLight.
  60622. */
  60623. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60624. protected _computeProjectionTextureViewLightMatrix(): void;
  60625. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60626. /**
  60627. * Main function for light texture projection matrix computing.
  60628. */
  60629. protected _computeProjectionTextureMatrix(): void;
  60630. protected _buildUniformLayout(): void;
  60631. private _computeAngleValues;
  60632. /**
  60633. * Sets the passed Effect "effect" with the Light textures.
  60634. * @param effect The effect to update
  60635. * @param lightIndex The index of the light in the effect to update
  60636. * @returns The light
  60637. */
  60638. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60639. /**
  60640. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60641. * @param effect The effect to update
  60642. * @param lightIndex The index of the light in the effect to update
  60643. * @returns The spot light
  60644. */
  60645. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60646. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60647. /**
  60648. * Disposes the light and the associated resources.
  60649. */
  60650. dispose(): void;
  60651. /**
  60652. * Prepares the list of defines specific to the light type.
  60653. * @param defines the list of defines
  60654. * @param lightIndex defines the index of the light for the effect
  60655. */
  60656. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60657. }
  60658. }
  60659. declare module "babylonjs/Gizmos/lightGizmo" {
  60660. import { Nullable } from "babylonjs/types";
  60661. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60662. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60663. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60664. import { Light } from "babylonjs/Lights/light";
  60665. import { Observable } from "babylonjs/Misc/observable";
  60666. /**
  60667. * Gizmo that enables viewing a light
  60668. */
  60669. export class LightGizmo extends Gizmo {
  60670. private _lightMesh;
  60671. private _material;
  60672. private _cachedPosition;
  60673. private _cachedForward;
  60674. private _attachedMeshParent;
  60675. private _pointerObserver;
  60676. /**
  60677. * Event that fires each time the gizmo is clicked
  60678. */
  60679. onClickedObservable: Observable<Light>;
  60680. /**
  60681. * Creates a LightGizmo
  60682. * @param gizmoLayer The utility layer the gizmo will be added to
  60683. */
  60684. constructor(gizmoLayer?: UtilityLayerRenderer);
  60685. private _light;
  60686. /**
  60687. * The light that the gizmo is attached to
  60688. */
  60689. set light(light: Nullable<Light>);
  60690. get light(): Nullable<Light>;
  60691. /**
  60692. * Gets the material used to render the light gizmo
  60693. */
  60694. get material(): StandardMaterial;
  60695. /**
  60696. * @hidden
  60697. * Updates the gizmo to match the attached mesh's position/rotation
  60698. */
  60699. protected _update(): void;
  60700. private static _Scale;
  60701. /**
  60702. * Creates the lines for a light mesh
  60703. */
  60704. private static _CreateLightLines;
  60705. /**
  60706. * Disposes of the light gizmo
  60707. */
  60708. dispose(): void;
  60709. private static _CreateHemisphericLightMesh;
  60710. private static _CreatePointLightMesh;
  60711. private static _CreateSpotLightMesh;
  60712. private static _CreateDirectionalLightMesh;
  60713. }
  60714. }
  60715. declare module "babylonjs/Gizmos/cameraGizmo" {
  60716. import { Nullable } from "babylonjs/types";
  60717. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60718. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60719. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60720. import { Camera } from "babylonjs/Cameras/camera";
  60721. import { Observable } from "babylonjs/Misc/observable";
  60722. /**
  60723. * Gizmo that enables viewing a camera
  60724. */
  60725. export class CameraGizmo extends Gizmo {
  60726. private _cameraMesh;
  60727. private _cameraLinesMesh;
  60728. private _material;
  60729. private _pointerObserver;
  60730. /**
  60731. * Event that fires each time the gizmo is clicked
  60732. */
  60733. onClickedObservable: Observable<Camera>;
  60734. /**
  60735. * Creates a CameraGizmo
  60736. * @param gizmoLayer The utility layer the gizmo will be added to
  60737. */
  60738. constructor(gizmoLayer?: UtilityLayerRenderer);
  60739. private _camera;
  60740. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60741. get displayFrustum(): boolean;
  60742. set displayFrustum(value: boolean);
  60743. /**
  60744. * The camera that the gizmo is attached to
  60745. */
  60746. set camera(camera: Nullable<Camera>);
  60747. get camera(): Nullable<Camera>;
  60748. /**
  60749. * Gets the material used to render the camera gizmo
  60750. */
  60751. get material(): StandardMaterial;
  60752. /**
  60753. * @hidden
  60754. * Updates the gizmo to match the attached mesh's position/rotation
  60755. */
  60756. protected _update(): void;
  60757. private static _Scale;
  60758. private _invProjection;
  60759. /**
  60760. * Disposes of the camera gizmo
  60761. */
  60762. dispose(): void;
  60763. private static _CreateCameraMesh;
  60764. private static _CreateCameraFrustum;
  60765. }
  60766. }
  60767. declare module "babylonjs/Gizmos/index" {
  60768. export * from "babylonjs/Gizmos/axisDragGizmo";
  60769. export * from "babylonjs/Gizmos/axisScaleGizmo";
  60770. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  60771. export * from "babylonjs/Gizmos/gizmo";
  60772. export * from "babylonjs/Gizmos/gizmoManager";
  60773. export * from "babylonjs/Gizmos/planeRotationGizmo";
  60774. export * from "babylonjs/Gizmos/positionGizmo";
  60775. export * from "babylonjs/Gizmos/rotationGizmo";
  60776. export * from "babylonjs/Gizmos/scaleGizmo";
  60777. export * from "babylonjs/Gizmos/lightGizmo";
  60778. export * from "babylonjs/Gizmos/cameraGizmo";
  60779. export * from "babylonjs/Gizmos/planeDragGizmo";
  60780. }
  60781. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  60782. /** @hidden */
  60783. export var backgroundFragmentDeclaration: {
  60784. name: string;
  60785. shader: string;
  60786. };
  60787. }
  60788. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  60789. /** @hidden */
  60790. export var backgroundUboDeclaration: {
  60791. name: string;
  60792. shader: string;
  60793. };
  60794. }
  60795. declare module "babylonjs/Shaders/background.fragment" {
  60796. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  60797. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60798. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60799. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60800. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60801. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60802. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60803. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60804. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60805. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60806. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  60807. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60808. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60809. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60810. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60811. /** @hidden */
  60812. export var backgroundPixelShader: {
  60813. name: string;
  60814. shader: string;
  60815. };
  60816. }
  60817. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60818. /** @hidden */
  60819. export var backgroundVertexDeclaration: {
  60820. name: string;
  60821. shader: string;
  60822. };
  60823. }
  60824. declare module "babylonjs/Shaders/background.vertex" {
  60825. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60826. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60827. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60828. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60829. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60830. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60831. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60832. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60833. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60834. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60835. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60836. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60837. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60838. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60839. /** @hidden */
  60840. export var backgroundVertexShader: {
  60841. name: string;
  60842. shader: string;
  60843. };
  60844. }
  60845. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60846. import { Nullable, int, float } from "babylonjs/types";
  60847. import { Scene } from "babylonjs/scene";
  60848. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60849. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60851. import { Mesh } from "babylonjs/Meshes/mesh";
  60852. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60853. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60854. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60855. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60856. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60857. import { Color3 } from "babylonjs/Maths/math.color";
  60858. import "babylonjs/Shaders/background.fragment";
  60859. import "babylonjs/Shaders/background.vertex";
  60860. /**
  60861. * Background material used to create an efficient environement around your scene.
  60862. */
  60863. export class BackgroundMaterial extends PushMaterial {
  60864. /**
  60865. * Standard reflectance value at parallel view angle.
  60866. */
  60867. static StandardReflectance0: number;
  60868. /**
  60869. * Standard reflectance value at grazing angle.
  60870. */
  60871. static StandardReflectance90: number;
  60872. protected _primaryColor: Color3;
  60873. /**
  60874. * Key light Color (multiply against the environement texture)
  60875. */
  60876. primaryColor: Color3;
  60877. protected __perceptualColor: Nullable<Color3>;
  60878. /**
  60879. * Experimental Internal Use Only.
  60880. *
  60881. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60882. * This acts as a helper to set the primary color to a more "human friendly" value.
  60883. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60884. * output color as close as possible from the chosen value.
  60885. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60886. * part of lighting setup.)
  60887. */
  60888. get _perceptualColor(): Nullable<Color3>;
  60889. set _perceptualColor(value: Nullable<Color3>);
  60890. protected _primaryColorShadowLevel: float;
  60891. /**
  60892. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60893. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60894. */
  60895. get primaryColorShadowLevel(): float;
  60896. set primaryColorShadowLevel(value: float);
  60897. protected _primaryColorHighlightLevel: float;
  60898. /**
  60899. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60900. * The primary color is used at the level chosen to define what the white area would look.
  60901. */
  60902. get primaryColorHighlightLevel(): float;
  60903. set primaryColorHighlightLevel(value: float);
  60904. protected _reflectionTexture: Nullable<BaseTexture>;
  60905. /**
  60906. * Reflection Texture used in the material.
  60907. * Should be author in a specific way for the best result (refer to the documentation).
  60908. */
  60909. reflectionTexture: Nullable<BaseTexture>;
  60910. protected _reflectionBlur: float;
  60911. /**
  60912. * Reflection Texture level of blur.
  60913. *
  60914. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60915. * texture twice.
  60916. */
  60917. reflectionBlur: float;
  60918. protected _diffuseTexture: Nullable<BaseTexture>;
  60919. /**
  60920. * Diffuse Texture used in the material.
  60921. * Should be author in a specific way for the best result (refer to the documentation).
  60922. */
  60923. diffuseTexture: Nullable<BaseTexture>;
  60924. protected _shadowLights: Nullable<IShadowLight[]>;
  60925. /**
  60926. * Specify the list of lights casting shadow on the material.
  60927. * All scene shadow lights will be included if null.
  60928. */
  60929. shadowLights: Nullable<IShadowLight[]>;
  60930. protected _shadowLevel: float;
  60931. /**
  60932. * Helps adjusting the shadow to a softer level if required.
  60933. * 0 means black shadows and 1 means no shadows.
  60934. */
  60935. shadowLevel: float;
  60936. protected _sceneCenter: Vector3;
  60937. /**
  60938. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60939. * It is usually zero but might be interesting to modify according to your setup.
  60940. */
  60941. sceneCenter: Vector3;
  60942. protected _opacityFresnel: boolean;
  60943. /**
  60944. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60945. * This helps ensuring a nice transition when the camera goes under the ground.
  60946. */
  60947. opacityFresnel: boolean;
  60948. protected _reflectionFresnel: boolean;
  60949. /**
  60950. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60951. * This helps adding a mirror texture on the ground.
  60952. */
  60953. reflectionFresnel: boolean;
  60954. protected _reflectionFalloffDistance: number;
  60955. /**
  60956. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60957. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60958. */
  60959. reflectionFalloffDistance: number;
  60960. protected _reflectionAmount: number;
  60961. /**
  60962. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60963. */
  60964. reflectionAmount: number;
  60965. protected _reflectionReflectance0: number;
  60966. /**
  60967. * This specifies the weight of the reflection at grazing angle.
  60968. */
  60969. reflectionReflectance0: number;
  60970. protected _reflectionReflectance90: number;
  60971. /**
  60972. * This specifies the weight of the reflection at a perpendicular point of view.
  60973. */
  60974. reflectionReflectance90: number;
  60975. /**
  60976. * Sets the reflection reflectance fresnel values according to the default standard
  60977. * empirically know to work well :-)
  60978. */
  60979. set reflectionStandardFresnelWeight(value: number);
  60980. protected _useRGBColor: boolean;
  60981. /**
  60982. * Helps to directly use the maps channels instead of their level.
  60983. */
  60984. useRGBColor: boolean;
  60985. protected _enableNoise: boolean;
  60986. /**
  60987. * This helps reducing the banding effect that could occur on the background.
  60988. */
  60989. enableNoise: boolean;
  60990. /**
  60991. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60992. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60993. * Recommended to be keep at 1.0 except for special cases.
  60994. */
  60995. get fovMultiplier(): number;
  60996. set fovMultiplier(value: number);
  60997. private _fovMultiplier;
  60998. /**
  60999. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61000. */
  61001. useEquirectangularFOV: boolean;
  61002. private _maxSimultaneousLights;
  61003. /**
  61004. * Number of Simultaneous lights allowed on the material.
  61005. */
  61006. maxSimultaneousLights: int;
  61007. private _shadowOnly;
  61008. /**
  61009. * Make the material only render shadows
  61010. */
  61011. shadowOnly: boolean;
  61012. /**
  61013. * Default configuration related to image processing available in the Background Material.
  61014. */
  61015. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61016. /**
  61017. * Keep track of the image processing observer to allow dispose and replace.
  61018. */
  61019. private _imageProcessingObserver;
  61020. /**
  61021. * Attaches a new image processing configuration to the PBR Material.
  61022. * @param configuration (if null the scene configuration will be use)
  61023. */
  61024. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61025. /**
  61026. * Gets the image processing configuration used either in this material.
  61027. */
  61028. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61029. /**
  61030. * Sets the Default image processing configuration used either in the this material.
  61031. *
  61032. * If sets to null, the scene one is in use.
  61033. */
  61034. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61035. /**
  61036. * Gets wether the color curves effect is enabled.
  61037. */
  61038. get cameraColorCurvesEnabled(): boolean;
  61039. /**
  61040. * Sets wether the color curves effect is enabled.
  61041. */
  61042. set cameraColorCurvesEnabled(value: boolean);
  61043. /**
  61044. * Gets wether the color grading effect is enabled.
  61045. */
  61046. get cameraColorGradingEnabled(): boolean;
  61047. /**
  61048. * Gets wether the color grading effect is enabled.
  61049. */
  61050. set cameraColorGradingEnabled(value: boolean);
  61051. /**
  61052. * Gets wether tonemapping is enabled or not.
  61053. */
  61054. get cameraToneMappingEnabled(): boolean;
  61055. /**
  61056. * Sets wether tonemapping is enabled or not
  61057. */
  61058. set cameraToneMappingEnabled(value: boolean);
  61059. /**
  61060. * The camera exposure used on this material.
  61061. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61062. * This corresponds to a photographic exposure.
  61063. */
  61064. get cameraExposure(): float;
  61065. /**
  61066. * The camera exposure used on this material.
  61067. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61068. * This corresponds to a photographic exposure.
  61069. */
  61070. set cameraExposure(value: float);
  61071. /**
  61072. * Gets The camera contrast used on this material.
  61073. */
  61074. get cameraContrast(): float;
  61075. /**
  61076. * Sets The camera contrast used on this material.
  61077. */
  61078. set cameraContrast(value: float);
  61079. /**
  61080. * Gets the Color Grading 2D Lookup Texture.
  61081. */
  61082. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61083. /**
  61084. * Sets the Color Grading 2D Lookup Texture.
  61085. */
  61086. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61087. /**
  61088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61090. * 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;
  61091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61092. */
  61093. get cameraColorCurves(): Nullable<ColorCurves>;
  61094. /**
  61095. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61096. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61097. * 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;
  61098. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61099. */
  61100. set cameraColorCurves(value: Nullable<ColorCurves>);
  61101. /**
  61102. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61103. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61104. */
  61105. switchToBGR: boolean;
  61106. private _renderTargets;
  61107. private _reflectionControls;
  61108. private _white;
  61109. private _primaryShadowColor;
  61110. private _primaryHighlightColor;
  61111. /**
  61112. * Instantiates a Background Material in the given scene
  61113. * @param name The friendly name of the material
  61114. * @param scene The scene to add the material to
  61115. */
  61116. constructor(name: string, scene: Scene);
  61117. /**
  61118. * Gets a boolean indicating that current material needs to register RTT
  61119. */
  61120. get hasRenderTargetTextures(): boolean;
  61121. /**
  61122. * The entire material has been created in order to prevent overdraw.
  61123. * @returns false
  61124. */
  61125. needAlphaTesting(): boolean;
  61126. /**
  61127. * The entire material has been created in order to prevent overdraw.
  61128. * @returns true if blending is enable
  61129. */
  61130. needAlphaBlending(): boolean;
  61131. /**
  61132. * Checks wether the material is ready to be rendered for a given mesh.
  61133. * @param mesh The mesh to render
  61134. * @param subMesh The submesh to check against
  61135. * @param useInstances Specify wether or not the material is used with instances
  61136. * @returns true if all the dependencies are ready (Textures, Effects...)
  61137. */
  61138. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61139. /**
  61140. * Compute the primary color according to the chosen perceptual color.
  61141. */
  61142. private _computePrimaryColorFromPerceptualColor;
  61143. /**
  61144. * Compute the highlights and shadow colors according to their chosen levels.
  61145. */
  61146. private _computePrimaryColors;
  61147. /**
  61148. * Build the uniform buffer used in the material.
  61149. */
  61150. buildUniformLayout(): void;
  61151. /**
  61152. * Unbind the material.
  61153. */
  61154. unbind(): void;
  61155. /**
  61156. * Bind only the world matrix to the material.
  61157. * @param world The world matrix to bind.
  61158. */
  61159. bindOnlyWorldMatrix(world: Matrix): void;
  61160. /**
  61161. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61162. * @param world The world matrix to bind.
  61163. * @param subMesh The submesh to bind for.
  61164. */
  61165. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61166. /**
  61167. * Checks to see if a texture is used in the material.
  61168. * @param texture - Base texture to use.
  61169. * @returns - Boolean specifying if a texture is used in the material.
  61170. */
  61171. hasTexture(texture: BaseTexture): boolean;
  61172. /**
  61173. * Dispose the material.
  61174. * @param forceDisposeEffect Force disposal of the associated effect.
  61175. * @param forceDisposeTextures Force disposal of the associated textures.
  61176. */
  61177. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61178. /**
  61179. * Clones the material.
  61180. * @param name The cloned name.
  61181. * @returns The cloned material.
  61182. */
  61183. clone(name: string): BackgroundMaterial;
  61184. /**
  61185. * Serializes the current material to its JSON representation.
  61186. * @returns The JSON representation.
  61187. */
  61188. serialize(): any;
  61189. /**
  61190. * Gets the class name of the material
  61191. * @returns "BackgroundMaterial"
  61192. */
  61193. getClassName(): string;
  61194. /**
  61195. * Parse a JSON input to create back a background material.
  61196. * @param source The JSON data to parse
  61197. * @param scene The scene to create the parsed material in
  61198. * @param rootUrl The root url of the assets the material depends upon
  61199. * @returns the instantiated BackgroundMaterial.
  61200. */
  61201. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61202. }
  61203. }
  61204. declare module "babylonjs/Helpers/environmentHelper" {
  61205. import { Observable } from "babylonjs/Misc/observable";
  61206. import { Nullable } from "babylonjs/types";
  61207. import { Scene } from "babylonjs/scene";
  61208. import { Vector3 } from "babylonjs/Maths/math.vector";
  61209. import { Color3 } from "babylonjs/Maths/math.color";
  61210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61211. import { Mesh } from "babylonjs/Meshes/mesh";
  61212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61213. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  61214. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61215. import "babylonjs/Meshes/Builders/planeBuilder";
  61216. import "babylonjs/Meshes/Builders/boxBuilder";
  61217. /**
  61218. * Represents the different options available during the creation of
  61219. * a Environment helper.
  61220. *
  61221. * This can control the default ground, skybox and image processing setup of your scene.
  61222. */
  61223. export interface IEnvironmentHelperOptions {
  61224. /**
  61225. * Specifies whether or not to create a ground.
  61226. * True by default.
  61227. */
  61228. createGround: boolean;
  61229. /**
  61230. * Specifies the ground size.
  61231. * 15 by default.
  61232. */
  61233. groundSize: number;
  61234. /**
  61235. * The texture used on the ground for the main color.
  61236. * Comes from the BabylonJS CDN by default.
  61237. *
  61238. * Remarks: Can be either a texture or a url.
  61239. */
  61240. groundTexture: string | BaseTexture;
  61241. /**
  61242. * The color mixed in the ground texture by default.
  61243. * BabylonJS clearColor by default.
  61244. */
  61245. groundColor: Color3;
  61246. /**
  61247. * Specifies the ground opacity.
  61248. * 1 by default.
  61249. */
  61250. groundOpacity: number;
  61251. /**
  61252. * Enables the ground to receive shadows.
  61253. * True by default.
  61254. */
  61255. enableGroundShadow: boolean;
  61256. /**
  61257. * Helps preventing the shadow to be fully black on the ground.
  61258. * 0.5 by default.
  61259. */
  61260. groundShadowLevel: number;
  61261. /**
  61262. * Creates a mirror texture attach to the ground.
  61263. * false by default.
  61264. */
  61265. enableGroundMirror: boolean;
  61266. /**
  61267. * Specifies the ground mirror size ratio.
  61268. * 0.3 by default as the default kernel is 64.
  61269. */
  61270. groundMirrorSizeRatio: number;
  61271. /**
  61272. * Specifies the ground mirror blur kernel size.
  61273. * 64 by default.
  61274. */
  61275. groundMirrorBlurKernel: number;
  61276. /**
  61277. * Specifies the ground mirror visibility amount.
  61278. * 1 by default
  61279. */
  61280. groundMirrorAmount: number;
  61281. /**
  61282. * Specifies the ground mirror reflectance weight.
  61283. * This uses the standard weight of the background material to setup the fresnel effect
  61284. * of the mirror.
  61285. * 1 by default.
  61286. */
  61287. groundMirrorFresnelWeight: number;
  61288. /**
  61289. * Specifies the ground mirror Falloff distance.
  61290. * This can helps reducing the size of the reflection.
  61291. * 0 by Default.
  61292. */
  61293. groundMirrorFallOffDistance: number;
  61294. /**
  61295. * Specifies the ground mirror texture type.
  61296. * Unsigned Int by Default.
  61297. */
  61298. groundMirrorTextureType: number;
  61299. /**
  61300. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61301. * the shown objects.
  61302. */
  61303. groundYBias: number;
  61304. /**
  61305. * Specifies whether or not to create a skybox.
  61306. * True by default.
  61307. */
  61308. createSkybox: boolean;
  61309. /**
  61310. * Specifies the skybox size.
  61311. * 20 by default.
  61312. */
  61313. skyboxSize: number;
  61314. /**
  61315. * The texture used on the skybox for the main color.
  61316. * Comes from the BabylonJS CDN by default.
  61317. *
  61318. * Remarks: Can be either a texture or a url.
  61319. */
  61320. skyboxTexture: string | BaseTexture;
  61321. /**
  61322. * The color mixed in the skybox texture by default.
  61323. * BabylonJS clearColor by default.
  61324. */
  61325. skyboxColor: Color3;
  61326. /**
  61327. * The background rotation around the Y axis of the scene.
  61328. * This helps aligning the key lights of your scene with the background.
  61329. * 0 by default.
  61330. */
  61331. backgroundYRotation: number;
  61332. /**
  61333. * Compute automatically the size of the elements to best fit with the scene.
  61334. */
  61335. sizeAuto: boolean;
  61336. /**
  61337. * Default position of the rootMesh if autoSize is not true.
  61338. */
  61339. rootPosition: Vector3;
  61340. /**
  61341. * Sets up the image processing in the scene.
  61342. * true by default.
  61343. */
  61344. setupImageProcessing: boolean;
  61345. /**
  61346. * The texture used as your environment texture in the scene.
  61347. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61348. *
  61349. * Remarks: Can be either a texture or a url.
  61350. */
  61351. environmentTexture: string | BaseTexture;
  61352. /**
  61353. * The value of the exposure to apply to the scene.
  61354. * 0.6 by default if setupImageProcessing is true.
  61355. */
  61356. cameraExposure: number;
  61357. /**
  61358. * The value of the contrast to apply to the scene.
  61359. * 1.6 by default if setupImageProcessing is true.
  61360. */
  61361. cameraContrast: number;
  61362. /**
  61363. * Specifies whether or not tonemapping should be enabled in the scene.
  61364. * true by default if setupImageProcessing is true.
  61365. */
  61366. toneMappingEnabled: boolean;
  61367. }
  61368. /**
  61369. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61370. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61371. * It also helps with the default setup of your imageProcessing configuration.
  61372. */
  61373. export class EnvironmentHelper {
  61374. /**
  61375. * Default ground texture URL.
  61376. */
  61377. private static _groundTextureCDNUrl;
  61378. /**
  61379. * Default skybox texture URL.
  61380. */
  61381. private static _skyboxTextureCDNUrl;
  61382. /**
  61383. * Default environment texture URL.
  61384. */
  61385. private static _environmentTextureCDNUrl;
  61386. /**
  61387. * Creates the default options for the helper.
  61388. */
  61389. private static _getDefaultOptions;
  61390. private _rootMesh;
  61391. /**
  61392. * Gets the root mesh created by the helper.
  61393. */
  61394. get rootMesh(): Mesh;
  61395. private _skybox;
  61396. /**
  61397. * Gets the skybox created by the helper.
  61398. */
  61399. get skybox(): Nullable<Mesh>;
  61400. private _skyboxTexture;
  61401. /**
  61402. * Gets the skybox texture created by the helper.
  61403. */
  61404. get skyboxTexture(): Nullable<BaseTexture>;
  61405. private _skyboxMaterial;
  61406. /**
  61407. * Gets the skybox material created by the helper.
  61408. */
  61409. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61410. private _ground;
  61411. /**
  61412. * Gets the ground mesh created by the helper.
  61413. */
  61414. get ground(): Nullable<Mesh>;
  61415. private _groundTexture;
  61416. /**
  61417. * Gets the ground texture created by the helper.
  61418. */
  61419. get groundTexture(): Nullable<BaseTexture>;
  61420. private _groundMirror;
  61421. /**
  61422. * Gets the ground mirror created by the helper.
  61423. */
  61424. get groundMirror(): Nullable<MirrorTexture>;
  61425. /**
  61426. * Gets the ground mirror render list to helps pushing the meshes
  61427. * you wish in the ground reflection.
  61428. */
  61429. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61430. private _groundMaterial;
  61431. /**
  61432. * Gets the ground material created by the helper.
  61433. */
  61434. get groundMaterial(): Nullable<BackgroundMaterial>;
  61435. /**
  61436. * Stores the creation options.
  61437. */
  61438. private readonly _scene;
  61439. private _options;
  61440. /**
  61441. * This observable will be notified with any error during the creation of the environment,
  61442. * mainly texture creation errors.
  61443. */
  61444. onErrorObservable: Observable<{
  61445. message?: string;
  61446. exception?: any;
  61447. }>;
  61448. /**
  61449. * constructor
  61450. * @param options Defines the options we want to customize the helper
  61451. * @param scene The scene to add the material to
  61452. */
  61453. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61454. /**
  61455. * Updates the background according to the new options
  61456. * @param options
  61457. */
  61458. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61459. /**
  61460. * Sets the primary color of all the available elements.
  61461. * @param color the main color to affect to the ground and the background
  61462. */
  61463. setMainColor(color: Color3): void;
  61464. /**
  61465. * Setup the image processing according to the specified options.
  61466. */
  61467. private _setupImageProcessing;
  61468. /**
  61469. * Setup the environment texture according to the specified options.
  61470. */
  61471. private _setupEnvironmentTexture;
  61472. /**
  61473. * Setup the background according to the specified options.
  61474. */
  61475. private _setupBackground;
  61476. /**
  61477. * Get the scene sizes according to the setup.
  61478. */
  61479. private _getSceneSize;
  61480. /**
  61481. * Setup the ground according to the specified options.
  61482. */
  61483. private _setupGround;
  61484. /**
  61485. * Setup the ground material according to the specified options.
  61486. */
  61487. private _setupGroundMaterial;
  61488. /**
  61489. * Setup the ground diffuse texture according to the specified options.
  61490. */
  61491. private _setupGroundDiffuseTexture;
  61492. /**
  61493. * Setup the ground mirror texture according to the specified options.
  61494. */
  61495. private _setupGroundMirrorTexture;
  61496. /**
  61497. * Setup the ground to receive the mirror texture.
  61498. */
  61499. private _setupMirrorInGroundMaterial;
  61500. /**
  61501. * Setup the skybox according to the specified options.
  61502. */
  61503. private _setupSkybox;
  61504. /**
  61505. * Setup the skybox material according to the specified options.
  61506. */
  61507. private _setupSkyboxMaterial;
  61508. /**
  61509. * Setup the skybox reflection texture according to the specified options.
  61510. */
  61511. private _setupSkyboxReflectionTexture;
  61512. private _errorHandler;
  61513. /**
  61514. * Dispose all the elements created by the Helper.
  61515. */
  61516. dispose(): void;
  61517. }
  61518. }
  61519. declare module "babylonjs/Helpers/textureDome" {
  61520. import { Scene } from "babylonjs/scene";
  61521. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61522. import { Mesh } from "babylonjs/Meshes/mesh";
  61523. import { Texture } from "babylonjs/Materials/Textures/texture";
  61524. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61525. import "babylonjs/Meshes/Builders/sphereBuilder";
  61526. import { Nullable } from "babylonjs/types";
  61527. import { Observable } from "babylonjs/Misc/observable";
  61528. /**
  61529. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61530. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61531. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61532. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61533. */
  61534. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61535. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61536. /**
  61537. * Define the source as a Monoscopic panoramic 360/180.
  61538. */
  61539. static readonly MODE_MONOSCOPIC: number;
  61540. /**
  61541. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61542. */
  61543. static readonly MODE_TOPBOTTOM: number;
  61544. /**
  61545. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61546. */
  61547. static readonly MODE_SIDEBYSIDE: number;
  61548. private _halfDome;
  61549. private _crossEye;
  61550. protected _useDirectMapping: boolean;
  61551. /**
  61552. * The texture being displayed on the sphere
  61553. */
  61554. protected _texture: T;
  61555. /**
  61556. * Gets the texture being displayed on the sphere
  61557. */
  61558. get texture(): T;
  61559. /**
  61560. * Sets the texture being displayed on the sphere
  61561. */
  61562. set texture(newTexture: T);
  61563. /**
  61564. * The skybox material
  61565. */
  61566. protected _material: BackgroundMaterial;
  61567. /**
  61568. * The surface used for the dome
  61569. */
  61570. protected _mesh: Mesh;
  61571. /**
  61572. * Gets the mesh used for the dome.
  61573. */
  61574. get mesh(): Mesh;
  61575. /**
  61576. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61577. */
  61578. private _halfDomeMask;
  61579. /**
  61580. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61581. * Also see the options.resolution property.
  61582. */
  61583. get fovMultiplier(): number;
  61584. set fovMultiplier(value: number);
  61585. protected _textureMode: number;
  61586. /**
  61587. * Gets or set the current texture mode for the texture. It can be:
  61588. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61589. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61590. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61591. */
  61592. get textureMode(): number;
  61593. /**
  61594. * Sets the current texture mode for the texture. It can be:
  61595. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61596. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61597. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61598. */
  61599. set textureMode(value: number);
  61600. /**
  61601. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61602. */
  61603. get halfDome(): boolean;
  61604. /**
  61605. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61606. */
  61607. set halfDome(enabled: boolean);
  61608. /**
  61609. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61610. */
  61611. set crossEye(enabled: boolean);
  61612. /**
  61613. * Is it a cross-eye texture?
  61614. */
  61615. get crossEye(): boolean;
  61616. /**
  61617. * The background material of this dome.
  61618. */
  61619. get material(): BackgroundMaterial;
  61620. /**
  61621. * Oberserver used in Stereoscopic VR Mode.
  61622. */
  61623. private _onBeforeCameraRenderObserver;
  61624. /**
  61625. * Observable raised when an error occured while loading the 360 image
  61626. */
  61627. onLoadErrorObservable: Observable<string>;
  61628. /**
  61629. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61630. * @param name Element's name, child elements will append suffixes for their own names.
  61631. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61632. * @param options An object containing optional or exposed sub element properties
  61633. */
  61634. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61635. resolution?: number;
  61636. clickToPlay?: boolean;
  61637. autoPlay?: boolean;
  61638. loop?: boolean;
  61639. size?: number;
  61640. poster?: string;
  61641. faceForward?: boolean;
  61642. useDirectMapping?: boolean;
  61643. halfDomeMode?: boolean;
  61644. crossEyeMode?: boolean;
  61645. generateMipMaps?: boolean;
  61646. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61647. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61648. protected _changeTextureMode(value: number): void;
  61649. /**
  61650. * Releases resources associated with this node.
  61651. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61652. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61653. */
  61654. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61655. }
  61656. }
  61657. declare module "babylonjs/Helpers/photoDome" {
  61658. import { Scene } from "babylonjs/scene";
  61659. import { Texture } from "babylonjs/Materials/Textures/texture";
  61660. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61661. /**
  61662. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61663. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61664. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61665. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61666. */
  61667. export class PhotoDome extends TextureDome<Texture> {
  61668. /**
  61669. * Define the image as a Monoscopic panoramic 360 image.
  61670. */
  61671. static readonly MODE_MONOSCOPIC: number;
  61672. /**
  61673. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61674. */
  61675. static readonly MODE_TOPBOTTOM: number;
  61676. /**
  61677. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61678. */
  61679. static readonly MODE_SIDEBYSIDE: number;
  61680. /**
  61681. * Gets or sets the texture being displayed on the sphere
  61682. */
  61683. get photoTexture(): Texture;
  61684. /**
  61685. * sets the texture being displayed on the sphere
  61686. */
  61687. set photoTexture(value: Texture);
  61688. /**
  61689. * Gets the current video mode for the video. It can be:
  61690. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61691. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61692. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61693. */
  61694. get imageMode(): number;
  61695. /**
  61696. * Sets the current video mode for the video. It can be:
  61697. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61698. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61699. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61700. */
  61701. set imageMode(value: number);
  61702. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61703. }
  61704. }
  61705. declare module "babylonjs/Misc/dds" {
  61706. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  61707. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61708. import { Nullable } from "babylonjs/types";
  61709. import { Scene } from "babylonjs/scene";
  61710. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  61711. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61712. /**
  61713. * Direct draw surface info
  61714. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61715. */
  61716. export interface DDSInfo {
  61717. /**
  61718. * Width of the texture
  61719. */
  61720. width: number;
  61721. /**
  61722. * Width of the texture
  61723. */
  61724. height: number;
  61725. /**
  61726. * Number of Mipmaps for the texture
  61727. * @see https://en.wikipedia.org/wiki/Mipmap
  61728. */
  61729. mipmapCount: number;
  61730. /**
  61731. * If the textures format is a known fourCC format
  61732. * @see https://www.fourcc.org/
  61733. */
  61734. isFourCC: boolean;
  61735. /**
  61736. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61737. */
  61738. isRGB: boolean;
  61739. /**
  61740. * If the texture is a lumincance format
  61741. */
  61742. isLuminance: boolean;
  61743. /**
  61744. * If this is a cube texture
  61745. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61746. */
  61747. isCube: boolean;
  61748. /**
  61749. * If the texture is a compressed format eg. FOURCC_DXT1
  61750. */
  61751. isCompressed: boolean;
  61752. /**
  61753. * The dxgiFormat of the texture
  61754. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61755. */
  61756. dxgiFormat: number;
  61757. /**
  61758. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61759. */
  61760. textureType: number;
  61761. /**
  61762. * Sphericle polynomial created for the dds texture
  61763. */
  61764. sphericalPolynomial?: SphericalPolynomial;
  61765. }
  61766. /**
  61767. * Class used to provide DDS decompression tools
  61768. */
  61769. export class DDSTools {
  61770. /**
  61771. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61772. */
  61773. static StoreLODInAlphaChannel: boolean;
  61774. /**
  61775. * Gets DDS information from an array buffer
  61776. * @param data defines the array buffer view to read data from
  61777. * @returns the DDS information
  61778. */
  61779. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61780. private static _FloatView;
  61781. private static _Int32View;
  61782. private static _ToHalfFloat;
  61783. private static _FromHalfFloat;
  61784. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61785. private static _GetHalfFloatRGBAArrayBuffer;
  61786. private static _GetFloatRGBAArrayBuffer;
  61787. private static _GetFloatAsUIntRGBAArrayBuffer;
  61788. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61789. private static _GetRGBAArrayBuffer;
  61790. private static _ExtractLongWordOrder;
  61791. private static _GetRGBArrayBuffer;
  61792. private static _GetLuminanceArrayBuffer;
  61793. /**
  61794. * Uploads DDS Levels to a Babylon Texture
  61795. * @hidden
  61796. */
  61797. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61798. }
  61799. module "babylonjs/Engines/thinEngine" {
  61800. interface ThinEngine {
  61801. /**
  61802. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61803. * @param rootUrl defines the url where the file to load is located
  61804. * @param scene defines the current scene
  61805. * @param lodScale defines scale to apply to the mip map selection
  61806. * @param lodOffset defines offset to apply to the mip map selection
  61807. * @param onLoad defines an optional callback raised when the texture is loaded
  61808. * @param onError defines an optional callback raised if there is an issue to load the texture
  61809. * @param format defines the format of the data
  61810. * @param forcedExtension defines the extension to use to pick the right loader
  61811. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61812. * @returns the cube texture as an InternalTexture
  61813. */
  61814. 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;
  61815. }
  61816. }
  61817. }
  61818. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61819. import { Nullable } from "babylonjs/types";
  61820. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61821. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61822. /**
  61823. * Implementation of the DDS Texture Loader.
  61824. * @hidden
  61825. */
  61826. export class _DDSTextureLoader implements IInternalTextureLoader {
  61827. /**
  61828. * Defines wether the loader supports cascade loading the different faces.
  61829. */
  61830. readonly supportCascades: boolean;
  61831. /**
  61832. * This returns if the loader support the current file information.
  61833. * @param extension defines the file extension of the file being loaded
  61834. * @returns true if the loader can load the specified file
  61835. */
  61836. canLoad(extension: string): boolean;
  61837. /**
  61838. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61839. * @param data contains the texture data
  61840. * @param texture defines the BabylonJS internal texture
  61841. * @param createPolynomials will be true if polynomials have been requested
  61842. * @param onLoad defines the callback to trigger once the texture is ready
  61843. * @param onError defines the callback to trigger in case of error
  61844. */
  61845. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61846. /**
  61847. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61848. * @param data contains the texture data
  61849. * @param texture defines the BabylonJS internal texture
  61850. * @param callback defines the method to call once ready to upload
  61851. */
  61852. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61853. }
  61854. }
  61855. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61856. import { Nullable } from "babylonjs/types";
  61857. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61858. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61859. /**
  61860. * Implementation of the ENV Texture Loader.
  61861. * @hidden
  61862. */
  61863. export class _ENVTextureLoader implements IInternalTextureLoader {
  61864. /**
  61865. * Defines wether the loader supports cascade loading the different faces.
  61866. */
  61867. readonly supportCascades: boolean;
  61868. /**
  61869. * This returns if the loader support the current file information.
  61870. * @param extension defines the file extension of the file being loaded
  61871. * @returns true if the loader can load the specified file
  61872. */
  61873. canLoad(extension: string): boolean;
  61874. /**
  61875. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61876. * @param data contains the texture data
  61877. * @param texture defines the BabylonJS internal texture
  61878. * @param createPolynomials will be true if polynomials have been requested
  61879. * @param onLoad defines the callback to trigger once the texture is ready
  61880. * @param onError defines the callback to trigger in case of error
  61881. */
  61882. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61883. /**
  61884. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61885. * @param data contains the texture data
  61886. * @param texture defines the BabylonJS internal texture
  61887. * @param callback defines the method to call once ready to upload
  61888. */
  61889. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61890. }
  61891. }
  61892. declare module "babylonjs/Misc/khronosTextureContainer" {
  61893. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61894. /**
  61895. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61896. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61897. */
  61898. export class KhronosTextureContainer {
  61899. /** contents of the KTX container file */
  61900. data: ArrayBufferView;
  61901. private static HEADER_LEN;
  61902. private static COMPRESSED_2D;
  61903. private static COMPRESSED_3D;
  61904. private static TEX_2D;
  61905. private static TEX_3D;
  61906. /**
  61907. * Gets the openGL type
  61908. */
  61909. glType: number;
  61910. /**
  61911. * Gets the openGL type size
  61912. */
  61913. glTypeSize: number;
  61914. /**
  61915. * Gets the openGL format
  61916. */
  61917. glFormat: number;
  61918. /**
  61919. * Gets the openGL internal format
  61920. */
  61921. glInternalFormat: number;
  61922. /**
  61923. * Gets the base internal format
  61924. */
  61925. glBaseInternalFormat: number;
  61926. /**
  61927. * Gets image width in pixel
  61928. */
  61929. pixelWidth: number;
  61930. /**
  61931. * Gets image height in pixel
  61932. */
  61933. pixelHeight: number;
  61934. /**
  61935. * Gets image depth in pixels
  61936. */
  61937. pixelDepth: number;
  61938. /**
  61939. * Gets the number of array elements
  61940. */
  61941. numberOfArrayElements: number;
  61942. /**
  61943. * Gets the number of faces
  61944. */
  61945. numberOfFaces: number;
  61946. /**
  61947. * Gets the number of mipmap levels
  61948. */
  61949. numberOfMipmapLevels: number;
  61950. /**
  61951. * Gets the bytes of key value data
  61952. */
  61953. bytesOfKeyValueData: number;
  61954. /**
  61955. * Gets the load type
  61956. */
  61957. loadType: number;
  61958. /**
  61959. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61960. */
  61961. isInvalid: boolean;
  61962. /**
  61963. * Creates a new KhronosTextureContainer
  61964. * @param data contents of the KTX container file
  61965. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61966. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61967. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61968. */
  61969. constructor(
  61970. /** contents of the KTX container file */
  61971. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61972. /**
  61973. * Uploads KTX content to a Babylon Texture.
  61974. * It is assumed that the texture has already been created & is currently bound
  61975. * @hidden
  61976. */
  61977. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61978. private _upload2DCompressedLevels;
  61979. /**
  61980. * Checks if the given data starts with a KTX file identifier.
  61981. * @param data the data to check
  61982. * @returns true if the data is a KTX file or false otherwise
  61983. */
  61984. static IsValid(data: ArrayBufferView): boolean;
  61985. }
  61986. }
  61987. declare module "babylonjs/Misc/workerPool" {
  61988. import { IDisposable } from "babylonjs/scene";
  61989. /**
  61990. * Helper class to push actions to a pool of workers.
  61991. */
  61992. export class WorkerPool implements IDisposable {
  61993. private _workerInfos;
  61994. private _pendingActions;
  61995. /**
  61996. * Constructor
  61997. * @param workers Array of workers to use for actions
  61998. */
  61999. constructor(workers: Array<Worker>);
  62000. /**
  62001. * Terminates all workers and clears any pending actions.
  62002. */
  62003. dispose(): void;
  62004. /**
  62005. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62006. * pended until a worker has completed its action.
  62007. * @param action The action to perform. Call onComplete when the action is complete.
  62008. */
  62009. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62010. private _execute;
  62011. }
  62012. }
  62013. declare module "babylonjs/Misc/khronosTextureContainer2" {
  62014. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62015. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62016. /**
  62017. * Class for loading KTX2 files
  62018. */
  62019. export class KhronosTextureContainer2 {
  62020. private static _WorkerPoolPromise?;
  62021. private static _Initialized;
  62022. private static _Ktx2Decoder;
  62023. /**
  62024. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62025. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62026. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62027. * Urls you can change:
  62028. * URLConfig.jsDecoderModule
  62029. * URLConfig.wasmUASTCToASTC
  62030. * URLConfig.wasmUASTCToBC7
  62031. * URLConfig.wasmUASTCToRGBA_UNORM
  62032. * URLConfig.wasmUASTCToRGBA_SRGB
  62033. * URLConfig.jsMSCTranscoder
  62034. * URLConfig.wasmMSCTranscoder
  62035. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  62036. */
  62037. static URLConfig: {
  62038. jsDecoderModule: string;
  62039. wasmUASTCToASTC: null;
  62040. wasmUASTCToBC7: null;
  62041. wasmUASTCToRGBA_UNORM: null;
  62042. wasmUASTCToRGBA_SRGB: null;
  62043. jsMSCTranscoder: null;
  62044. wasmMSCTranscoder: null;
  62045. };
  62046. /**
  62047. * Default number of workers used to handle data decoding
  62048. */
  62049. static DefaultNumWorkers: number;
  62050. private static GetDefaultNumWorkers;
  62051. private _engine;
  62052. private static _CreateWorkerPool;
  62053. /**
  62054. * Constructor
  62055. * @param engine The engine to use
  62056. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62057. */
  62058. constructor(engine: ThinEngine, numWorkers?: number);
  62059. /** @hidden */
  62060. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62061. /**
  62062. * Stop all async operations and release resources.
  62063. */
  62064. dispose(): void;
  62065. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62066. /**
  62067. * Checks if the given data starts with a KTX2 file identifier.
  62068. * @param data the data to check
  62069. * @returns true if the data is a KTX2 file or false otherwise
  62070. */
  62071. static IsValid(data: ArrayBufferView): boolean;
  62072. }
  62073. }
  62074. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  62075. import { Nullable } from "babylonjs/types";
  62076. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62077. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62078. /**
  62079. * Implementation of the KTX Texture Loader.
  62080. * @hidden
  62081. */
  62082. export class _KTXTextureLoader implements IInternalTextureLoader {
  62083. /**
  62084. * Defines wether the loader supports cascade loading the different faces.
  62085. */
  62086. readonly supportCascades: boolean;
  62087. /**
  62088. * This returns if the loader support the current file information.
  62089. * @param extension defines the file extension of the file being loaded
  62090. * @param mimeType defines the optional mime type of the file being loaded
  62091. * @returns true if the loader can load the specified file
  62092. */
  62093. canLoad(extension: string, mimeType?: string): boolean;
  62094. /**
  62095. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62096. * @param data contains the texture data
  62097. * @param texture defines the BabylonJS internal texture
  62098. * @param createPolynomials will be true if polynomials have been requested
  62099. * @param onLoad defines the callback to trigger once the texture is ready
  62100. * @param onError defines the callback to trigger in case of error
  62101. */
  62102. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62103. /**
  62104. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62105. * @param data contains the texture data
  62106. * @param texture defines the BabylonJS internal texture
  62107. * @param callback defines the method to call once ready to upload
  62108. */
  62109. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62110. }
  62111. }
  62112. declare module "babylonjs/Helpers/sceneHelpers" {
  62113. import { Nullable } from "babylonjs/types";
  62114. import { Mesh } from "babylonjs/Meshes/mesh";
  62115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62116. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  62117. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  62118. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62119. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62120. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62121. import "babylonjs/Meshes/Builders/boxBuilder";
  62122. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  62123. /** @hidden */
  62124. export var _forceSceneHelpersToBundle: boolean;
  62125. module "babylonjs/scene" {
  62126. interface Scene {
  62127. /**
  62128. * Creates a default light for the scene.
  62129. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62130. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62131. */
  62132. createDefaultLight(replace?: boolean): void;
  62133. /**
  62134. * Creates a default camera for the scene.
  62135. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62136. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62137. * @param replace has default false, when true replaces the active camera in the scene
  62138. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62139. */
  62140. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62141. /**
  62142. * Creates a default camera and a default light.
  62143. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62144. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62145. * @param replace has the default false, when true replaces the active camera/light in the scene
  62146. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62147. */
  62148. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62149. /**
  62150. * Creates a new sky box
  62151. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62152. * @param environmentTexture defines the texture to use as environment texture
  62153. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62154. * @param scale defines the overall scale of the skybox
  62155. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62156. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62157. * @returns a new mesh holding the sky box
  62158. */
  62159. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62160. /**
  62161. * Creates a new environment
  62162. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62163. * @param options defines the options you can use to configure the environment
  62164. * @returns the new EnvironmentHelper
  62165. */
  62166. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62167. /**
  62168. * Creates a new VREXperienceHelper
  62169. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62170. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62171. * @returns a new VREXperienceHelper
  62172. */
  62173. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62174. /**
  62175. * Creates a new WebXRDefaultExperience
  62176. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62177. * @param options experience options
  62178. * @returns a promise for a new WebXRDefaultExperience
  62179. */
  62180. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62181. }
  62182. }
  62183. }
  62184. declare module "babylonjs/Helpers/videoDome" {
  62185. import { Scene } from "babylonjs/scene";
  62186. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  62187. import { TextureDome } from "babylonjs/Helpers/textureDome";
  62188. /**
  62189. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62190. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62191. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62192. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62193. */
  62194. export class VideoDome extends TextureDome<VideoTexture> {
  62195. /**
  62196. * Define the video source as a Monoscopic panoramic 360 video.
  62197. */
  62198. static readonly MODE_MONOSCOPIC: number;
  62199. /**
  62200. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62201. */
  62202. static readonly MODE_TOPBOTTOM: number;
  62203. /**
  62204. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62205. */
  62206. static readonly MODE_SIDEBYSIDE: number;
  62207. /**
  62208. * Get the video texture associated with this video dome
  62209. */
  62210. get videoTexture(): VideoTexture;
  62211. /**
  62212. * Get the video mode of this dome
  62213. */
  62214. get videoMode(): number;
  62215. /**
  62216. * Set the video mode of this dome.
  62217. * @see textureMode
  62218. */
  62219. set videoMode(value: number);
  62220. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62221. }
  62222. }
  62223. declare module "babylonjs/Helpers/index" {
  62224. export * from "babylonjs/Helpers/environmentHelper";
  62225. export * from "babylonjs/Helpers/photoDome";
  62226. export * from "babylonjs/Helpers/sceneHelpers";
  62227. export * from "babylonjs/Helpers/videoDome";
  62228. }
  62229. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  62230. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62231. import { IDisposable } from "babylonjs/scene";
  62232. import { Engine } from "babylonjs/Engines/engine";
  62233. /**
  62234. * This class can be used to get instrumentation data from a Babylon engine
  62235. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62236. */
  62237. export class EngineInstrumentation implements IDisposable {
  62238. /**
  62239. * Define the instrumented engine.
  62240. */
  62241. engine: Engine;
  62242. private _captureGPUFrameTime;
  62243. private _gpuFrameTimeToken;
  62244. private _gpuFrameTime;
  62245. private _captureShaderCompilationTime;
  62246. private _shaderCompilationTime;
  62247. private _onBeginFrameObserver;
  62248. private _onEndFrameObserver;
  62249. private _onBeforeShaderCompilationObserver;
  62250. private _onAfterShaderCompilationObserver;
  62251. /**
  62252. * Gets the perf counter used for GPU frame time
  62253. */
  62254. get gpuFrameTimeCounter(): PerfCounter;
  62255. /**
  62256. * Gets the GPU frame time capture status
  62257. */
  62258. get captureGPUFrameTime(): boolean;
  62259. /**
  62260. * Enable or disable the GPU frame time capture
  62261. */
  62262. set captureGPUFrameTime(value: boolean);
  62263. /**
  62264. * Gets the perf counter used for shader compilation time
  62265. */
  62266. get shaderCompilationTimeCounter(): PerfCounter;
  62267. /**
  62268. * Gets the shader compilation time capture status
  62269. */
  62270. get captureShaderCompilationTime(): boolean;
  62271. /**
  62272. * Enable or disable the shader compilation time capture
  62273. */
  62274. set captureShaderCompilationTime(value: boolean);
  62275. /**
  62276. * Instantiates a new engine instrumentation.
  62277. * This class can be used to get instrumentation data from a Babylon engine
  62278. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62279. * @param engine Defines the engine to instrument
  62280. */
  62281. constructor(
  62282. /**
  62283. * Define the instrumented engine.
  62284. */
  62285. engine: Engine);
  62286. /**
  62287. * Dispose and release associated resources.
  62288. */
  62289. dispose(): void;
  62290. }
  62291. }
  62292. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  62293. import { Scene, IDisposable } from "babylonjs/scene";
  62294. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62295. /**
  62296. * This class can be used to get instrumentation data from a Babylon engine
  62297. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62298. */
  62299. export class SceneInstrumentation implements IDisposable {
  62300. /**
  62301. * Defines the scene to instrument
  62302. */
  62303. scene: Scene;
  62304. private _captureActiveMeshesEvaluationTime;
  62305. private _activeMeshesEvaluationTime;
  62306. private _captureRenderTargetsRenderTime;
  62307. private _renderTargetsRenderTime;
  62308. private _captureFrameTime;
  62309. private _frameTime;
  62310. private _captureRenderTime;
  62311. private _renderTime;
  62312. private _captureInterFrameTime;
  62313. private _interFrameTime;
  62314. private _captureParticlesRenderTime;
  62315. private _particlesRenderTime;
  62316. private _captureSpritesRenderTime;
  62317. private _spritesRenderTime;
  62318. private _capturePhysicsTime;
  62319. private _physicsTime;
  62320. private _captureAnimationsTime;
  62321. private _animationsTime;
  62322. private _captureCameraRenderTime;
  62323. private _cameraRenderTime;
  62324. private _onBeforeActiveMeshesEvaluationObserver;
  62325. private _onAfterActiveMeshesEvaluationObserver;
  62326. private _onBeforeRenderTargetsRenderObserver;
  62327. private _onAfterRenderTargetsRenderObserver;
  62328. private _onAfterRenderObserver;
  62329. private _onBeforeDrawPhaseObserver;
  62330. private _onAfterDrawPhaseObserver;
  62331. private _onBeforeAnimationsObserver;
  62332. private _onBeforeParticlesRenderingObserver;
  62333. private _onAfterParticlesRenderingObserver;
  62334. private _onBeforeSpritesRenderingObserver;
  62335. private _onAfterSpritesRenderingObserver;
  62336. private _onBeforePhysicsObserver;
  62337. private _onAfterPhysicsObserver;
  62338. private _onAfterAnimationsObserver;
  62339. private _onBeforeCameraRenderObserver;
  62340. private _onAfterCameraRenderObserver;
  62341. /**
  62342. * Gets the perf counter used for active meshes evaluation time
  62343. */
  62344. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62345. /**
  62346. * Gets the active meshes evaluation time capture status
  62347. */
  62348. get captureActiveMeshesEvaluationTime(): boolean;
  62349. /**
  62350. * Enable or disable the active meshes evaluation time capture
  62351. */
  62352. set captureActiveMeshesEvaluationTime(value: boolean);
  62353. /**
  62354. * Gets the perf counter used for render targets render time
  62355. */
  62356. get renderTargetsRenderTimeCounter(): PerfCounter;
  62357. /**
  62358. * Gets the render targets render time capture status
  62359. */
  62360. get captureRenderTargetsRenderTime(): boolean;
  62361. /**
  62362. * Enable or disable the render targets render time capture
  62363. */
  62364. set captureRenderTargetsRenderTime(value: boolean);
  62365. /**
  62366. * Gets the perf counter used for particles render time
  62367. */
  62368. get particlesRenderTimeCounter(): PerfCounter;
  62369. /**
  62370. * Gets the particles render time capture status
  62371. */
  62372. get captureParticlesRenderTime(): boolean;
  62373. /**
  62374. * Enable or disable the particles render time capture
  62375. */
  62376. set captureParticlesRenderTime(value: boolean);
  62377. /**
  62378. * Gets the perf counter used for sprites render time
  62379. */
  62380. get spritesRenderTimeCounter(): PerfCounter;
  62381. /**
  62382. * Gets the sprites render time capture status
  62383. */
  62384. get captureSpritesRenderTime(): boolean;
  62385. /**
  62386. * Enable or disable the sprites render time capture
  62387. */
  62388. set captureSpritesRenderTime(value: boolean);
  62389. /**
  62390. * Gets the perf counter used for physics time
  62391. */
  62392. get physicsTimeCounter(): PerfCounter;
  62393. /**
  62394. * Gets the physics time capture status
  62395. */
  62396. get capturePhysicsTime(): boolean;
  62397. /**
  62398. * Enable or disable the physics time capture
  62399. */
  62400. set capturePhysicsTime(value: boolean);
  62401. /**
  62402. * Gets the perf counter used for animations time
  62403. */
  62404. get animationsTimeCounter(): PerfCounter;
  62405. /**
  62406. * Gets the animations time capture status
  62407. */
  62408. get captureAnimationsTime(): boolean;
  62409. /**
  62410. * Enable or disable the animations time capture
  62411. */
  62412. set captureAnimationsTime(value: boolean);
  62413. /**
  62414. * Gets the perf counter used for frame time capture
  62415. */
  62416. get frameTimeCounter(): PerfCounter;
  62417. /**
  62418. * Gets the frame time capture status
  62419. */
  62420. get captureFrameTime(): boolean;
  62421. /**
  62422. * Enable or disable the frame time capture
  62423. */
  62424. set captureFrameTime(value: boolean);
  62425. /**
  62426. * Gets the perf counter used for inter-frames time capture
  62427. */
  62428. get interFrameTimeCounter(): PerfCounter;
  62429. /**
  62430. * Gets the inter-frames time capture status
  62431. */
  62432. get captureInterFrameTime(): boolean;
  62433. /**
  62434. * Enable or disable the inter-frames time capture
  62435. */
  62436. set captureInterFrameTime(value: boolean);
  62437. /**
  62438. * Gets the perf counter used for render time capture
  62439. */
  62440. get renderTimeCounter(): PerfCounter;
  62441. /**
  62442. * Gets the render time capture status
  62443. */
  62444. get captureRenderTime(): boolean;
  62445. /**
  62446. * Enable or disable the render time capture
  62447. */
  62448. set captureRenderTime(value: boolean);
  62449. /**
  62450. * Gets the perf counter used for camera render time capture
  62451. */
  62452. get cameraRenderTimeCounter(): PerfCounter;
  62453. /**
  62454. * Gets the camera render time capture status
  62455. */
  62456. get captureCameraRenderTime(): boolean;
  62457. /**
  62458. * Enable or disable the camera render time capture
  62459. */
  62460. set captureCameraRenderTime(value: boolean);
  62461. /**
  62462. * Gets the perf counter used for draw calls
  62463. */
  62464. get drawCallsCounter(): PerfCounter;
  62465. /**
  62466. * Instantiates a new scene instrumentation.
  62467. * This class can be used to get instrumentation data from a Babylon engine
  62468. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62469. * @param scene Defines the scene to instrument
  62470. */
  62471. constructor(
  62472. /**
  62473. * Defines the scene to instrument
  62474. */
  62475. scene: Scene);
  62476. /**
  62477. * Dispose and release associated resources.
  62478. */
  62479. dispose(): void;
  62480. }
  62481. }
  62482. declare module "babylonjs/Instrumentation/index" {
  62483. export * from "babylonjs/Instrumentation/engineInstrumentation";
  62484. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  62485. export * from "babylonjs/Instrumentation/timeToken";
  62486. }
  62487. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  62488. /** @hidden */
  62489. export var glowMapGenerationPixelShader: {
  62490. name: string;
  62491. shader: string;
  62492. };
  62493. }
  62494. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  62495. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62496. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62497. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62498. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62499. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62500. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62501. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62502. /** @hidden */
  62503. export var glowMapGenerationVertexShader: {
  62504. name: string;
  62505. shader: string;
  62506. };
  62507. }
  62508. declare module "babylonjs/Layers/effectLayer" {
  62509. import { Observable } from "babylonjs/Misc/observable";
  62510. import { Nullable } from "babylonjs/types";
  62511. import { Camera } from "babylonjs/Cameras/camera";
  62512. import { Scene } from "babylonjs/scene";
  62513. import { ISize } from "babylonjs/Maths/math.size";
  62514. import { Color4 } from "babylonjs/Maths/math.color";
  62515. import { Engine } from "babylonjs/Engines/engine";
  62516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62518. import { Mesh } from "babylonjs/Meshes/mesh";
  62519. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62521. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62522. import { Effect } from "babylonjs/Materials/effect";
  62523. import { Material } from "babylonjs/Materials/material";
  62524. import "babylonjs/Shaders/glowMapGeneration.fragment";
  62525. import "babylonjs/Shaders/glowMapGeneration.vertex";
  62526. /**
  62527. * Effect layer options. This helps customizing the behaviour
  62528. * of the effect layer.
  62529. */
  62530. export interface IEffectLayerOptions {
  62531. /**
  62532. * Multiplication factor apply to the canvas size to compute the render target size
  62533. * used to generated the objects (the smaller the faster).
  62534. */
  62535. mainTextureRatio: number;
  62536. /**
  62537. * Enforces a fixed size texture to ensure effect stability across devices.
  62538. */
  62539. mainTextureFixedSize?: number;
  62540. /**
  62541. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62542. */
  62543. alphaBlendingMode: number;
  62544. /**
  62545. * The camera attached to the layer.
  62546. */
  62547. camera: Nullable<Camera>;
  62548. /**
  62549. * The rendering group to draw the layer in.
  62550. */
  62551. renderingGroupId: number;
  62552. }
  62553. /**
  62554. * The effect layer Helps adding post process effect blended with the main pass.
  62555. *
  62556. * This can be for instance use to generate glow or higlight effects on the scene.
  62557. *
  62558. * The effect layer class can not be used directly and is intented to inherited from to be
  62559. * customized per effects.
  62560. */
  62561. export abstract class EffectLayer {
  62562. private _vertexBuffers;
  62563. private _indexBuffer;
  62564. private _cachedDefines;
  62565. private _effectLayerMapGenerationEffect;
  62566. private _effectLayerOptions;
  62567. private _mergeEffect;
  62568. protected _scene: Scene;
  62569. protected _engine: Engine;
  62570. protected _maxSize: number;
  62571. protected _mainTextureDesiredSize: ISize;
  62572. protected _mainTexture: RenderTargetTexture;
  62573. protected _shouldRender: boolean;
  62574. protected _postProcesses: PostProcess[];
  62575. protected _textures: BaseTexture[];
  62576. protected _emissiveTextureAndColor: {
  62577. texture: Nullable<BaseTexture>;
  62578. color: Color4;
  62579. };
  62580. /**
  62581. * The name of the layer
  62582. */
  62583. name: string;
  62584. /**
  62585. * The clear color of the texture used to generate the glow map.
  62586. */
  62587. neutralColor: Color4;
  62588. /**
  62589. * Specifies whether the highlight layer is enabled or not.
  62590. */
  62591. isEnabled: boolean;
  62592. /**
  62593. * Gets the camera attached to the layer.
  62594. */
  62595. get camera(): Nullable<Camera>;
  62596. /**
  62597. * Gets the rendering group id the layer should render in.
  62598. */
  62599. get renderingGroupId(): number;
  62600. set renderingGroupId(renderingGroupId: number);
  62601. /**
  62602. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62603. */
  62604. disableBoundingBoxesFromEffectLayer: boolean;
  62605. /**
  62606. * An event triggered when the effect layer has been disposed.
  62607. */
  62608. onDisposeObservable: Observable<EffectLayer>;
  62609. /**
  62610. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62611. */
  62612. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62613. /**
  62614. * An event triggered when the generated texture is being merged in the scene.
  62615. */
  62616. onBeforeComposeObservable: Observable<EffectLayer>;
  62617. /**
  62618. * An event triggered when the mesh is rendered into the effect render target.
  62619. */
  62620. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62621. /**
  62622. * An event triggered after the mesh has been rendered into the effect render target.
  62623. */
  62624. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62625. /**
  62626. * An event triggered when the generated texture has been merged in the scene.
  62627. */
  62628. onAfterComposeObservable: Observable<EffectLayer>;
  62629. /**
  62630. * An event triggered when the efffect layer changes its size.
  62631. */
  62632. onSizeChangedObservable: Observable<EffectLayer>;
  62633. /** @hidden */
  62634. static _SceneComponentInitialization: (scene: Scene) => void;
  62635. /**
  62636. * Instantiates a new effect Layer and references it in the scene.
  62637. * @param name The name of the layer
  62638. * @param scene The scene to use the layer in
  62639. */
  62640. constructor(
  62641. /** The Friendly of the effect in the scene */
  62642. name: string, scene: Scene);
  62643. /**
  62644. * Get the effect name of the layer.
  62645. * @return The effect name
  62646. */
  62647. abstract getEffectName(): string;
  62648. /**
  62649. * Checks for the readiness of the element composing the layer.
  62650. * @param subMesh the mesh to check for
  62651. * @param useInstances specify whether or not to use instances to render the mesh
  62652. * @return true if ready otherwise, false
  62653. */
  62654. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62655. /**
  62656. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62657. * @returns true if the effect requires stencil during the main canvas render pass.
  62658. */
  62659. abstract needStencil(): boolean;
  62660. /**
  62661. * Create the merge effect. This is the shader use to blit the information back
  62662. * to the main canvas at the end of the scene rendering.
  62663. * @returns The effect containing the shader used to merge the effect on the main canvas
  62664. */
  62665. protected abstract _createMergeEffect(): Effect;
  62666. /**
  62667. * Creates the render target textures and post processes used in the effect layer.
  62668. */
  62669. protected abstract _createTextureAndPostProcesses(): void;
  62670. /**
  62671. * Implementation specific of rendering the generating effect on the main canvas.
  62672. * @param effect The effect used to render through
  62673. */
  62674. protected abstract _internalRender(effect: Effect): void;
  62675. /**
  62676. * Sets the required values for both the emissive texture and and the main color.
  62677. */
  62678. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62679. /**
  62680. * Free any resources and references associated to a mesh.
  62681. * Internal use
  62682. * @param mesh The mesh to free.
  62683. */
  62684. abstract _disposeMesh(mesh: Mesh): void;
  62685. /**
  62686. * Serializes this layer (Glow or Highlight for example)
  62687. * @returns a serialized layer object
  62688. */
  62689. abstract serialize?(): any;
  62690. /**
  62691. * Initializes the effect layer with the required options.
  62692. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62693. */
  62694. protected _init(options: Partial<IEffectLayerOptions>): void;
  62695. /**
  62696. * Generates the index buffer of the full screen quad blending to the main canvas.
  62697. */
  62698. private _generateIndexBuffer;
  62699. /**
  62700. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62701. */
  62702. private _generateVertexBuffer;
  62703. /**
  62704. * Sets the main texture desired size which is the closest power of two
  62705. * of the engine canvas size.
  62706. */
  62707. private _setMainTextureSize;
  62708. /**
  62709. * Creates the main texture for the effect layer.
  62710. */
  62711. protected _createMainTexture(): void;
  62712. /**
  62713. * Adds specific effects defines.
  62714. * @param defines The defines to add specifics to.
  62715. */
  62716. protected _addCustomEffectDefines(defines: string[]): void;
  62717. /**
  62718. * Checks for the readiness of the element composing the layer.
  62719. * @param subMesh the mesh to check for
  62720. * @param useInstances specify whether or not to use instances to render the mesh
  62721. * @param emissiveTexture the associated emissive texture used to generate the glow
  62722. * @return true if ready otherwise, false
  62723. */
  62724. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62725. /**
  62726. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62727. */
  62728. render(): void;
  62729. /**
  62730. * Determine if a given mesh will be used in the current effect.
  62731. * @param mesh mesh to test
  62732. * @returns true if the mesh will be used
  62733. */
  62734. hasMesh(mesh: AbstractMesh): boolean;
  62735. /**
  62736. * Returns true if the layer contains information to display, otherwise false.
  62737. * @returns true if the glow layer should be rendered
  62738. */
  62739. shouldRender(): boolean;
  62740. /**
  62741. * Returns true if the mesh should render, otherwise false.
  62742. * @param mesh The mesh to render
  62743. * @returns true if it should render otherwise false
  62744. */
  62745. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62746. /**
  62747. * Returns true if the mesh can be rendered, otherwise false.
  62748. * @param mesh The mesh to render
  62749. * @param material The material used on the mesh
  62750. * @returns true if it can be rendered otherwise false
  62751. */
  62752. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62753. /**
  62754. * Returns true if the mesh should render, otherwise false.
  62755. * @param mesh The mesh to render
  62756. * @returns true if it should render otherwise false
  62757. */
  62758. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62759. /**
  62760. * Renders the submesh passed in parameter to the generation map.
  62761. */
  62762. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62763. /**
  62764. * Defines whether the current material of the mesh should be use to render the effect.
  62765. * @param mesh defines the current mesh to render
  62766. */
  62767. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62768. /**
  62769. * Rebuild the required buffers.
  62770. * @hidden Internal use only.
  62771. */
  62772. _rebuild(): void;
  62773. /**
  62774. * Dispose only the render target textures and post process.
  62775. */
  62776. private _disposeTextureAndPostProcesses;
  62777. /**
  62778. * Dispose the highlight layer and free resources.
  62779. */
  62780. dispose(): void;
  62781. /**
  62782. * Gets the class name of the effect layer
  62783. * @returns the string with the class name of the effect layer
  62784. */
  62785. getClassName(): string;
  62786. /**
  62787. * Creates an effect layer from parsed effect layer data
  62788. * @param parsedEffectLayer defines effect layer data
  62789. * @param scene defines the current scene
  62790. * @param rootUrl defines the root URL containing the effect layer information
  62791. * @returns a parsed effect Layer
  62792. */
  62793. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62794. }
  62795. }
  62796. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  62797. import { Scene } from "babylonjs/scene";
  62798. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62799. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62800. import { AbstractScene } from "babylonjs/abstractScene";
  62801. module "babylonjs/abstractScene" {
  62802. interface AbstractScene {
  62803. /**
  62804. * The list of effect layers (highlights/glow) added to the scene
  62805. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62806. * @see https://doc.babylonjs.com/how_to/glow_layer
  62807. */
  62808. effectLayers: Array<EffectLayer>;
  62809. /**
  62810. * Removes the given effect layer from this scene.
  62811. * @param toRemove defines the effect layer to remove
  62812. * @returns the index of the removed effect layer
  62813. */
  62814. removeEffectLayer(toRemove: EffectLayer): number;
  62815. /**
  62816. * Adds the given effect layer to this scene
  62817. * @param newEffectLayer defines the effect layer to add
  62818. */
  62819. addEffectLayer(newEffectLayer: EffectLayer): void;
  62820. }
  62821. }
  62822. /**
  62823. * Defines the layer scene component responsible to manage any effect layers
  62824. * in a given scene.
  62825. */
  62826. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62827. /**
  62828. * The component name helpfull to identify the component in the list of scene components.
  62829. */
  62830. readonly name: string;
  62831. /**
  62832. * The scene the component belongs to.
  62833. */
  62834. scene: Scene;
  62835. private _engine;
  62836. private _renderEffects;
  62837. private _needStencil;
  62838. private _previousStencilState;
  62839. /**
  62840. * Creates a new instance of the component for the given scene
  62841. * @param scene Defines the scene to register the component in
  62842. */
  62843. constructor(scene: Scene);
  62844. /**
  62845. * Registers the component in a given scene
  62846. */
  62847. register(): void;
  62848. /**
  62849. * Rebuilds the elements related to this component in case of
  62850. * context lost for instance.
  62851. */
  62852. rebuild(): void;
  62853. /**
  62854. * Serializes the component data to the specified json object
  62855. * @param serializationObject The object to serialize to
  62856. */
  62857. serialize(serializationObject: any): void;
  62858. /**
  62859. * Adds all the elements from the container to the scene
  62860. * @param container the container holding the elements
  62861. */
  62862. addFromContainer(container: AbstractScene): void;
  62863. /**
  62864. * Removes all the elements in the container from the scene
  62865. * @param container contains the elements to remove
  62866. * @param dispose if the removed element should be disposed (default: false)
  62867. */
  62868. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62869. /**
  62870. * Disposes the component and the associated ressources.
  62871. */
  62872. dispose(): void;
  62873. private _isReadyForMesh;
  62874. private _renderMainTexture;
  62875. private _setStencil;
  62876. private _setStencilBack;
  62877. private _draw;
  62878. private _drawCamera;
  62879. private _drawRenderingGroup;
  62880. }
  62881. }
  62882. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62883. /** @hidden */
  62884. export var glowMapMergePixelShader: {
  62885. name: string;
  62886. shader: string;
  62887. };
  62888. }
  62889. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62890. /** @hidden */
  62891. export var glowMapMergeVertexShader: {
  62892. name: string;
  62893. shader: string;
  62894. };
  62895. }
  62896. declare module "babylonjs/Layers/glowLayer" {
  62897. import { Nullable } from "babylonjs/types";
  62898. import { Camera } from "babylonjs/Cameras/camera";
  62899. import { Scene } from "babylonjs/scene";
  62900. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62902. import { Mesh } from "babylonjs/Meshes/mesh";
  62903. import { Texture } from "babylonjs/Materials/Textures/texture";
  62904. import { Effect } from "babylonjs/Materials/effect";
  62905. import { Material } from "babylonjs/Materials/material";
  62906. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62907. import { Color4 } from "babylonjs/Maths/math.color";
  62908. import "babylonjs/Shaders/glowMapMerge.fragment";
  62909. import "babylonjs/Shaders/glowMapMerge.vertex";
  62910. import "babylonjs/Layers/effectLayerSceneComponent";
  62911. module "babylonjs/abstractScene" {
  62912. interface AbstractScene {
  62913. /**
  62914. * Return a the first highlight layer of the scene with a given name.
  62915. * @param name The name of the highlight layer to look for.
  62916. * @return The highlight layer if found otherwise null.
  62917. */
  62918. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62919. }
  62920. }
  62921. /**
  62922. * Glow layer options. This helps customizing the behaviour
  62923. * of the glow layer.
  62924. */
  62925. export interface IGlowLayerOptions {
  62926. /**
  62927. * Multiplication factor apply to the canvas size to compute the render target size
  62928. * used to generated the glowing objects (the smaller the faster).
  62929. */
  62930. mainTextureRatio: number;
  62931. /**
  62932. * Enforces a fixed size texture to ensure resize independant blur.
  62933. */
  62934. mainTextureFixedSize?: number;
  62935. /**
  62936. * How big is the kernel of the blur texture.
  62937. */
  62938. blurKernelSize: number;
  62939. /**
  62940. * The camera attached to the layer.
  62941. */
  62942. camera: Nullable<Camera>;
  62943. /**
  62944. * Enable MSAA by chosing the number of samples.
  62945. */
  62946. mainTextureSamples?: number;
  62947. /**
  62948. * The rendering group to draw the layer in.
  62949. */
  62950. renderingGroupId: number;
  62951. }
  62952. /**
  62953. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62954. *
  62955. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62956. *
  62957. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62958. */
  62959. export class GlowLayer extends EffectLayer {
  62960. /**
  62961. * Effect Name of the layer.
  62962. */
  62963. static readonly EffectName: string;
  62964. /**
  62965. * The default blur kernel size used for the glow.
  62966. */
  62967. static DefaultBlurKernelSize: number;
  62968. /**
  62969. * The default texture size ratio used for the glow.
  62970. */
  62971. static DefaultTextureRatio: number;
  62972. /**
  62973. * Sets the kernel size of the blur.
  62974. */
  62975. set blurKernelSize(value: number);
  62976. /**
  62977. * Gets the kernel size of the blur.
  62978. */
  62979. get blurKernelSize(): number;
  62980. /**
  62981. * Sets the glow intensity.
  62982. */
  62983. set intensity(value: number);
  62984. /**
  62985. * Gets the glow intensity.
  62986. */
  62987. get intensity(): number;
  62988. private _options;
  62989. private _intensity;
  62990. private _horizontalBlurPostprocess1;
  62991. private _verticalBlurPostprocess1;
  62992. private _horizontalBlurPostprocess2;
  62993. private _verticalBlurPostprocess2;
  62994. private _blurTexture1;
  62995. private _blurTexture2;
  62996. private _postProcesses1;
  62997. private _postProcesses2;
  62998. private _includedOnlyMeshes;
  62999. private _excludedMeshes;
  63000. private _meshesUsingTheirOwnMaterials;
  63001. /**
  63002. * Callback used to let the user override the color selection on a per mesh basis
  63003. */
  63004. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  63005. /**
  63006. * Callback used to let the user override the texture selection on a per mesh basis
  63007. */
  63008. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  63009. /**
  63010. * Instantiates a new glow Layer and references it to the scene.
  63011. * @param name The name of the layer
  63012. * @param scene The scene to use the layer in
  63013. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63014. */
  63015. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63016. /**
  63017. * Get the effect name of the layer.
  63018. * @return The effect name
  63019. */
  63020. getEffectName(): string;
  63021. /**
  63022. * Create the merge effect. This is the shader use to blit the information back
  63023. * to the main canvas at the end of the scene rendering.
  63024. */
  63025. protected _createMergeEffect(): Effect;
  63026. /**
  63027. * Creates the render target textures and post processes used in the glow layer.
  63028. */
  63029. protected _createTextureAndPostProcesses(): void;
  63030. /**
  63031. * Checks for the readiness of the element composing the layer.
  63032. * @param subMesh the mesh to check for
  63033. * @param useInstances specify wether or not to use instances to render the mesh
  63034. * @param emissiveTexture the associated emissive texture used to generate the glow
  63035. * @return true if ready otherwise, false
  63036. */
  63037. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63038. /**
  63039. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  63040. */
  63041. needStencil(): boolean;
  63042. /**
  63043. * Returns true if the mesh can be rendered, otherwise false.
  63044. * @param mesh The mesh to render
  63045. * @param material The material used on the mesh
  63046. * @returns true if it can be rendered otherwise false
  63047. */
  63048. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63049. /**
  63050. * Implementation specific of rendering the generating effect on the main canvas.
  63051. * @param effect The effect used to render through
  63052. */
  63053. protected _internalRender(effect: Effect): void;
  63054. /**
  63055. * Sets the required values for both the emissive texture and and the main color.
  63056. */
  63057. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63058. /**
  63059. * Returns true if the mesh should render, otherwise false.
  63060. * @param mesh The mesh to render
  63061. * @returns true if it should render otherwise false
  63062. */
  63063. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63064. /**
  63065. * Adds specific effects defines.
  63066. * @param defines The defines to add specifics to.
  63067. */
  63068. protected _addCustomEffectDefines(defines: string[]): void;
  63069. /**
  63070. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63071. * @param mesh The mesh to exclude from the glow layer
  63072. */
  63073. addExcludedMesh(mesh: Mesh): void;
  63074. /**
  63075. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63076. * @param mesh The mesh to remove
  63077. */
  63078. removeExcludedMesh(mesh: Mesh): void;
  63079. /**
  63080. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63081. * @param mesh The mesh to include in the glow layer
  63082. */
  63083. addIncludedOnlyMesh(mesh: Mesh): void;
  63084. /**
  63085. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63086. * @param mesh The mesh to remove
  63087. */
  63088. removeIncludedOnlyMesh(mesh: Mesh): void;
  63089. /**
  63090. * Determine if a given mesh will be used in the glow layer
  63091. * @param mesh The mesh to test
  63092. * @returns true if the mesh will be highlighted by the current glow layer
  63093. */
  63094. hasMesh(mesh: AbstractMesh): boolean;
  63095. /**
  63096. * Defines whether the current material of the mesh should be use to render the effect.
  63097. * @param mesh defines the current mesh to render
  63098. */
  63099. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63100. /**
  63101. * Add a mesh to be rendered through its own material and not with emissive only.
  63102. * @param mesh The mesh for which we need to use its material
  63103. */
  63104. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63105. /**
  63106. * Remove a mesh from being rendered through its own material and not with emissive only.
  63107. * @param mesh The mesh for which we need to not use its material
  63108. */
  63109. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63110. /**
  63111. * Free any resources and references associated to a mesh.
  63112. * Internal use
  63113. * @param mesh The mesh to free.
  63114. * @hidden
  63115. */
  63116. _disposeMesh(mesh: Mesh): void;
  63117. /**
  63118. * Gets the class name of the effect layer
  63119. * @returns the string with the class name of the effect layer
  63120. */
  63121. getClassName(): string;
  63122. /**
  63123. * Serializes this glow layer
  63124. * @returns a serialized glow layer object
  63125. */
  63126. serialize(): any;
  63127. /**
  63128. * Creates a Glow Layer from parsed glow layer data
  63129. * @param parsedGlowLayer defines glow layer data
  63130. * @param scene defines the current scene
  63131. * @param rootUrl defines the root URL containing the glow layer information
  63132. * @returns a parsed Glow Layer
  63133. */
  63134. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63135. }
  63136. }
  63137. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  63138. /** @hidden */
  63139. export var glowBlurPostProcessPixelShader: {
  63140. name: string;
  63141. shader: string;
  63142. };
  63143. }
  63144. declare module "babylonjs/Layers/highlightLayer" {
  63145. import { Observable } from "babylonjs/Misc/observable";
  63146. import { Nullable } from "babylonjs/types";
  63147. import { Camera } from "babylonjs/Cameras/camera";
  63148. import { Scene } from "babylonjs/scene";
  63149. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63151. import { Mesh } from "babylonjs/Meshes/mesh";
  63152. import { Effect } from "babylonjs/Materials/effect";
  63153. import { Material } from "babylonjs/Materials/material";
  63154. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  63155. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63156. import "babylonjs/Shaders/glowMapMerge.fragment";
  63157. import "babylonjs/Shaders/glowMapMerge.vertex";
  63158. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  63159. module "babylonjs/abstractScene" {
  63160. interface AbstractScene {
  63161. /**
  63162. * Return a the first highlight layer of the scene with a given name.
  63163. * @param name The name of the highlight layer to look for.
  63164. * @return The highlight layer if found otherwise null.
  63165. */
  63166. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63167. }
  63168. }
  63169. /**
  63170. * Highlight layer options. This helps customizing the behaviour
  63171. * of the highlight layer.
  63172. */
  63173. export interface IHighlightLayerOptions {
  63174. /**
  63175. * Multiplication factor apply to the canvas size to compute the render target size
  63176. * used to generated the glowing objects (the smaller the faster).
  63177. */
  63178. mainTextureRatio: number;
  63179. /**
  63180. * Enforces a fixed size texture to ensure resize independant blur.
  63181. */
  63182. mainTextureFixedSize?: number;
  63183. /**
  63184. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63185. * of the picture to blur (the smaller the faster).
  63186. */
  63187. blurTextureSizeRatio: number;
  63188. /**
  63189. * How big in texel of the blur texture is the vertical blur.
  63190. */
  63191. blurVerticalSize: number;
  63192. /**
  63193. * How big in texel of the blur texture is the horizontal blur.
  63194. */
  63195. blurHorizontalSize: number;
  63196. /**
  63197. * Alpha blending mode used to apply the blur. Default is combine.
  63198. */
  63199. alphaBlendingMode: number;
  63200. /**
  63201. * The camera attached to the layer.
  63202. */
  63203. camera: Nullable<Camera>;
  63204. /**
  63205. * Should we display highlight as a solid stroke?
  63206. */
  63207. isStroke?: boolean;
  63208. /**
  63209. * The rendering group to draw the layer in.
  63210. */
  63211. renderingGroupId: number;
  63212. }
  63213. /**
  63214. * The highlight layer Helps adding a glow effect around a mesh.
  63215. *
  63216. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63217. * glowy meshes to your scene.
  63218. *
  63219. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63220. */
  63221. export class HighlightLayer extends EffectLayer {
  63222. name: string;
  63223. /**
  63224. * Effect Name of the highlight layer.
  63225. */
  63226. static readonly EffectName: string;
  63227. /**
  63228. * The neutral color used during the preparation of the glow effect.
  63229. * This is black by default as the blend operation is a blend operation.
  63230. */
  63231. static NeutralColor: Color4;
  63232. /**
  63233. * Stencil value used for glowing meshes.
  63234. */
  63235. static GlowingMeshStencilReference: number;
  63236. /**
  63237. * Stencil value used for the other meshes in the scene.
  63238. */
  63239. static NormalMeshStencilReference: number;
  63240. /**
  63241. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63242. */
  63243. innerGlow: boolean;
  63244. /**
  63245. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63246. */
  63247. outerGlow: boolean;
  63248. /**
  63249. * Specifies the horizontal size of the blur.
  63250. */
  63251. set blurHorizontalSize(value: number);
  63252. /**
  63253. * Specifies the vertical size of the blur.
  63254. */
  63255. set blurVerticalSize(value: number);
  63256. /**
  63257. * Gets the horizontal size of the blur.
  63258. */
  63259. get blurHorizontalSize(): number;
  63260. /**
  63261. * Gets the vertical size of the blur.
  63262. */
  63263. get blurVerticalSize(): number;
  63264. /**
  63265. * An event triggered when the highlight layer is being blurred.
  63266. */
  63267. onBeforeBlurObservable: Observable<HighlightLayer>;
  63268. /**
  63269. * An event triggered when the highlight layer has been blurred.
  63270. */
  63271. onAfterBlurObservable: Observable<HighlightLayer>;
  63272. private _instanceGlowingMeshStencilReference;
  63273. private _options;
  63274. private _downSamplePostprocess;
  63275. private _horizontalBlurPostprocess;
  63276. private _verticalBlurPostprocess;
  63277. private _blurTexture;
  63278. private _meshes;
  63279. private _excludedMeshes;
  63280. /**
  63281. * Instantiates a new highlight Layer and references it to the scene..
  63282. * @param name The name of the layer
  63283. * @param scene The scene to use the layer in
  63284. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63285. */
  63286. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63287. /**
  63288. * Get the effect name of the layer.
  63289. * @return The effect name
  63290. */
  63291. getEffectName(): string;
  63292. /**
  63293. * Create the merge effect. This is the shader use to blit the information back
  63294. * to the main canvas at the end of the scene rendering.
  63295. */
  63296. protected _createMergeEffect(): Effect;
  63297. /**
  63298. * Creates the render target textures and post processes used in the highlight layer.
  63299. */
  63300. protected _createTextureAndPostProcesses(): void;
  63301. /**
  63302. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63303. */
  63304. needStencil(): boolean;
  63305. /**
  63306. * Checks for the readiness of the element composing the layer.
  63307. * @param subMesh the mesh to check for
  63308. * @param useInstances specify wether or not to use instances to render the mesh
  63309. * @param emissiveTexture the associated emissive texture used to generate the glow
  63310. * @return true if ready otherwise, false
  63311. */
  63312. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63313. /**
  63314. * Implementation specific of rendering the generating effect on the main canvas.
  63315. * @param effect The effect used to render through
  63316. */
  63317. protected _internalRender(effect: Effect): void;
  63318. /**
  63319. * Returns true if the layer contains information to display, otherwise false.
  63320. */
  63321. shouldRender(): boolean;
  63322. /**
  63323. * Returns true if the mesh should render, otherwise false.
  63324. * @param mesh The mesh to render
  63325. * @returns true if it should render otherwise false
  63326. */
  63327. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63328. /**
  63329. * Returns true if the mesh can be rendered, otherwise false.
  63330. * @param mesh The mesh to render
  63331. * @param material The material used on the mesh
  63332. * @returns true if it can be rendered otherwise false
  63333. */
  63334. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63335. /**
  63336. * Adds specific effects defines.
  63337. * @param defines The defines to add specifics to.
  63338. */
  63339. protected _addCustomEffectDefines(defines: string[]): void;
  63340. /**
  63341. * Sets the required values for both the emissive texture and and the main color.
  63342. */
  63343. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63344. /**
  63345. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63346. * @param mesh The mesh to exclude from the highlight layer
  63347. */
  63348. addExcludedMesh(mesh: Mesh): void;
  63349. /**
  63350. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63351. * @param mesh The mesh to highlight
  63352. */
  63353. removeExcludedMesh(mesh: Mesh): void;
  63354. /**
  63355. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63356. * @param mesh mesh to test
  63357. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63358. */
  63359. hasMesh(mesh: AbstractMesh): boolean;
  63360. /**
  63361. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63362. * @param mesh The mesh to highlight
  63363. * @param color The color of the highlight
  63364. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63365. */
  63366. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63367. /**
  63368. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63369. * @param mesh The mesh to highlight
  63370. */
  63371. removeMesh(mesh: Mesh): void;
  63372. /**
  63373. * Remove all the meshes currently referenced in the highlight layer
  63374. */
  63375. removeAllMeshes(): void;
  63376. /**
  63377. * Force the stencil to the normal expected value for none glowing parts
  63378. */
  63379. private _defaultStencilReference;
  63380. /**
  63381. * Free any resources and references associated to a mesh.
  63382. * Internal use
  63383. * @param mesh The mesh to free.
  63384. * @hidden
  63385. */
  63386. _disposeMesh(mesh: Mesh): void;
  63387. /**
  63388. * Dispose the highlight layer and free resources.
  63389. */
  63390. dispose(): void;
  63391. /**
  63392. * Gets the class name of the effect layer
  63393. * @returns the string with the class name of the effect layer
  63394. */
  63395. getClassName(): string;
  63396. /**
  63397. * Serializes this Highlight layer
  63398. * @returns a serialized Highlight layer object
  63399. */
  63400. serialize(): any;
  63401. /**
  63402. * Creates a Highlight layer from parsed Highlight layer data
  63403. * @param parsedHightlightLayer defines the Highlight layer data
  63404. * @param scene defines the current scene
  63405. * @param rootUrl defines the root URL containing the Highlight layer information
  63406. * @returns a parsed Highlight layer
  63407. */
  63408. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63409. }
  63410. }
  63411. declare module "babylonjs/Layers/layerSceneComponent" {
  63412. import { Scene } from "babylonjs/scene";
  63413. import { ISceneComponent } from "babylonjs/sceneComponent";
  63414. import { Layer } from "babylonjs/Layers/layer";
  63415. import { AbstractScene } from "babylonjs/abstractScene";
  63416. module "babylonjs/abstractScene" {
  63417. interface AbstractScene {
  63418. /**
  63419. * The list of layers (background and foreground) of the scene
  63420. */
  63421. layers: Array<Layer>;
  63422. }
  63423. }
  63424. /**
  63425. * Defines the layer scene component responsible to manage any layers
  63426. * in a given scene.
  63427. */
  63428. export class LayerSceneComponent implements ISceneComponent {
  63429. /**
  63430. * The component name helpfull to identify the component in the list of scene components.
  63431. */
  63432. readonly name: string;
  63433. /**
  63434. * The scene the component belongs to.
  63435. */
  63436. scene: Scene;
  63437. private _engine;
  63438. /**
  63439. * Creates a new instance of the component for the given scene
  63440. * @param scene Defines the scene to register the component in
  63441. */
  63442. constructor(scene: Scene);
  63443. /**
  63444. * Registers the component in a given scene
  63445. */
  63446. register(): void;
  63447. /**
  63448. * Rebuilds the elements related to this component in case of
  63449. * context lost for instance.
  63450. */
  63451. rebuild(): void;
  63452. /**
  63453. * Disposes the component and the associated ressources.
  63454. */
  63455. dispose(): void;
  63456. private _draw;
  63457. private _drawCameraPredicate;
  63458. private _drawCameraBackground;
  63459. private _drawCameraForeground;
  63460. private _drawRenderTargetPredicate;
  63461. private _drawRenderTargetBackground;
  63462. private _drawRenderTargetForeground;
  63463. /**
  63464. * Adds all the elements from the container to the scene
  63465. * @param container the container holding the elements
  63466. */
  63467. addFromContainer(container: AbstractScene): void;
  63468. /**
  63469. * Removes all the elements in the container from the scene
  63470. * @param container contains the elements to remove
  63471. * @param dispose if the removed element should be disposed (default: false)
  63472. */
  63473. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63474. }
  63475. }
  63476. declare module "babylonjs/Shaders/layer.fragment" {
  63477. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63478. /** @hidden */
  63479. export var layerPixelShader: {
  63480. name: string;
  63481. shader: string;
  63482. };
  63483. }
  63484. declare module "babylonjs/Shaders/layer.vertex" {
  63485. /** @hidden */
  63486. export var layerVertexShader: {
  63487. name: string;
  63488. shader: string;
  63489. };
  63490. }
  63491. declare module "babylonjs/Layers/layer" {
  63492. import { Observable } from "babylonjs/Misc/observable";
  63493. import { Nullable } from "babylonjs/types";
  63494. import { Scene } from "babylonjs/scene";
  63495. import { Vector2 } from "babylonjs/Maths/math.vector";
  63496. import { Color4 } from "babylonjs/Maths/math.color";
  63497. import { Texture } from "babylonjs/Materials/Textures/texture";
  63498. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63499. import "babylonjs/Shaders/layer.fragment";
  63500. import "babylonjs/Shaders/layer.vertex";
  63501. /**
  63502. * This represents a full screen 2d layer.
  63503. * This can be useful to display a picture in the background of your scene for instance.
  63504. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63505. */
  63506. export class Layer {
  63507. /**
  63508. * Define the name of the layer.
  63509. */
  63510. name: string;
  63511. /**
  63512. * Define the texture the layer should display.
  63513. */
  63514. texture: Nullable<Texture>;
  63515. /**
  63516. * Is the layer in background or foreground.
  63517. */
  63518. isBackground: boolean;
  63519. /**
  63520. * Define the color of the layer (instead of texture).
  63521. */
  63522. color: Color4;
  63523. /**
  63524. * Define the scale of the layer in order to zoom in out of the texture.
  63525. */
  63526. scale: Vector2;
  63527. /**
  63528. * Define an offset for the layer in order to shift the texture.
  63529. */
  63530. offset: Vector2;
  63531. /**
  63532. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63533. */
  63534. alphaBlendingMode: number;
  63535. /**
  63536. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63537. * Alpha test will not mix with the background color in case of transparency.
  63538. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63539. */
  63540. alphaTest: boolean;
  63541. /**
  63542. * Define a mask to restrict the layer to only some of the scene cameras.
  63543. */
  63544. layerMask: number;
  63545. /**
  63546. * Define the list of render target the layer is visible into.
  63547. */
  63548. renderTargetTextures: RenderTargetTexture[];
  63549. /**
  63550. * Define if the layer is only used in renderTarget or if it also
  63551. * renders in the main frame buffer of the canvas.
  63552. */
  63553. renderOnlyInRenderTargetTextures: boolean;
  63554. private _scene;
  63555. private _vertexBuffers;
  63556. private _indexBuffer;
  63557. private _effect;
  63558. private _previousDefines;
  63559. /**
  63560. * An event triggered when the layer is disposed.
  63561. */
  63562. onDisposeObservable: Observable<Layer>;
  63563. private _onDisposeObserver;
  63564. /**
  63565. * Back compatibility with callback before the onDisposeObservable existed.
  63566. * The set callback will be triggered when the layer has been disposed.
  63567. */
  63568. set onDispose(callback: () => void);
  63569. /**
  63570. * An event triggered before rendering the scene
  63571. */
  63572. onBeforeRenderObservable: Observable<Layer>;
  63573. private _onBeforeRenderObserver;
  63574. /**
  63575. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63576. * The set callback will be triggered just before rendering the layer.
  63577. */
  63578. set onBeforeRender(callback: () => void);
  63579. /**
  63580. * An event triggered after rendering the scene
  63581. */
  63582. onAfterRenderObservable: Observable<Layer>;
  63583. private _onAfterRenderObserver;
  63584. /**
  63585. * Back compatibility with callback before the onAfterRenderObservable existed.
  63586. * The set callback will be triggered just after rendering the layer.
  63587. */
  63588. set onAfterRender(callback: () => void);
  63589. /**
  63590. * Instantiates a new layer.
  63591. * This represents a full screen 2d layer.
  63592. * This can be useful to display a picture in the background of your scene for instance.
  63593. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63594. * @param name Define the name of the layer in the scene
  63595. * @param imgUrl Define the url of the texture to display in the layer
  63596. * @param scene Define the scene the layer belongs to
  63597. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63598. * @param color Defines a color for the layer
  63599. */
  63600. constructor(
  63601. /**
  63602. * Define the name of the layer.
  63603. */
  63604. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63605. private _createIndexBuffer;
  63606. /** @hidden */
  63607. _rebuild(): void;
  63608. /**
  63609. * Renders the layer in the scene.
  63610. */
  63611. render(): void;
  63612. /**
  63613. * Disposes and releases the associated ressources.
  63614. */
  63615. dispose(): void;
  63616. }
  63617. }
  63618. declare module "babylonjs/Layers/index" {
  63619. export * from "babylonjs/Layers/effectLayer";
  63620. export * from "babylonjs/Layers/effectLayerSceneComponent";
  63621. export * from "babylonjs/Layers/glowLayer";
  63622. export * from "babylonjs/Layers/highlightLayer";
  63623. export * from "babylonjs/Layers/layer";
  63624. export * from "babylonjs/Layers/layerSceneComponent";
  63625. }
  63626. declare module "babylonjs/Shaders/lensFlare.fragment" {
  63627. /** @hidden */
  63628. export var lensFlarePixelShader: {
  63629. name: string;
  63630. shader: string;
  63631. };
  63632. }
  63633. declare module "babylonjs/Shaders/lensFlare.vertex" {
  63634. /** @hidden */
  63635. export var lensFlareVertexShader: {
  63636. name: string;
  63637. shader: string;
  63638. };
  63639. }
  63640. declare module "babylonjs/LensFlares/lensFlareSystem" {
  63641. import { Scene } from "babylonjs/scene";
  63642. import { Vector3 } from "babylonjs/Maths/math.vector";
  63643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63644. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  63645. import "babylonjs/Shaders/lensFlare.fragment";
  63646. import "babylonjs/Shaders/lensFlare.vertex";
  63647. import { Viewport } from "babylonjs/Maths/math.viewport";
  63648. /**
  63649. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63650. * It is usually composed of several `lensFlare`.
  63651. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63652. */
  63653. export class LensFlareSystem {
  63654. /**
  63655. * Define the name of the lens flare system
  63656. */
  63657. name: string;
  63658. /**
  63659. * List of lens flares used in this system.
  63660. */
  63661. lensFlares: LensFlare[];
  63662. /**
  63663. * Define a limit from the border the lens flare can be visible.
  63664. */
  63665. borderLimit: number;
  63666. /**
  63667. * Define a viewport border we do not want to see the lens flare in.
  63668. */
  63669. viewportBorder: number;
  63670. /**
  63671. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63672. */
  63673. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63674. /**
  63675. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63676. */
  63677. layerMask: number;
  63678. /**
  63679. * Define the id of the lens flare system in the scene.
  63680. * (equal to name by default)
  63681. */
  63682. id: string;
  63683. private _scene;
  63684. private _emitter;
  63685. private _vertexBuffers;
  63686. private _indexBuffer;
  63687. private _effect;
  63688. private _positionX;
  63689. private _positionY;
  63690. private _isEnabled;
  63691. /** @hidden */
  63692. static _SceneComponentInitialization: (scene: Scene) => void;
  63693. /**
  63694. * Instantiates a lens flare system.
  63695. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63696. * It is usually composed of several `lensFlare`.
  63697. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63698. * @param name Define the name of the lens flare system in the scene
  63699. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63700. * @param scene Define the scene the lens flare system belongs to
  63701. */
  63702. constructor(
  63703. /**
  63704. * Define the name of the lens flare system
  63705. */
  63706. name: string, emitter: any, scene: Scene);
  63707. /**
  63708. * Define if the lens flare system is enabled.
  63709. */
  63710. get isEnabled(): boolean;
  63711. set isEnabled(value: boolean);
  63712. /**
  63713. * Get the scene the effects belongs to.
  63714. * @returns the scene holding the lens flare system
  63715. */
  63716. getScene(): Scene;
  63717. /**
  63718. * Get the emitter of the lens flare system.
  63719. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63720. * @returns the emitter of the lens flare system
  63721. */
  63722. getEmitter(): any;
  63723. /**
  63724. * Set the emitter of the lens flare system.
  63725. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63726. * @param newEmitter Define the new emitter of the system
  63727. */
  63728. setEmitter(newEmitter: any): void;
  63729. /**
  63730. * Get the lens flare system emitter position.
  63731. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63732. * @returns the position
  63733. */
  63734. getEmitterPosition(): Vector3;
  63735. /**
  63736. * @hidden
  63737. */
  63738. computeEffectivePosition(globalViewport: Viewport): boolean;
  63739. /** @hidden */
  63740. _isVisible(): boolean;
  63741. /**
  63742. * @hidden
  63743. */
  63744. render(): boolean;
  63745. /**
  63746. * Dispose and release the lens flare with its associated resources.
  63747. */
  63748. dispose(): void;
  63749. /**
  63750. * Parse a lens flare system from a JSON repressentation
  63751. * @param parsedLensFlareSystem Define the JSON to parse
  63752. * @param scene Define the scene the parsed system should be instantiated in
  63753. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63754. * @returns the parsed system
  63755. */
  63756. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63757. /**
  63758. * Serialize the current Lens Flare System into a JSON representation.
  63759. * @returns the serialized JSON
  63760. */
  63761. serialize(): any;
  63762. }
  63763. }
  63764. declare module "babylonjs/LensFlares/lensFlare" {
  63765. import { Nullable } from "babylonjs/types";
  63766. import { Color3 } from "babylonjs/Maths/math.color";
  63767. import { Texture } from "babylonjs/Materials/Textures/texture";
  63768. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63769. /**
  63770. * This represents one of the lens effect in a `lensFlareSystem`.
  63771. * It controls one of the indiviual texture used in the effect.
  63772. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63773. */
  63774. export class LensFlare {
  63775. /**
  63776. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63777. */
  63778. size: number;
  63779. /**
  63780. * 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.
  63781. */
  63782. position: number;
  63783. /**
  63784. * Define the lens color.
  63785. */
  63786. color: Color3;
  63787. /**
  63788. * Define the lens texture.
  63789. */
  63790. texture: Nullable<Texture>;
  63791. /**
  63792. * Define the alpha mode to render this particular lens.
  63793. */
  63794. alphaMode: number;
  63795. private _system;
  63796. /**
  63797. * Creates a new Lens Flare.
  63798. * This represents one of the lens effect in a `lensFlareSystem`.
  63799. * It controls one of the indiviual texture used in the effect.
  63800. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63801. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63802. * @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.
  63803. * @param color Define the lens color
  63804. * @param imgUrl Define the lens texture url
  63805. * @param system Define the `lensFlareSystem` this flare is part of
  63806. * @returns The newly created Lens Flare
  63807. */
  63808. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63809. /**
  63810. * Instantiates a new Lens Flare.
  63811. * This represents one of the lens effect in a `lensFlareSystem`.
  63812. * It controls one of the indiviual texture used in the effect.
  63813. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63814. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63815. * @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.
  63816. * @param color Define the lens color
  63817. * @param imgUrl Define the lens texture url
  63818. * @param system Define the `lensFlareSystem` this flare is part of
  63819. */
  63820. constructor(
  63821. /**
  63822. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63823. */
  63824. size: number,
  63825. /**
  63826. * 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.
  63827. */
  63828. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63829. /**
  63830. * Dispose and release the lens flare with its associated resources.
  63831. */
  63832. dispose(): void;
  63833. }
  63834. }
  63835. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63836. import { Nullable } from "babylonjs/types";
  63837. import { Scene } from "babylonjs/scene";
  63838. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63839. import { AbstractScene } from "babylonjs/abstractScene";
  63840. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63841. module "babylonjs/abstractScene" {
  63842. interface AbstractScene {
  63843. /**
  63844. * The list of lens flare system added to the scene
  63845. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63846. */
  63847. lensFlareSystems: Array<LensFlareSystem>;
  63848. /**
  63849. * Removes the given lens flare system from this scene.
  63850. * @param toRemove The lens flare system to remove
  63851. * @returns The index of the removed lens flare system
  63852. */
  63853. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63854. /**
  63855. * Adds the given lens flare system to this scene
  63856. * @param newLensFlareSystem The lens flare system to add
  63857. */
  63858. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63859. /**
  63860. * Gets a lens flare system using its name
  63861. * @param name defines the name to look for
  63862. * @returns the lens flare system or null if not found
  63863. */
  63864. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63865. /**
  63866. * Gets a lens flare system using its id
  63867. * @param id defines the id to look for
  63868. * @returns the lens flare system or null if not found
  63869. */
  63870. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63871. }
  63872. }
  63873. /**
  63874. * Defines the lens flare scene component responsible to manage any lens flares
  63875. * in a given scene.
  63876. */
  63877. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63878. /**
  63879. * The component name helpfull to identify the component in the list of scene components.
  63880. */
  63881. readonly name: string;
  63882. /**
  63883. * The scene the component belongs to.
  63884. */
  63885. scene: Scene;
  63886. /**
  63887. * Creates a new instance of the component for the given scene
  63888. * @param scene Defines the scene to register the component in
  63889. */
  63890. constructor(scene: Scene);
  63891. /**
  63892. * Registers the component in a given scene
  63893. */
  63894. register(): void;
  63895. /**
  63896. * Rebuilds the elements related to this component in case of
  63897. * context lost for instance.
  63898. */
  63899. rebuild(): void;
  63900. /**
  63901. * Adds all the elements from the container to the scene
  63902. * @param container the container holding the elements
  63903. */
  63904. addFromContainer(container: AbstractScene): void;
  63905. /**
  63906. * Removes all the elements in the container from the scene
  63907. * @param container contains the elements to remove
  63908. * @param dispose if the removed element should be disposed (default: false)
  63909. */
  63910. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63911. /**
  63912. * Serializes the component data to the specified json object
  63913. * @param serializationObject The object to serialize to
  63914. */
  63915. serialize(serializationObject: any): void;
  63916. /**
  63917. * Disposes the component and the associated ressources.
  63918. */
  63919. dispose(): void;
  63920. private _draw;
  63921. }
  63922. }
  63923. declare module "babylonjs/LensFlares/index" {
  63924. export * from "babylonjs/LensFlares/lensFlare";
  63925. export * from "babylonjs/LensFlares/lensFlareSystem";
  63926. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63927. }
  63928. declare module "babylonjs/Shaders/depth.fragment" {
  63929. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63930. /** @hidden */
  63931. export var depthPixelShader: {
  63932. name: string;
  63933. shader: string;
  63934. };
  63935. }
  63936. declare module "babylonjs/Shaders/depth.vertex" {
  63937. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63938. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63940. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63941. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63942. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63943. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63944. /** @hidden */
  63945. export var depthVertexShader: {
  63946. name: string;
  63947. shader: string;
  63948. };
  63949. }
  63950. declare module "babylonjs/Rendering/depthRenderer" {
  63951. import { Nullable } from "babylonjs/types";
  63952. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63953. import { Scene } from "babylonjs/scene";
  63954. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63955. import { Camera } from "babylonjs/Cameras/camera";
  63956. import "babylonjs/Shaders/depth.fragment";
  63957. import "babylonjs/Shaders/depth.vertex";
  63958. /**
  63959. * This represents a depth renderer in Babylon.
  63960. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63961. */
  63962. export class DepthRenderer {
  63963. private _scene;
  63964. private _depthMap;
  63965. private _effect;
  63966. private readonly _storeNonLinearDepth;
  63967. private readonly _clearColor;
  63968. /** Get if the depth renderer is using packed depth or not */
  63969. readonly isPacked: boolean;
  63970. private _cachedDefines;
  63971. private _camera;
  63972. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63973. enabled: boolean;
  63974. /**
  63975. * Specifiess that the depth renderer will only be used within
  63976. * the camera it is created for.
  63977. * This can help forcing its rendering during the camera processing.
  63978. */
  63979. useOnlyInActiveCamera: boolean;
  63980. /** @hidden */
  63981. static _SceneComponentInitialization: (scene: Scene) => void;
  63982. /**
  63983. * Instantiates a depth renderer
  63984. * @param scene The scene the renderer belongs to
  63985. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63986. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63987. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63988. */
  63989. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63990. /**
  63991. * Creates the depth rendering effect and checks if the effect is ready.
  63992. * @param subMesh The submesh to be used to render the depth map of
  63993. * @param useInstances If multiple world instances should be used
  63994. * @returns if the depth renderer is ready to render the depth map
  63995. */
  63996. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63997. /**
  63998. * Gets the texture which the depth map will be written to.
  63999. * @returns The depth map texture
  64000. */
  64001. getDepthMap(): RenderTargetTexture;
  64002. /**
  64003. * Disposes of the depth renderer.
  64004. */
  64005. dispose(): void;
  64006. }
  64007. }
  64008. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  64009. /** @hidden */
  64010. export var minmaxReduxPixelShader: {
  64011. name: string;
  64012. shader: string;
  64013. };
  64014. }
  64015. declare module "babylonjs/Misc/minMaxReducer" {
  64016. import { Nullable } from "babylonjs/types";
  64017. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64018. import { Camera } from "babylonjs/Cameras/camera";
  64019. import { Observer } from "babylonjs/Misc/observable";
  64020. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64021. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  64022. import { Observable } from "babylonjs/Misc/observable";
  64023. import "babylonjs/Shaders/minmaxRedux.fragment";
  64024. /**
  64025. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64026. * and maximum values from all values of the texture.
  64027. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64028. * The source values are read from the red channel of the texture.
  64029. */
  64030. export class MinMaxReducer {
  64031. /**
  64032. * Observable triggered when the computation has been performed
  64033. */
  64034. onAfterReductionPerformed: Observable<{
  64035. min: number;
  64036. max: number;
  64037. }>;
  64038. protected _camera: Camera;
  64039. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64040. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64041. protected _postProcessManager: PostProcessManager;
  64042. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64043. protected _forceFullscreenViewport: boolean;
  64044. /**
  64045. * Creates a min/max reducer
  64046. * @param camera The camera to use for the post processes
  64047. */
  64048. constructor(camera: Camera);
  64049. /**
  64050. * Gets the texture used to read the values from.
  64051. */
  64052. get sourceTexture(): Nullable<RenderTargetTexture>;
  64053. /**
  64054. * Sets the source texture to read the values from.
  64055. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64056. * because in such textures '1' value must not be taken into account to compute the maximum
  64057. * as this value is used to clear the texture.
  64058. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64059. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64060. * @param depthRedux Indicates if the texture is a depth texture or not
  64061. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64062. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64063. */
  64064. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64065. /**
  64066. * Defines the refresh rate of the computation.
  64067. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64068. */
  64069. get refreshRate(): number;
  64070. set refreshRate(value: number);
  64071. protected _activated: boolean;
  64072. /**
  64073. * Gets the activation status of the reducer
  64074. */
  64075. get activated(): boolean;
  64076. /**
  64077. * Activates the reduction computation.
  64078. * When activated, the observers registered in onAfterReductionPerformed are
  64079. * called after the compuation is performed
  64080. */
  64081. activate(): void;
  64082. /**
  64083. * Deactivates the reduction computation.
  64084. */
  64085. deactivate(): void;
  64086. /**
  64087. * Disposes the min/max reducer
  64088. * @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.
  64089. */
  64090. dispose(disposeAll?: boolean): void;
  64091. }
  64092. }
  64093. declare module "babylonjs/Misc/depthReducer" {
  64094. import { Nullable } from "babylonjs/types";
  64095. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64096. import { Camera } from "babylonjs/Cameras/camera";
  64097. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64098. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  64099. /**
  64100. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64101. */
  64102. export class DepthReducer extends MinMaxReducer {
  64103. private _depthRenderer;
  64104. private _depthRendererId;
  64105. /**
  64106. * Gets the depth renderer used for the computation.
  64107. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64108. */
  64109. get depthRenderer(): Nullable<DepthRenderer>;
  64110. /**
  64111. * Creates a depth reducer
  64112. * @param camera The camera used to render the depth texture
  64113. */
  64114. constructor(camera: Camera);
  64115. /**
  64116. * Sets the depth renderer to use to generate the depth map
  64117. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64118. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64119. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64120. */
  64121. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64122. /** @hidden */
  64123. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64124. /**
  64125. * Activates the reduction computation.
  64126. * When activated, the observers registered in onAfterReductionPerformed are
  64127. * called after the compuation is performed
  64128. */
  64129. activate(): void;
  64130. /**
  64131. * Deactivates the reduction computation.
  64132. */
  64133. deactivate(): void;
  64134. /**
  64135. * Disposes the depth reducer
  64136. * @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.
  64137. */
  64138. dispose(disposeAll?: boolean): void;
  64139. }
  64140. }
  64141. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  64142. import { Nullable } from "babylonjs/types";
  64143. import { Scene } from "babylonjs/scene";
  64144. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64145. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64147. import { Effect } from "babylonjs/Materials/effect";
  64148. import "babylonjs/Shaders/shadowMap.fragment";
  64149. import "babylonjs/Shaders/shadowMap.vertex";
  64150. import "babylonjs/Shaders/depthBoxBlur.fragment";
  64151. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  64152. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64153. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64154. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64155. /**
  64156. * A CSM implementation allowing casting shadows on large scenes.
  64157. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64158. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64159. */
  64160. export class CascadedShadowGenerator extends ShadowGenerator {
  64161. private static readonly frustumCornersNDCSpace;
  64162. /**
  64163. * Name of the CSM class
  64164. */
  64165. static CLASSNAME: string;
  64166. /**
  64167. * Defines the default number of cascades used by the CSM.
  64168. */
  64169. static readonly DEFAULT_CASCADES_COUNT: number;
  64170. /**
  64171. * Defines the minimum number of cascades used by the CSM.
  64172. */
  64173. static readonly MIN_CASCADES_COUNT: number;
  64174. /**
  64175. * Defines the maximum number of cascades used by the CSM.
  64176. */
  64177. static readonly MAX_CASCADES_COUNT: number;
  64178. protected _validateFilter(filter: number): number;
  64179. /**
  64180. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64181. */
  64182. penumbraDarkness: number;
  64183. private _numCascades;
  64184. /**
  64185. * Gets or set the number of cascades used by the CSM.
  64186. */
  64187. get numCascades(): number;
  64188. set numCascades(value: number);
  64189. /**
  64190. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64191. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64192. */
  64193. stabilizeCascades: boolean;
  64194. private _freezeShadowCastersBoundingInfo;
  64195. private _freezeShadowCastersBoundingInfoObservable;
  64196. /**
  64197. * Enables or disables the shadow casters bounding info computation.
  64198. * If your shadow casters don't move, you can disable this feature.
  64199. * If it is enabled, the bounding box computation is done every frame.
  64200. */
  64201. get freezeShadowCastersBoundingInfo(): boolean;
  64202. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64203. private _scbiMin;
  64204. private _scbiMax;
  64205. protected _computeShadowCastersBoundingInfo(): void;
  64206. protected _shadowCastersBoundingInfo: BoundingInfo;
  64207. /**
  64208. * Gets or sets the shadow casters bounding info.
  64209. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64210. * so that the system won't overwrite the bounds you provide
  64211. */
  64212. get shadowCastersBoundingInfo(): BoundingInfo;
  64213. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64214. protected _breaksAreDirty: boolean;
  64215. protected _minDistance: number;
  64216. protected _maxDistance: number;
  64217. /**
  64218. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64219. *
  64220. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64221. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64222. * @param min minimal distance for the breaks (default to 0.)
  64223. * @param max maximal distance for the breaks (default to 1.)
  64224. */
  64225. setMinMaxDistance(min: number, max: number): void;
  64226. /** Gets the minimal distance used in the cascade break computation */
  64227. get minDistance(): number;
  64228. /** Gets the maximal distance used in the cascade break computation */
  64229. get maxDistance(): number;
  64230. /**
  64231. * Gets the class name of that object
  64232. * @returns "CascadedShadowGenerator"
  64233. */
  64234. getClassName(): string;
  64235. private _cascadeMinExtents;
  64236. private _cascadeMaxExtents;
  64237. /**
  64238. * Gets a cascade minimum extents
  64239. * @param cascadeIndex index of the cascade
  64240. * @returns the minimum cascade extents
  64241. */
  64242. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64243. /**
  64244. * Gets a cascade maximum extents
  64245. * @param cascadeIndex index of the cascade
  64246. * @returns the maximum cascade extents
  64247. */
  64248. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64249. private _cascades;
  64250. private _currentLayer;
  64251. private _viewSpaceFrustumsZ;
  64252. private _viewMatrices;
  64253. private _projectionMatrices;
  64254. private _transformMatrices;
  64255. private _transformMatricesAsArray;
  64256. private _frustumLengths;
  64257. private _lightSizeUVCorrection;
  64258. private _depthCorrection;
  64259. private _frustumCornersWorldSpace;
  64260. private _frustumCenter;
  64261. private _shadowCameraPos;
  64262. private _shadowMaxZ;
  64263. /**
  64264. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64265. * It defaults to camera.maxZ
  64266. */
  64267. get shadowMaxZ(): number;
  64268. /**
  64269. * Sets the shadow max z distance.
  64270. */
  64271. set shadowMaxZ(value: number);
  64272. protected _debug: boolean;
  64273. /**
  64274. * Gets or sets the debug flag.
  64275. * When enabled, the cascades are materialized by different colors on the screen.
  64276. */
  64277. get debug(): boolean;
  64278. set debug(dbg: boolean);
  64279. private _depthClamp;
  64280. /**
  64281. * Gets or sets the depth clamping value.
  64282. *
  64283. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64284. * to account for the shadow casters far away.
  64285. *
  64286. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64287. */
  64288. get depthClamp(): boolean;
  64289. set depthClamp(value: boolean);
  64290. private _cascadeBlendPercentage;
  64291. /**
  64292. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64293. * It defaults to 0.1 (10% blending).
  64294. */
  64295. get cascadeBlendPercentage(): number;
  64296. set cascadeBlendPercentage(value: number);
  64297. private _lambda;
  64298. /**
  64299. * Gets or set the lambda parameter.
  64300. * This parameter is used to split the camera frustum and create the cascades.
  64301. * 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.
  64302. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64303. */
  64304. get lambda(): number;
  64305. set lambda(value: number);
  64306. /**
  64307. * Gets the view matrix corresponding to a given cascade
  64308. * @param cascadeNum cascade to retrieve the view matrix from
  64309. * @returns the cascade view matrix
  64310. */
  64311. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64312. /**
  64313. * Gets the projection matrix corresponding to a given cascade
  64314. * @param cascadeNum cascade to retrieve the projection matrix from
  64315. * @returns the cascade projection matrix
  64316. */
  64317. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64318. /**
  64319. * Gets the transformation matrix corresponding to a given cascade
  64320. * @param cascadeNum cascade to retrieve the transformation matrix from
  64321. * @returns the cascade transformation matrix
  64322. */
  64323. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64324. private _depthRenderer;
  64325. /**
  64326. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64327. *
  64328. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64329. *
  64330. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64331. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64332. * @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
  64333. */
  64334. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64335. private _depthReducer;
  64336. private _autoCalcDepthBounds;
  64337. /**
  64338. * Gets or sets the autoCalcDepthBounds property.
  64339. *
  64340. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64341. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64342. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64343. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64344. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64345. */
  64346. get autoCalcDepthBounds(): boolean;
  64347. set autoCalcDepthBounds(value: boolean);
  64348. /**
  64349. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64350. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64351. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64352. * for setting the refresh rate on the renderer yourself!
  64353. */
  64354. get autoCalcDepthBoundsRefreshRate(): number;
  64355. set autoCalcDepthBoundsRefreshRate(value: number);
  64356. /**
  64357. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64358. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64359. * you change the camera near/far planes!
  64360. */
  64361. splitFrustum(): void;
  64362. private _splitFrustum;
  64363. private _computeMatrices;
  64364. private _computeFrustumInWorldSpace;
  64365. private _computeCascadeFrustum;
  64366. /**
  64367. * Support test.
  64368. */
  64369. static get IsSupported(): boolean;
  64370. /** @hidden */
  64371. static _SceneComponentInitialization: (scene: Scene) => void;
  64372. /**
  64373. * Creates a Cascaded Shadow Generator object.
  64374. * A ShadowGenerator is the required tool to use the shadows.
  64375. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64376. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64377. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64378. * @param light The directional light object generating the shadows.
  64379. * @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.
  64380. */
  64381. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64382. protected _initializeGenerator(): void;
  64383. protected _createTargetRenderTexture(): void;
  64384. protected _initializeShadowMap(): void;
  64385. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64386. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64387. /**
  64388. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64389. * @param defines Defines of the material we want to update
  64390. * @param lightIndex Index of the light in the enabled light list of the material
  64391. */
  64392. prepareDefines(defines: any, lightIndex: number): void;
  64393. /**
  64394. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64395. * defined in the generator but impacting the effect).
  64396. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64397. * @param effect The effect we are binfing the information for
  64398. */
  64399. bindShadowLight(lightIndex: string, effect: Effect): void;
  64400. /**
  64401. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64402. * (eq to view projection * shadow projection matrices)
  64403. * @returns The transform matrix used to create the shadow map
  64404. */
  64405. getTransformMatrix(): Matrix;
  64406. /**
  64407. * Disposes the ShadowGenerator.
  64408. * Returns nothing.
  64409. */
  64410. dispose(): void;
  64411. /**
  64412. * Serializes the shadow generator setup to a json object.
  64413. * @returns The serialized JSON object
  64414. */
  64415. serialize(): any;
  64416. /**
  64417. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64418. * @param parsedShadowGenerator The JSON object to parse
  64419. * @param scene The scene to create the shadow map for
  64420. * @returns The parsed shadow generator
  64421. */
  64422. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64423. }
  64424. }
  64425. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  64426. import { Scene } from "babylonjs/scene";
  64427. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  64428. import { AbstractScene } from "babylonjs/abstractScene";
  64429. /**
  64430. * Defines the shadow generator component responsible to manage any shadow generators
  64431. * in a given scene.
  64432. */
  64433. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64434. /**
  64435. * The component name helpfull to identify the component in the list of scene components.
  64436. */
  64437. readonly name: string;
  64438. /**
  64439. * The scene the component belongs to.
  64440. */
  64441. scene: Scene;
  64442. /**
  64443. * Creates a new instance of the component for the given scene
  64444. * @param scene Defines the scene to register the component in
  64445. */
  64446. constructor(scene: Scene);
  64447. /**
  64448. * Registers the component in a given scene
  64449. */
  64450. register(): void;
  64451. /**
  64452. * Rebuilds the elements related to this component in case of
  64453. * context lost for instance.
  64454. */
  64455. rebuild(): void;
  64456. /**
  64457. * Serializes the component data to the specified json object
  64458. * @param serializationObject The object to serialize to
  64459. */
  64460. serialize(serializationObject: any): void;
  64461. /**
  64462. * Adds all the elements from the container to the scene
  64463. * @param container the container holding the elements
  64464. */
  64465. addFromContainer(container: AbstractScene): void;
  64466. /**
  64467. * Removes all the elements in the container from the scene
  64468. * @param container contains the elements to remove
  64469. * @param dispose if the removed element should be disposed (default: false)
  64470. */
  64471. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64472. /**
  64473. * Rebuilds the elements related to this component in case of
  64474. * context lost for instance.
  64475. */
  64476. dispose(): void;
  64477. private _gatherRenderTargets;
  64478. }
  64479. }
  64480. declare module "babylonjs/Lights/Shadows/index" {
  64481. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  64482. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  64483. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  64484. }
  64485. declare module "babylonjs/Lights/pointLight" {
  64486. import { Scene } from "babylonjs/scene";
  64487. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64489. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  64490. import { Effect } from "babylonjs/Materials/effect";
  64491. /**
  64492. * A point light is a light defined by an unique point in world space.
  64493. * The light is emitted in every direction from this point.
  64494. * A good example of a point light is a standard light bulb.
  64495. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64496. */
  64497. export class PointLight extends ShadowLight {
  64498. private _shadowAngle;
  64499. /**
  64500. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64501. * This specifies what angle the shadow will use to be created.
  64502. *
  64503. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64504. */
  64505. get shadowAngle(): number;
  64506. /**
  64507. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64508. * This specifies what angle the shadow will use to be created.
  64509. *
  64510. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64511. */
  64512. set shadowAngle(value: number);
  64513. /**
  64514. * Gets the direction if it has been set.
  64515. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64516. */
  64517. get direction(): Vector3;
  64518. /**
  64519. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64520. */
  64521. set direction(value: Vector3);
  64522. /**
  64523. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64524. * A PointLight emits the light in every direction.
  64525. * It can cast shadows.
  64526. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64527. * ```javascript
  64528. * var pointLight = new PointLight("pl", camera.position, scene);
  64529. * ```
  64530. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64531. * @param name The light friendly name
  64532. * @param position The position of the point light in the scene
  64533. * @param scene The scene the lights belongs to
  64534. */
  64535. constructor(name: string, position: Vector3, scene: Scene);
  64536. /**
  64537. * Returns the string "PointLight"
  64538. * @returns the class name
  64539. */
  64540. getClassName(): string;
  64541. /**
  64542. * Returns the integer 0.
  64543. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64544. */
  64545. getTypeID(): number;
  64546. /**
  64547. * Specifies wether or not the shadowmap should be a cube texture.
  64548. * @returns true if the shadowmap needs to be a cube texture.
  64549. */
  64550. needCube(): boolean;
  64551. /**
  64552. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64553. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64554. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64555. */
  64556. getShadowDirection(faceIndex?: number): Vector3;
  64557. /**
  64558. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64559. * - fov = PI / 2
  64560. * - aspect ratio : 1.0
  64561. * - z-near and far equal to the active camera minZ and maxZ.
  64562. * Returns the PointLight.
  64563. */
  64564. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64565. protected _buildUniformLayout(): void;
  64566. /**
  64567. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64568. * @param effect The effect to update
  64569. * @param lightIndex The index of the light in the effect to update
  64570. * @returns The point light
  64571. */
  64572. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64573. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64574. /**
  64575. * Prepares the list of defines specific to the light type.
  64576. * @param defines the list of defines
  64577. * @param lightIndex defines the index of the light for the effect
  64578. */
  64579. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64580. }
  64581. }
  64582. declare module "babylonjs/Lights/index" {
  64583. export * from "babylonjs/Lights/light";
  64584. export * from "babylonjs/Lights/shadowLight";
  64585. export * from "babylonjs/Lights/Shadows/index";
  64586. export * from "babylonjs/Lights/directionalLight";
  64587. export * from "babylonjs/Lights/hemisphericLight";
  64588. export * from "babylonjs/Lights/pointLight";
  64589. export * from "babylonjs/Lights/spotLight";
  64590. }
  64591. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  64592. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64593. /**
  64594. * Header information of HDR texture files.
  64595. */
  64596. export interface HDRInfo {
  64597. /**
  64598. * The height of the texture in pixels.
  64599. */
  64600. height: number;
  64601. /**
  64602. * The width of the texture in pixels.
  64603. */
  64604. width: number;
  64605. /**
  64606. * The index of the beginning of the data in the binary file.
  64607. */
  64608. dataPosition: number;
  64609. }
  64610. /**
  64611. * This groups tools to convert HDR texture to native colors array.
  64612. */
  64613. export class HDRTools {
  64614. private static Ldexp;
  64615. private static Rgbe2float;
  64616. private static readStringLine;
  64617. /**
  64618. * Reads header information from an RGBE texture stored in a native array.
  64619. * More information on this format are available here:
  64620. * https://en.wikipedia.org/wiki/RGBE_image_format
  64621. *
  64622. * @param uint8array The binary file stored in native array.
  64623. * @return The header information.
  64624. */
  64625. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64626. /**
  64627. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64628. * This RGBE texture needs to store the information as a panorama.
  64629. *
  64630. * More information on this format are available here:
  64631. * https://en.wikipedia.org/wiki/RGBE_image_format
  64632. *
  64633. * @param buffer The binary file stored in an array buffer.
  64634. * @param size The expected size of the extracted cubemap.
  64635. * @return The Cube Map information.
  64636. */
  64637. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64638. /**
  64639. * Returns the pixels data extracted from an RGBE texture.
  64640. * This pixels will be stored left to right up to down in the R G B order in one array.
  64641. *
  64642. * More information on this format are available here:
  64643. * https://en.wikipedia.org/wiki/RGBE_image_format
  64644. *
  64645. * @param uint8array The binary file stored in an array buffer.
  64646. * @param hdrInfo The header information of the file.
  64647. * @return The pixels data in RGB right to left up to down order.
  64648. */
  64649. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64650. private static RGBE_ReadPixels_RLE;
  64651. private static RGBE_ReadPixels_NOT_RLE;
  64652. }
  64653. }
  64654. declare module "babylonjs/Materials/effectRenderer" {
  64655. import { Nullable } from "babylonjs/types";
  64656. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64657. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64658. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64659. import { Viewport } from "babylonjs/Maths/math.viewport";
  64660. import { Observable } from "babylonjs/Misc/observable";
  64661. import { Effect } from "babylonjs/Materials/effect";
  64662. import "babylonjs/Shaders/postprocess.vertex";
  64663. /**
  64664. * Effect Render Options
  64665. */
  64666. export interface IEffectRendererOptions {
  64667. /**
  64668. * Defines the vertices positions.
  64669. */
  64670. positions?: number[];
  64671. /**
  64672. * Defines the indices.
  64673. */
  64674. indices?: number[];
  64675. }
  64676. /**
  64677. * Helper class to render one or more effects.
  64678. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64679. */
  64680. export class EffectRenderer {
  64681. private engine;
  64682. private static _DefaultOptions;
  64683. private _vertexBuffers;
  64684. private _indexBuffer;
  64685. private _fullscreenViewport;
  64686. /**
  64687. * Creates an effect renderer
  64688. * @param engine the engine to use for rendering
  64689. * @param options defines the options of the effect renderer
  64690. */
  64691. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64692. /**
  64693. * Sets the current viewport in normalized coordinates 0-1
  64694. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64695. */
  64696. setViewport(viewport?: Viewport): void;
  64697. /**
  64698. * Binds the embedded attributes buffer to the effect.
  64699. * @param effect Defines the effect to bind the attributes for
  64700. */
  64701. bindBuffers(effect: Effect): void;
  64702. /**
  64703. * Sets the current effect wrapper to use during draw.
  64704. * The effect needs to be ready before calling this api.
  64705. * This also sets the default full screen position attribute.
  64706. * @param effectWrapper Defines the effect to draw with
  64707. */
  64708. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64709. /**
  64710. * Restores engine states
  64711. */
  64712. restoreStates(): void;
  64713. /**
  64714. * Draws a full screen quad.
  64715. */
  64716. draw(): void;
  64717. private isRenderTargetTexture;
  64718. /**
  64719. * renders one or more effects to a specified texture
  64720. * @param effectWrapper the effect to renderer
  64721. * @param outputTexture texture to draw to, if null it will render to the screen.
  64722. */
  64723. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64724. /**
  64725. * Disposes of the effect renderer
  64726. */
  64727. dispose(): void;
  64728. }
  64729. /**
  64730. * Options to create an EffectWrapper
  64731. */
  64732. interface EffectWrapperCreationOptions {
  64733. /**
  64734. * Engine to use to create the effect
  64735. */
  64736. engine: ThinEngine;
  64737. /**
  64738. * Fragment shader for the effect
  64739. */
  64740. fragmentShader: string;
  64741. /**
  64742. * Use the shader store instead of direct source code
  64743. */
  64744. useShaderStore?: boolean;
  64745. /**
  64746. * Vertex shader for the effect
  64747. */
  64748. vertexShader?: string;
  64749. /**
  64750. * Attributes to use in the shader
  64751. */
  64752. attributeNames?: Array<string>;
  64753. /**
  64754. * Uniforms to use in the shader
  64755. */
  64756. uniformNames?: Array<string>;
  64757. /**
  64758. * Texture sampler names to use in the shader
  64759. */
  64760. samplerNames?: Array<string>;
  64761. /**
  64762. * Defines to use in the shader
  64763. */
  64764. defines?: Array<string>;
  64765. /**
  64766. * Callback when effect is compiled
  64767. */
  64768. onCompiled?: Nullable<(effect: Effect) => void>;
  64769. /**
  64770. * The friendly name of the effect displayed in Spector.
  64771. */
  64772. name?: string;
  64773. }
  64774. /**
  64775. * Wraps an effect to be used for rendering
  64776. */
  64777. export class EffectWrapper {
  64778. /**
  64779. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64780. */
  64781. onApplyObservable: Observable<{}>;
  64782. /**
  64783. * The underlying effect
  64784. */
  64785. effect: Effect;
  64786. /**
  64787. * Creates an effect to be renderer
  64788. * @param creationOptions options to create the effect
  64789. */
  64790. constructor(creationOptions: EffectWrapperCreationOptions);
  64791. /**
  64792. * Disposes of the effect wrapper
  64793. */
  64794. dispose(): void;
  64795. }
  64796. }
  64797. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  64798. /** @hidden */
  64799. export var hdrFilteringVertexShader: {
  64800. name: string;
  64801. shader: string;
  64802. };
  64803. }
  64804. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  64805. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64806. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  64807. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  64808. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  64809. /** @hidden */
  64810. export var hdrFilteringPixelShader: {
  64811. name: string;
  64812. shader: string;
  64813. };
  64814. }
  64815. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64817. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64818. import { Nullable } from "babylonjs/types";
  64819. import "babylonjs/Shaders/hdrFiltering.vertex";
  64820. import "babylonjs/Shaders/hdrFiltering.fragment";
  64821. /**
  64822. * Options for texture filtering
  64823. */
  64824. interface IHDRFilteringOptions {
  64825. /**
  64826. * Scales pixel intensity for the input HDR map.
  64827. */
  64828. hdrScale?: number;
  64829. /**
  64830. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64831. */
  64832. quality?: number;
  64833. }
  64834. /**
  64835. * Filters HDR maps to get correct renderings of PBR reflections
  64836. */
  64837. export class HDRFiltering {
  64838. private _engine;
  64839. private _effectRenderer;
  64840. private _effectWrapper;
  64841. private _lodGenerationOffset;
  64842. private _lodGenerationScale;
  64843. /**
  64844. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64845. * you care about baking speed.
  64846. */
  64847. quality: number;
  64848. /**
  64849. * Scales pixel intensity for the input HDR map.
  64850. */
  64851. hdrScale: number;
  64852. /**
  64853. * Instantiates HDR filter for reflection maps
  64854. *
  64855. * @param engine Thin engine
  64856. * @param options Options
  64857. */
  64858. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64859. private _createRenderTarget;
  64860. private _prefilterInternal;
  64861. private _createEffect;
  64862. /**
  64863. * Get a value indicating if the filter is ready to be used
  64864. * @param texture Texture to filter
  64865. * @returns true if the filter is ready
  64866. */
  64867. isReady(texture: BaseTexture): boolean;
  64868. /**
  64869. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64870. * Prefiltering will be invoked at the end of next rendering pass.
  64871. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64872. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64873. * @param texture Texture to filter
  64874. * @param onFinished Callback when filtering is done
  64875. * @return Promise called when prefiltering is done
  64876. */
  64877. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64878. }
  64879. }
  64880. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64881. import { Nullable } from "babylonjs/types";
  64882. import { Scene } from "babylonjs/scene";
  64883. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64885. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64886. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64887. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64888. /**
  64889. * This represents a texture coming from an HDR input.
  64890. *
  64891. * The only supported format is currently panorama picture stored in RGBE format.
  64892. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64893. */
  64894. export class HDRCubeTexture extends BaseTexture {
  64895. private static _facesMapping;
  64896. private _generateHarmonics;
  64897. private _noMipmap;
  64898. private _prefilterOnLoad;
  64899. private _textureMatrix;
  64900. private _size;
  64901. private _onLoad;
  64902. private _onError;
  64903. /**
  64904. * The texture URL.
  64905. */
  64906. url: string;
  64907. protected _isBlocking: boolean;
  64908. /**
  64909. * Sets wether or not the texture is blocking during loading.
  64910. */
  64911. set isBlocking(value: boolean);
  64912. /**
  64913. * Gets wether or not the texture is blocking during loading.
  64914. */
  64915. get isBlocking(): boolean;
  64916. protected _rotationY: number;
  64917. /**
  64918. * Sets texture matrix rotation angle around Y axis in radians.
  64919. */
  64920. set rotationY(value: number);
  64921. /**
  64922. * Gets texture matrix rotation angle around Y axis radians.
  64923. */
  64924. get rotationY(): number;
  64925. /**
  64926. * Gets or sets the center of the bounding box associated with the cube texture
  64927. * It must define where the camera used to render the texture was set
  64928. */
  64929. boundingBoxPosition: Vector3;
  64930. private _boundingBoxSize;
  64931. /**
  64932. * Gets or sets the size of the bounding box associated with the cube texture
  64933. * When defined, the cubemap will switch to local mode
  64934. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64935. * @example https://www.babylonjs-playground.com/#RNASML
  64936. */
  64937. set boundingBoxSize(value: Vector3);
  64938. get boundingBoxSize(): Vector3;
  64939. /**
  64940. * Instantiates an HDRTexture from the following parameters.
  64941. *
  64942. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64943. * @param sceneOrEngine The scene or engine the texture will be used in
  64944. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64945. * @param noMipmap Forces to not generate the mipmap if true
  64946. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64947. * @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)
  64948. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64949. */
  64950. 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>);
  64951. /**
  64952. * Get the current class name of the texture useful for serialization or dynamic coding.
  64953. * @returns "HDRCubeTexture"
  64954. */
  64955. getClassName(): string;
  64956. /**
  64957. * Occurs when the file is raw .hdr file.
  64958. */
  64959. private loadTexture;
  64960. clone(): HDRCubeTexture;
  64961. delayLoad(): void;
  64962. /**
  64963. * Get the texture reflection matrix used to rotate/transform the reflection.
  64964. * @returns the reflection matrix
  64965. */
  64966. getReflectionTextureMatrix(): Matrix;
  64967. /**
  64968. * Set the texture reflection matrix used to rotate/transform the reflection.
  64969. * @param value Define the reflection matrix to set
  64970. */
  64971. setReflectionTextureMatrix(value: Matrix): void;
  64972. /**
  64973. * Parses a JSON representation of an HDR Texture in order to create the texture
  64974. * @param parsedTexture Define the JSON representation
  64975. * @param scene Define the scene the texture should be created in
  64976. * @param rootUrl Define the root url in case we need to load relative dependencies
  64977. * @returns the newly created texture after parsing
  64978. */
  64979. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64980. serialize(): any;
  64981. }
  64982. }
  64983. declare module "babylonjs/Physics/physicsEngine" {
  64984. import { Nullable } from "babylonjs/types";
  64985. import { Vector3 } from "babylonjs/Maths/math.vector";
  64986. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64987. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64988. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64989. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64990. /**
  64991. * Class used to control physics engine
  64992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64993. */
  64994. export class PhysicsEngine implements IPhysicsEngine {
  64995. private _physicsPlugin;
  64996. /**
  64997. * Global value used to control the smallest number supported by the simulation
  64998. */
  64999. static Epsilon: number;
  65000. private _impostors;
  65001. private _joints;
  65002. private _subTimeStep;
  65003. /**
  65004. * Gets the gravity vector used by the simulation
  65005. */
  65006. gravity: Vector3;
  65007. /**
  65008. * Factory used to create the default physics plugin.
  65009. * @returns The default physics plugin
  65010. */
  65011. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  65012. /**
  65013. * Creates a new Physics Engine
  65014. * @param gravity defines the gravity vector used by the simulation
  65015. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  65016. */
  65017. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  65018. /**
  65019. * Sets the gravity vector used by the simulation
  65020. * @param gravity defines the gravity vector to use
  65021. */
  65022. setGravity(gravity: Vector3): void;
  65023. /**
  65024. * Set the time step of the physics engine.
  65025. * Default is 1/60.
  65026. * To slow it down, enter 1/600 for example.
  65027. * To speed it up, 1/30
  65028. * @param newTimeStep defines the new timestep to apply to this world.
  65029. */
  65030. setTimeStep(newTimeStep?: number): void;
  65031. /**
  65032. * Get the time step of the physics engine.
  65033. * @returns the current time step
  65034. */
  65035. getTimeStep(): number;
  65036. /**
  65037. * Set the sub time step of the physics engine.
  65038. * Default is 0 meaning there is no sub steps
  65039. * To increase physics resolution precision, set a small value (like 1 ms)
  65040. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65041. */
  65042. setSubTimeStep(subTimeStep?: number): void;
  65043. /**
  65044. * Get the sub time step of the physics engine.
  65045. * @returns the current sub time step
  65046. */
  65047. getSubTimeStep(): number;
  65048. /**
  65049. * Release all resources
  65050. */
  65051. dispose(): void;
  65052. /**
  65053. * Gets the name of the current physics plugin
  65054. * @returns the name of the plugin
  65055. */
  65056. getPhysicsPluginName(): string;
  65057. /**
  65058. * Adding a new impostor for the impostor tracking.
  65059. * This will be done by the impostor itself.
  65060. * @param impostor the impostor to add
  65061. */
  65062. addImpostor(impostor: PhysicsImpostor): void;
  65063. /**
  65064. * Remove an impostor from the engine.
  65065. * This impostor and its mesh will not longer be updated by the physics engine.
  65066. * @param impostor the impostor to remove
  65067. */
  65068. removeImpostor(impostor: PhysicsImpostor): void;
  65069. /**
  65070. * Add a joint to the physics engine
  65071. * @param mainImpostor defines the main impostor to which the joint is added.
  65072. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65073. * @param joint defines the joint that will connect both impostors.
  65074. */
  65075. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65076. /**
  65077. * Removes a joint from the simulation
  65078. * @param mainImpostor defines the impostor used with the joint
  65079. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65080. * @param joint defines the joint to remove
  65081. */
  65082. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65083. /**
  65084. * Called by the scene. No need to call it.
  65085. * @param delta defines the timespam between frames
  65086. */
  65087. _step(delta: number): void;
  65088. /**
  65089. * Gets the current plugin used to run the simulation
  65090. * @returns current plugin
  65091. */
  65092. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65093. /**
  65094. * Gets the list of physic impostors
  65095. * @returns an array of PhysicsImpostor
  65096. */
  65097. getImpostors(): Array<PhysicsImpostor>;
  65098. /**
  65099. * Gets the impostor for a physics enabled object
  65100. * @param object defines the object impersonated by the impostor
  65101. * @returns the PhysicsImpostor or null if not found
  65102. */
  65103. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65104. /**
  65105. * Gets the impostor for a physics body object
  65106. * @param body defines physics body used by the impostor
  65107. * @returns the PhysicsImpostor or null if not found
  65108. */
  65109. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65110. /**
  65111. * Does a raycast in the physics world
  65112. * @param from when should the ray start?
  65113. * @param to when should the ray end?
  65114. * @returns PhysicsRaycastResult
  65115. */
  65116. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65117. }
  65118. }
  65119. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  65120. import { Nullable } from "babylonjs/types";
  65121. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65123. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65124. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65125. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65126. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65127. /** @hidden */
  65128. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65129. private _useDeltaForWorldStep;
  65130. world: any;
  65131. name: string;
  65132. private _physicsMaterials;
  65133. private _fixedTimeStep;
  65134. private _cannonRaycastResult;
  65135. private _raycastResult;
  65136. private _physicsBodysToRemoveAfterStep;
  65137. private _firstFrame;
  65138. BJSCANNON: any;
  65139. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65140. setGravity(gravity: Vector3): void;
  65141. setTimeStep(timeStep: number): void;
  65142. getTimeStep(): number;
  65143. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65144. private _removeMarkedPhysicsBodiesFromWorld;
  65145. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65146. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65147. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65148. private _processChildMeshes;
  65149. removePhysicsBody(impostor: PhysicsImpostor): void;
  65150. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65151. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65152. private _addMaterial;
  65153. private _checkWithEpsilon;
  65154. private _createShape;
  65155. private _createHeightmap;
  65156. private _minus90X;
  65157. private _plus90X;
  65158. private _tmpPosition;
  65159. private _tmpDeltaPosition;
  65160. private _tmpUnityRotation;
  65161. private _updatePhysicsBodyTransformation;
  65162. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65163. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65164. isSupported(): boolean;
  65165. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65166. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65167. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65168. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65169. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65170. getBodyMass(impostor: PhysicsImpostor): number;
  65171. getBodyFriction(impostor: PhysicsImpostor): number;
  65172. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65173. getBodyRestitution(impostor: PhysicsImpostor): number;
  65174. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65175. sleepBody(impostor: PhysicsImpostor): void;
  65176. wakeUpBody(impostor: PhysicsImpostor): void;
  65177. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65178. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65179. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65180. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65181. getRadius(impostor: PhysicsImpostor): number;
  65182. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65183. dispose(): void;
  65184. private _extendNamespace;
  65185. /**
  65186. * Does a raycast in the physics world
  65187. * @param from when should the ray start?
  65188. * @param to when should the ray end?
  65189. * @returns PhysicsRaycastResult
  65190. */
  65191. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65192. }
  65193. }
  65194. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  65195. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65196. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65197. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65199. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65200. import { Nullable } from "babylonjs/types";
  65201. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65202. /** @hidden */
  65203. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65204. private _useDeltaForWorldStep;
  65205. world: any;
  65206. name: string;
  65207. BJSOIMO: any;
  65208. private _raycastResult;
  65209. private _fixedTimeStep;
  65210. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65211. setGravity(gravity: Vector3): void;
  65212. setTimeStep(timeStep: number): void;
  65213. getTimeStep(): number;
  65214. private _tmpImpostorsArray;
  65215. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65216. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65217. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65218. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65219. private _tmpPositionVector;
  65220. removePhysicsBody(impostor: PhysicsImpostor): void;
  65221. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65222. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65223. isSupported(): boolean;
  65224. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65225. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65226. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65227. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65228. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65229. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65230. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65231. getBodyMass(impostor: PhysicsImpostor): number;
  65232. getBodyFriction(impostor: PhysicsImpostor): number;
  65233. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65234. getBodyRestitution(impostor: PhysicsImpostor): number;
  65235. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65236. sleepBody(impostor: PhysicsImpostor): void;
  65237. wakeUpBody(impostor: PhysicsImpostor): void;
  65238. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65239. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65240. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65241. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65242. getRadius(impostor: PhysicsImpostor): number;
  65243. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65244. dispose(): void;
  65245. /**
  65246. * Does a raycast in the physics world
  65247. * @param from when should the ray start?
  65248. * @param to when should the ray end?
  65249. * @returns PhysicsRaycastResult
  65250. */
  65251. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65252. }
  65253. }
  65254. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  65255. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  65256. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65257. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65258. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65259. import { Nullable } from "babylonjs/types";
  65260. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65261. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65262. /**
  65263. * AmmoJS Physics plugin
  65264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65265. * @see https://github.com/kripken/ammo.js/
  65266. */
  65267. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65268. private _useDeltaForWorldStep;
  65269. /**
  65270. * Reference to the Ammo library
  65271. */
  65272. bjsAMMO: any;
  65273. /**
  65274. * Created ammoJS world which physics bodies are added to
  65275. */
  65276. world: any;
  65277. /**
  65278. * Name of the plugin
  65279. */
  65280. name: string;
  65281. private _timeStep;
  65282. private _fixedTimeStep;
  65283. private _maxSteps;
  65284. private _tmpQuaternion;
  65285. private _tmpAmmoTransform;
  65286. private _tmpAmmoQuaternion;
  65287. private _tmpAmmoConcreteContactResultCallback;
  65288. private _collisionConfiguration;
  65289. private _dispatcher;
  65290. private _overlappingPairCache;
  65291. private _solver;
  65292. private _softBodySolver;
  65293. private _tmpAmmoVectorA;
  65294. private _tmpAmmoVectorB;
  65295. private _tmpAmmoVectorC;
  65296. private _tmpAmmoVectorD;
  65297. private _tmpContactCallbackResult;
  65298. private _tmpAmmoVectorRCA;
  65299. private _tmpAmmoVectorRCB;
  65300. private _raycastResult;
  65301. private _tmpContactPoint;
  65302. private static readonly DISABLE_COLLISION_FLAG;
  65303. private static readonly KINEMATIC_FLAG;
  65304. private static readonly DISABLE_DEACTIVATION_FLAG;
  65305. /**
  65306. * Initializes the ammoJS plugin
  65307. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65308. * @param ammoInjection can be used to inject your own ammo reference
  65309. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65310. */
  65311. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65312. /**
  65313. * Sets the gravity of the physics world (m/(s^2))
  65314. * @param gravity Gravity to set
  65315. */
  65316. setGravity(gravity: Vector3): void;
  65317. /**
  65318. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65319. * @param timeStep timestep to use in seconds
  65320. */
  65321. setTimeStep(timeStep: number): void;
  65322. /**
  65323. * 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)
  65324. * @param fixedTimeStep fixedTimeStep to use in seconds
  65325. */
  65326. setFixedTimeStep(fixedTimeStep: number): void;
  65327. /**
  65328. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65329. * @param maxSteps the maximum number of steps by the physics engine per frame
  65330. */
  65331. setMaxSteps(maxSteps: number): void;
  65332. /**
  65333. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65334. * @returns the current timestep in seconds
  65335. */
  65336. getTimeStep(): number;
  65337. /**
  65338. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65339. */
  65340. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65341. private _isImpostorInContact;
  65342. private _isImpostorPairInContact;
  65343. private _stepSimulation;
  65344. /**
  65345. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65346. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65347. * After the step the babylon meshes are set to the position of the physics imposters
  65348. * @param delta amount of time to step forward
  65349. * @param impostors array of imposters to update before/after the step
  65350. */
  65351. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65352. /**
  65353. * Update babylon mesh to match physics world object
  65354. * @param impostor imposter to match
  65355. */
  65356. private _afterSoftStep;
  65357. /**
  65358. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65359. * @param impostor imposter to match
  65360. */
  65361. private _ropeStep;
  65362. /**
  65363. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65364. * @param impostor imposter to match
  65365. */
  65366. private _softbodyOrClothStep;
  65367. private _tmpMatrix;
  65368. /**
  65369. * Applies an impulse on the imposter
  65370. * @param impostor imposter to apply impulse to
  65371. * @param force amount of force to be applied to the imposter
  65372. * @param contactPoint the location to apply the impulse on the imposter
  65373. */
  65374. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65375. /**
  65376. * Applies a force on the imposter
  65377. * @param impostor imposter to apply force
  65378. * @param force amount of force to be applied to the imposter
  65379. * @param contactPoint the location to apply the force on the imposter
  65380. */
  65381. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65382. /**
  65383. * Creates a physics body using the plugin
  65384. * @param impostor the imposter to create the physics body on
  65385. */
  65386. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65387. /**
  65388. * Removes the physics body from the imposter and disposes of the body's memory
  65389. * @param impostor imposter to remove the physics body from
  65390. */
  65391. removePhysicsBody(impostor: PhysicsImpostor): void;
  65392. /**
  65393. * Generates a joint
  65394. * @param impostorJoint the imposter joint to create the joint with
  65395. */
  65396. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65397. /**
  65398. * Removes a joint
  65399. * @param impostorJoint the imposter joint to remove the joint from
  65400. */
  65401. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65402. private _addMeshVerts;
  65403. /**
  65404. * Initialise the soft body vertices to match its object's (mesh) vertices
  65405. * Softbody vertices (nodes) are in world space and to match this
  65406. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65407. * @param impostor to create the softbody for
  65408. */
  65409. private _softVertexData;
  65410. /**
  65411. * Create an impostor's soft body
  65412. * @param impostor to create the softbody for
  65413. */
  65414. private _createSoftbody;
  65415. /**
  65416. * Create cloth for an impostor
  65417. * @param impostor to create the softbody for
  65418. */
  65419. private _createCloth;
  65420. /**
  65421. * Create rope for an impostor
  65422. * @param impostor to create the softbody for
  65423. */
  65424. private _createRope;
  65425. /**
  65426. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65427. * @param impostor to create the custom physics shape for
  65428. */
  65429. private _createCustom;
  65430. private _addHullVerts;
  65431. private _createShape;
  65432. /**
  65433. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65434. * @param impostor imposter containing the physics body and babylon object
  65435. */
  65436. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65437. /**
  65438. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65439. * @param impostor imposter containing the physics body and babylon object
  65440. * @param newPosition new position
  65441. * @param newRotation new rotation
  65442. */
  65443. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65444. /**
  65445. * If this plugin is supported
  65446. * @returns true if its supported
  65447. */
  65448. isSupported(): boolean;
  65449. /**
  65450. * Sets the linear velocity of the physics body
  65451. * @param impostor imposter to set the velocity on
  65452. * @param velocity velocity to set
  65453. */
  65454. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65455. /**
  65456. * Sets the angular velocity of the physics body
  65457. * @param impostor imposter to set the velocity on
  65458. * @param velocity velocity to set
  65459. */
  65460. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65461. /**
  65462. * gets the linear velocity
  65463. * @param impostor imposter to get linear velocity from
  65464. * @returns linear velocity
  65465. */
  65466. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65467. /**
  65468. * gets the angular velocity
  65469. * @param impostor imposter to get angular velocity from
  65470. * @returns angular velocity
  65471. */
  65472. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65473. /**
  65474. * Sets the mass of physics body
  65475. * @param impostor imposter to set the mass on
  65476. * @param mass mass to set
  65477. */
  65478. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65479. /**
  65480. * Gets the mass of the physics body
  65481. * @param impostor imposter to get the mass from
  65482. * @returns mass
  65483. */
  65484. getBodyMass(impostor: PhysicsImpostor): number;
  65485. /**
  65486. * Gets friction of the impostor
  65487. * @param impostor impostor to get friction from
  65488. * @returns friction value
  65489. */
  65490. getBodyFriction(impostor: PhysicsImpostor): number;
  65491. /**
  65492. * Sets friction of the impostor
  65493. * @param impostor impostor to set friction on
  65494. * @param friction friction value
  65495. */
  65496. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65497. /**
  65498. * Gets restitution of the impostor
  65499. * @param impostor impostor to get restitution from
  65500. * @returns restitution value
  65501. */
  65502. getBodyRestitution(impostor: PhysicsImpostor): number;
  65503. /**
  65504. * Sets resitution of the impostor
  65505. * @param impostor impostor to set resitution on
  65506. * @param restitution resitution value
  65507. */
  65508. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65509. /**
  65510. * Gets pressure inside the impostor
  65511. * @param impostor impostor to get pressure from
  65512. * @returns pressure value
  65513. */
  65514. getBodyPressure(impostor: PhysicsImpostor): number;
  65515. /**
  65516. * Sets pressure inside a soft body impostor
  65517. * Cloth and rope must remain 0 pressure
  65518. * @param impostor impostor to set pressure on
  65519. * @param pressure pressure value
  65520. */
  65521. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65522. /**
  65523. * Gets stiffness of the impostor
  65524. * @param impostor impostor to get stiffness from
  65525. * @returns pressure value
  65526. */
  65527. getBodyStiffness(impostor: PhysicsImpostor): number;
  65528. /**
  65529. * Sets stiffness of the impostor
  65530. * @param impostor impostor to set stiffness on
  65531. * @param stiffness stiffness value from 0 to 1
  65532. */
  65533. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65534. /**
  65535. * Gets velocityIterations of the impostor
  65536. * @param impostor impostor to get velocity iterations from
  65537. * @returns velocityIterations value
  65538. */
  65539. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65540. /**
  65541. * Sets velocityIterations of the impostor
  65542. * @param impostor impostor to set velocity iterations on
  65543. * @param velocityIterations velocityIterations value
  65544. */
  65545. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65546. /**
  65547. * Gets positionIterations of the impostor
  65548. * @param impostor impostor to get position iterations from
  65549. * @returns positionIterations value
  65550. */
  65551. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65552. /**
  65553. * Sets positionIterations of the impostor
  65554. * @param impostor impostor to set position on
  65555. * @param positionIterations positionIterations value
  65556. */
  65557. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65558. /**
  65559. * Append an anchor to a cloth object
  65560. * @param impostor is the cloth impostor to add anchor to
  65561. * @param otherImpostor is the rigid impostor to anchor to
  65562. * @param width ratio across width from 0 to 1
  65563. * @param height ratio up height from 0 to 1
  65564. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65565. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65566. */
  65567. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65568. /**
  65569. * Append an hook to a rope object
  65570. * @param impostor is the rope impostor to add hook to
  65571. * @param otherImpostor is the rigid impostor to hook to
  65572. * @param length ratio along the rope from 0 to 1
  65573. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65574. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65575. */
  65576. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65577. /**
  65578. * Sleeps the physics body and stops it from being active
  65579. * @param impostor impostor to sleep
  65580. */
  65581. sleepBody(impostor: PhysicsImpostor): void;
  65582. /**
  65583. * Activates the physics body
  65584. * @param impostor impostor to activate
  65585. */
  65586. wakeUpBody(impostor: PhysicsImpostor): void;
  65587. /**
  65588. * Updates the distance parameters of the joint
  65589. * @param joint joint to update
  65590. * @param maxDistance maximum distance of the joint
  65591. * @param minDistance minimum distance of the joint
  65592. */
  65593. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65594. /**
  65595. * Sets a motor on the joint
  65596. * @param joint joint to set motor on
  65597. * @param speed speed of the motor
  65598. * @param maxForce maximum force of the motor
  65599. * @param motorIndex index of the motor
  65600. */
  65601. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65602. /**
  65603. * Sets the motors limit
  65604. * @param joint joint to set limit on
  65605. * @param upperLimit upper limit
  65606. * @param lowerLimit lower limit
  65607. */
  65608. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65609. /**
  65610. * Syncs the position and rotation of a mesh with the impostor
  65611. * @param mesh mesh to sync
  65612. * @param impostor impostor to update the mesh with
  65613. */
  65614. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65615. /**
  65616. * Gets the radius of the impostor
  65617. * @param impostor impostor to get radius from
  65618. * @returns the radius
  65619. */
  65620. getRadius(impostor: PhysicsImpostor): number;
  65621. /**
  65622. * Gets the box size of the impostor
  65623. * @param impostor impostor to get box size from
  65624. * @param result the resulting box size
  65625. */
  65626. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65627. /**
  65628. * Disposes of the impostor
  65629. */
  65630. dispose(): void;
  65631. /**
  65632. * Does a raycast in the physics world
  65633. * @param from when should the ray start?
  65634. * @param to when should the ray end?
  65635. * @returns PhysicsRaycastResult
  65636. */
  65637. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65638. }
  65639. }
  65640. declare module "babylonjs/Probes/reflectionProbe" {
  65641. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65642. import { Vector3 } from "babylonjs/Maths/math.vector";
  65643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65644. import { Nullable } from "babylonjs/types";
  65645. import { Scene } from "babylonjs/scene";
  65646. module "babylonjs/abstractScene" {
  65647. interface AbstractScene {
  65648. /**
  65649. * The list of reflection probes added to the scene
  65650. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65651. */
  65652. reflectionProbes: Array<ReflectionProbe>;
  65653. /**
  65654. * Removes the given reflection probe from this scene.
  65655. * @param toRemove The reflection probe to remove
  65656. * @returns The index of the removed reflection probe
  65657. */
  65658. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65659. /**
  65660. * Adds the given reflection probe to this scene.
  65661. * @param newReflectionProbe The reflection probe to add
  65662. */
  65663. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65664. }
  65665. }
  65666. /**
  65667. * Class used to generate realtime reflection / refraction cube textures
  65668. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65669. */
  65670. export class ReflectionProbe {
  65671. /** defines the name of the probe */
  65672. name: string;
  65673. private _scene;
  65674. private _renderTargetTexture;
  65675. private _projectionMatrix;
  65676. private _viewMatrix;
  65677. private _target;
  65678. private _add;
  65679. private _attachedMesh;
  65680. private _invertYAxis;
  65681. /** Gets or sets probe position (center of the cube map) */
  65682. position: Vector3;
  65683. /**
  65684. * Creates a new reflection probe
  65685. * @param name defines the name of the probe
  65686. * @param size defines the texture resolution (for each face)
  65687. * @param scene defines the hosting scene
  65688. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65689. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65690. */
  65691. constructor(
  65692. /** defines the name of the probe */
  65693. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65694. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65695. get samples(): number;
  65696. set samples(value: number);
  65697. /** Gets or sets the refresh rate to use (on every frame by default) */
  65698. get refreshRate(): number;
  65699. set refreshRate(value: number);
  65700. /**
  65701. * Gets the hosting scene
  65702. * @returns a Scene
  65703. */
  65704. getScene(): Scene;
  65705. /** Gets the internal CubeTexture used to render to */
  65706. get cubeTexture(): RenderTargetTexture;
  65707. /** Gets the list of meshes to render */
  65708. get renderList(): Nullable<AbstractMesh[]>;
  65709. /**
  65710. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65711. * @param mesh defines the mesh to attach to
  65712. */
  65713. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65714. /**
  65715. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65716. * @param renderingGroupId The rendering group id corresponding to its index
  65717. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65718. */
  65719. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65720. /**
  65721. * Clean all associated resources
  65722. */
  65723. dispose(): void;
  65724. /**
  65725. * Converts the reflection probe information to a readable string for debug purpose.
  65726. * @param fullDetails Supports for multiple levels of logging within scene loading
  65727. * @returns the human readable reflection probe info
  65728. */
  65729. toString(fullDetails?: boolean): string;
  65730. /**
  65731. * Get the class name of the relfection probe.
  65732. * @returns "ReflectionProbe"
  65733. */
  65734. getClassName(): string;
  65735. /**
  65736. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65737. * @returns The JSON representation of the texture
  65738. */
  65739. serialize(): any;
  65740. /**
  65741. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65742. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65743. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65744. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65745. * @returns The parsed reflection probe if successful
  65746. */
  65747. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65748. }
  65749. }
  65750. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  65751. /** @hidden */
  65752. export var _BabylonLoaderRegistered: boolean;
  65753. /**
  65754. * Helps setting up some configuration for the babylon file loader.
  65755. */
  65756. export class BabylonFileLoaderConfiguration {
  65757. /**
  65758. * The loader does not allow injecting custom physix engine into the plugins.
  65759. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65760. * So you could set this variable to your engine import to make it work.
  65761. */
  65762. static LoaderInjectedPhysicsEngine: any;
  65763. }
  65764. }
  65765. declare module "babylonjs/Loading/Plugins/index" {
  65766. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  65767. }
  65768. declare module "babylonjs/Loading/index" {
  65769. export * from "babylonjs/Loading/loadingScreen";
  65770. export * from "babylonjs/Loading/Plugins/index";
  65771. export * from "babylonjs/Loading/sceneLoader";
  65772. export * from "babylonjs/Loading/sceneLoaderFlags";
  65773. }
  65774. declare module "babylonjs/Materials/Background/index" {
  65775. export * from "babylonjs/Materials/Background/backgroundMaterial";
  65776. }
  65777. declare module "babylonjs/Materials/Occlusion/occlusionMaterial" {
  65778. import { Scene } from "babylonjs/scene";
  65779. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  65780. import "babylonjs/Shaders/color.fragment";
  65781. import "babylonjs/Shaders/color.vertex";
  65782. /**
  65783. * A material to use for fast depth-only rendering.
  65784. */
  65785. export class OcclusionMaterial extends ShaderMaterial {
  65786. constructor(name: string, scene: Scene);
  65787. }
  65788. }
  65789. declare module "babylonjs/Materials/Occlusion/index" {
  65790. export * from "babylonjs/Materials/Occlusion/occlusionMaterial";
  65791. }
  65792. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  65793. import { Scene } from "babylonjs/scene";
  65794. import { Color3 } from "babylonjs/Maths/math.color";
  65795. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65796. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65797. /**
  65798. * The Physically based simple base material of BJS.
  65799. *
  65800. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65801. * It is used as the base class for both the specGloss and metalRough conventions.
  65802. */
  65803. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65804. /**
  65805. * Number of Simultaneous lights allowed on the material.
  65806. */
  65807. maxSimultaneousLights: number;
  65808. /**
  65809. * If sets to true, disables all the lights affecting the material.
  65810. */
  65811. disableLighting: boolean;
  65812. /**
  65813. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65814. */
  65815. environmentTexture: BaseTexture;
  65816. /**
  65817. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65818. */
  65819. invertNormalMapX: boolean;
  65820. /**
  65821. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65822. */
  65823. invertNormalMapY: boolean;
  65824. /**
  65825. * Normal map used in the model.
  65826. */
  65827. normalTexture: BaseTexture;
  65828. /**
  65829. * Emissivie color used to self-illuminate the model.
  65830. */
  65831. emissiveColor: Color3;
  65832. /**
  65833. * Emissivie texture used to self-illuminate the model.
  65834. */
  65835. emissiveTexture: BaseTexture;
  65836. /**
  65837. * Occlusion Channel Strenght.
  65838. */
  65839. occlusionStrength: number;
  65840. /**
  65841. * Occlusion Texture of the material (adding extra occlusion effects).
  65842. */
  65843. occlusionTexture: BaseTexture;
  65844. /**
  65845. * Defines the alpha limits in alpha test mode.
  65846. */
  65847. alphaCutOff: number;
  65848. /**
  65849. * Gets the current double sided mode.
  65850. */
  65851. get doubleSided(): boolean;
  65852. /**
  65853. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65854. */
  65855. set doubleSided(value: boolean);
  65856. /**
  65857. * Stores the pre-calculated light information of a mesh in a texture.
  65858. */
  65859. lightmapTexture: BaseTexture;
  65860. /**
  65861. * If true, the light map contains occlusion information instead of lighting info.
  65862. */
  65863. useLightmapAsShadowmap: boolean;
  65864. /**
  65865. * Instantiates a new PBRMaterial instance.
  65866. *
  65867. * @param name The material name
  65868. * @param scene The scene the material will be use in.
  65869. */
  65870. constructor(name: string, scene: Scene);
  65871. getClassName(): string;
  65872. }
  65873. }
  65874. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65875. import { Scene } from "babylonjs/scene";
  65876. import { Color3 } from "babylonjs/Maths/math.color";
  65877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65878. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65879. /**
  65880. * The PBR material of BJS following the metal roughness convention.
  65881. *
  65882. * This fits to the PBR convention in the GLTF definition:
  65883. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65884. */
  65885. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65886. /**
  65887. * The base color has two different interpretations depending on the value of metalness.
  65888. * When the material is a metal, the base color is the specific measured reflectance value
  65889. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65890. * of the material.
  65891. */
  65892. baseColor: Color3;
  65893. /**
  65894. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65895. * well as opacity information in the alpha channel.
  65896. */
  65897. baseTexture: BaseTexture;
  65898. /**
  65899. * Specifies the metallic scalar value of the material.
  65900. * Can also be used to scale the metalness values of the metallic texture.
  65901. */
  65902. metallic: number;
  65903. /**
  65904. * Specifies the roughness scalar value of the material.
  65905. * Can also be used to scale the roughness values of the metallic texture.
  65906. */
  65907. roughness: number;
  65908. /**
  65909. * Texture containing both the metallic value in the B channel and the
  65910. * roughness value in the G channel to keep better precision.
  65911. */
  65912. metallicRoughnessTexture: BaseTexture;
  65913. /**
  65914. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65915. *
  65916. * @param name The material name
  65917. * @param scene The scene the material will be use in.
  65918. */
  65919. constructor(name: string, scene: Scene);
  65920. /**
  65921. * Return the currrent class name of the material.
  65922. */
  65923. getClassName(): string;
  65924. /**
  65925. * Makes a duplicate of the current material.
  65926. * @param name - name to use for the new material.
  65927. */
  65928. clone(name: string): PBRMetallicRoughnessMaterial;
  65929. /**
  65930. * Serialize the material to a parsable JSON object.
  65931. */
  65932. serialize(): any;
  65933. /**
  65934. * Parses a JSON object correponding to the serialize function.
  65935. */
  65936. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65937. }
  65938. }
  65939. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65940. import { Scene } from "babylonjs/scene";
  65941. import { Color3 } from "babylonjs/Maths/math.color";
  65942. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65943. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65944. /**
  65945. * The PBR material of BJS following the specular glossiness convention.
  65946. *
  65947. * This fits to the PBR convention in the GLTF definition:
  65948. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65949. */
  65950. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65951. /**
  65952. * Specifies the diffuse color of the material.
  65953. */
  65954. diffuseColor: Color3;
  65955. /**
  65956. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65957. * channel.
  65958. */
  65959. diffuseTexture: BaseTexture;
  65960. /**
  65961. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65962. */
  65963. specularColor: Color3;
  65964. /**
  65965. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65966. */
  65967. glossiness: number;
  65968. /**
  65969. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65970. */
  65971. specularGlossinessTexture: BaseTexture;
  65972. /**
  65973. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65974. *
  65975. * @param name The material name
  65976. * @param scene The scene the material will be use in.
  65977. */
  65978. constructor(name: string, scene: Scene);
  65979. /**
  65980. * Return the currrent class name of the material.
  65981. */
  65982. getClassName(): string;
  65983. /**
  65984. * Makes a duplicate of the current material.
  65985. * @param name - name to use for the new material.
  65986. */
  65987. clone(name: string): PBRSpecularGlossinessMaterial;
  65988. /**
  65989. * Serialize the material to a parsable JSON object.
  65990. */
  65991. serialize(): any;
  65992. /**
  65993. * Parses a JSON object correponding to the serialize function.
  65994. */
  65995. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65996. }
  65997. }
  65998. declare module "babylonjs/Materials/PBR/index" {
  65999. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  66000. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  66001. export * from "babylonjs/Materials/PBR/pbrMaterial";
  66002. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  66003. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  66004. }
  66005. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  66006. import { Nullable } from "babylonjs/types";
  66007. import { Scene } from "babylonjs/scene";
  66008. import { Matrix } from "babylonjs/Maths/math.vector";
  66009. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66010. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  66011. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66012. /**
  66013. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  66014. * It can help converting any input color in a desired output one. This can then be used to create effects
  66015. * from sepia, black and white to sixties or futuristic rendering...
  66016. *
  66017. * The only supported format is currently 3dl.
  66018. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  66019. */
  66020. export class ColorGradingTexture extends BaseTexture {
  66021. /**
  66022. * The texture URL.
  66023. */
  66024. url: string;
  66025. /**
  66026. * Empty line regex stored for GC.
  66027. */
  66028. private static _noneEmptyLineRegex;
  66029. private _textureMatrix;
  66030. private _onLoad;
  66031. /**
  66032. * Instantiates a ColorGradingTexture from the following parameters.
  66033. *
  66034. * @param url The location of the color gradind data (currently only supporting 3dl)
  66035. * @param sceneOrEngine The scene or engine the texture will be used in
  66036. * @param onLoad defines a callback triggered when the texture has been loaded
  66037. */
  66038. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66039. /**
  66040. * Fires the onload event from the constructor if requested.
  66041. */
  66042. private _triggerOnLoad;
  66043. /**
  66044. * Returns the texture matrix used in most of the material.
  66045. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66046. */
  66047. getTextureMatrix(): Matrix;
  66048. /**
  66049. * Occurs when the file being loaded is a .3dl LUT file.
  66050. */
  66051. private load3dlTexture;
  66052. /**
  66053. * Starts the loading process of the texture.
  66054. */
  66055. private loadTexture;
  66056. /**
  66057. * Clones the color gradind texture.
  66058. */
  66059. clone(): ColorGradingTexture;
  66060. /**
  66061. * Called during delayed load for textures.
  66062. */
  66063. delayLoad(): void;
  66064. /**
  66065. * Parses a color grading texture serialized by Babylon.
  66066. * @param parsedTexture The texture information being parsedTexture
  66067. * @param scene The scene to load the texture in
  66068. * @param rootUrl The root url of the data assets to load
  66069. * @return A color gradind texture
  66070. */
  66071. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66072. /**
  66073. * Serializes the LUT texture to json format.
  66074. */
  66075. serialize(): any;
  66076. }
  66077. }
  66078. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  66079. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66080. import { Scene } from "babylonjs/scene";
  66081. import { Nullable } from "babylonjs/types";
  66082. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66083. /**
  66084. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66085. */
  66086. export class EquiRectangularCubeTexture extends BaseTexture {
  66087. /** The six faces of the cube. */
  66088. private static _FacesMapping;
  66089. private _noMipmap;
  66090. private _onLoad;
  66091. private _onError;
  66092. /** The size of the cubemap. */
  66093. private _size;
  66094. /** The buffer of the image. */
  66095. private _buffer;
  66096. /** The width of the input image. */
  66097. private _width;
  66098. /** The height of the input image. */
  66099. private _height;
  66100. /** The URL to the image. */
  66101. url: string;
  66102. /**
  66103. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66104. * @param url The location of the image
  66105. * @param scene The scene the texture will be used in
  66106. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66107. * @param noMipmap Forces to not generate the mipmap if true
  66108. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66109. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66110. * @param onLoad — defines a callback called when texture is loaded
  66111. * @param onError — defines a callback called if there is an error
  66112. */
  66113. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66114. /**
  66115. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66116. */
  66117. private loadImage;
  66118. /**
  66119. * Convert the image buffer into a cubemap and create a CubeTexture.
  66120. */
  66121. private loadTexture;
  66122. /**
  66123. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66124. * @param buffer The ArrayBuffer that should be converted.
  66125. * @returns The buffer as Float32Array.
  66126. */
  66127. private getFloat32ArrayFromArrayBuffer;
  66128. /**
  66129. * Get the current class name of the texture useful for serialization or dynamic coding.
  66130. * @returns "EquiRectangularCubeTexture"
  66131. */
  66132. getClassName(): string;
  66133. /**
  66134. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66135. * @returns A clone of the current EquiRectangularCubeTexture.
  66136. */
  66137. clone(): EquiRectangularCubeTexture;
  66138. }
  66139. }
  66140. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  66141. import { Nullable } from "babylonjs/types";
  66142. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66143. import { Matrix } from "babylonjs/Maths/math.vector";
  66144. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  66145. import "babylonjs/Engines/Extensions/engine.videoTexture";
  66146. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  66147. import { Scene } from "babylonjs/scene";
  66148. /**
  66149. * Defines the options related to the creation of an HtmlElementTexture
  66150. */
  66151. export interface IHtmlElementTextureOptions {
  66152. /**
  66153. * Defines wether mip maps should be created or not.
  66154. */
  66155. generateMipMaps?: boolean;
  66156. /**
  66157. * Defines the sampling mode of the texture.
  66158. */
  66159. samplingMode?: number;
  66160. /**
  66161. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66162. */
  66163. engine: Nullable<ThinEngine>;
  66164. /**
  66165. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66166. */
  66167. scene: Nullable<Scene>;
  66168. }
  66169. /**
  66170. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66171. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66172. * is automatically managed.
  66173. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66174. * in your application.
  66175. *
  66176. * As the update is not automatic, you need to call them manually.
  66177. */
  66178. export class HtmlElementTexture extends BaseTexture {
  66179. /**
  66180. * The texture URL.
  66181. */
  66182. element: HTMLVideoElement | HTMLCanvasElement;
  66183. private static readonly DefaultOptions;
  66184. private _textureMatrix;
  66185. private _isVideo;
  66186. private _generateMipMaps;
  66187. private _samplingMode;
  66188. /**
  66189. * Instantiates a HtmlElementTexture from the following parameters.
  66190. *
  66191. * @param name Defines the name of the texture
  66192. * @param element Defines the video or canvas the texture is filled with
  66193. * @param options Defines the other none mandatory texture creation options
  66194. */
  66195. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66196. private _createInternalTexture;
  66197. /**
  66198. * Returns the texture matrix used in most of the material.
  66199. */
  66200. getTextureMatrix(): Matrix;
  66201. /**
  66202. * Updates the content of the texture.
  66203. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66204. */
  66205. update(invertY?: Nullable<boolean>): void;
  66206. }
  66207. }
  66208. declare module "babylonjs/Misc/tga" {
  66209. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66210. /**
  66211. * Based on jsTGALoader - Javascript loader for TGA file
  66212. * By Vincent Thibault
  66213. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66214. */
  66215. export class TGATools {
  66216. private static _TYPE_INDEXED;
  66217. private static _TYPE_RGB;
  66218. private static _TYPE_GREY;
  66219. private static _TYPE_RLE_INDEXED;
  66220. private static _TYPE_RLE_RGB;
  66221. private static _TYPE_RLE_GREY;
  66222. private static _ORIGIN_MASK;
  66223. private static _ORIGIN_SHIFT;
  66224. private static _ORIGIN_BL;
  66225. private static _ORIGIN_BR;
  66226. private static _ORIGIN_UL;
  66227. private static _ORIGIN_UR;
  66228. /**
  66229. * Gets the header of a TGA file
  66230. * @param data defines the TGA data
  66231. * @returns the header
  66232. */
  66233. static GetTGAHeader(data: Uint8Array): any;
  66234. /**
  66235. * Uploads TGA content to a Babylon Texture
  66236. * @hidden
  66237. */
  66238. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66239. /** @hidden */
  66240. 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;
  66241. /** @hidden */
  66242. 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;
  66243. /** @hidden */
  66244. 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;
  66245. /** @hidden */
  66246. 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;
  66247. /** @hidden */
  66248. 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;
  66249. /** @hidden */
  66250. 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;
  66251. }
  66252. }
  66253. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  66254. import { Nullable } from "babylonjs/types";
  66255. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66256. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66257. /**
  66258. * Implementation of the TGA Texture Loader.
  66259. * @hidden
  66260. */
  66261. export class _TGATextureLoader implements IInternalTextureLoader {
  66262. /**
  66263. * Defines wether the loader supports cascade loading the different faces.
  66264. */
  66265. readonly supportCascades: boolean;
  66266. /**
  66267. * This returns if the loader support the current file information.
  66268. * @param extension defines the file extension of the file being loaded
  66269. * @returns true if the loader can load the specified file
  66270. */
  66271. canLoad(extension: string): boolean;
  66272. /**
  66273. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66274. * @param data contains the texture data
  66275. * @param texture defines the BabylonJS internal texture
  66276. * @param createPolynomials will be true if polynomials have been requested
  66277. * @param onLoad defines the callback to trigger once the texture is ready
  66278. * @param onError defines the callback to trigger in case of error
  66279. */
  66280. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66281. /**
  66282. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66283. * @param data contains the texture data
  66284. * @param texture defines the BabylonJS internal texture
  66285. * @param callback defines the method to call once ready to upload
  66286. */
  66287. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66288. }
  66289. }
  66290. declare module "babylonjs/Misc/basis" {
  66291. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66292. /**
  66293. * Info about the .basis files
  66294. */
  66295. class BasisFileInfo {
  66296. /**
  66297. * If the file has alpha
  66298. */
  66299. hasAlpha: boolean;
  66300. /**
  66301. * Info about each image of the basis file
  66302. */
  66303. images: Array<{
  66304. levels: Array<{
  66305. width: number;
  66306. height: number;
  66307. transcodedPixels: ArrayBufferView;
  66308. }>;
  66309. }>;
  66310. }
  66311. /**
  66312. * Result of transcoding a basis file
  66313. */
  66314. class TranscodeResult {
  66315. /**
  66316. * Info about the .basis file
  66317. */
  66318. fileInfo: BasisFileInfo;
  66319. /**
  66320. * Format to use when loading the file
  66321. */
  66322. format: number;
  66323. }
  66324. /**
  66325. * Configuration options for the Basis transcoder
  66326. */
  66327. export class BasisTranscodeConfiguration {
  66328. /**
  66329. * Supported compression formats used to determine the supported output format of the transcoder
  66330. */
  66331. supportedCompressionFormats?: {
  66332. /**
  66333. * etc1 compression format
  66334. */
  66335. etc1?: boolean;
  66336. /**
  66337. * s3tc compression format
  66338. */
  66339. s3tc?: boolean;
  66340. /**
  66341. * pvrtc compression format
  66342. */
  66343. pvrtc?: boolean;
  66344. /**
  66345. * etc2 compression format
  66346. */
  66347. etc2?: boolean;
  66348. };
  66349. /**
  66350. * If mipmap levels should be loaded for transcoded images (Default: true)
  66351. */
  66352. loadMipmapLevels?: boolean;
  66353. /**
  66354. * Index of a single image to load (Default: all images)
  66355. */
  66356. loadSingleImage?: number;
  66357. }
  66358. /**
  66359. * Used to load .Basis files
  66360. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66361. */
  66362. export class BasisTools {
  66363. private static _IgnoreSupportedFormats;
  66364. /**
  66365. * URL to use when loading the basis transcoder
  66366. */
  66367. static JSModuleURL: string;
  66368. /**
  66369. * URL to use when loading the wasm module for the transcoder
  66370. */
  66371. static WasmModuleURL: string;
  66372. /**
  66373. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66374. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66375. * @returns internal format corresponding to the Basis format
  66376. */
  66377. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66378. private static _WorkerPromise;
  66379. private static _Worker;
  66380. private static _actionId;
  66381. private static _CreateWorkerAsync;
  66382. /**
  66383. * Transcodes a loaded image file to compressed pixel data
  66384. * @param data image data to transcode
  66385. * @param config configuration options for the transcoding
  66386. * @returns a promise resulting in the transcoded image
  66387. */
  66388. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66389. /**
  66390. * Loads a texture from the transcode result
  66391. * @param texture texture load to
  66392. * @param transcodeResult the result of transcoding the basis file to load from
  66393. */
  66394. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66395. }
  66396. }
  66397. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  66398. import { Nullable } from "babylonjs/types";
  66399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66400. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66401. /**
  66402. * Loader for .basis file format
  66403. */
  66404. export class _BasisTextureLoader implements IInternalTextureLoader {
  66405. /**
  66406. * Defines whether the loader supports cascade loading the different faces.
  66407. */
  66408. readonly supportCascades: boolean;
  66409. /**
  66410. * This returns if the loader support the current file information.
  66411. * @param extension defines the file extension of the file being loaded
  66412. * @returns true if the loader can load the specified file
  66413. */
  66414. canLoad(extension: string): boolean;
  66415. /**
  66416. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66417. * @param data contains the texture data
  66418. * @param texture defines the BabylonJS internal texture
  66419. * @param createPolynomials will be true if polynomials have been requested
  66420. * @param onLoad defines the callback to trigger once the texture is ready
  66421. * @param onError defines the callback to trigger in case of error
  66422. */
  66423. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66424. /**
  66425. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66426. * @param data contains the texture data
  66427. * @param texture defines the BabylonJS internal texture
  66428. * @param callback defines the method to call once ready to upload
  66429. */
  66430. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66431. }
  66432. }
  66433. declare module "babylonjs/Materials/Textures/Loaders/index" {
  66434. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  66435. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  66436. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  66437. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  66438. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  66439. }
  66440. declare module "babylonjs/Materials/Textures/Packer/frame" {
  66441. import { Vector2 } from "babylonjs/Maths/math.vector";
  66442. /**
  66443. * Defines the basic options interface of a TexturePacker Frame
  66444. */
  66445. export interface ITexturePackerFrame {
  66446. /**
  66447. * The frame ID
  66448. */
  66449. id: number;
  66450. /**
  66451. * The frames Scale
  66452. */
  66453. scale: Vector2;
  66454. /**
  66455. * The Frames offset
  66456. */
  66457. offset: Vector2;
  66458. }
  66459. /**
  66460. * This is a support class for frame Data on texture packer sets.
  66461. */
  66462. export class TexturePackerFrame implements ITexturePackerFrame {
  66463. /**
  66464. * The frame ID
  66465. */
  66466. id: number;
  66467. /**
  66468. * The frames Scale
  66469. */
  66470. scale: Vector2;
  66471. /**
  66472. * The Frames offset
  66473. */
  66474. offset: Vector2;
  66475. /**
  66476. * Initializes a texture package frame.
  66477. * @param id The numerical frame identifier
  66478. * @param scale Scalar Vector2 for UV frame
  66479. * @param offset Vector2 for the frame position in UV units.
  66480. * @returns TexturePackerFrame
  66481. */
  66482. constructor(id: number, scale: Vector2, offset: Vector2);
  66483. }
  66484. }
  66485. declare module "babylonjs/Materials/Textures/Packer/packer" {
  66486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66487. import { Scene } from "babylonjs/scene";
  66488. import { Nullable } from "babylonjs/types";
  66489. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  66490. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  66491. /**
  66492. * Defines the basic options interface of a TexturePacker
  66493. */
  66494. export interface ITexturePackerOptions {
  66495. /**
  66496. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66497. */
  66498. map?: string[];
  66499. /**
  66500. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66501. */
  66502. uvsIn?: string;
  66503. /**
  66504. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66505. */
  66506. uvsOut?: string;
  66507. /**
  66508. * number representing the layout style. Defaults to LAYOUT_STRIP
  66509. */
  66510. layout?: number;
  66511. /**
  66512. * number of columns if using custom column count layout(2). This defaults to 4.
  66513. */
  66514. colnum?: number;
  66515. /**
  66516. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66517. */
  66518. updateInputMeshes?: boolean;
  66519. /**
  66520. * boolean flag to dispose all the source textures. Defaults to true.
  66521. */
  66522. disposeSources?: boolean;
  66523. /**
  66524. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66525. */
  66526. fillBlanks?: boolean;
  66527. /**
  66528. * string value representing the context fill style color. Defaults to 'black'.
  66529. */
  66530. customFillColor?: string;
  66531. /**
  66532. * Width and Height Value of each Frame in the TexturePacker Sets
  66533. */
  66534. frameSize?: number;
  66535. /**
  66536. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66537. */
  66538. paddingRatio?: number;
  66539. /**
  66540. * Number that declares the fill method for the padding gutter.
  66541. */
  66542. paddingMode?: number;
  66543. /**
  66544. * If in SUBUV_COLOR padding mode what color to use.
  66545. */
  66546. paddingColor?: Color3 | Color4;
  66547. }
  66548. /**
  66549. * Defines the basic interface of a TexturePacker JSON File
  66550. */
  66551. export interface ITexturePackerJSON {
  66552. /**
  66553. * The frame ID
  66554. */
  66555. name: string;
  66556. /**
  66557. * The base64 channel data
  66558. */
  66559. sets: any;
  66560. /**
  66561. * The options of the Packer
  66562. */
  66563. options: ITexturePackerOptions;
  66564. /**
  66565. * The frame data of the Packer
  66566. */
  66567. frames: Array<number>;
  66568. }
  66569. /**
  66570. * This is a support class that generates a series of packed texture sets.
  66571. * @see https://doc.babylonjs.com/babylon101/materials
  66572. */
  66573. export class TexturePacker {
  66574. /** Packer Layout Constant 0 */
  66575. static readonly LAYOUT_STRIP: number;
  66576. /** Packer Layout Constant 1 */
  66577. static readonly LAYOUT_POWER2: number;
  66578. /** Packer Layout Constant 2 */
  66579. static readonly LAYOUT_COLNUM: number;
  66580. /** Packer Layout Constant 0 */
  66581. static readonly SUBUV_WRAP: number;
  66582. /** Packer Layout Constant 1 */
  66583. static readonly SUBUV_EXTEND: number;
  66584. /** Packer Layout Constant 2 */
  66585. static readonly SUBUV_COLOR: number;
  66586. /** The Name of the Texture Package */
  66587. name: string;
  66588. /** The scene scope of the TexturePacker */
  66589. scene: Scene;
  66590. /** The Meshes to target */
  66591. meshes: AbstractMesh[];
  66592. /** Arguments passed with the Constructor */
  66593. options: ITexturePackerOptions;
  66594. /** The promise that is started upon initialization */
  66595. promise: Nullable<Promise<TexturePacker | string>>;
  66596. /** The Container object for the channel sets that are generated */
  66597. sets: object;
  66598. /** The Container array for the frames that are generated */
  66599. frames: TexturePackerFrame[];
  66600. /** The expected number of textures the system is parsing. */
  66601. private _expecting;
  66602. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66603. private _paddingValue;
  66604. /**
  66605. * Initializes a texture package series from an array of meshes or a single mesh.
  66606. * @param name The name of the package
  66607. * @param meshes The target meshes to compose the package from
  66608. * @param options The arguments that texture packer should follow while building.
  66609. * @param scene The scene which the textures are scoped to.
  66610. * @returns TexturePacker
  66611. */
  66612. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66613. /**
  66614. * Starts the package process
  66615. * @param resolve The promises resolution function
  66616. * @returns TexturePacker
  66617. */
  66618. private _createFrames;
  66619. /**
  66620. * Calculates the Size of the Channel Sets
  66621. * @returns Vector2
  66622. */
  66623. private _calculateSize;
  66624. /**
  66625. * Calculates the UV data for the frames.
  66626. * @param baseSize the base frameSize
  66627. * @param padding the base frame padding
  66628. * @param dtSize size of the Dynamic Texture for that channel
  66629. * @param dtUnits is 1/dtSize
  66630. * @param update flag to update the input meshes
  66631. */
  66632. private _calculateMeshUVFrames;
  66633. /**
  66634. * Calculates the frames Offset.
  66635. * @param index of the frame
  66636. * @returns Vector2
  66637. */
  66638. private _getFrameOffset;
  66639. /**
  66640. * Updates a Mesh to the frame data
  66641. * @param mesh that is the target
  66642. * @param frameID or the frame index
  66643. */
  66644. private _updateMeshUV;
  66645. /**
  66646. * Updates a Meshes materials to use the texture packer channels
  66647. * @param m is the mesh to target
  66648. * @param force all channels on the packer to be set.
  66649. */
  66650. private _updateTextureReferences;
  66651. /**
  66652. * Public method to set a Mesh to a frame
  66653. * @param m that is the target
  66654. * @param frameID or the frame index
  66655. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66656. */
  66657. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66658. /**
  66659. * Starts the async promise to compile the texture packer.
  66660. * @returns Promise<void>
  66661. */
  66662. processAsync(): Promise<void>;
  66663. /**
  66664. * Disposes all textures associated with this packer
  66665. */
  66666. dispose(): void;
  66667. /**
  66668. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66669. * @param imageType is the image type to use.
  66670. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66671. */
  66672. download(imageType?: string, quality?: number): void;
  66673. /**
  66674. * Public method to load a texturePacker JSON file.
  66675. * @param data of the JSON file in string format.
  66676. */
  66677. updateFromJSON(data: string): void;
  66678. }
  66679. }
  66680. declare module "babylonjs/Materials/Textures/Packer/index" {
  66681. export * from "babylonjs/Materials/Textures/Packer/packer";
  66682. export * from "babylonjs/Materials/Textures/Packer/frame";
  66683. }
  66684. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  66685. import { Scene } from "babylonjs/scene";
  66686. import { Texture } from "babylonjs/Materials/Textures/texture";
  66687. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66688. /**
  66689. * 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.
  66690. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66691. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66692. */
  66693. export class CustomProceduralTexture extends ProceduralTexture {
  66694. private _animate;
  66695. private _time;
  66696. private _config;
  66697. private _texturePath;
  66698. /**
  66699. * Instantiates a new Custom Procedural Texture.
  66700. * 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.
  66701. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66702. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66703. * @param name Define the name of the texture
  66704. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66705. * @param size Define the size of the texture to create
  66706. * @param scene Define the scene the texture belongs to
  66707. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66708. * @param generateMipMaps Define if the texture should creates mip maps or not
  66709. */
  66710. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66711. private _loadJson;
  66712. /**
  66713. * Is the texture ready to be used ? (rendered at least once)
  66714. * @returns true if ready, otherwise, false.
  66715. */
  66716. isReady(): boolean;
  66717. /**
  66718. * Render the texture to its associated render target.
  66719. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66720. */
  66721. render(useCameraPostProcess?: boolean): void;
  66722. /**
  66723. * Update the list of dependant textures samplers in the shader.
  66724. */
  66725. updateTextures(): void;
  66726. /**
  66727. * Update the uniform values of the procedural texture in the shader.
  66728. */
  66729. updateShaderUniforms(): void;
  66730. /**
  66731. * Define if the texture animates or not.
  66732. */
  66733. get animate(): boolean;
  66734. set animate(value: boolean);
  66735. }
  66736. }
  66737. declare module "babylonjs/Shaders/noise.fragment" {
  66738. /** @hidden */
  66739. export var noisePixelShader: {
  66740. name: string;
  66741. shader: string;
  66742. };
  66743. }
  66744. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  66745. import { Nullable } from "babylonjs/types";
  66746. import { Scene } from "babylonjs/scene";
  66747. import { Texture } from "babylonjs/Materials/Textures/texture";
  66748. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66749. import "babylonjs/Shaders/noise.fragment";
  66750. /**
  66751. * Class used to generate noise procedural textures
  66752. */
  66753. export class NoiseProceduralTexture extends ProceduralTexture {
  66754. /** Gets or sets the start time (default is 0) */
  66755. time: number;
  66756. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66757. brightness: number;
  66758. /** Defines the number of octaves to process */
  66759. octaves: number;
  66760. /** Defines the level of persistence (0.8 by default) */
  66761. persistence: number;
  66762. /** Gets or sets animation speed factor (default is 1) */
  66763. animationSpeedFactor: number;
  66764. /**
  66765. * Creates a new NoiseProceduralTexture
  66766. * @param name defines the name fo the texture
  66767. * @param size defines the size of the texture (default is 256)
  66768. * @param scene defines the hosting scene
  66769. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66770. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66771. */
  66772. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66773. private _updateShaderUniforms;
  66774. protected _getDefines(): string;
  66775. /** Generate the current state of the procedural texture */
  66776. render(useCameraPostProcess?: boolean): void;
  66777. /**
  66778. * Serializes this noise procedural texture
  66779. * @returns a serialized noise procedural texture object
  66780. */
  66781. serialize(): any;
  66782. /**
  66783. * Clone the texture.
  66784. * @returns the cloned texture
  66785. */
  66786. clone(): NoiseProceduralTexture;
  66787. /**
  66788. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66789. * @param parsedTexture defines parsed texture data
  66790. * @param scene defines the current scene
  66791. * @param rootUrl defines the root URL containing noise procedural texture information
  66792. * @returns a parsed NoiseProceduralTexture
  66793. */
  66794. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66795. }
  66796. }
  66797. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  66798. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  66799. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  66800. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66801. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  66802. }
  66803. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  66804. import { Nullable } from "babylonjs/types";
  66805. import { Scene } from "babylonjs/scene";
  66806. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  66807. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66808. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66809. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66810. /**
  66811. * Raw cube texture where the raw buffers are passed in
  66812. */
  66813. export class RawCubeTexture extends CubeTexture {
  66814. /**
  66815. * Creates a cube texture where the raw buffers are passed in.
  66816. * @param scene defines the scene the texture is attached to
  66817. * @param data defines the array of data to use to create each face
  66818. * @param size defines the size of the textures
  66819. * @param format defines the format of the data
  66820. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66821. * @param generateMipMaps defines if the engine should generate the mip levels
  66822. * @param invertY defines if data must be stored with Y axis inverted
  66823. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66824. * @param compression defines the compression used (null by default)
  66825. */
  66826. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66827. /**
  66828. * Updates the raw cube texture.
  66829. * @param data defines the data to store
  66830. * @param format defines the data format
  66831. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66832. * @param invertY defines if data must be stored with Y axis inverted
  66833. * @param compression defines the compression used (null by default)
  66834. * @param level defines which level of the texture to update
  66835. */
  66836. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66837. /**
  66838. * Updates a raw cube texture with RGBD encoded data.
  66839. * @param data defines the array of data [mipmap][face] to use to create each face
  66840. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66841. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66842. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66843. * @returns a promsie that resolves when the operation is complete
  66844. */
  66845. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66846. /**
  66847. * Clones the raw cube texture.
  66848. * @return a new cube texture
  66849. */
  66850. clone(): CubeTexture;
  66851. /** @hidden */
  66852. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66853. }
  66854. }
  66855. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66856. import { Scene } from "babylonjs/scene";
  66857. import { Texture } from "babylonjs/Materials/Textures/texture";
  66858. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66859. /**
  66860. * Class used to store 2D array textures containing user data
  66861. */
  66862. export class RawTexture2DArray extends Texture {
  66863. /** Gets or sets the texture format to use */
  66864. format: number;
  66865. /**
  66866. * Create a new RawTexture2DArray
  66867. * @param data defines the data of the texture
  66868. * @param width defines the width of the texture
  66869. * @param height defines the height of the texture
  66870. * @param depth defines the number of layers of the texture
  66871. * @param format defines the texture format to use
  66872. * @param scene defines the hosting scene
  66873. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66874. * @param invertY defines if texture must be stored with Y axis inverted
  66875. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66876. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66877. */
  66878. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66879. /** Gets or sets the texture format to use */
  66880. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66881. /**
  66882. * Update the texture with new data
  66883. * @param data defines the data to store in the texture
  66884. */
  66885. update(data: ArrayBufferView): void;
  66886. }
  66887. }
  66888. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66889. import { Scene } from "babylonjs/scene";
  66890. import { Texture } from "babylonjs/Materials/Textures/texture";
  66891. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66892. /**
  66893. * Class used to store 3D textures containing user data
  66894. */
  66895. export class RawTexture3D extends Texture {
  66896. /** Gets or sets the texture format to use */
  66897. format: number;
  66898. /**
  66899. * Create a new RawTexture3D
  66900. * @param data defines the data of the texture
  66901. * @param width defines the width of the texture
  66902. * @param height defines the height of the texture
  66903. * @param depth defines the depth of the texture
  66904. * @param format defines the texture format to use
  66905. * @param scene defines the hosting scene
  66906. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66907. * @param invertY defines if texture must be stored with Y axis inverted
  66908. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66909. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66910. */
  66911. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66912. /** Gets or sets the texture format to use */
  66913. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66914. /**
  66915. * Update the texture with new data
  66916. * @param data defines the data to store in the texture
  66917. */
  66918. update(data: ArrayBufferView): void;
  66919. }
  66920. }
  66921. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66922. import { Scene } from "babylonjs/scene";
  66923. import { Plane } from "babylonjs/Maths/math.plane";
  66924. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66925. /**
  66926. * Creates a refraction texture used by refraction channel of the standard material.
  66927. * It is like a mirror but to see through a material.
  66928. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66929. */
  66930. export class RefractionTexture extends RenderTargetTexture {
  66931. /**
  66932. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66933. * 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.
  66934. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66935. */
  66936. refractionPlane: Plane;
  66937. /**
  66938. * Define how deep under the surface we should see.
  66939. */
  66940. depth: number;
  66941. /**
  66942. * Creates a refraction texture used by refraction channel of the standard material.
  66943. * It is like a mirror but to see through a material.
  66944. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66945. * @param name Define the texture name
  66946. * @param size Define the size of the underlying texture
  66947. * @param scene Define the scene the refraction belongs to
  66948. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66949. */
  66950. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66951. /**
  66952. * Clone the refraction texture.
  66953. * @returns the cloned texture
  66954. */
  66955. clone(): RefractionTexture;
  66956. /**
  66957. * Serialize the texture to a JSON representation you could use in Parse later on
  66958. * @returns the serialized JSON representation
  66959. */
  66960. serialize(): any;
  66961. }
  66962. }
  66963. declare module "babylonjs/Materials/Textures/index" {
  66964. export * from "babylonjs/Materials/Textures/baseTexture";
  66965. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66966. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66967. export * from "babylonjs/Materials/Textures/cubeTexture";
  66968. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66969. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66970. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66971. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66972. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66973. export * from "babylonjs/Materials/Textures/internalTexture";
  66974. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66975. export * from "babylonjs/Materials/Textures/Loaders/index";
  66976. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66977. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66978. export * from "babylonjs/Materials/Textures/Packer/index";
  66979. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66980. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66981. export * from "babylonjs/Materials/Textures/rawTexture";
  66982. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66983. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66984. export * from "babylonjs/Materials/Textures/refractionTexture";
  66985. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66986. export * from "babylonjs/Materials/Textures/texture";
  66987. export * from "babylonjs/Materials/Textures/videoTexture";
  66988. }
  66989. declare module "babylonjs/Materials/Node/Enums/index" {
  66990. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66991. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66992. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66993. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66994. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66995. }
  66996. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67000. import { Mesh } from "babylonjs/Meshes/mesh";
  67001. import { Effect } from "babylonjs/Materials/effect";
  67002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67003. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67004. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67005. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67006. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  67007. /**
  67008. * Block used to add support for vertex skinning (bones)
  67009. */
  67010. export class BonesBlock extends NodeMaterialBlock {
  67011. /**
  67012. * Creates a new BonesBlock
  67013. * @param name defines the block name
  67014. */
  67015. constructor(name: string);
  67016. /**
  67017. * Initialize the block and prepare the context for build
  67018. * @param state defines the state that will be used for the build
  67019. */
  67020. initialize(state: NodeMaterialBuildState): void;
  67021. /**
  67022. * Gets the current class name
  67023. * @returns the class name
  67024. */
  67025. getClassName(): string;
  67026. /**
  67027. * Gets the matrix indices input component
  67028. */
  67029. get matricesIndices(): NodeMaterialConnectionPoint;
  67030. /**
  67031. * Gets the matrix weights input component
  67032. */
  67033. get matricesWeights(): NodeMaterialConnectionPoint;
  67034. /**
  67035. * Gets the extra matrix indices input component
  67036. */
  67037. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  67038. /**
  67039. * Gets the extra matrix weights input component
  67040. */
  67041. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67042. /**
  67043. * Gets the world input component
  67044. */
  67045. get world(): NodeMaterialConnectionPoint;
  67046. /**
  67047. * Gets the output component
  67048. */
  67049. get output(): NodeMaterialConnectionPoint;
  67050. autoConfigure(material: NodeMaterial): void;
  67051. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67052. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67054. protected _buildBlock(state: NodeMaterialBuildState): this;
  67055. }
  67056. }
  67057. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  67058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67062. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67063. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67064. /**
  67065. * Block used to add support for instances
  67066. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67067. */
  67068. export class InstancesBlock extends NodeMaterialBlock {
  67069. /**
  67070. * Creates a new InstancesBlock
  67071. * @param name defines the block name
  67072. */
  67073. constructor(name: string);
  67074. /**
  67075. * Gets the current class name
  67076. * @returns the class name
  67077. */
  67078. getClassName(): string;
  67079. /**
  67080. * Gets the first world row input component
  67081. */
  67082. get world0(): NodeMaterialConnectionPoint;
  67083. /**
  67084. * Gets the second world row input component
  67085. */
  67086. get world1(): NodeMaterialConnectionPoint;
  67087. /**
  67088. * Gets the third world row input component
  67089. */
  67090. get world2(): NodeMaterialConnectionPoint;
  67091. /**
  67092. * Gets the forth world row input component
  67093. */
  67094. get world3(): NodeMaterialConnectionPoint;
  67095. /**
  67096. * Gets the world input component
  67097. */
  67098. get world(): NodeMaterialConnectionPoint;
  67099. /**
  67100. * Gets the output component
  67101. */
  67102. get output(): NodeMaterialConnectionPoint;
  67103. /**
  67104. * Gets the isntanceID component
  67105. */
  67106. get instanceID(): NodeMaterialConnectionPoint;
  67107. autoConfigure(material: NodeMaterial): void;
  67108. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67109. protected _buildBlock(state: NodeMaterialBuildState): this;
  67110. }
  67111. }
  67112. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  67113. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67114. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67117. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67118. import { Effect } from "babylonjs/Materials/effect";
  67119. import { Mesh } from "babylonjs/Meshes/mesh";
  67120. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67121. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67122. /**
  67123. * Block used to add morph targets support to vertex shader
  67124. */
  67125. export class MorphTargetsBlock extends NodeMaterialBlock {
  67126. private _repeatableContentAnchor;
  67127. /**
  67128. * Create a new MorphTargetsBlock
  67129. * @param name defines the block name
  67130. */
  67131. constructor(name: string);
  67132. /**
  67133. * Gets the current class name
  67134. * @returns the class name
  67135. */
  67136. getClassName(): string;
  67137. /**
  67138. * Gets the position input component
  67139. */
  67140. get position(): NodeMaterialConnectionPoint;
  67141. /**
  67142. * Gets the normal input component
  67143. */
  67144. get normal(): NodeMaterialConnectionPoint;
  67145. /**
  67146. * Gets the tangent input component
  67147. */
  67148. get tangent(): NodeMaterialConnectionPoint;
  67149. /**
  67150. * Gets the tangent input component
  67151. */
  67152. get uv(): NodeMaterialConnectionPoint;
  67153. /**
  67154. * Gets the position output component
  67155. */
  67156. get positionOutput(): NodeMaterialConnectionPoint;
  67157. /**
  67158. * Gets the normal output component
  67159. */
  67160. get normalOutput(): NodeMaterialConnectionPoint;
  67161. /**
  67162. * Gets the tangent output component
  67163. */
  67164. get tangentOutput(): NodeMaterialConnectionPoint;
  67165. /**
  67166. * Gets the tangent output component
  67167. */
  67168. get uvOutput(): NodeMaterialConnectionPoint;
  67169. initialize(state: NodeMaterialBuildState): void;
  67170. autoConfigure(material: NodeMaterial): void;
  67171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67172. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67173. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67174. protected _buildBlock(state: NodeMaterialBuildState): this;
  67175. }
  67176. }
  67177. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  67178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67181. import { Nullable } from "babylonjs/types";
  67182. import { Scene } from "babylonjs/scene";
  67183. import { Effect } from "babylonjs/Materials/effect";
  67184. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67185. import { Mesh } from "babylonjs/Meshes/mesh";
  67186. import { Light } from "babylonjs/Lights/light";
  67187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67188. /**
  67189. * Block used to get data information from a light
  67190. */
  67191. export class LightInformationBlock extends NodeMaterialBlock {
  67192. private _lightDataUniformName;
  67193. private _lightColorUniformName;
  67194. private _lightTypeDefineName;
  67195. /**
  67196. * Gets or sets the light associated with this block
  67197. */
  67198. light: Nullable<Light>;
  67199. /**
  67200. * Creates a new LightInformationBlock
  67201. * @param name defines the block name
  67202. */
  67203. constructor(name: string);
  67204. /**
  67205. * Gets the current class name
  67206. * @returns the class name
  67207. */
  67208. getClassName(): string;
  67209. /**
  67210. * Gets the world position input component
  67211. */
  67212. get worldPosition(): NodeMaterialConnectionPoint;
  67213. /**
  67214. * Gets the direction output component
  67215. */
  67216. get direction(): NodeMaterialConnectionPoint;
  67217. /**
  67218. * Gets the direction output component
  67219. */
  67220. get color(): NodeMaterialConnectionPoint;
  67221. /**
  67222. * Gets the direction output component
  67223. */
  67224. get intensity(): NodeMaterialConnectionPoint;
  67225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67227. protected _buildBlock(state: NodeMaterialBuildState): this;
  67228. serialize(): any;
  67229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67230. }
  67231. }
  67232. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  67233. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  67234. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  67235. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  67236. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  67237. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  67238. }
  67239. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  67240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67244. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67245. import { Effect } from "babylonjs/Materials/effect";
  67246. import { Mesh } from "babylonjs/Meshes/mesh";
  67247. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67248. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67249. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67250. /**
  67251. * Block used to add image processing support to fragment shader
  67252. */
  67253. export class ImageProcessingBlock extends NodeMaterialBlock {
  67254. /**
  67255. * Create a new ImageProcessingBlock
  67256. * @param name defines the block name
  67257. */
  67258. constructor(name: string);
  67259. /**
  67260. * Gets the current class name
  67261. * @returns the class name
  67262. */
  67263. getClassName(): string;
  67264. /**
  67265. * Gets the color input component
  67266. */
  67267. get color(): NodeMaterialConnectionPoint;
  67268. /**
  67269. * Gets the output component
  67270. */
  67271. get output(): NodeMaterialConnectionPoint;
  67272. /**
  67273. * Initialize the block and prepare the context for build
  67274. * @param state defines the state that will be used for the build
  67275. */
  67276. initialize(state: NodeMaterialBuildState): void;
  67277. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67279. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67280. protected _buildBlock(state: NodeMaterialBuildState): this;
  67281. }
  67282. }
  67283. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  67284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67287. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67289. import { Effect } from "babylonjs/Materials/effect";
  67290. import { Mesh } from "babylonjs/Meshes/mesh";
  67291. import { Scene } from "babylonjs/scene";
  67292. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  67293. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67294. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67295. /**
  67296. * Block used to pertub normals based on a normal map
  67297. */
  67298. export class PerturbNormalBlock extends NodeMaterialBlock {
  67299. private _tangentSpaceParameterName;
  67300. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67301. invertX: boolean;
  67302. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67303. invertY: boolean;
  67304. /**
  67305. * Create a new PerturbNormalBlock
  67306. * @param name defines the block name
  67307. */
  67308. constructor(name: string);
  67309. /**
  67310. * Gets the current class name
  67311. * @returns the class name
  67312. */
  67313. getClassName(): string;
  67314. /**
  67315. * Gets the world position input component
  67316. */
  67317. get worldPosition(): NodeMaterialConnectionPoint;
  67318. /**
  67319. * Gets the world normal input component
  67320. */
  67321. get worldNormal(): NodeMaterialConnectionPoint;
  67322. /**
  67323. * Gets the world tangent input component
  67324. */
  67325. get worldTangent(): NodeMaterialConnectionPoint;
  67326. /**
  67327. * Gets the uv input component
  67328. */
  67329. get uv(): NodeMaterialConnectionPoint;
  67330. /**
  67331. * Gets the normal map color input component
  67332. */
  67333. get normalMapColor(): NodeMaterialConnectionPoint;
  67334. /**
  67335. * Gets the strength input component
  67336. */
  67337. get strength(): NodeMaterialConnectionPoint;
  67338. /**
  67339. * Gets the output component
  67340. */
  67341. get output(): NodeMaterialConnectionPoint;
  67342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67344. autoConfigure(material: NodeMaterial): void;
  67345. protected _buildBlock(state: NodeMaterialBuildState): this;
  67346. protected _dumpPropertiesCode(): string;
  67347. serialize(): any;
  67348. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67349. }
  67350. }
  67351. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  67352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67353. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67355. /**
  67356. * Block used to discard a pixel if a value is smaller than a cutoff
  67357. */
  67358. export class DiscardBlock extends NodeMaterialBlock {
  67359. /**
  67360. * Create a new DiscardBlock
  67361. * @param name defines the block name
  67362. */
  67363. constructor(name: string);
  67364. /**
  67365. * Gets the current class name
  67366. * @returns the class name
  67367. */
  67368. getClassName(): string;
  67369. /**
  67370. * Gets the color input component
  67371. */
  67372. get value(): NodeMaterialConnectionPoint;
  67373. /**
  67374. * Gets the cutoff input component
  67375. */
  67376. get cutoff(): NodeMaterialConnectionPoint;
  67377. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67378. }
  67379. }
  67380. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  67381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67384. /**
  67385. * Block used to test if the fragment shader is front facing
  67386. */
  67387. export class FrontFacingBlock extends NodeMaterialBlock {
  67388. /**
  67389. * Creates a new FrontFacingBlock
  67390. * @param name defines the block name
  67391. */
  67392. constructor(name: string);
  67393. /**
  67394. * Gets the current class name
  67395. * @returns the class name
  67396. */
  67397. getClassName(): string;
  67398. /**
  67399. * Gets the output component
  67400. */
  67401. get output(): NodeMaterialConnectionPoint;
  67402. protected _buildBlock(state: NodeMaterialBuildState): this;
  67403. }
  67404. }
  67405. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  67406. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67407. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67408. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67409. /**
  67410. * Block used to get the derivative value on x and y of a given input
  67411. */
  67412. export class DerivativeBlock extends NodeMaterialBlock {
  67413. /**
  67414. * Create a new DerivativeBlock
  67415. * @param name defines the block name
  67416. */
  67417. constructor(name: string);
  67418. /**
  67419. * Gets the current class name
  67420. * @returns the class name
  67421. */
  67422. getClassName(): string;
  67423. /**
  67424. * Gets the input component
  67425. */
  67426. get input(): NodeMaterialConnectionPoint;
  67427. /**
  67428. * Gets the derivative output on x
  67429. */
  67430. get dx(): NodeMaterialConnectionPoint;
  67431. /**
  67432. * Gets the derivative output on y
  67433. */
  67434. get dy(): NodeMaterialConnectionPoint;
  67435. protected _buildBlock(state: NodeMaterialBuildState): this;
  67436. }
  67437. }
  67438. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  67439. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67440. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67441. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67442. /**
  67443. * Block used to make gl_FragCoord available
  67444. */
  67445. export class FragCoordBlock extends NodeMaterialBlock {
  67446. /**
  67447. * Creates a new FragCoordBlock
  67448. * @param name defines the block name
  67449. */
  67450. constructor(name: string);
  67451. /**
  67452. * Gets the current class name
  67453. * @returns the class name
  67454. */
  67455. getClassName(): string;
  67456. /**
  67457. * Gets the xy component
  67458. */
  67459. get xy(): NodeMaterialConnectionPoint;
  67460. /**
  67461. * Gets the xyz component
  67462. */
  67463. get xyz(): NodeMaterialConnectionPoint;
  67464. /**
  67465. * Gets the xyzw component
  67466. */
  67467. get xyzw(): NodeMaterialConnectionPoint;
  67468. /**
  67469. * Gets the x component
  67470. */
  67471. get x(): NodeMaterialConnectionPoint;
  67472. /**
  67473. * Gets the y component
  67474. */
  67475. get y(): NodeMaterialConnectionPoint;
  67476. /**
  67477. * Gets the z component
  67478. */
  67479. get z(): NodeMaterialConnectionPoint;
  67480. /**
  67481. * Gets the w component
  67482. */
  67483. get output(): NodeMaterialConnectionPoint;
  67484. protected writeOutputs(state: NodeMaterialBuildState): string;
  67485. protected _buildBlock(state: NodeMaterialBuildState): this;
  67486. }
  67487. }
  67488. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  67489. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67490. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67491. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67492. import { Effect } from "babylonjs/Materials/effect";
  67493. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67494. import { Mesh } from "babylonjs/Meshes/mesh";
  67495. /**
  67496. * Block used to get the screen sizes
  67497. */
  67498. export class ScreenSizeBlock extends NodeMaterialBlock {
  67499. private _varName;
  67500. private _scene;
  67501. /**
  67502. * Creates a new ScreenSizeBlock
  67503. * @param name defines the block name
  67504. */
  67505. constructor(name: string);
  67506. /**
  67507. * Gets the current class name
  67508. * @returns the class name
  67509. */
  67510. getClassName(): string;
  67511. /**
  67512. * Gets the xy component
  67513. */
  67514. get xy(): NodeMaterialConnectionPoint;
  67515. /**
  67516. * Gets the x component
  67517. */
  67518. get x(): NodeMaterialConnectionPoint;
  67519. /**
  67520. * Gets the y component
  67521. */
  67522. get y(): NodeMaterialConnectionPoint;
  67523. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67524. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67525. protected _buildBlock(state: NodeMaterialBuildState): this;
  67526. }
  67527. }
  67528. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  67529. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  67530. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  67531. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  67532. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  67533. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  67534. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  67535. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  67536. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  67537. }
  67538. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  67539. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67540. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67541. import { Mesh } from "babylonjs/Meshes/mesh";
  67542. import { Effect } from "babylonjs/Materials/effect";
  67543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67545. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67546. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  67547. /**
  67548. * Block used to add support for scene fog
  67549. */
  67550. export class FogBlock extends NodeMaterialBlock {
  67551. private _fogDistanceName;
  67552. private _fogParameters;
  67553. /**
  67554. * Create a new FogBlock
  67555. * @param name defines the block name
  67556. */
  67557. constructor(name: string);
  67558. /**
  67559. * Gets the current class name
  67560. * @returns the class name
  67561. */
  67562. getClassName(): string;
  67563. /**
  67564. * Gets the world position input component
  67565. */
  67566. get worldPosition(): NodeMaterialConnectionPoint;
  67567. /**
  67568. * Gets the view input component
  67569. */
  67570. get view(): NodeMaterialConnectionPoint;
  67571. /**
  67572. * Gets the color input component
  67573. */
  67574. get input(): NodeMaterialConnectionPoint;
  67575. /**
  67576. * Gets the fog color input component
  67577. */
  67578. get fogColor(): NodeMaterialConnectionPoint;
  67579. /**
  67580. * Gets the output component
  67581. */
  67582. get output(): NodeMaterialConnectionPoint;
  67583. autoConfigure(material: NodeMaterial): void;
  67584. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67585. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67586. protected _buildBlock(state: NodeMaterialBuildState): this;
  67587. }
  67588. }
  67589. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  67590. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67591. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67592. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67594. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67595. import { Effect } from "babylonjs/Materials/effect";
  67596. import { Mesh } from "babylonjs/Meshes/mesh";
  67597. import { Light } from "babylonjs/Lights/light";
  67598. import { Nullable } from "babylonjs/types";
  67599. import { Scene } from "babylonjs/scene";
  67600. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  67601. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  67602. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  67603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67604. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  67605. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  67606. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  67607. /**
  67608. * Block used to add light in the fragment shader
  67609. */
  67610. export class LightBlock extends NodeMaterialBlock {
  67611. private _lightId;
  67612. /**
  67613. * Gets or sets the light associated with this block
  67614. */
  67615. light: Nullable<Light>;
  67616. /**
  67617. * Create a new LightBlock
  67618. * @param name defines the block name
  67619. */
  67620. constructor(name: string);
  67621. /**
  67622. * Gets the current class name
  67623. * @returns the class name
  67624. */
  67625. getClassName(): string;
  67626. /**
  67627. * Gets the world position input component
  67628. */
  67629. get worldPosition(): NodeMaterialConnectionPoint;
  67630. /**
  67631. * Gets the world normal input component
  67632. */
  67633. get worldNormal(): NodeMaterialConnectionPoint;
  67634. /**
  67635. * Gets the camera (or eye) position component
  67636. */
  67637. get cameraPosition(): NodeMaterialConnectionPoint;
  67638. /**
  67639. * Gets the glossiness component
  67640. */
  67641. get glossiness(): NodeMaterialConnectionPoint;
  67642. /**
  67643. * Gets the glossinness power component
  67644. */
  67645. get glossPower(): NodeMaterialConnectionPoint;
  67646. /**
  67647. * Gets the diffuse color component
  67648. */
  67649. get diffuseColor(): NodeMaterialConnectionPoint;
  67650. /**
  67651. * Gets the specular color component
  67652. */
  67653. get specularColor(): NodeMaterialConnectionPoint;
  67654. /**
  67655. * Gets the view matrix component
  67656. */
  67657. get view(): NodeMaterialConnectionPoint;
  67658. /**
  67659. * Gets the diffuse output component
  67660. */
  67661. get diffuseOutput(): NodeMaterialConnectionPoint;
  67662. /**
  67663. * Gets the specular output component
  67664. */
  67665. get specularOutput(): NodeMaterialConnectionPoint;
  67666. /**
  67667. * Gets the shadow output component
  67668. */
  67669. get shadow(): NodeMaterialConnectionPoint;
  67670. autoConfigure(material: NodeMaterial): void;
  67671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67672. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67673. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67674. private _injectVertexCode;
  67675. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67676. serialize(): any;
  67677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67678. }
  67679. }
  67680. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  67681. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67682. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67683. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67684. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67685. /**
  67686. * Block used to read a reflection texture from a sampler
  67687. */
  67688. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67689. /**
  67690. * Create a new ReflectionTextureBlock
  67691. * @param name defines the block name
  67692. */
  67693. constructor(name: string);
  67694. /**
  67695. * Gets the current class name
  67696. * @returns the class name
  67697. */
  67698. getClassName(): string;
  67699. /**
  67700. * Gets the world position input component
  67701. */
  67702. get position(): NodeMaterialConnectionPoint;
  67703. /**
  67704. * Gets the world position input component
  67705. */
  67706. get worldPosition(): NodeMaterialConnectionPoint;
  67707. /**
  67708. * Gets the world normal input component
  67709. */
  67710. get worldNormal(): NodeMaterialConnectionPoint;
  67711. /**
  67712. * Gets the world input component
  67713. */
  67714. get world(): NodeMaterialConnectionPoint;
  67715. /**
  67716. * Gets the camera (or eye) position component
  67717. */
  67718. get cameraPosition(): NodeMaterialConnectionPoint;
  67719. /**
  67720. * Gets the view input component
  67721. */
  67722. get view(): NodeMaterialConnectionPoint;
  67723. /**
  67724. * Gets the rgb output component
  67725. */
  67726. get rgb(): NodeMaterialConnectionPoint;
  67727. /**
  67728. * Gets the rgba output component
  67729. */
  67730. get rgba(): NodeMaterialConnectionPoint;
  67731. /**
  67732. * Gets the r output component
  67733. */
  67734. get r(): NodeMaterialConnectionPoint;
  67735. /**
  67736. * Gets the g output component
  67737. */
  67738. get g(): NodeMaterialConnectionPoint;
  67739. /**
  67740. * Gets the b output component
  67741. */
  67742. get b(): NodeMaterialConnectionPoint;
  67743. /**
  67744. * Gets the a output component
  67745. */
  67746. get a(): NodeMaterialConnectionPoint;
  67747. autoConfigure(material: NodeMaterial): void;
  67748. protected _buildBlock(state: NodeMaterialBuildState): this;
  67749. }
  67750. }
  67751. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  67752. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  67753. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  67754. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  67755. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  67756. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  67757. }
  67758. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  67759. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  67760. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  67761. }
  67762. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  67763. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67764. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67765. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67766. /**
  67767. * Block used to add 2 vectors
  67768. */
  67769. export class AddBlock extends NodeMaterialBlock {
  67770. /**
  67771. * Creates a new AddBlock
  67772. * @param name defines the block name
  67773. */
  67774. constructor(name: string);
  67775. /**
  67776. * Gets the current class name
  67777. * @returns the class name
  67778. */
  67779. getClassName(): string;
  67780. /**
  67781. * Gets the left operand input component
  67782. */
  67783. get left(): NodeMaterialConnectionPoint;
  67784. /**
  67785. * Gets the right operand input component
  67786. */
  67787. get right(): NodeMaterialConnectionPoint;
  67788. /**
  67789. * Gets the output component
  67790. */
  67791. get output(): NodeMaterialConnectionPoint;
  67792. protected _buildBlock(state: NodeMaterialBuildState): this;
  67793. }
  67794. }
  67795. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  67796. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67797. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67798. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67799. /**
  67800. * Block used to scale a vector by a float
  67801. */
  67802. export class ScaleBlock extends NodeMaterialBlock {
  67803. /**
  67804. * Creates a new ScaleBlock
  67805. * @param name defines the block name
  67806. */
  67807. constructor(name: string);
  67808. /**
  67809. * Gets the current class name
  67810. * @returns the class name
  67811. */
  67812. getClassName(): string;
  67813. /**
  67814. * Gets the input component
  67815. */
  67816. get input(): NodeMaterialConnectionPoint;
  67817. /**
  67818. * Gets the factor input component
  67819. */
  67820. get factor(): NodeMaterialConnectionPoint;
  67821. /**
  67822. * Gets the output component
  67823. */
  67824. get output(): NodeMaterialConnectionPoint;
  67825. protected _buildBlock(state: NodeMaterialBuildState): this;
  67826. }
  67827. }
  67828. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  67829. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67830. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67831. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67832. import { Scene } from "babylonjs/scene";
  67833. /**
  67834. * Block used to clamp a float
  67835. */
  67836. export class ClampBlock extends NodeMaterialBlock {
  67837. /** Gets or sets the minimum range */
  67838. minimum: number;
  67839. /** Gets or sets the maximum range */
  67840. maximum: number;
  67841. /**
  67842. * Creates a new ClampBlock
  67843. * @param name defines the block name
  67844. */
  67845. constructor(name: string);
  67846. /**
  67847. * Gets the current class name
  67848. * @returns the class name
  67849. */
  67850. getClassName(): string;
  67851. /**
  67852. * Gets the value input component
  67853. */
  67854. get value(): NodeMaterialConnectionPoint;
  67855. /**
  67856. * Gets the output component
  67857. */
  67858. get output(): NodeMaterialConnectionPoint;
  67859. protected _buildBlock(state: NodeMaterialBuildState): this;
  67860. protected _dumpPropertiesCode(): string;
  67861. serialize(): any;
  67862. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67863. }
  67864. }
  67865. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67869. /**
  67870. * Block used to apply a cross product between 2 vectors
  67871. */
  67872. export class CrossBlock extends NodeMaterialBlock {
  67873. /**
  67874. * Creates a new CrossBlock
  67875. * @param name defines the block name
  67876. */
  67877. constructor(name: string);
  67878. /**
  67879. * Gets the current class name
  67880. * @returns the class name
  67881. */
  67882. getClassName(): string;
  67883. /**
  67884. * Gets the left operand input component
  67885. */
  67886. get left(): NodeMaterialConnectionPoint;
  67887. /**
  67888. * Gets the right operand input component
  67889. */
  67890. get right(): NodeMaterialConnectionPoint;
  67891. /**
  67892. * Gets the output component
  67893. */
  67894. get output(): NodeMaterialConnectionPoint;
  67895. protected _buildBlock(state: NodeMaterialBuildState): this;
  67896. }
  67897. }
  67898. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67902. /**
  67903. * Block used to apply a dot product between 2 vectors
  67904. */
  67905. export class DotBlock extends NodeMaterialBlock {
  67906. /**
  67907. * Creates a new DotBlock
  67908. * @param name defines the block name
  67909. */
  67910. constructor(name: string);
  67911. /**
  67912. * Gets the current class name
  67913. * @returns the class name
  67914. */
  67915. getClassName(): string;
  67916. /**
  67917. * Gets the left operand input component
  67918. */
  67919. get left(): NodeMaterialConnectionPoint;
  67920. /**
  67921. * Gets the right operand input component
  67922. */
  67923. get right(): NodeMaterialConnectionPoint;
  67924. /**
  67925. * Gets the output component
  67926. */
  67927. get output(): NodeMaterialConnectionPoint;
  67928. protected _buildBlock(state: NodeMaterialBuildState): this;
  67929. }
  67930. }
  67931. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67935. /**
  67936. * Block used to normalize a vector
  67937. */
  67938. export class NormalizeBlock extends NodeMaterialBlock {
  67939. /**
  67940. * Creates a new NormalizeBlock
  67941. * @param name defines the block name
  67942. */
  67943. constructor(name: string);
  67944. /**
  67945. * Gets the current class name
  67946. * @returns the class name
  67947. */
  67948. getClassName(): string;
  67949. /**
  67950. * Gets the input component
  67951. */
  67952. get input(): NodeMaterialConnectionPoint;
  67953. /**
  67954. * Gets the output component
  67955. */
  67956. get output(): NodeMaterialConnectionPoint;
  67957. protected _buildBlock(state: NodeMaterialBuildState): this;
  67958. }
  67959. }
  67960. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67961. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67962. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67963. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67964. /**
  67965. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67966. */
  67967. export class ColorMergerBlock extends NodeMaterialBlock {
  67968. /**
  67969. * Create a new ColorMergerBlock
  67970. * @param name defines the block name
  67971. */
  67972. constructor(name: string);
  67973. /**
  67974. * Gets the current class name
  67975. * @returns the class name
  67976. */
  67977. getClassName(): string;
  67978. /**
  67979. * Gets the rgb component (input)
  67980. */
  67981. get rgbIn(): NodeMaterialConnectionPoint;
  67982. /**
  67983. * Gets the r component (input)
  67984. */
  67985. get r(): NodeMaterialConnectionPoint;
  67986. /**
  67987. * Gets the g component (input)
  67988. */
  67989. get g(): NodeMaterialConnectionPoint;
  67990. /**
  67991. * Gets the b component (input)
  67992. */
  67993. get b(): NodeMaterialConnectionPoint;
  67994. /**
  67995. * Gets the a component (input)
  67996. */
  67997. get a(): NodeMaterialConnectionPoint;
  67998. /**
  67999. * Gets the rgba component (output)
  68000. */
  68001. get rgba(): NodeMaterialConnectionPoint;
  68002. /**
  68003. * Gets the rgb component (output)
  68004. */
  68005. get rgbOut(): NodeMaterialConnectionPoint;
  68006. /**
  68007. * Gets the rgb component (output)
  68008. * @deprecated Please use rgbOut instead.
  68009. */
  68010. get rgb(): NodeMaterialConnectionPoint;
  68011. protected _buildBlock(state: NodeMaterialBuildState): this;
  68012. }
  68013. }
  68014. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  68015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68018. /**
  68019. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  68020. */
  68021. export class VectorSplitterBlock extends NodeMaterialBlock {
  68022. /**
  68023. * Create a new VectorSplitterBlock
  68024. * @param name defines the block name
  68025. */
  68026. constructor(name: string);
  68027. /**
  68028. * Gets the current class name
  68029. * @returns the class name
  68030. */
  68031. getClassName(): string;
  68032. /**
  68033. * Gets the xyzw component (input)
  68034. */
  68035. get xyzw(): NodeMaterialConnectionPoint;
  68036. /**
  68037. * Gets the xyz component (input)
  68038. */
  68039. get xyzIn(): NodeMaterialConnectionPoint;
  68040. /**
  68041. * Gets the xy component (input)
  68042. */
  68043. get xyIn(): NodeMaterialConnectionPoint;
  68044. /**
  68045. * Gets the xyz component (output)
  68046. */
  68047. get xyzOut(): NodeMaterialConnectionPoint;
  68048. /**
  68049. * Gets the xy component (output)
  68050. */
  68051. get xyOut(): NodeMaterialConnectionPoint;
  68052. /**
  68053. * Gets the x component (output)
  68054. */
  68055. get x(): NodeMaterialConnectionPoint;
  68056. /**
  68057. * Gets the y component (output)
  68058. */
  68059. get y(): NodeMaterialConnectionPoint;
  68060. /**
  68061. * Gets the z component (output)
  68062. */
  68063. get z(): NodeMaterialConnectionPoint;
  68064. /**
  68065. * Gets the w component (output)
  68066. */
  68067. get w(): NodeMaterialConnectionPoint;
  68068. protected _inputRename(name: string): string;
  68069. protected _outputRename(name: string): string;
  68070. protected _buildBlock(state: NodeMaterialBuildState): this;
  68071. }
  68072. }
  68073. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  68074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68077. /**
  68078. * Block used to lerp between 2 values
  68079. */
  68080. export class LerpBlock extends NodeMaterialBlock {
  68081. /**
  68082. * Creates a new LerpBlock
  68083. * @param name defines the block name
  68084. */
  68085. constructor(name: string);
  68086. /**
  68087. * Gets the current class name
  68088. * @returns the class name
  68089. */
  68090. getClassName(): string;
  68091. /**
  68092. * Gets the left operand input component
  68093. */
  68094. get left(): NodeMaterialConnectionPoint;
  68095. /**
  68096. * Gets the right operand input component
  68097. */
  68098. get right(): NodeMaterialConnectionPoint;
  68099. /**
  68100. * Gets the gradient operand input component
  68101. */
  68102. get gradient(): NodeMaterialConnectionPoint;
  68103. /**
  68104. * Gets the output component
  68105. */
  68106. get output(): NodeMaterialConnectionPoint;
  68107. protected _buildBlock(state: NodeMaterialBuildState): this;
  68108. }
  68109. }
  68110. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  68111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68113. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68114. /**
  68115. * Block used to divide 2 vectors
  68116. */
  68117. export class DivideBlock extends NodeMaterialBlock {
  68118. /**
  68119. * Creates a new DivideBlock
  68120. * @param name defines the block name
  68121. */
  68122. constructor(name: string);
  68123. /**
  68124. * Gets the current class name
  68125. * @returns the class name
  68126. */
  68127. getClassName(): string;
  68128. /**
  68129. * Gets the left operand input component
  68130. */
  68131. get left(): NodeMaterialConnectionPoint;
  68132. /**
  68133. * Gets the right operand input component
  68134. */
  68135. get right(): NodeMaterialConnectionPoint;
  68136. /**
  68137. * Gets the output component
  68138. */
  68139. get output(): NodeMaterialConnectionPoint;
  68140. protected _buildBlock(state: NodeMaterialBuildState): this;
  68141. }
  68142. }
  68143. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  68144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68147. /**
  68148. * Block used to subtract 2 vectors
  68149. */
  68150. export class SubtractBlock extends NodeMaterialBlock {
  68151. /**
  68152. * Creates a new SubtractBlock
  68153. * @param name defines the block name
  68154. */
  68155. constructor(name: string);
  68156. /**
  68157. * Gets the current class name
  68158. * @returns the class name
  68159. */
  68160. getClassName(): string;
  68161. /**
  68162. * Gets the left operand input component
  68163. */
  68164. get left(): NodeMaterialConnectionPoint;
  68165. /**
  68166. * Gets the right operand input component
  68167. */
  68168. get right(): NodeMaterialConnectionPoint;
  68169. /**
  68170. * Gets the output component
  68171. */
  68172. get output(): NodeMaterialConnectionPoint;
  68173. protected _buildBlock(state: NodeMaterialBuildState): this;
  68174. }
  68175. }
  68176. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  68177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68180. /**
  68181. * Block used to step a value
  68182. */
  68183. export class StepBlock extends NodeMaterialBlock {
  68184. /**
  68185. * Creates a new StepBlock
  68186. * @param name defines the block name
  68187. */
  68188. constructor(name: string);
  68189. /**
  68190. * Gets the current class name
  68191. * @returns the class name
  68192. */
  68193. getClassName(): string;
  68194. /**
  68195. * Gets the value operand input component
  68196. */
  68197. get value(): NodeMaterialConnectionPoint;
  68198. /**
  68199. * Gets the edge operand input component
  68200. */
  68201. get edge(): NodeMaterialConnectionPoint;
  68202. /**
  68203. * Gets the output component
  68204. */
  68205. get output(): NodeMaterialConnectionPoint;
  68206. protected _buildBlock(state: NodeMaterialBuildState): this;
  68207. }
  68208. }
  68209. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  68210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68213. /**
  68214. * Block used to get the opposite (1 - x) of a value
  68215. */
  68216. export class OneMinusBlock extends NodeMaterialBlock {
  68217. /**
  68218. * Creates a new OneMinusBlock
  68219. * @param name defines the block name
  68220. */
  68221. constructor(name: string);
  68222. /**
  68223. * Gets the current class name
  68224. * @returns the class name
  68225. */
  68226. getClassName(): string;
  68227. /**
  68228. * Gets the input component
  68229. */
  68230. get input(): NodeMaterialConnectionPoint;
  68231. /**
  68232. * Gets the output component
  68233. */
  68234. get output(): NodeMaterialConnectionPoint;
  68235. protected _buildBlock(state: NodeMaterialBuildState): this;
  68236. }
  68237. }
  68238. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  68239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68242. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68243. /**
  68244. * Block used to get the view direction
  68245. */
  68246. export class ViewDirectionBlock extends NodeMaterialBlock {
  68247. /**
  68248. * Creates a new ViewDirectionBlock
  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 world position component
  68259. */
  68260. get worldPosition(): NodeMaterialConnectionPoint;
  68261. /**
  68262. * Gets the camera position component
  68263. */
  68264. get cameraPosition(): NodeMaterialConnectionPoint;
  68265. /**
  68266. * Gets the output component
  68267. */
  68268. get output(): NodeMaterialConnectionPoint;
  68269. autoConfigure(material: NodeMaterial): void;
  68270. protected _buildBlock(state: NodeMaterialBuildState): this;
  68271. }
  68272. }
  68273. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  68274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68277. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68278. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  68279. /**
  68280. * Block used to compute fresnel value
  68281. */
  68282. export class FresnelBlock extends NodeMaterialBlock {
  68283. /**
  68284. * Create a new FresnelBlock
  68285. * @param name defines the block name
  68286. */
  68287. constructor(name: string);
  68288. /**
  68289. * Gets the current class name
  68290. * @returns the class name
  68291. */
  68292. getClassName(): string;
  68293. /**
  68294. * Gets the world normal input component
  68295. */
  68296. get worldNormal(): NodeMaterialConnectionPoint;
  68297. /**
  68298. * Gets the view direction input component
  68299. */
  68300. get viewDirection(): NodeMaterialConnectionPoint;
  68301. /**
  68302. * Gets the bias input component
  68303. */
  68304. get bias(): NodeMaterialConnectionPoint;
  68305. /**
  68306. * Gets the camera (or eye) position component
  68307. */
  68308. get power(): NodeMaterialConnectionPoint;
  68309. /**
  68310. * Gets the fresnel output component
  68311. */
  68312. get fresnel(): NodeMaterialConnectionPoint;
  68313. autoConfigure(material: NodeMaterial): void;
  68314. protected _buildBlock(state: NodeMaterialBuildState): this;
  68315. }
  68316. }
  68317. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  68318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68321. /**
  68322. * Block used to get the max of 2 values
  68323. */
  68324. export class MaxBlock extends NodeMaterialBlock {
  68325. /**
  68326. * Creates a new MaxBlock
  68327. * @param name defines the block name
  68328. */
  68329. constructor(name: string);
  68330. /**
  68331. * Gets the current class name
  68332. * @returns the class name
  68333. */
  68334. getClassName(): string;
  68335. /**
  68336. * Gets the left operand input component
  68337. */
  68338. get left(): NodeMaterialConnectionPoint;
  68339. /**
  68340. * Gets the right operand input component
  68341. */
  68342. get right(): NodeMaterialConnectionPoint;
  68343. /**
  68344. * Gets the output component
  68345. */
  68346. get output(): NodeMaterialConnectionPoint;
  68347. protected _buildBlock(state: NodeMaterialBuildState): this;
  68348. }
  68349. }
  68350. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  68351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68354. /**
  68355. * Block used to get the min of 2 values
  68356. */
  68357. export class MinBlock extends NodeMaterialBlock {
  68358. /**
  68359. * Creates a new MinBlock
  68360. * @param name defines the block name
  68361. */
  68362. constructor(name: string);
  68363. /**
  68364. * Gets the current class name
  68365. * @returns the class name
  68366. */
  68367. getClassName(): string;
  68368. /**
  68369. * Gets the left operand input component
  68370. */
  68371. get left(): NodeMaterialConnectionPoint;
  68372. /**
  68373. * Gets the right operand input component
  68374. */
  68375. get right(): NodeMaterialConnectionPoint;
  68376. /**
  68377. * Gets the output component
  68378. */
  68379. get output(): NodeMaterialConnectionPoint;
  68380. protected _buildBlock(state: NodeMaterialBuildState): this;
  68381. }
  68382. }
  68383. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  68384. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68385. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68386. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68387. /**
  68388. * Block used to get the distance between 2 values
  68389. */
  68390. export class DistanceBlock extends NodeMaterialBlock {
  68391. /**
  68392. * Creates a new DistanceBlock
  68393. * @param name defines the block name
  68394. */
  68395. constructor(name: string);
  68396. /**
  68397. * Gets the current class name
  68398. * @returns the class name
  68399. */
  68400. getClassName(): string;
  68401. /**
  68402. * Gets the left operand input component
  68403. */
  68404. get left(): NodeMaterialConnectionPoint;
  68405. /**
  68406. * Gets the right operand input component
  68407. */
  68408. get right(): NodeMaterialConnectionPoint;
  68409. /**
  68410. * Gets the output component
  68411. */
  68412. get output(): NodeMaterialConnectionPoint;
  68413. protected _buildBlock(state: NodeMaterialBuildState): this;
  68414. }
  68415. }
  68416. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  68417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68420. /**
  68421. * Block used to get the length of a vector
  68422. */
  68423. export class LengthBlock extends NodeMaterialBlock {
  68424. /**
  68425. * Creates a new LengthBlock
  68426. * @param name defines the block name
  68427. */
  68428. constructor(name: string);
  68429. /**
  68430. * Gets the current class name
  68431. * @returns the class name
  68432. */
  68433. getClassName(): string;
  68434. /**
  68435. * Gets the value input component
  68436. */
  68437. get value(): NodeMaterialConnectionPoint;
  68438. /**
  68439. * Gets the output component
  68440. */
  68441. get output(): NodeMaterialConnectionPoint;
  68442. protected _buildBlock(state: NodeMaterialBuildState): this;
  68443. }
  68444. }
  68445. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  68446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68449. /**
  68450. * Block used to get negative version of a value (i.e. x * -1)
  68451. */
  68452. export class NegateBlock extends NodeMaterialBlock {
  68453. /**
  68454. * Creates a new NegateBlock
  68455. * @param name defines the block name
  68456. */
  68457. constructor(name: string);
  68458. /**
  68459. * Gets the current class name
  68460. * @returns the class name
  68461. */
  68462. getClassName(): string;
  68463. /**
  68464. * Gets the value input component
  68465. */
  68466. get value(): NodeMaterialConnectionPoint;
  68467. /**
  68468. * Gets the output component
  68469. */
  68470. get output(): NodeMaterialConnectionPoint;
  68471. protected _buildBlock(state: NodeMaterialBuildState): this;
  68472. }
  68473. }
  68474. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  68475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68478. /**
  68479. * Block used to get the value of the first parameter raised to the power of the second
  68480. */
  68481. export class PowBlock extends NodeMaterialBlock {
  68482. /**
  68483. * Creates a new PowBlock
  68484. * @param name defines the block name
  68485. */
  68486. constructor(name: string);
  68487. /**
  68488. * Gets the current class name
  68489. * @returns the class name
  68490. */
  68491. getClassName(): string;
  68492. /**
  68493. * Gets the value operand input component
  68494. */
  68495. get value(): NodeMaterialConnectionPoint;
  68496. /**
  68497. * Gets the power operand input component
  68498. */
  68499. get power(): NodeMaterialConnectionPoint;
  68500. /**
  68501. * Gets the output component
  68502. */
  68503. get output(): NodeMaterialConnectionPoint;
  68504. protected _buildBlock(state: NodeMaterialBuildState): this;
  68505. }
  68506. }
  68507. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  68508. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68511. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68512. /**
  68513. * Block used to get a random number
  68514. */
  68515. export class RandomNumberBlock extends NodeMaterialBlock {
  68516. /**
  68517. * Creates a new RandomNumberBlock
  68518. * @param name defines the block name
  68519. */
  68520. constructor(name: string);
  68521. /**
  68522. * Gets the current class name
  68523. * @returns the class name
  68524. */
  68525. getClassName(): string;
  68526. /**
  68527. * Gets the seed input component
  68528. */
  68529. get seed(): NodeMaterialConnectionPoint;
  68530. /**
  68531. * Gets the output component
  68532. */
  68533. get output(): NodeMaterialConnectionPoint;
  68534. protected _buildBlock(state: NodeMaterialBuildState): this;
  68535. }
  68536. }
  68537. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  68538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68541. /**
  68542. * Block used to compute arc tangent of 2 values
  68543. */
  68544. export class ArcTan2Block extends NodeMaterialBlock {
  68545. /**
  68546. * Creates a new ArcTan2Block
  68547. * @param name defines the block name
  68548. */
  68549. constructor(name: string);
  68550. /**
  68551. * Gets the current class name
  68552. * @returns the class name
  68553. */
  68554. getClassName(): string;
  68555. /**
  68556. * Gets the x operand input component
  68557. */
  68558. get x(): NodeMaterialConnectionPoint;
  68559. /**
  68560. * Gets the y operand input component
  68561. */
  68562. get y(): NodeMaterialConnectionPoint;
  68563. /**
  68564. * Gets the output component
  68565. */
  68566. get output(): NodeMaterialConnectionPoint;
  68567. protected _buildBlock(state: NodeMaterialBuildState): this;
  68568. }
  68569. }
  68570. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  68571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68574. /**
  68575. * Block used to smooth step a value
  68576. */
  68577. export class SmoothStepBlock extends NodeMaterialBlock {
  68578. /**
  68579. * Creates a new SmoothStepBlock
  68580. * @param name defines the block name
  68581. */
  68582. constructor(name: string);
  68583. /**
  68584. * Gets the current class name
  68585. * @returns the class name
  68586. */
  68587. getClassName(): string;
  68588. /**
  68589. * Gets the value operand input component
  68590. */
  68591. get value(): NodeMaterialConnectionPoint;
  68592. /**
  68593. * Gets the first edge operand input component
  68594. */
  68595. get edge0(): NodeMaterialConnectionPoint;
  68596. /**
  68597. * Gets the second edge operand input component
  68598. */
  68599. get edge1(): NodeMaterialConnectionPoint;
  68600. /**
  68601. * Gets the output component
  68602. */
  68603. get output(): NodeMaterialConnectionPoint;
  68604. protected _buildBlock(state: NodeMaterialBuildState): this;
  68605. }
  68606. }
  68607. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  68608. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68609. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68610. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68611. /**
  68612. * Block used to get the reciprocal (1 / x) of a value
  68613. */
  68614. export class ReciprocalBlock extends NodeMaterialBlock {
  68615. /**
  68616. * Creates a new ReciprocalBlock
  68617. * @param name defines the block name
  68618. */
  68619. constructor(name: string);
  68620. /**
  68621. * Gets the current class name
  68622. * @returns the class name
  68623. */
  68624. getClassName(): string;
  68625. /**
  68626. * Gets the input component
  68627. */
  68628. get input(): NodeMaterialConnectionPoint;
  68629. /**
  68630. * Gets the output component
  68631. */
  68632. get output(): NodeMaterialConnectionPoint;
  68633. protected _buildBlock(state: NodeMaterialBuildState): this;
  68634. }
  68635. }
  68636. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  68637. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68638. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68639. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68640. /**
  68641. * Block used to replace a color by another one
  68642. */
  68643. export class ReplaceColorBlock extends NodeMaterialBlock {
  68644. /**
  68645. * Creates a new ReplaceColorBlock
  68646. * @param name defines the block name
  68647. */
  68648. constructor(name: string);
  68649. /**
  68650. * Gets the current class name
  68651. * @returns the class name
  68652. */
  68653. getClassName(): string;
  68654. /**
  68655. * Gets the value input component
  68656. */
  68657. get value(): NodeMaterialConnectionPoint;
  68658. /**
  68659. * Gets the reference input component
  68660. */
  68661. get reference(): NodeMaterialConnectionPoint;
  68662. /**
  68663. * Gets the distance input component
  68664. */
  68665. get distance(): NodeMaterialConnectionPoint;
  68666. /**
  68667. * Gets the replacement input component
  68668. */
  68669. get replacement(): NodeMaterialConnectionPoint;
  68670. /**
  68671. * Gets the output component
  68672. */
  68673. get output(): NodeMaterialConnectionPoint;
  68674. protected _buildBlock(state: NodeMaterialBuildState): this;
  68675. }
  68676. }
  68677. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  68678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68681. /**
  68682. * Block used to posterize a value
  68683. * @see https://en.wikipedia.org/wiki/Posterization
  68684. */
  68685. export class PosterizeBlock extends NodeMaterialBlock {
  68686. /**
  68687. * Creates a new PosterizeBlock
  68688. * @param name defines the block name
  68689. */
  68690. constructor(name: string);
  68691. /**
  68692. * Gets the current class name
  68693. * @returns the class name
  68694. */
  68695. getClassName(): string;
  68696. /**
  68697. * Gets the value input component
  68698. */
  68699. get value(): NodeMaterialConnectionPoint;
  68700. /**
  68701. * Gets the steps input component
  68702. */
  68703. get steps(): NodeMaterialConnectionPoint;
  68704. /**
  68705. * Gets the output component
  68706. */
  68707. get output(): NodeMaterialConnectionPoint;
  68708. protected _buildBlock(state: NodeMaterialBuildState): this;
  68709. }
  68710. }
  68711. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  68712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68715. import { Scene } from "babylonjs/scene";
  68716. /**
  68717. * Operations supported by the Wave block
  68718. */
  68719. export enum WaveBlockKind {
  68720. /** SawTooth */
  68721. SawTooth = 0,
  68722. /** Square */
  68723. Square = 1,
  68724. /** Triangle */
  68725. Triangle = 2
  68726. }
  68727. /**
  68728. * Block used to apply wave operation to floats
  68729. */
  68730. export class WaveBlock extends NodeMaterialBlock {
  68731. /**
  68732. * Gets or sets the kibnd of wave to be applied by the block
  68733. */
  68734. kind: WaveBlockKind;
  68735. /**
  68736. * Creates a new WaveBlock
  68737. * @param name defines the block name
  68738. */
  68739. constructor(name: string);
  68740. /**
  68741. * Gets the current class name
  68742. * @returns the class name
  68743. */
  68744. getClassName(): string;
  68745. /**
  68746. * Gets the input component
  68747. */
  68748. get input(): NodeMaterialConnectionPoint;
  68749. /**
  68750. * Gets the output component
  68751. */
  68752. get output(): NodeMaterialConnectionPoint;
  68753. protected _buildBlock(state: NodeMaterialBuildState): this;
  68754. serialize(): any;
  68755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68756. }
  68757. }
  68758. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  68759. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68761. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68762. import { Color3 } from "babylonjs/Maths/math.color";
  68763. import { Scene } from "babylonjs/scene";
  68764. import { Observable } from "babylonjs/Misc/observable";
  68765. /**
  68766. * Class used to store a color step for the GradientBlock
  68767. */
  68768. export class GradientBlockColorStep {
  68769. private _step;
  68770. /**
  68771. * Gets value indicating which step this color is associated with (between 0 and 1)
  68772. */
  68773. get step(): number;
  68774. /**
  68775. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68776. */
  68777. set step(val: number);
  68778. private _color;
  68779. /**
  68780. * Gets the color associated with this step
  68781. */
  68782. get color(): Color3;
  68783. /**
  68784. * Sets the color associated with this step
  68785. */
  68786. set color(val: Color3);
  68787. /**
  68788. * Creates a new GradientBlockColorStep
  68789. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68790. * @param color defines the color associated with this step
  68791. */
  68792. constructor(step: number, color: Color3);
  68793. }
  68794. /**
  68795. * Block used to return a color from a gradient based on an input value between 0 and 1
  68796. */
  68797. export class GradientBlock extends NodeMaterialBlock {
  68798. /**
  68799. * Gets or sets the list of color steps
  68800. */
  68801. colorSteps: GradientBlockColorStep[];
  68802. /** Gets an observable raised when the value is changed */
  68803. onValueChangedObservable: Observable<GradientBlock>;
  68804. /** calls observable when the value is changed*/
  68805. colorStepsUpdated(): void;
  68806. /**
  68807. * Creates a new GradientBlock
  68808. * @param name defines the block name
  68809. */
  68810. constructor(name: string);
  68811. /**
  68812. * Gets the current class name
  68813. * @returns the class name
  68814. */
  68815. getClassName(): string;
  68816. /**
  68817. * Gets the gradient input component
  68818. */
  68819. get gradient(): NodeMaterialConnectionPoint;
  68820. /**
  68821. * Gets the output component
  68822. */
  68823. get output(): NodeMaterialConnectionPoint;
  68824. private _writeColorConstant;
  68825. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68826. serialize(): any;
  68827. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68828. protected _dumpPropertiesCode(): string;
  68829. }
  68830. }
  68831. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68835. /**
  68836. * Block used to normalize lerp between 2 values
  68837. */
  68838. export class NLerpBlock extends NodeMaterialBlock {
  68839. /**
  68840. * Creates a new NLerpBlock
  68841. * @param name defines the block name
  68842. */
  68843. constructor(name: string);
  68844. /**
  68845. * Gets the current class name
  68846. * @returns the class name
  68847. */
  68848. getClassName(): string;
  68849. /**
  68850. * Gets the left operand input component
  68851. */
  68852. get left(): NodeMaterialConnectionPoint;
  68853. /**
  68854. * Gets the right operand input component
  68855. */
  68856. get right(): NodeMaterialConnectionPoint;
  68857. /**
  68858. * Gets the gradient operand input component
  68859. */
  68860. get gradient(): NodeMaterialConnectionPoint;
  68861. /**
  68862. * Gets the output component
  68863. */
  68864. get output(): NodeMaterialConnectionPoint;
  68865. protected _buildBlock(state: NodeMaterialBuildState): this;
  68866. }
  68867. }
  68868. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68869. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68870. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68871. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68872. import { Scene } from "babylonjs/scene";
  68873. /**
  68874. * block used to Generate a Worley Noise 3D Noise Pattern
  68875. */
  68876. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68877. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68878. manhattanDistance: boolean;
  68879. /**
  68880. * Creates a new WorleyNoise3DBlock
  68881. * @param name defines the block name
  68882. */
  68883. constructor(name: string);
  68884. /**
  68885. * Gets the current class name
  68886. * @returns the class name
  68887. */
  68888. getClassName(): string;
  68889. /**
  68890. * Gets the seed input component
  68891. */
  68892. get seed(): NodeMaterialConnectionPoint;
  68893. /**
  68894. * Gets the jitter input component
  68895. */
  68896. get jitter(): NodeMaterialConnectionPoint;
  68897. /**
  68898. * Gets the output component
  68899. */
  68900. get output(): NodeMaterialConnectionPoint;
  68901. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68902. /**
  68903. * Exposes the properties to the UI?
  68904. */
  68905. protected _dumpPropertiesCode(): string;
  68906. /**
  68907. * Exposes the properties to the Seralize?
  68908. */
  68909. serialize(): any;
  68910. /**
  68911. * Exposes the properties to the deseralize?
  68912. */
  68913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68914. }
  68915. }
  68916. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68919. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68920. /**
  68921. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68922. */
  68923. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68924. /**
  68925. * Creates a new SimplexPerlin3DBlock
  68926. * @param name defines the block name
  68927. */
  68928. constructor(name: string);
  68929. /**
  68930. * Gets the current class name
  68931. * @returns the class name
  68932. */
  68933. getClassName(): string;
  68934. /**
  68935. * Gets the seed operand input component
  68936. */
  68937. get seed(): NodeMaterialConnectionPoint;
  68938. /**
  68939. * Gets the output component
  68940. */
  68941. get output(): NodeMaterialConnectionPoint;
  68942. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68943. }
  68944. }
  68945. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68946. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68947. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68948. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68949. /**
  68950. * Block used to blend normals
  68951. */
  68952. export class NormalBlendBlock extends NodeMaterialBlock {
  68953. /**
  68954. * Creates a new NormalBlendBlock
  68955. * @param name defines the block name
  68956. */
  68957. constructor(name: string);
  68958. /**
  68959. * Gets the current class name
  68960. * @returns the class name
  68961. */
  68962. getClassName(): string;
  68963. /**
  68964. * Gets the first input component
  68965. */
  68966. get normalMap0(): NodeMaterialConnectionPoint;
  68967. /**
  68968. * Gets the second input component
  68969. */
  68970. get normalMap1(): NodeMaterialConnectionPoint;
  68971. /**
  68972. * Gets the output component
  68973. */
  68974. get output(): NodeMaterialConnectionPoint;
  68975. protected _buildBlock(state: NodeMaterialBuildState): this;
  68976. }
  68977. }
  68978. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68979. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68980. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68982. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68983. /**
  68984. * Block used to rotate a 2d vector by a given angle
  68985. */
  68986. export class Rotate2dBlock extends NodeMaterialBlock {
  68987. /**
  68988. * Creates a new Rotate2dBlock
  68989. * @param name defines the block name
  68990. */
  68991. constructor(name: string);
  68992. /**
  68993. * Gets the current class name
  68994. * @returns the class name
  68995. */
  68996. getClassName(): string;
  68997. /**
  68998. * Gets the input vector
  68999. */
  69000. get input(): NodeMaterialConnectionPoint;
  69001. /**
  69002. * Gets the input angle
  69003. */
  69004. get angle(): NodeMaterialConnectionPoint;
  69005. /**
  69006. * Gets the output component
  69007. */
  69008. get output(): NodeMaterialConnectionPoint;
  69009. autoConfigure(material: NodeMaterial): void;
  69010. protected _buildBlock(state: NodeMaterialBuildState): this;
  69011. }
  69012. }
  69013. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  69014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69017. /**
  69018. * Block used to get the reflected vector from a direction and a normal
  69019. */
  69020. export class ReflectBlock extends NodeMaterialBlock {
  69021. /**
  69022. * Creates a new ReflectBlock
  69023. * @param name defines the block name
  69024. */
  69025. constructor(name: string);
  69026. /**
  69027. * Gets the current class name
  69028. * @returns the class name
  69029. */
  69030. getClassName(): string;
  69031. /**
  69032. * Gets the incident component
  69033. */
  69034. get incident(): NodeMaterialConnectionPoint;
  69035. /**
  69036. * Gets the normal component
  69037. */
  69038. get normal(): NodeMaterialConnectionPoint;
  69039. /**
  69040. * Gets the output component
  69041. */
  69042. get output(): NodeMaterialConnectionPoint;
  69043. protected _buildBlock(state: NodeMaterialBuildState): this;
  69044. }
  69045. }
  69046. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  69047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69050. /**
  69051. * Block used to get the refracted vector from a direction and a normal
  69052. */
  69053. export class RefractBlock extends NodeMaterialBlock {
  69054. /**
  69055. * Creates a new RefractBlock
  69056. * @param name defines the block name
  69057. */
  69058. constructor(name: string);
  69059. /**
  69060. * Gets the current class name
  69061. * @returns the class name
  69062. */
  69063. getClassName(): string;
  69064. /**
  69065. * Gets the incident component
  69066. */
  69067. get incident(): NodeMaterialConnectionPoint;
  69068. /**
  69069. * Gets the normal component
  69070. */
  69071. get normal(): NodeMaterialConnectionPoint;
  69072. /**
  69073. * Gets the index of refraction component
  69074. */
  69075. get ior(): NodeMaterialConnectionPoint;
  69076. /**
  69077. * Gets the output component
  69078. */
  69079. get output(): NodeMaterialConnectionPoint;
  69080. protected _buildBlock(state: NodeMaterialBuildState): this;
  69081. }
  69082. }
  69083. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  69084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69087. /**
  69088. * Block used to desaturate a color
  69089. */
  69090. export class DesaturateBlock extends NodeMaterialBlock {
  69091. /**
  69092. * Creates a new DesaturateBlock
  69093. * @param name defines the block name
  69094. */
  69095. constructor(name: string);
  69096. /**
  69097. * Gets the current class name
  69098. * @returns the class name
  69099. */
  69100. getClassName(): string;
  69101. /**
  69102. * Gets the color operand input component
  69103. */
  69104. get color(): NodeMaterialConnectionPoint;
  69105. /**
  69106. * Gets the level operand input component
  69107. */
  69108. get level(): NodeMaterialConnectionPoint;
  69109. /**
  69110. * Gets the output component
  69111. */
  69112. get output(): NodeMaterialConnectionPoint;
  69113. protected _buildBlock(state: NodeMaterialBuildState): this;
  69114. }
  69115. }
  69116. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  69117. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69118. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69119. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69120. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  69121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69122. import { Nullable } from "babylonjs/types";
  69123. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69124. import { Mesh } from "babylonjs/Meshes/mesh";
  69125. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69126. import { Effect } from "babylonjs/Materials/effect";
  69127. import { Scene } from "babylonjs/scene";
  69128. /**
  69129. * Block used to implement the reflection module of the PBR material
  69130. */
  69131. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69132. /** @hidden */
  69133. _defineLODReflectionAlpha: string;
  69134. /** @hidden */
  69135. _defineLinearSpecularReflection: string;
  69136. private _vEnvironmentIrradianceName;
  69137. /** @hidden */
  69138. _vReflectionMicrosurfaceInfosName: string;
  69139. /** @hidden */
  69140. _vReflectionInfosName: string;
  69141. /** @hidden */
  69142. _vReflectionFilteringInfoName: string;
  69143. private _scene;
  69144. /**
  69145. * The properties below are set by the main PBR block prior to calling methods of this class.
  69146. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69147. * It's less burden on the user side in the editor part.
  69148. */
  69149. /** @hidden */
  69150. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69151. /** @hidden */
  69152. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69153. /** @hidden */
  69154. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69155. /** @hidden */
  69156. viewConnectionPoint: NodeMaterialConnectionPoint;
  69157. /**
  69158. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69159. * diffuse part of the IBL.
  69160. */
  69161. useSphericalHarmonics: boolean;
  69162. /**
  69163. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69164. */
  69165. forceIrradianceInFragment: boolean;
  69166. /**
  69167. * Create a new ReflectionBlock
  69168. * @param name defines the block name
  69169. */
  69170. constructor(name: string);
  69171. /**
  69172. * Gets the current class name
  69173. * @returns the class name
  69174. */
  69175. getClassName(): string;
  69176. /**
  69177. * Gets the position input component
  69178. */
  69179. get position(): NodeMaterialConnectionPoint;
  69180. /**
  69181. * Gets the world position input component
  69182. */
  69183. get worldPosition(): NodeMaterialConnectionPoint;
  69184. /**
  69185. * Gets the world normal input component
  69186. */
  69187. get worldNormal(): NodeMaterialConnectionPoint;
  69188. /**
  69189. * Gets the world input component
  69190. */
  69191. get world(): NodeMaterialConnectionPoint;
  69192. /**
  69193. * Gets the camera (or eye) position component
  69194. */
  69195. get cameraPosition(): NodeMaterialConnectionPoint;
  69196. /**
  69197. * Gets the view input component
  69198. */
  69199. get view(): NodeMaterialConnectionPoint;
  69200. /**
  69201. * Gets the color input component
  69202. */
  69203. get color(): NodeMaterialConnectionPoint;
  69204. /**
  69205. * Gets the reflection object output component
  69206. */
  69207. get reflection(): NodeMaterialConnectionPoint;
  69208. /**
  69209. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69210. */
  69211. get hasTexture(): boolean;
  69212. /**
  69213. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69214. */
  69215. get reflectionColor(): string;
  69216. protected _getTexture(): Nullable<BaseTexture>;
  69217. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69218. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69219. /**
  69220. * Gets the code to inject in the vertex shader
  69221. * @param state current state of the node material building
  69222. * @returns the shader code
  69223. */
  69224. handleVertexSide(state: NodeMaterialBuildState): string;
  69225. /**
  69226. * Gets the main code of the block (fragment side)
  69227. * @param state current state of the node material building
  69228. * @param normalVarName name of the existing variable corresponding to the normal
  69229. * @returns the shader code
  69230. */
  69231. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69232. protected _buildBlock(state: NodeMaterialBuildState): this;
  69233. protected _dumpPropertiesCode(): string;
  69234. serialize(): any;
  69235. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69236. }
  69237. }
  69238. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  69239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69242. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69244. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69245. import { Scene } from "babylonjs/scene";
  69246. import { Nullable } from "babylonjs/types";
  69247. /**
  69248. * Block used to implement the sheen module of the PBR material
  69249. */
  69250. export class SheenBlock extends NodeMaterialBlock {
  69251. /**
  69252. * Create a new SheenBlock
  69253. * @param name defines the block name
  69254. */
  69255. constructor(name: string);
  69256. /**
  69257. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69258. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69259. * making it easier to setup and tweak the effect
  69260. */
  69261. albedoScaling: boolean;
  69262. /**
  69263. * Defines if the sheen is linked to the sheen color.
  69264. */
  69265. linkSheenWithAlbedo: boolean;
  69266. /**
  69267. * Initialize the block and prepare the context for build
  69268. * @param state defines the state that will be used for the build
  69269. */
  69270. initialize(state: NodeMaterialBuildState): void;
  69271. /**
  69272. * Gets the current class name
  69273. * @returns the class name
  69274. */
  69275. getClassName(): string;
  69276. /**
  69277. * Gets the intensity input component
  69278. */
  69279. get intensity(): NodeMaterialConnectionPoint;
  69280. /**
  69281. * Gets the color input component
  69282. */
  69283. get color(): NodeMaterialConnectionPoint;
  69284. /**
  69285. * Gets the roughness input component
  69286. */
  69287. get roughness(): NodeMaterialConnectionPoint;
  69288. /**
  69289. * Gets the sheen object output component
  69290. */
  69291. get sheen(): NodeMaterialConnectionPoint;
  69292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69293. /**
  69294. * Gets the main code of the block (fragment side)
  69295. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69296. * @returns the shader code
  69297. */
  69298. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69299. protected _buildBlock(state: NodeMaterialBuildState): this;
  69300. protected _dumpPropertiesCode(): string;
  69301. serialize(): any;
  69302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69303. }
  69304. }
  69305. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  69306. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69307. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69308. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69309. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69311. /**
  69312. * Block used to implement the anisotropy module of the PBR material
  69313. */
  69314. export class AnisotropyBlock extends NodeMaterialBlock {
  69315. /**
  69316. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69317. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69318. * It's less burden on the user side in the editor part.
  69319. */
  69320. /** @hidden */
  69321. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69322. /** @hidden */
  69323. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69324. /**
  69325. * Create a new AnisotropyBlock
  69326. * @param name defines the block name
  69327. */
  69328. constructor(name: string);
  69329. /**
  69330. * Initialize the block and prepare the context for build
  69331. * @param state defines the state that will be used for the build
  69332. */
  69333. initialize(state: NodeMaterialBuildState): void;
  69334. /**
  69335. * Gets the current class name
  69336. * @returns the class name
  69337. */
  69338. getClassName(): string;
  69339. /**
  69340. * Gets the intensity input component
  69341. */
  69342. get intensity(): NodeMaterialConnectionPoint;
  69343. /**
  69344. * Gets the direction input component
  69345. */
  69346. get direction(): NodeMaterialConnectionPoint;
  69347. /**
  69348. * Gets the uv input component
  69349. */
  69350. get uv(): NodeMaterialConnectionPoint;
  69351. /**
  69352. * Gets the worldTangent input component
  69353. */
  69354. get worldTangent(): NodeMaterialConnectionPoint;
  69355. /**
  69356. * Gets the anisotropy object output component
  69357. */
  69358. get anisotropy(): NodeMaterialConnectionPoint;
  69359. private _generateTBNSpace;
  69360. /**
  69361. * Gets the main code of the block (fragment side)
  69362. * @param state current state of the node material building
  69363. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69364. * @returns the shader code
  69365. */
  69366. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69367. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69368. protected _buildBlock(state: NodeMaterialBuildState): this;
  69369. }
  69370. }
  69371. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  69372. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69373. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69374. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69375. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69377. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69378. import { Scene } from "babylonjs/scene";
  69379. import { Nullable } from "babylonjs/types";
  69380. import { Mesh } from "babylonjs/Meshes/mesh";
  69381. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69382. import { Effect } from "babylonjs/Materials/effect";
  69383. /**
  69384. * Block used to implement the clear coat module of the PBR material
  69385. */
  69386. export class ClearCoatBlock extends NodeMaterialBlock {
  69387. private _scene;
  69388. /**
  69389. * Create a new ClearCoatBlock
  69390. * @param name defines the block name
  69391. */
  69392. constructor(name: string);
  69393. /**
  69394. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69395. */
  69396. remapF0OnInterfaceChange: boolean;
  69397. /**
  69398. * Initialize the block and prepare the context for build
  69399. * @param state defines the state that will be used for the build
  69400. */
  69401. initialize(state: NodeMaterialBuildState): void;
  69402. /**
  69403. * Gets the current class name
  69404. * @returns the class name
  69405. */
  69406. getClassName(): string;
  69407. /**
  69408. * Gets the intensity input component
  69409. */
  69410. get intensity(): NodeMaterialConnectionPoint;
  69411. /**
  69412. * Gets the roughness input component
  69413. */
  69414. get roughness(): NodeMaterialConnectionPoint;
  69415. /**
  69416. * Gets the ior input component
  69417. */
  69418. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69419. /**
  69420. * Gets the bump texture input component
  69421. */
  69422. get normalMapColor(): NodeMaterialConnectionPoint;
  69423. /**
  69424. * Gets the uv input component
  69425. */
  69426. get uv(): NodeMaterialConnectionPoint;
  69427. /**
  69428. * Gets the tint color input component
  69429. */
  69430. get tintColor(): NodeMaterialConnectionPoint;
  69431. /**
  69432. * Gets the tint "at distance" input component
  69433. */
  69434. get tintAtDistance(): NodeMaterialConnectionPoint;
  69435. /**
  69436. * Gets the tint thickness input component
  69437. */
  69438. get tintThickness(): NodeMaterialConnectionPoint;
  69439. /**
  69440. * Gets the world tangent input component
  69441. */
  69442. get worldTangent(): NodeMaterialConnectionPoint;
  69443. /**
  69444. * Gets the clear coat object output component
  69445. */
  69446. get clearcoat(): NodeMaterialConnectionPoint;
  69447. autoConfigure(material: NodeMaterial): void;
  69448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69449. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69450. private _generateTBNSpace;
  69451. /**
  69452. * Gets the main code of the block (fragment side)
  69453. * @param state current state of the node material building
  69454. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69455. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69456. * @param worldPosVarName name of the variable holding the world position
  69457. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69458. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69459. * @param worldNormalVarName name of the variable holding the world normal
  69460. * @returns the shader code
  69461. */
  69462. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69463. protected _buildBlock(state: NodeMaterialBuildState): this;
  69464. protected _dumpPropertiesCode(): string;
  69465. serialize(): any;
  69466. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69467. }
  69468. }
  69469. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  69470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69471. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69472. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69473. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69475. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69476. import { Nullable } from "babylonjs/types";
  69477. /**
  69478. * Block used to implement the sub surface module of the PBR material
  69479. */
  69480. export class SubSurfaceBlock extends NodeMaterialBlock {
  69481. /**
  69482. * Create a new SubSurfaceBlock
  69483. * @param name defines the block name
  69484. */
  69485. constructor(name: string);
  69486. /**
  69487. * Initialize the block and prepare the context for build
  69488. * @param state defines the state that will be used for the build
  69489. */
  69490. initialize(state: NodeMaterialBuildState): void;
  69491. /**
  69492. * Gets the current class name
  69493. * @returns the class name
  69494. */
  69495. getClassName(): string;
  69496. /**
  69497. * Gets the thickness component
  69498. */
  69499. get thickness(): NodeMaterialConnectionPoint;
  69500. /**
  69501. * Gets the tint color input component
  69502. */
  69503. get tintColor(): NodeMaterialConnectionPoint;
  69504. /**
  69505. * Gets the translucency intensity input component
  69506. */
  69507. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69508. /**
  69509. * Gets the translucency diffusion distance input component
  69510. */
  69511. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69512. /**
  69513. * Gets the refraction object parameters
  69514. */
  69515. get refraction(): NodeMaterialConnectionPoint;
  69516. /**
  69517. * Gets the sub surface object output component
  69518. */
  69519. get subsurface(): NodeMaterialConnectionPoint;
  69520. autoConfigure(material: NodeMaterial): void;
  69521. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69522. /**
  69523. * Gets the main code of the block (fragment side)
  69524. * @param state current state of the node material building
  69525. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69526. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69527. * @param worldPosVarName name of the variable holding the world position
  69528. * @returns the shader code
  69529. */
  69530. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69531. protected _buildBlock(state: NodeMaterialBuildState): this;
  69532. }
  69533. }
  69534. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  69535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69536. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69538. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69539. import { Light } from "babylonjs/Lights/light";
  69540. import { Nullable } from "babylonjs/types";
  69541. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69542. import { Effect } from "babylonjs/Materials/effect";
  69543. import { Mesh } from "babylonjs/Meshes/mesh";
  69544. import { Scene } from "babylonjs/scene";
  69545. /**
  69546. * Block used to implement the PBR metallic/roughness model
  69547. */
  69548. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69549. /**
  69550. * Gets or sets the light associated with this block
  69551. */
  69552. light: Nullable<Light>;
  69553. private _lightId;
  69554. private _scene;
  69555. private _environmentBRDFTexture;
  69556. private _environmentBrdfSamplerName;
  69557. private _vNormalWName;
  69558. private _invertNormalName;
  69559. private _metallicReflectanceColor;
  69560. private _metallicF0Factor;
  69561. private _vMetallicReflectanceFactorsName;
  69562. /**
  69563. * Create a new ReflectionBlock
  69564. * @param name defines the block name
  69565. */
  69566. constructor(name: string);
  69567. /**
  69568. * Intensity of the direct lights e.g. the four lights available in your scene.
  69569. * This impacts both the direct diffuse and specular highlights.
  69570. */
  69571. directIntensity: number;
  69572. /**
  69573. * Intensity of the environment e.g. how much the environment will light the object
  69574. * either through harmonics for rough material or through the refelction for shiny ones.
  69575. */
  69576. environmentIntensity: number;
  69577. /**
  69578. * This is a special control allowing the reduction of the specular highlights coming from the
  69579. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69580. */
  69581. specularIntensity: number;
  69582. /**
  69583. * Defines the falloff type used in this material.
  69584. * It by default is Physical.
  69585. */
  69586. lightFalloff: number;
  69587. /**
  69588. * Specifies that alpha test should be used
  69589. */
  69590. useAlphaTest: boolean;
  69591. /**
  69592. * Defines the alpha limits in alpha test mode.
  69593. */
  69594. alphaTestCutoff: number;
  69595. /**
  69596. * Specifies that alpha blending should be used
  69597. */
  69598. useAlphaBlending: boolean;
  69599. /**
  69600. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69601. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69602. */
  69603. useRadianceOverAlpha: boolean;
  69604. /**
  69605. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69606. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69607. */
  69608. useSpecularOverAlpha: boolean;
  69609. /**
  69610. * Enables specular anti aliasing in the PBR shader.
  69611. * It will both interacts on the Geometry for analytical and IBL lighting.
  69612. * It also prefilter the roughness map based on the bump values.
  69613. */
  69614. enableSpecularAntiAliasing: boolean;
  69615. /**
  69616. * Enables realtime filtering on the texture.
  69617. */
  69618. realTimeFiltering: boolean;
  69619. /**
  69620. * Quality switch for realtime filtering
  69621. */
  69622. realTimeFilteringQuality: number;
  69623. /**
  69624. * Defines if the material uses energy conservation.
  69625. */
  69626. useEnergyConservation: boolean;
  69627. /**
  69628. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69629. * too much the area relying on ambient texture to define their ambient occlusion.
  69630. */
  69631. useRadianceOcclusion: boolean;
  69632. /**
  69633. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69634. * makes the reflect vector face the model (under horizon).
  69635. */
  69636. useHorizonOcclusion: boolean;
  69637. /**
  69638. * If set to true, no lighting calculations will be applied.
  69639. */
  69640. unlit: boolean;
  69641. /**
  69642. * Force normal to face away from face.
  69643. */
  69644. forceNormalForward: boolean;
  69645. /**
  69646. * Defines the material debug mode.
  69647. * It helps seeing only some components of the material while troubleshooting.
  69648. */
  69649. debugMode: number;
  69650. /**
  69651. * Specify from where on screen the debug mode should start.
  69652. * The value goes from -1 (full screen) to 1 (not visible)
  69653. * It helps with side by side comparison against the final render
  69654. * This defaults to 0
  69655. */
  69656. debugLimit: number;
  69657. /**
  69658. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69659. * You can use the factor to better multiply the final value.
  69660. */
  69661. debugFactor: number;
  69662. /**
  69663. * Initialize the block and prepare the context for build
  69664. * @param state defines the state that will be used for the build
  69665. */
  69666. initialize(state: NodeMaterialBuildState): void;
  69667. /**
  69668. * Gets the current class name
  69669. * @returns the class name
  69670. */
  69671. getClassName(): string;
  69672. /**
  69673. * Gets the world position input component
  69674. */
  69675. get worldPosition(): NodeMaterialConnectionPoint;
  69676. /**
  69677. * Gets the world normal input component
  69678. */
  69679. get worldNormal(): NodeMaterialConnectionPoint;
  69680. /**
  69681. * Gets the view matrix parameter
  69682. */
  69683. get view(): NodeMaterialConnectionPoint;
  69684. /**
  69685. * Gets the camera position input component
  69686. */
  69687. get cameraPosition(): NodeMaterialConnectionPoint;
  69688. /**
  69689. * Gets the perturbed normal input component
  69690. */
  69691. get perturbedNormal(): NodeMaterialConnectionPoint;
  69692. /**
  69693. * Gets the base color input component
  69694. */
  69695. get baseColor(): NodeMaterialConnectionPoint;
  69696. /**
  69697. * Gets the metallic input component
  69698. */
  69699. get metallic(): NodeMaterialConnectionPoint;
  69700. /**
  69701. * Gets the roughness input component
  69702. */
  69703. get roughness(): NodeMaterialConnectionPoint;
  69704. /**
  69705. * Gets the ambient occlusion input component
  69706. */
  69707. get ambientOcc(): NodeMaterialConnectionPoint;
  69708. /**
  69709. * Gets the opacity input component
  69710. */
  69711. get opacity(): NodeMaterialConnectionPoint;
  69712. /**
  69713. * Gets the index of refraction input component
  69714. */
  69715. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69716. /**
  69717. * Gets the ambient color input component
  69718. */
  69719. get ambientColor(): NodeMaterialConnectionPoint;
  69720. /**
  69721. * Gets the reflection object parameters
  69722. */
  69723. get reflection(): NodeMaterialConnectionPoint;
  69724. /**
  69725. * Gets the clear coat object parameters
  69726. */
  69727. get clearcoat(): NodeMaterialConnectionPoint;
  69728. /**
  69729. * Gets the sheen object parameters
  69730. */
  69731. get sheen(): NodeMaterialConnectionPoint;
  69732. /**
  69733. * Gets the sub surface object parameters
  69734. */
  69735. get subsurface(): NodeMaterialConnectionPoint;
  69736. /**
  69737. * Gets the anisotropy object parameters
  69738. */
  69739. get anisotropy(): NodeMaterialConnectionPoint;
  69740. /**
  69741. * Gets the ambient output component
  69742. */
  69743. get ambientClr(): NodeMaterialConnectionPoint;
  69744. /**
  69745. * Gets the diffuse output component
  69746. */
  69747. get diffuseDir(): NodeMaterialConnectionPoint;
  69748. /**
  69749. * Gets the specular output component
  69750. */
  69751. get specularDir(): NodeMaterialConnectionPoint;
  69752. /**
  69753. * Gets the clear coat output component
  69754. */
  69755. get clearcoatDir(): NodeMaterialConnectionPoint;
  69756. /**
  69757. * Gets the sheen output component
  69758. */
  69759. get sheenDir(): NodeMaterialConnectionPoint;
  69760. /**
  69761. * Gets the indirect diffuse output component
  69762. */
  69763. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69764. /**
  69765. * Gets the indirect specular output component
  69766. */
  69767. get specularIndirect(): NodeMaterialConnectionPoint;
  69768. /**
  69769. * Gets the indirect clear coat output component
  69770. */
  69771. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69772. /**
  69773. * Gets the indirect sheen output component
  69774. */
  69775. get sheenIndirect(): NodeMaterialConnectionPoint;
  69776. /**
  69777. * Gets the refraction output component
  69778. */
  69779. get refraction(): NodeMaterialConnectionPoint;
  69780. /**
  69781. * Gets the global lighting output component
  69782. */
  69783. get lighting(): NodeMaterialConnectionPoint;
  69784. /**
  69785. * Gets the shadow output component
  69786. */
  69787. get shadow(): NodeMaterialConnectionPoint;
  69788. /**
  69789. * Gets the alpha output component
  69790. */
  69791. get alpha(): NodeMaterialConnectionPoint;
  69792. autoConfigure(material: NodeMaterial): void;
  69793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69794. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69795. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69796. private _injectVertexCode;
  69797. private _getAlbedoOpacityCode;
  69798. private _getAmbientOcclusionCode;
  69799. private _getReflectivityCode;
  69800. protected _buildBlock(state: NodeMaterialBuildState): this;
  69801. protected _dumpPropertiesCode(): string;
  69802. serialize(): any;
  69803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69804. }
  69805. }
  69806. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69807. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69808. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69809. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69810. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69811. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69812. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69813. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69814. }
  69815. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69816. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69817. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69818. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69819. }
  69820. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69824. /**
  69825. * Block used to compute value of one parameter modulo another
  69826. */
  69827. export class ModBlock extends NodeMaterialBlock {
  69828. /**
  69829. * Creates a new ModBlock
  69830. * @param name defines the block name
  69831. */
  69832. constructor(name: string);
  69833. /**
  69834. * Gets the current class name
  69835. * @returns the class name
  69836. */
  69837. getClassName(): string;
  69838. /**
  69839. * Gets the left operand input component
  69840. */
  69841. get left(): NodeMaterialConnectionPoint;
  69842. /**
  69843. * Gets the right operand input component
  69844. */
  69845. get right(): NodeMaterialConnectionPoint;
  69846. /**
  69847. * Gets the output component
  69848. */
  69849. get output(): NodeMaterialConnectionPoint;
  69850. protected _buildBlock(state: NodeMaterialBuildState): this;
  69851. }
  69852. }
  69853. declare module "babylonjs/Materials/Node/Blocks/index" {
  69854. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69855. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69856. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69857. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69858. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69859. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69860. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69861. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69862. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69863. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69864. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69865. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69866. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69867. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69868. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69869. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69870. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69871. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69872. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69873. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69874. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69875. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69876. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69877. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69878. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69879. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69880. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69881. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69882. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69883. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69884. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69885. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69886. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69887. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69888. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69889. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69890. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69891. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69892. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69893. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69894. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69895. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69896. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69897. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69898. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69899. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69900. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69901. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69902. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69903. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69904. }
  69905. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69906. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69907. }
  69908. declare module "babylonjs/Materials/Node/index" {
  69909. export * from "babylonjs/Materials/Node/Enums/index";
  69910. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69911. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69912. export * from "babylonjs/Materials/Node/nodeMaterial";
  69913. export * from "babylonjs/Materials/Node/Blocks/index";
  69914. export * from "babylonjs/Materials/Node/Optimizers/index";
  69915. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69916. }
  69917. declare module "babylonjs/Materials/index" {
  69918. export * from "babylonjs/Materials/Background/index";
  69919. export * from "babylonjs/Materials/colorCurves";
  69920. export * from "babylonjs/Materials/iEffectFallbacks";
  69921. export * from "babylonjs/Materials/effectFallbacks";
  69922. export * from "babylonjs/Materials/effect";
  69923. export * from "babylonjs/Materials/fresnelParameters";
  69924. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69925. export * from "babylonjs/Materials/material";
  69926. export * from "babylonjs/Materials/materialDefines";
  69927. export * from "babylonjs/Materials/thinMaterialHelper";
  69928. export * from "babylonjs/Materials/materialHelper";
  69929. export * from "babylonjs/Materials/multiMaterial";
  69930. export * from "babylonjs/Materials/Occlusion/index";
  69931. export * from "babylonjs/Materials/PBR/index";
  69932. export * from "babylonjs/Materials/pushMaterial";
  69933. export * from "babylonjs/Materials/shaderMaterial";
  69934. export * from "babylonjs/Materials/standardMaterial";
  69935. export * from "babylonjs/Materials/Textures/index";
  69936. export * from "babylonjs/Materials/uniformBuffer";
  69937. export * from "babylonjs/Materials/materialFlags";
  69938. export * from "babylonjs/Materials/Node/index";
  69939. export * from "babylonjs/Materials/effectRenderer";
  69940. export * from "babylonjs/Materials/shadowDepthWrapper";
  69941. }
  69942. declare module "babylonjs/Maths/index" {
  69943. export * from "babylonjs/Maths/math.scalar";
  69944. export * from "babylonjs/Maths/math.functions";
  69945. export * from "babylonjs/Maths/math";
  69946. export * from "babylonjs/Maths/sphericalPolynomial";
  69947. }
  69948. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69949. import { IDisposable } from "babylonjs/scene";
  69950. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69951. /**
  69952. * Configuration for Draco compression
  69953. */
  69954. export interface IDracoCompressionConfiguration {
  69955. /**
  69956. * Configuration for the decoder.
  69957. */
  69958. decoder: {
  69959. /**
  69960. * The url to the WebAssembly module.
  69961. */
  69962. wasmUrl?: string;
  69963. /**
  69964. * The url to the WebAssembly binary.
  69965. */
  69966. wasmBinaryUrl?: string;
  69967. /**
  69968. * The url to the fallback JavaScript module.
  69969. */
  69970. fallbackUrl?: string;
  69971. };
  69972. }
  69973. /**
  69974. * Draco compression (https://google.github.io/draco/)
  69975. *
  69976. * This class wraps the Draco module.
  69977. *
  69978. * **Encoder**
  69979. *
  69980. * The encoder is not currently implemented.
  69981. *
  69982. * **Decoder**
  69983. *
  69984. * 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.
  69985. *
  69986. * To update the configuration, use the following code:
  69987. * ```javascript
  69988. * DracoCompression.Configuration = {
  69989. * decoder: {
  69990. * wasmUrl: "<url to the WebAssembly library>",
  69991. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69992. * fallbackUrl: "<url to the fallback JavaScript library>",
  69993. * }
  69994. * };
  69995. * ```
  69996. *
  69997. * 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.
  69998. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69999. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  70000. *
  70001. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  70002. * ```javascript
  70003. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  70004. * ```
  70005. *
  70006. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  70007. */
  70008. export class DracoCompression implements IDisposable {
  70009. private _workerPoolPromise?;
  70010. private _decoderModulePromise?;
  70011. /**
  70012. * The configuration. Defaults to the following urls:
  70013. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  70014. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  70015. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  70016. */
  70017. static Configuration: IDracoCompressionConfiguration;
  70018. /**
  70019. * Returns true if the decoder configuration is available.
  70020. */
  70021. static get DecoderAvailable(): boolean;
  70022. /**
  70023. * Default number of workers to create when creating the draco compression object.
  70024. */
  70025. static DefaultNumWorkers: number;
  70026. private static GetDefaultNumWorkers;
  70027. private static _Default;
  70028. /**
  70029. * Default instance for the draco compression object.
  70030. */
  70031. static get Default(): DracoCompression;
  70032. /**
  70033. * Constructor
  70034. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  70035. */
  70036. constructor(numWorkers?: number);
  70037. /**
  70038. * Stop all async operations and release resources.
  70039. */
  70040. dispose(): void;
  70041. /**
  70042. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  70043. * @returns a promise that resolves when ready
  70044. */
  70045. whenReadyAsync(): Promise<void>;
  70046. /**
  70047. * Decode Draco compressed mesh data to vertex data.
  70048. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  70049. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  70050. * @returns A promise that resolves with the decoded vertex data
  70051. */
  70052. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  70053. [kind: string]: number;
  70054. }): Promise<VertexData>;
  70055. }
  70056. }
  70057. declare module "babylonjs/Meshes/Compression/index" {
  70058. export * from "babylonjs/Meshes/Compression/dracoCompression";
  70059. }
  70060. declare module "babylonjs/Meshes/csg" {
  70061. import { Nullable } from "babylonjs/types";
  70062. import { Scene } from "babylonjs/scene";
  70063. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  70064. import { Mesh } from "babylonjs/Meshes/mesh";
  70065. import { Material } from "babylonjs/Materials/material";
  70066. /**
  70067. * Class for building Constructive Solid Geometry
  70068. */
  70069. export class CSG {
  70070. private polygons;
  70071. /**
  70072. * The world matrix
  70073. */
  70074. matrix: Matrix;
  70075. /**
  70076. * Stores the position
  70077. */
  70078. position: Vector3;
  70079. /**
  70080. * Stores the rotation
  70081. */
  70082. rotation: Vector3;
  70083. /**
  70084. * Stores the rotation quaternion
  70085. */
  70086. rotationQuaternion: Nullable<Quaternion>;
  70087. /**
  70088. * Stores the scaling vector
  70089. */
  70090. scaling: Vector3;
  70091. /**
  70092. * Convert the Mesh to CSG
  70093. * @param mesh The Mesh to convert to CSG
  70094. * @returns A new CSG from the Mesh
  70095. */
  70096. static FromMesh(mesh: Mesh): CSG;
  70097. /**
  70098. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  70099. * @param polygons Polygons used to construct a CSG solid
  70100. */
  70101. private static FromPolygons;
  70102. /**
  70103. * Clones, or makes a deep copy, of the CSG
  70104. * @returns A new CSG
  70105. */
  70106. clone(): CSG;
  70107. /**
  70108. * Unions this CSG with another CSG
  70109. * @param csg The CSG to union against this CSG
  70110. * @returns The unioned CSG
  70111. */
  70112. union(csg: CSG): CSG;
  70113. /**
  70114. * Unions this CSG with another CSG in place
  70115. * @param csg The CSG to union against this CSG
  70116. */
  70117. unionInPlace(csg: CSG): void;
  70118. /**
  70119. * Subtracts this CSG with another CSG
  70120. * @param csg The CSG to subtract against this CSG
  70121. * @returns A new CSG
  70122. */
  70123. subtract(csg: CSG): CSG;
  70124. /**
  70125. * Subtracts this CSG with another CSG in place
  70126. * @param csg The CSG to subtact against this CSG
  70127. */
  70128. subtractInPlace(csg: CSG): void;
  70129. /**
  70130. * Intersect this CSG with another CSG
  70131. * @param csg The CSG to intersect against this CSG
  70132. * @returns A new CSG
  70133. */
  70134. intersect(csg: CSG): CSG;
  70135. /**
  70136. * Intersects this CSG with another CSG in place
  70137. * @param csg The CSG to intersect against this CSG
  70138. */
  70139. intersectInPlace(csg: CSG): void;
  70140. /**
  70141. * Return a new CSG solid with solid and empty space switched. This solid is
  70142. * not modified.
  70143. * @returns A new CSG solid with solid and empty space switched
  70144. */
  70145. inverse(): CSG;
  70146. /**
  70147. * Inverses the CSG in place
  70148. */
  70149. inverseInPlace(): void;
  70150. /**
  70151. * This is used to keep meshes transformations so they can be restored
  70152. * when we build back a Babylon Mesh
  70153. * NB : All CSG operations are performed in world coordinates
  70154. * @param csg The CSG to copy the transform attributes from
  70155. * @returns This CSG
  70156. */
  70157. copyTransformAttributes(csg: CSG): CSG;
  70158. /**
  70159. * Build Raw mesh from CSG
  70160. * Coordinates here are in world space
  70161. * @param name The name of the mesh geometry
  70162. * @param scene The Scene
  70163. * @param keepSubMeshes Specifies if the submeshes should be kept
  70164. * @returns A new Mesh
  70165. */
  70166. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70167. /**
  70168. * Build Mesh from CSG taking material and transforms into account
  70169. * @param name The name of the Mesh
  70170. * @param material The material of the Mesh
  70171. * @param scene The Scene
  70172. * @param keepSubMeshes Specifies if submeshes should be kept
  70173. * @returns The new Mesh
  70174. */
  70175. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70176. }
  70177. }
  70178. declare module "babylonjs/Meshes/trailMesh" {
  70179. import { Mesh } from "babylonjs/Meshes/mesh";
  70180. import { Scene } from "babylonjs/scene";
  70181. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70182. /**
  70183. * Class used to create a trail following a mesh
  70184. */
  70185. export class TrailMesh extends Mesh {
  70186. private _generator;
  70187. private _autoStart;
  70188. private _running;
  70189. private _diameter;
  70190. private _length;
  70191. private _sectionPolygonPointsCount;
  70192. private _sectionVectors;
  70193. private _sectionNormalVectors;
  70194. private _beforeRenderObserver;
  70195. /**
  70196. * @constructor
  70197. * @param name The value used by scene.getMeshByName() to do a lookup.
  70198. * @param generator The mesh or transform node to generate a trail.
  70199. * @param scene The scene to add this mesh to.
  70200. * @param diameter Diameter of trailing mesh. Default is 1.
  70201. * @param length Length of trailing mesh. Default is 60.
  70202. * @param autoStart Automatically start trailing mesh. Default true.
  70203. */
  70204. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70205. /**
  70206. * "TrailMesh"
  70207. * @returns "TrailMesh"
  70208. */
  70209. getClassName(): string;
  70210. private _createMesh;
  70211. /**
  70212. * Start trailing mesh.
  70213. */
  70214. start(): void;
  70215. /**
  70216. * Stop trailing mesh.
  70217. */
  70218. stop(): void;
  70219. /**
  70220. * Update trailing mesh geometry.
  70221. */
  70222. update(): void;
  70223. /**
  70224. * Returns a new TrailMesh object.
  70225. * @param name is a string, the name given to the new mesh
  70226. * @param newGenerator use new generator object for cloned trail mesh
  70227. * @returns a new mesh
  70228. */
  70229. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70230. /**
  70231. * Serializes this trail mesh
  70232. * @param serializationObject object to write serialization to
  70233. */
  70234. serialize(serializationObject: any): void;
  70235. /**
  70236. * Parses a serialized trail mesh
  70237. * @param parsedMesh the serialized mesh
  70238. * @param scene the scene to create the trail mesh in
  70239. * @returns the created trail mesh
  70240. */
  70241. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70242. }
  70243. }
  70244. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  70245. import { Nullable } from "babylonjs/types";
  70246. import { Scene } from "babylonjs/scene";
  70247. import { Vector4 } from "babylonjs/Maths/math.vector";
  70248. import { Color4 } from "babylonjs/Maths/math.color";
  70249. import { Mesh } from "babylonjs/Meshes/mesh";
  70250. /**
  70251. * Class containing static functions to help procedurally build meshes
  70252. */
  70253. export class TiledBoxBuilder {
  70254. /**
  70255. * Creates a box mesh
  70256. * 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)
  70257. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70261. * @param name defines the name of the mesh
  70262. * @param options defines the options used to create the mesh
  70263. * @param scene defines the hosting scene
  70264. * @returns the box mesh
  70265. */
  70266. static CreateTiledBox(name: string, options: {
  70267. pattern?: number;
  70268. width?: number;
  70269. height?: number;
  70270. depth?: number;
  70271. tileSize?: number;
  70272. tileWidth?: number;
  70273. tileHeight?: number;
  70274. alignHorizontal?: number;
  70275. alignVertical?: number;
  70276. faceUV?: Vector4[];
  70277. faceColors?: Color4[];
  70278. sideOrientation?: number;
  70279. updatable?: boolean;
  70280. }, scene?: Nullable<Scene>): Mesh;
  70281. }
  70282. }
  70283. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  70284. import { Vector4 } from "babylonjs/Maths/math.vector";
  70285. import { Mesh } from "babylonjs/Meshes/mesh";
  70286. /**
  70287. * Class containing static functions to help procedurally build meshes
  70288. */
  70289. export class TorusKnotBuilder {
  70290. /**
  70291. * Creates a torus knot mesh
  70292. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70293. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70294. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70295. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70299. * @param name defines the name of the mesh
  70300. * @param options defines the options used to create the mesh
  70301. * @param scene defines the hosting scene
  70302. * @returns the torus knot mesh
  70303. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70304. */
  70305. static CreateTorusKnot(name: string, options: {
  70306. radius?: number;
  70307. tube?: number;
  70308. radialSegments?: number;
  70309. tubularSegments?: number;
  70310. p?: number;
  70311. q?: number;
  70312. updatable?: boolean;
  70313. sideOrientation?: number;
  70314. frontUVs?: Vector4;
  70315. backUVs?: Vector4;
  70316. }, scene: any): Mesh;
  70317. }
  70318. }
  70319. declare module "babylonjs/Meshes/polygonMesh" {
  70320. import { Scene } from "babylonjs/scene";
  70321. import { Vector2 } from "babylonjs/Maths/math.vector";
  70322. import { Mesh } from "babylonjs/Meshes/mesh";
  70323. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  70324. import { Path2 } from "babylonjs/Maths/math.path";
  70325. /**
  70326. * Polygon
  70327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70328. */
  70329. export class Polygon {
  70330. /**
  70331. * Creates a rectangle
  70332. * @param xmin bottom X coord
  70333. * @param ymin bottom Y coord
  70334. * @param xmax top X coord
  70335. * @param ymax top Y coord
  70336. * @returns points that make the resulting rectation
  70337. */
  70338. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70339. /**
  70340. * Creates a circle
  70341. * @param radius radius of circle
  70342. * @param cx scale in x
  70343. * @param cy scale in y
  70344. * @param numberOfSides number of sides that make up the circle
  70345. * @returns points that make the resulting circle
  70346. */
  70347. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70348. /**
  70349. * Creates a polygon from input string
  70350. * @param input Input polygon data
  70351. * @returns the parsed points
  70352. */
  70353. static Parse(input: string): Vector2[];
  70354. /**
  70355. * Starts building a polygon from x and y coordinates
  70356. * @param x x coordinate
  70357. * @param y y coordinate
  70358. * @returns the started path2
  70359. */
  70360. static StartingAt(x: number, y: number): Path2;
  70361. }
  70362. /**
  70363. * Builds a polygon
  70364. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70365. */
  70366. export class PolygonMeshBuilder {
  70367. private _points;
  70368. private _outlinepoints;
  70369. private _holes;
  70370. private _name;
  70371. private _scene;
  70372. private _epoints;
  70373. private _eholes;
  70374. private _addToepoint;
  70375. /**
  70376. * Babylon reference to the earcut plugin.
  70377. */
  70378. bjsEarcut: any;
  70379. /**
  70380. * Creates a PolygonMeshBuilder
  70381. * @param name name of the builder
  70382. * @param contours Path of the polygon
  70383. * @param scene scene to add to when creating the mesh
  70384. * @param earcutInjection can be used to inject your own earcut reference
  70385. */
  70386. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70387. /**
  70388. * Adds a whole within the polygon
  70389. * @param hole Array of points defining the hole
  70390. * @returns this
  70391. */
  70392. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70393. /**
  70394. * Creates the polygon
  70395. * @param updatable If the mesh should be updatable
  70396. * @param depth The depth of the mesh created
  70397. * @returns the created mesh
  70398. */
  70399. build(updatable?: boolean, depth?: number): Mesh;
  70400. /**
  70401. * Creates the polygon
  70402. * @param depth The depth of the mesh created
  70403. * @returns the created VertexData
  70404. */
  70405. buildVertexData(depth?: number): VertexData;
  70406. /**
  70407. * Adds a side to the polygon
  70408. * @param positions points that make the polygon
  70409. * @param normals normals of the polygon
  70410. * @param uvs uvs of the polygon
  70411. * @param indices indices of the polygon
  70412. * @param bounds bounds of the polygon
  70413. * @param points points of the polygon
  70414. * @param depth depth of the polygon
  70415. * @param flip flip of the polygon
  70416. */
  70417. private addSide;
  70418. }
  70419. }
  70420. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  70421. import { Scene } from "babylonjs/scene";
  70422. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70423. import { Color4 } from "babylonjs/Maths/math.color";
  70424. import { Mesh } from "babylonjs/Meshes/mesh";
  70425. import { Nullable } from "babylonjs/types";
  70426. /**
  70427. * Class containing static functions to help procedurally build meshes
  70428. */
  70429. export class PolygonBuilder {
  70430. /**
  70431. * Creates a polygon mesh
  70432. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70433. * * 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
  70434. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70437. * * Remember you can only change the shape positions, not their number when updating a polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  70442. * @returns the polygon mesh
  70443. */
  70444. static CreatePolygon(name: string, options: {
  70445. shape: Vector3[];
  70446. holes?: Vector3[][];
  70447. depth?: number;
  70448. faceUV?: Vector4[];
  70449. faceColors?: Color4[];
  70450. updatable?: boolean;
  70451. sideOrientation?: number;
  70452. frontUVs?: Vector4;
  70453. backUVs?: Vector4;
  70454. wrap?: boolean;
  70455. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70456. /**
  70457. * Creates an extruded polygon mesh, with depth in the Y direction.
  70458. * * 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)
  70459. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70460. * @param name defines the name of the mesh
  70461. * @param options defines the options used to create the mesh
  70462. * @param scene defines the hosting scene
  70463. * @param earcutInjection can be used to inject your own earcut reference
  70464. * @returns the polygon mesh
  70465. */
  70466. static ExtrudePolygon(name: string, options: {
  70467. shape: Vector3[];
  70468. holes?: Vector3[][];
  70469. depth?: number;
  70470. faceUV?: Vector4[];
  70471. faceColors?: Color4[];
  70472. updatable?: boolean;
  70473. sideOrientation?: number;
  70474. frontUVs?: Vector4;
  70475. backUVs?: Vector4;
  70476. wrap?: boolean;
  70477. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70478. }
  70479. }
  70480. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  70481. import { Scene } from "babylonjs/scene";
  70482. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70483. import { Mesh } from "babylonjs/Meshes/mesh";
  70484. import { Nullable } from "babylonjs/types";
  70485. /**
  70486. * Class containing static functions to help procedurally build meshes
  70487. */
  70488. export class LatheBuilder {
  70489. /**
  70490. * Creates lathe mesh.
  70491. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70492. * * 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
  70493. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70494. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70495. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70496. * * 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
  70497. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70498. * * 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
  70499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70501. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70503. * @param name defines the name of the mesh
  70504. * @param options defines the options used to create the mesh
  70505. * @param scene defines the hosting scene
  70506. * @returns the lathe mesh
  70507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70508. */
  70509. static CreateLathe(name: string, options: {
  70510. shape: Vector3[];
  70511. radius?: number;
  70512. tessellation?: number;
  70513. clip?: number;
  70514. arc?: number;
  70515. closed?: boolean;
  70516. updatable?: boolean;
  70517. sideOrientation?: number;
  70518. frontUVs?: Vector4;
  70519. backUVs?: Vector4;
  70520. cap?: number;
  70521. invertUV?: boolean;
  70522. }, scene?: Nullable<Scene>): Mesh;
  70523. }
  70524. }
  70525. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  70526. import { Nullable } from "babylonjs/types";
  70527. import { Scene } from "babylonjs/scene";
  70528. import { Vector4 } from "babylonjs/Maths/math.vector";
  70529. import { Mesh } from "babylonjs/Meshes/mesh";
  70530. /**
  70531. * Class containing static functions to help procedurally build meshes
  70532. */
  70533. export class TiledPlaneBuilder {
  70534. /**
  70535. * Creates a tiled plane mesh
  70536. * * The parameter `pattern` will, depending on value, do nothing or
  70537. * * * flip (reflect about central vertical) alternate tiles across and up
  70538. * * * flip every tile on alternate rows
  70539. * * * rotate (180 degs) alternate tiles across and up
  70540. * * * rotate every tile on alternate rows
  70541. * * * flip and rotate alternate tiles across and up
  70542. * * * flip and rotate every tile on alternate rows
  70543. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70544. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70545. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70547. * * 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)
  70548. * * 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)
  70549. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70550. * @param name defines the name of the mesh
  70551. * @param options defines the options used to create the mesh
  70552. * @param scene defines the hosting scene
  70553. * @returns the box mesh
  70554. */
  70555. static CreateTiledPlane(name: string, options: {
  70556. pattern?: number;
  70557. tileSize?: number;
  70558. tileWidth?: number;
  70559. tileHeight?: number;
  70560. size?: number;
  70561. width?: number;
  70562. height?: number;
  70563. alignHorizontal?: number;
  70564. alignVertical?: number;
  70565. sideOrientation?: number;
  70566. frontUVs?: Vector4;
  70567. backUVs?: Vector4;
  70568. updatable?: boolean;
  70569. }, scene?: Nullable<Scene>): Mesh;
  70570. }
  70571. }
  70572. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  70573. import { Nullable } from "babylonjs/types";
  70574. import { Scene } from "babylonjs/scene";
  70575. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70576. import { Mesh } from "babylonjs/Meshes/mesh";
  70577. /**
  70578. * Class containing static functions to help procedurally build meshes
  70579. */
  70580. export class TubeBuilder {
  70581. /**
  70582. * Creates a tube mesh.
  70583. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70584. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70585. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70586. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70587. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70588. * * 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)
  70589. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70590. * * 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
  70591. * * 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
  70592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70594. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70596. * @param name defines the name of the mesh
  70597. * @param options defines the options used to create the mesh
  70598. * @param scene defines the hosting scene
  70599. * @returns the tube mesh
  70600. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70601. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70602. */
  70603. static CreateTube(name: string, options: {
  70604. path: Vector3[];
  70605. radius?: number;
  70606. tessellation?: number;
  70607. radiusFunction?: {
  70608. (i: number, distance: number): number;
  70609. };
  70610. cap?: number;
  70611. arc?: number;
  70612. updatable?: boolean;
  70613. sideOrientation?: number;
  70614. frontUVs?: Vector4;
  70615. backUVs?: Vector4;
  70616. instance?: Mesh;
  70617. invertUV?: boolean;
  70618. }, scene?: Nullable<Scene>): Mesh;
  70619. }
  70620. }
  70621. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  70622. import { Scene } from "babylonjs/scene";
  70623. import { Vector4 } from "babylonjs/Maths/math.vector";
  70624. import { Mesh } from "babylonjs/Meshes/mesh";
  70625. import { Nullable } from "babylonjs/types";
  70626. /**
  70627. * Class containing static functions to help procedurally build meshes
  70628. */
  70629. export class IcoSphereBuilder {
  70630. /**
  70631. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70632. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70633. * * 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`)
  70634. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70635. * * 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
  70636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70637. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70639. * @param name defines the name of the mesh
  70640. * @param options defines the options used to create the mesh
  70641. * @param scene defines the hosting scene
  70642. * @returns the icosahedron mesh
  70643. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70644. */
  70645. static CreateIcoSphere(name: string, options: {
  70646. radius?: number;
  70647. radiusX?: number;
  70648. radiusY?: number;
  70649. radiusZ?: number;
  70650. flat?: boolean;
  70651. subdivisions?: number;
  70652. sideOrientation?: number;
  70653. frontUVs?: Vector4;
  70654. backUVs?: Vector4;
  70655. updatable?: boolean;
  70656. }, scene?: Nullable<Scene>): Mesh;
  70657. }
  70658. }
  70659. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  70660. import { Vector3 } from "babylonjs/Maths/math.vector";
  70661. import { Mesh } from "babylonjs/Meshes/mesh";
  70662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70663. /**
  70664. * Class containing static functions to help procedurally build meshes
  70665. */
  70666. export class DecalBuilder {
  70667. /**
  70668. * Creates a decal mesh.
  70669. * 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
  70670. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70671. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70672. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70673. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70674. * @param name defines the name of the mesh
  70675. * @param sourceMesh defines the mesh where the decal must be applied
  70676. * @param options defines the options used to create the mesh
  70677. * @param scene defines the hosting scene
  70678. * @returns the decal mesh
  70679. * @see https://doc.babylonjs.com/how_to/decals
  70680. */
  70681. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70682. position?: Vector3;
  70683. normal?: Vector3;
  70684. size?: Vector3;
  70685. angle?: number;
  70686. }): Mesh;
  70687. }
  70688. }
  70689. declare module "babylonjs/Meshes/meshBuilder" {
  70690. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70691. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70692. import { Nullable } from "babylonjs/types";
  70693. import { Scene } from "babylonjs/scene";
  70694. import { Mesh } from "babylonjs/Meshes/mesh";
  70695. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70696. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70698. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70699. import { Plane } from "babylonjs/Maths/math.plane";
  70700. /**
  70701. * Class containing static functions to help procedurally build meshes
  70702. */
  70703. export class MeshBuilder {
  70704. /**
  70705. * Creates a box mesh
  70706. * * The parameter `size` sets the size (float) of each box side (default 1)
  70707. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70708. * * 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)
  70709. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70713. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70714. * @param name defines the name of the mesh
  70715. * @param options defines the options used to create the mesh
  70716. * @param scene defines the hosting scene
  70717. * @returns the box mesh
  70718. */
  70719. static CreateBox(name: string, options: {
  70720. size?: number;
  70721. width?: number;
  70722. height?: number;
  70723. depth?: number;
  70724. faceUV?: Vector4[];
  70725. faceColors?: Color4[];
  70726. sideOrientation?: number;
  70727. frontUVs?: Vector4;
  70728. backUVs?: Vector4;
  70729. wrap?: boolean;
  70730. topBaseAt?: number;
  70731. bottomBaseAt?: number;
  70732. updatable?: boolean;
  70733. }, scene?: Nullable<Scene>): Mesh;
  70734. /**
  70735. * Creates a tiled box mesh
  70736. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70738. * @param name defines the name of the mesh
  70739. * @param options defines the options used to create the mesh
  70740. * @param scene defines the hosting scene
  70741. * @returns the tiled box mesh
  70742. */
  70743. static CreateTiledBox(name: string, options: {
  70744. pattern?: number;
  70745. size?: number;
  70746. width?: number;
  70747. height?: number;
  70748. depth: number;
  70749. tileSize?: number;
  70750. tileWidth?: number;
  70751. tileHeight?: number;
  70752. faceUV?: Vector4[];
  70753. faceColors?: Color4[];
  70754. alignHorizontal?: number;
  70755. alignVertical?: number;
  70756. sideOrientation?: number;
  70757. updatable?: boolean;
  70758. }, scene?: Nullable<Scene>): Mesh;
  70759. /**
  70760. * Creates a sphere mesh
  70761. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70762. * * 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`)
  70763. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70764. * * 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
  70765. * * 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)
  70766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70769. * @param name defines the name of the mesh
  70770. * @param options defines the options used to create the mesh
  70771. * @param scene defines the hosting scene
  70772. * @returns the sphere mesh
  70773. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70774. */
  70775. static CreateSphere(name: string, options: {
  70776. segments?: number;
  70777. diameter?: number;
  70778. diameterX?: number;
  70779. diameterY?: number;
  70780. diameterZ?: number;
  70781. arc?: number;
  70782. slice?: number;
  70783. sideOrientation?: number;
  70784. frontUVs?: Vector4;
  70785. backUVs?: Vector4;
  70786. updatable?: boolean;
  70787. }, scene?: Nullable<Scene>): Mesh;
  70788. /**
  70789. * Creates a plane polygonal mesh. By default, this is a disc
  70790. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70791. * * 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
  70792. * * 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
  70793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70796. * @param name defines the name of the mesh
  70797. * @param options defines the options used to create the mesh
  70798. * @param scene defines the hosting scene
  70799. * @returns the plane polygonal mesh
  70800. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70801. */
  70802. static CreateDisc(name: string, options: {
  70803. radius?: number;
  70804. tessellation?: number;
  70805. arc?: number;
  70806. updatable?: boolean;
  70807. sideOrientation?: number;
  70808. frontUVs?: Vector4;
  70809. backUVs?: Vector4;
  70810. }, scene?: Nullable<Scene>): Mesh;
  70811. /**
  70812. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70813. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70814. * * 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`)
  70815. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70816. * * 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
  70817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70820. * @param name defines the name of the mesh
  70821. * @param options defines the options used to create the mesh
  70822. * @param scene defines the hosting scene
  70823. * @returns the icosahedron mesh
  70824. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70825. */
  70826. static CreateIcoSphere(name: string, options: {
  70827. radius?: number;
  70828. radiusX?: number;
  70829. radiusY?: number;
  70830. radiusZ?: number;
  70831. flat?: boolean;
  70832. subdivisions?: number;
  70833. sideOrientation?: number;
  70834. frontUVs?: Vector4;
  70835. backUVs?: Vector4;
  70836. updatable?: boolean;
  70837. }, scene?: Nullable<Scene>): Mesh;
  70838. /**
  70839. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70840. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70841. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70842. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70843. * * 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
  70844. * * 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
  70845. * * 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
  70846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70849. * * 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
  70850. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70851. * * 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
  70852. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70854. * @param name defines the name of the mesh
  70855. * @param options defines the options used to create the mesh
  70856. * @param scene defines the hosting scene
  70857. * @returns the ribbon mesh
  70858. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70859. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70860. */
  70861. static CreateRibbon(name: string, options: {
  70862. pathArray: Vector3[][];
  70863. closeArray?: boolean;
  70864. closePath?: boolean;
  70865. offset?: number;
  70866. updatable?: boolean;
  70867. sideOrientation?: number;
  70868. frontUVs?: Vector4;
  70869. backUVs?: Vector4;
  70870. instance?: Mesh;
  70871. invertUV?: boolean;
  70872. uvs?: Vector2[];
  70873. colors?: Color4[];
  70874. }, scene?: Nullable<Scene>): Mesh;
  70875. /**
  70876. * Creates a cylinder or a cone mesh
  70877. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70878. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70879. * * 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.
  70880. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70881. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70882. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70883. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70884. * * 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).
  70885. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70886. * * 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).
  70887. * * 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
  70888. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70889. * * 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
  70890. * * 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.
  70891. * * If `enclose` is false, a ring surface is one element.
  70892. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70893. * * 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
  70894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70897. * @param name defines the name of the mesh
  70898. * @param options defines the options used to create the mesh
  70899. * @param scene defines the hosting scene
  70900. * @returns the cylinder mesh
  70901. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70902. */
  70903. static CreateCylinder(name: string, options: {
  70904. height?: number;
  70905. diameterTop?: number;
  70906. diameterBottom?: number;
  70907. diameter?: number;
  70908. tessellation?: number;
  70909. subdivisions?: number;
  70910. arc?: number;
  70911. faceColors?: Color4[];
  70912. faceUV?: Vector4[];
  70913. updatable?: boolean;
  70914. hasRings?: boolean;
  70915. enclose?: boolean;
  70916. cap?: number;
  70917. sideOrientation?: number;
  70918. frontUVs?: Vector4;
  70919. backUVs?: Vector4;
  70920. }, scene?: Nullable<Scene>): Mesh;
  70921. /**
  70922. * Creates a torus mesh
  70923. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70924. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70925. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70929. * @param name defines the name of the mesh
  70930. * @param options defines the options used to create the mesh
  70931. * @param scene defines the hosting scene
  70932. * @returns the torus mesh
  70933. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70934. */
  70935. static CreateTorus(name: string, options: {
  70936. diameter?: number;
  70937. thickness?: number;
  70938. tessellation?: number;
  70939. updatable?: boolean;
  70940. sideOrientation?: number;
  70941. frontUVs?: Vector4;
  70942. backUVs?: Vector4;
  70943. }, scene?: Nullable<Scene>): Mesh;
  70944. /**
  70945. * Creates a torus knot mesh
  70946. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70947. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70948. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70949. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70953. * @param name defines the name of the mesh
  70954. * @param options defines the options used to create the mesh
  70955. * @param scene defines the hosting scene
  70956. * @returns the torus knot mesh
  70957. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70958. */
  70959. static CreateTorusKnot(name: string, options: {
  70960. radius?: number;
  70961. tube?: number;
  70962. radialSegments?: number;
  70963. tubularSegments?: number;
  70964. p?: number;
  70965. q?: number;
  70966. updatable?: boolean;
  70967. sideOrientation?: number;
  70968. frontUVs?: Vector4;
  70969. backUVs?: Vector4;
  70970. }, scene?: Nullable<Scene>): Mesh;
  70971. /**
  70972. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70973. * * 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
  70974. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70975. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70976. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70977. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70978. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70979. * * 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
  70980. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  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. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70983. * @param name defines the name of the new line system
  70984. * @param options defines the options used to create the line system
  70985. * @param scene defines the hosting scene
  70986. * @returns a new line system mesh
  70987. */
  70988. static CreateLineSystem(name: string, options: {
  70989. lines: Vector3[][];
  70990. updatable?: boolean;
  70991. instance?: Nullable<LinesMesh>;
  70992. colors?: Nullable<Color4[][]>;
  70993. useVertexAlpha?: boolean;
  70994. }, scene: Nullable<Scene>): LinesMesh;
  70995. /**
  70996. * Creates a line mesh
  70997. * 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
  70998. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70999. * * The parameter `points` is an array successive Vector3
  71000. * * 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
  71001. * * The optional parameter `colors` is an array of successive Color4, one per line point
  71002. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  71003. * * When updating an instance, remember that only point positions can change, not the number of points
  71004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71005. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  71006. * @param name defines the name of the new line system
  71007. * @param options defines the options used to create the line system
  71008. * @param scene defines the hosting scene
  71009. * @returns a new line mesh
  71010. */
  71011. static CreateLines(name: string, options: {
  71012. points: Vector3[];
  71013. updatable?: boolean;
  71014. instance?: Nullable<LinesMesh>;
  71015. colors?: Color4[];
  71016. useVertexAlpha?: boolean;
  71017. }, scene?: Nullable<Scene>): LinesMesh;
  71018. /**
  71019. * Creates a dashed line mesh
  71020. * * 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
  71021. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  71022. * * The parameter `points` is an array successive Vector3
  71023. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  71024. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  71025. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  71026. * * 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
  71027. * * When updating an instance, remember that only point positions can change, not the number of points
  71028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71029. * @param name defines the name of the mesh
  71030. * @param options defines the options used to create the mesh
  71031. * @param scene defines the hosting scene
  71032. * @returns the dashed line mesh
  71033. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  71034. */
  71035. static CreateDashedLines(name: string, options: {
  71036. points: Vector3[];
  71037. dashSize?: number;
  71038. gapSize?: number;
  71039. dashNb?: number;
  71040. updatable?: boolean;
  71041. instance?: LinesMesh;
  71042. }, scene?: Nullable<Scene>): LinesMesh;
  71043. /**
  71044. * 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.
  71045. * * 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.
  71046. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71047. * * 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.
  71048. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  71049. * * 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
  71050. * * 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
  71051. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  71052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71054. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  71055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71056. * @param name defines the name of the mesh
  71057. * @param options defines the options used to create the mesh
  71058. * @param scene defines the hosting scene
  71059. * @returns the extruded shape mesh
  71060. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71061. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71062. */
  71063. static ExtrudeShape(name: string, options: {
  71064. shape: Vector3[];
  71065. path: Vector3[];
  71066. scale?: number;
  71067. rotation?: number;
  71068. cap?: number;
  71069. updatable?: boolean;
  71070. sideOrientation?: number;
  71071. frontUVs?: Vector4;
  71072. backUVs?: Vector4;
  71073. instance?: Mesh;
  71074. invertUV?: boolean;
  71075. }, scene?: Nullable<Scene>): Mesh;
  71076. /**
  71077. * Creates an custom extruded shape mesh.
  71078. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  71079. * * 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.
  71080. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71081. * * 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
  71082. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  71083. * * 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
  71084. * * It must returns a float value that will be the scale value applied to the shape on each path point
  71085. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  71086. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  71087. * * 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
  71088. * * 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
  71089. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  71090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71092. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71094. * @param name defines the name of the mesh
  71095. * @param options defines the options used to create the mesh
  71096. * @param scene defines the hosting scene
  71097. * @returns the custom extruded shape mesh
  71098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  71099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71101. */
  71102. static ExtrudeShapeCustom(name: string, options: {
  71103. shape: Vector3[];
  71104. path: Vector3[];
  71105. scaleFunction?: any;
  71106. rotationFunction?: any;
  71107. ribbonCloseArray?: boolean;
  71108. ribbonClosePath?: boolean;
  71109. cap?: number;
  71110. updatable?: boolean;
  71111. sideOrientation?: number;
  71112. frontUVs?: Vector4;
  71113. backUVs?: Vector4;
  71114. instance?: Mesh;
  71115. invertUV?: boolean;
  71116. }, scene?: Nullable<Scene>): Mesh;
  71117. /**
  71118. * Creates lathe mesh.
  71119. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  71120. * * 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
  71121. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  71122. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  71123. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  71124. * * 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
  71125. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  71126. * * 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
  71127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71131. * @param name defines the name of the mesh
  71132. * @param options defines the options used to create the mesh
  71133. * @param scene defines the hosting scene
  71134. * @returns the lathe mesh
  71135. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71136. */
  71137. static CreateLathe(name: string, options: {
  71138. shape: Vector3[];
  71139. radius?: number;
  71140. tessellation?: number;
  71141. clip?: number;
  71142. arc?: number;
  71143. closed?: boolean;
  71144. updatable?: boolean;
  71145. sideOrientation?: number;
  71146. frontUVs?: Vector4;
  71147. backUVs?: Vector4;
  71148. cap?: number;
  71149. invertUV?: boolean;
  71150. }, scene?: Nullable<Scene>): Mesh;
  71151. /**
  71152. * Creates a tiled plane mesh
  71153. * * You can set a limited pattern arrangement with the tiles
  71154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71157. * @param name defines the name of the mesh
  71158. * @param options defines the options used to create the mesh
  71159. * @param scene defines the hosting scene
  71160. * @returns the plane mesh
  71161. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71162. */
  71163. static CreateTiledPlane(name: string, options: {
  71164. pattern?: number;
  71165. tileSize?: number;
  71166. tileWidth?: number;
  71167. tileHeight?: number;
  71168. size?: number;
  71169. width?: number;
  71170. height?: number;
  71171. alignHorizontal?: number;
  71172. alignVertical?: number;
  71173. sideOrientation?: number;
  71174. frontUVs?: Vector4;
  71175. backUVs?: Vector4;
  71176. updatable?: boolean;
  71177. }, scene?: Nullable<Scene>): Mesh;
  71178. /**
  71179. * Creates a plane mesh
  71180. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71181. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71182. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71186. * @param name defines the name of the mesh
  71187. * @param options defines the options used to create the mesh
  71188. * @param scene defines the hosting scene
  71189. * @returns the plane mesh
  71190. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71191. */
  71192. static CreatePlane(name: string, options: {
  71193. size?: number;
  71194. width?: number;
  71195. height?: number;
  71196. sideOrientation?: number;
  71197. frontUVs?: Vector4;
  71198. backUVs?: Vector4;
  71199. updatable?: boolean;
  71200. sourcePlane?: Plane;
  71201. }, scene?: Nullable<Scene>): Mesh;
  71202. /**
  71203. * Creates a ground mesh
  71204. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71205. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71207. * @param name defines the name of the mesh
  71208. * @param options defines the options used to create the mesh
  71209. * @param scene defines the hosting scene
  71210. * @returns the ground mesh
  71211. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71212. */
  71213. static CreateGround(name: string, options: {
  71214. width?: number;
  71215. height?: number;
  71216. subdivisions?: number;
  71217. subdivisionsX?: number;
  71218. subdivisionsY?: number;
  71219. updatable?: boolean;
  71220. }, scene?: Nullable<Scene>): Mesh;
  71221. /**
  71222. * Creates a tiled ground mesh
  71223. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71224. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71225. * * 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
  71226. * * 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
  71227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71228. * @param name defines the name of the mesh
  71229. * @param options defines the options used to create the mesh
  71230. * @param scene defines the hosting scene
  71231. * @returns the tiled ground mesh
  71232. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71233. */
  71234. static CreateTiledGround(name: string, options: {
  71235. xmin: number;
  71236. zmin: number;
  71237. xmax: number;
  71238. zmax: number;
  71239. subdivisions?: {
  71240. w: number;
  71241. h: number;
  71242. };
  71243. precision?: {
  71244. w: number;
  71245. h: number;
  71246. };
  71247. updatable?: boolean;
  71248. }, scene?: Nullable<Scene>): Mesh;
  71249. /**
  71250. * Creates a ground mesh from a height map
  71251. * * The parameter `url` sets the URL of the height map image resource.
  71252. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71253. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71254. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71255. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71256. * * 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.
  71257. * * 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).
  71258. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71260. * @param name defines the name of the mesh
  71261. * @param url defines the url to the height map
  71262. * @param options defines the options used to create the mesh
  71263. * @param scene defines the hosting scene
  71264. * @returns the ground mesh
  71265. * @see https://doc.babylonjs.com/babylon101/height_map
  71266. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71267. */
  71268. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71269. width?: number;
  71270. height?: number;
  71271. subdivisions?: number;
  71272. minHeight?: number;
  71273. maxHeight?: number;
  71274. colorFilter?: Color3;
  71275. alphaFilter?: number;
  71276. updatable?: boolean;
  71277. onReady?: (mesh: GroundMesh) => void;
  71278. }, scene?: Nullable<Scene>): GroundMesh;
  71279. /**
  71280. * Creates a polygon mesh
  71281. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71282. * * 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
  71283. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  71286. * * Remember you can only change the shape positions, not their number when updating a polygon
  71287. * @param name defines the name of the mesh
  71288. * @param options defines the options used to create the mesh
  71289. * @param scene defines the hosting scene
  71290. * @param earcutInjection can be used to inject your own earcut reference
  71291. * @returns the polygon mesh
  71292. */
  71293. static CreatePolygon(name: string, options: {
  71294. shape: Vector3[];
  71295. holes?: Vector3[][];
  71296. depth?: number;
  71297. faceUV?: Vector4[];
  71298. faceColors?: Color4[];
  71299. updatable?: boolean;
  71300. sideOrientation?: number;
  71301. frontUVs?: Vector4;
  71302. backUVs?: Vector4;
  71303. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71304. /**
  71305. * Creates an extruded polygon mesh, with depth in the Y direction.
  71306. * * 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)
  71307. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71308. * @param name defines the name of the mesh
  71309. * @param options defines the options used to create the mesh
  71310. * @param scene defines the hosting scene
  71311. * @param earcutInjection can be used to inject your own earcut reference
  71312. * @returns the polygon mesh
  71313. */
  71314. static ExtrudePolygon(name: string, options: {
  71315. shape: Vector3[];
  71316. holes?: Vector3[][];
  71317. depth?: number;
  71318. faceUV?: Vector4[];
  71319. faceColors?: Color4[];
  71320. updatable?: boolean;
  71321. sideOrientation?: number;
  71322. frontUVs?: Vector4;
  71323. backUVs?: Vector4;
  71324. wrap?: boolean;
  71325. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71326. /**
  71327. * Creates a tube mesh.
  71328. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71329. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71330. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71331. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71332. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  71333. * * 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)
  71334. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71335. * * 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
  71336. * * 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
  71337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71341. * @param name defines the name of the mesh
  71342. * @param options defines the options used to create the mesh
  71343. * @param scene defines the hosting scene
  71344. * @returns the tube mesh
  71345. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71346. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71347. */
  71348. static CreateTube(name: string, options: {
  71349. path: Vector3[];
  71350. radius?: number;
  71351. tessellation?: number;
  71352. radiusFunction?: {
  71353. (i: number, distance: number): number;
  71354. };
  71355. cap?: number;
  71356. arc?: number;
  71357. updatable?: boolean;
  71358. sideOrientation?: number;
  71359. frontUVs?: Vector4;
  71360. backUVs?: Vector4;
  71361. instance?: Mesh;
  71362. invertUV?: boolean;
  71363. }, scene?: Nullable<Scene>): Mesh;
  71364. /**
  71365. * Creates a polyhedron mesh
  71366. * * 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
  71367. * * The parameter `size` (positive float, default 1) sets the polygon size
  71368. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71369. * * 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`
  71370. * * 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
  71371. * * 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)`)
  71372. * * 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
  71373. * * 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
  71374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71377. * @param name defines the name of the mesh
  71378. * @param options defines the options used to create the mesh
  71379. * @param scene defines the hosting scene
  71380. * @returns the polyhedron mesh
  71381. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71382. */
  71383. static CreatePolyhedron(name: string, options: {
  71384. type?: number;
  71385. size?: number;
  71386. sizeX?: number;
  71387. sizeY?: number;
  71388. sizeZ?: number;
  71389. custom?: any;
  71390. faceUV?: Vector4[];
  71391. faceColors?: Color4[];
  71392. flat?: boolean;
  71393. updatable?: boolean;
  71394. sideOrientation?: number;
  71395. frontUVs?: Vector4;
  71396. backUVs?: Vector4;
  71397. }, scene?: Nullable<Scene>): Mesh;
  71398. /**
  71399. * Creates a decal mesh.
  71400. * 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
  71401. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71402. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71403. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71404. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71405. * @param name defines the name of the mesh
  71406. * @param sourceMesh defines the mesh where the decal must be applied
  71407. * @param options defines the options used to create the mesh
  71408. * @param scene defines the hosting scene
  71409. * @returns the decal mesh
  71410. * @see https://doc.babylonjs.com/how_to/decals
  71411. */
  71412. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71413. position?: Vector3;
  71414. normal?: Vector3;
  71415. size?: Vector3;
  71416. angle?: number;
  71417. }): Mesh;
  71418. /**
  71419. * Creates a Capsule Mesh
  71420. * @param name defines the name of the mesh.
  71421. * @param options the constructors options used to shape the mesh.
  71422. * @param scene defines the scene the mesh is scoped to.
  71423. * @returns the capsule mesh
  71424. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71425. */
  71426. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71427. }
  71428. }
  71429. declare module "babylonjs/Meshes/meshSimplification" {
  71430. import { Mesh } from "babylonjs/Meshes/mesh";
  71431. /**
  71432. * A simplifier interface for future simplification implementations
  71433. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71434. */
  71435. export interface ISimplifier {
  71436. /**
  71437. * Simplification of a given mesh according to the given settings.
  71438. * Since this requires computation, it is assumed that the function runs async.
  71439. * @param settings The settings of the simplification, including quality and distance
  71440. * @param successCallback A callback that will be called after the mesh was simplified.
  71441. * @param errorCallback in case of an error, this callback will be called. optional.
  71442. */
  71443. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71444. }
  71445. /**
  71446. * Expected simplification settings.
  71447. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71448. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71449. */
  71450. export interface ISimplificationSettings {
  71451. /**
  71452. * Gets or sets the expected quality
  71453. */
  71454. quality: number;
  71455. /**
  71456. * Gets or sets the distance when this optimized version should be used
  71457. */
  71458. distance: number;
  71459. /**
  71460. * Gets an already optimized mesh
  71461. */
  71462. optimizeMesh?: boolean;
  71463. }
  71464. /**
  71465. * Class used to specify simplification options
  71466. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71467. */
  71468. export class SimplificationSettings implements ISimplificationSettings {
  71469. /** expected quality */
  71470. quality: number;
  71471. /** distance when this optimized version should be used */
  71472. distance: number;
  71473. /** already optimized mesh */
  71474. optimizeMesh?: boolean | undefined;
  71475. /**
  71476. * Creates a SimplificationSettings
  71477. * @param quality expected quality
  71478. * @param distance distance when this optimized version should be used
  71479. * @param optimizeMesh already optimized mesh
  71480. */
  71481. constructor(
  71482. /** expected quality */
  71483. quality: number,
  71484. /** distance when this optimized version should be used */
  71485. distance: number,
  71486. /** already optimized mesh */
  71487. optimizeMesh?: boolean | undefined);
  71488. }
  71489. /**
  71490. * Interface used to define a simplification task
  71491. */
  71492. export interface ISimplificationTask {
  71493. /**
  71494. * Array of settings
  71495. */
  71496. settings: Array<ISimplificationSettings>;
  71497. /**
  71498. * Simplification type
  71499. */
  71500. simplificationType: SimplificationType;
  71501. /**
  71502. * Mesh to simplify
  71503. */
  71504. mesh: Mesh;
  71505. /**
  71506. * Callback called on success
  71507. */
  71508. successCallback?: () => void;
  71509. /**
  71510. * Defines if parallel processing can be used
  71511. */
  71512. parallelProcessing: boolean;
  71513. }
  71514. /**
  71515. * Queue used to order the simplification tasks
  71516. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71517. */
  71518. export class SimplificationQueue {
  71519. private _simplificationArray;
  71520. /**
  71521. * Gets a boolean indicating that the process is still running
  71522. */
  71523. running: boolean;
  71524. /**
  71525. * Creates a new queue
  71526. */
  71527. constructor();
  71528. /**
  71529. * Adds a new simplification task
  71530. * @param task defines a task to add
  71531. */
  71532. addTask(task: ISimplificationTask): void;
  71533. /**
  71534. * Execute next task
  71535. */
  71536. executeNext(): void;
  71537. /**
  71538. * Execute a simplification task
  71539. * @param task defines the task to run
  71540. */
  71541. runSimplification(task: ISimplificationTask): void;
  71542. private getSimplifier;
  71543. }
  71544. /**
  71545. * The implemented types of simplification
  71546. * At the moment only Quadratic Error Decimation is implemented
  71547. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71548. */
  71549. export enum SimplificationType {
  71550. /** Quadratic error decimation */
  71551. QUADRATIC = 0
  71552. }
  71553. /**
  71554. * An implementation of the Quadratic Error simplification algorithm.
  71555. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71556. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71557. * @author RaananW
  71558. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71559. */
  71560. export class QuadraticErrorSimplification implements ISimplifier {
  71561. private _mesh;
  71562. private triangles;
  71563. private vertices;
  71564. private references;
  71565. private _reconstructedMesh;
  71566. /** Gets or sets the number pf sync interations */
  71567. syncIterations: number;
  71568. /** Gets or sets the aggressiveness of the simplifier */
  71569. aggressiveness: number;
  71570. /** Gets or sets the number of allowed iterations for decimation */
  71571. decimationIterations: number;
  71572. /** Gets or sets the espilon to use for bounding box computation */
  71573. boundingBoxEpsilon: number;
  71574. /**
  71575. * Creates a new QuadraticErrorSimplification
  71576. * @param _mesh defines the target mesh
  71577. */
  71578. constructor(_mesh: Mesh);
  71579. /**
  71580. * Simplification of a given mesh according to the given settings.
  71581. * Since this requires computation, it is assumed that the function runs async.
  71582. * @param settings The settings of the simplification, including quality and distance
  71583. * @param successCallback A callback that will be called after the mesh was simplified.
  71584. */
  71585. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71586. private runDecimation;
  71587. private initWithMesh;
  71588. private init;
  71589. private reconstructMesh;
  71590. private initDecimatedMesh;
  71591. private isFlipped;
  71592. private updateTriangles;
  71593. private identifyBorder;
  71594. private updateMesh;
  71595. private vertexError;
  71596. private calculateError;
  71597. }
  71598. }
  71599. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  71600. import { Scene } from "babylonjs/scene";
  71601. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  71602. import { ISceneComponent } from "babylonjs/sceneComponent";
  71603. module "babylonjs/scene" {
  71604. interface Scene {
  71605. /** @hidden (Backing field) */
  71606. _simplificationQueue: SimplificationQueue;
  71607. /**
  71608. * Gets or sets the simplification queue attached to the scene
  71609. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71610. */
  71611. simplificationQueue: SimplificationQueue;
  71612. }
  71613. }
  71614. module "babylonjs/Meshes/mesh" {
  71615. interface Mesh {
  71616. /**
  71617. * Simplify the mesh according to the given array of settings.
  71618. * Function will return immediately and will simplify async
  71619. * @param settings a collection of simplification settings
  71620. * @param parallelProcessing should all levels calculate parallel or one after the other
  71621. * @param simplificationType the type of simplification to run
  71622. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71623. * @returns the current mesh
  71624. */
  71625. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71626. }
  71627. }
  71628. /**
  71629. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71630. * created in a scene
  71631. */
  71632. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71633. /**
  71634. * The component name helpfull to identify the component in the list of scene components.
  71635. */
  71636. readonly name: string;
  71637. /**
  71638. * The scene the component belongs to.
  71639. */
  71640. scene: Scene;
  71641. /**
  71642. * Creates a new instance of the component for the given scene
  71643. * @param scene Defines the scene to register the component in
  71644. */
  71645. constructor(scene: Scene);
  71646. /**
  71647. * Registers the component in a given scene
  71648. */
  71649. register(): void;
  71650. /**
  71651. * Rebuilds the elements related to this component in case of
  71652. * context lost for instance.
  71653. */
  71654. rebuild(): void;
  71655. /**
  71656. * Disposes the component and the associated ressources
  71657. */
  71658. dispose(): void;
  71659. private _beforeCameraUpdate;
  71660. }
  71661. }
  71662. declare module "babylonjs/Meshes/Builders/index" {
  71663. export * from "babylonjs/Meshes/Builders/boxBuilder";
  71664. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  71665. export * from "babylonjs/Meshes/Builders/discBuilder";
  71666. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  71667. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  71668. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71669. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71670. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71671. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71672. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71673. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71674. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71675. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71676. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71677. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71678. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71679. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71680. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71681. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71682. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71683. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71684. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71685. }
  71686. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71687. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71688. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71689. import { Matrix } from "babylonjs/Maths/math.vector";
  71690. module "babylonjs/Meshes/mesh" {
  71691. interface Mesh {
  71692. /**
  71693. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71694. */
  71695. thinInstanceEnablePicking: boolean;
  71696. /**
  71697. * Creates a new thin instance
  71698. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71699. * @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
  71700. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71701. */
  71702. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71703. /**
  71704. * Adds the transformation (matrix) of the current mesh as a thin instance
  71705. * @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
  71706. * @returns the thin instance index number
  71707. */
  71708. thinInstanceAddSelf(refresh: boolean): number;
  71709. /**
  71710. * Registers a custom attribute to be used with thin instances
  71711. * @param kind name of the attribute
  71712. * @param stride size in floats of the attribute
  71713. */
  71714. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71715. /**
  71716. * Sets the matrix of a thin instance
  71717. * @param index index of the thin instance
  71718. * @param matrix matrix to set
  71719. * @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
  71720. */
  71721. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71722. /**
  71723. * Sets the value of a custom attribute for a thin instance
  71724. * @param kind name of the attribute
  71725. * @param index index of the thin instance
  71726. * @param value value to set
  71727. * @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
  71728. */
  71729. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71730. /**
  71731. * 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.
  71732. */
  71733. thinInstanceCount: number;
  71734. /**
  71735. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71736. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71737. * @param buffer buffer to set
  71738. * @param stride size in floats of each value of the buffer
  71739. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71740. */
  71741. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71742. /**
  71743. * Gets the list of world matrices
  71744. * @return an array containing all the world matrices from the thin instances
  71745. */
  71746. thinInstanceGetWorldMatrices(): Matrix[];
  71747. /**
  71748. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71749. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71750. */
  71751. thinInstanceBufferUpdated(kind: string): void;
  71752. /**
  71753. * Applies a partial update to a buffer directly on the GPU
  71754. * 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
  71755. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71756. * @param data the data to set in the GPU buffer
  71757. * @param offset the offset in the GPU buffer where to update the data
  71758. */
  71759. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71760. /**
  71761. * Refreshes the bounding info, taking into account all the thin instances defined
  71762. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71763. */
  71764. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71765. /** @hidden */
  71766. _thinInstanceInitializeUserStorage(): void;
  71767. /** @hidden */
  71768. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71769. /** @hidden */
  71770. _userThinInstanceBuffersStorage: {
  71771. data: {
  71772. [key: string]: Float32Array;
  71773. };
  71774. sizes: {
  71775. [key: string]: number;
  71776. };
  71777. vertexBuffers: {
  71778. [key: string]: Nullable<VertexBuffer>;
  71779. };
  71780. strides: {
  71781. [key: string]: number;
  71782. };
  71783. };
  71784. }
  71785. }
  71786. }
  71787. declare module "babylonjs/Meshes/index" {
  71788. export * from "babylonjs/Meshes/abstractMesh";
  71789. export * from "babylonjs/Meshes/buffer";
  71790. export * from "babylonjs/Meshes/Compression/index";
  71791. export * from "babylonjs/Meshes/csg";
  71792. export * from "babylonjs/Meshes/geometry";
  71793. export * from "babylonjs/Meshes/groundMesh";
  71794. export * from "babylonjs/Meshes/trailMesh";
  71795. export * from "babylonjs/Meshes/instancedMesh";
  71796. export * from "babylonjs/Meshes/linesMesh";
  71797. export * from "babylonjs/Meshes/mesh";
  71798. export * from "babylonjs/Meshes/mesh.vertexData";
  71799. export * from "babylonjs/Meshes/meshBuilder";
  71800. export * from "babylonjs/Meshes/meshSimplification";
  71801. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71802. export * from "babylonjs/Meshes/polygonMesh";
  71803. export * from "babylonjs/Meshes/subMesh";
  71804. export * from "babylonjs/Meshes/meshLODLevel";
  71805. export * from "babylonjs/Meshes/transformNode";
  71806. export * from "babylonjs/Meshes/Builders/index";
  71807. export * from "babylonjs/Meshes/dataBuffer";
  71808. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71809. import "babylonjs/Meshes/thinInstanceMesh";
  71810. export * from "babylonjs/Meshes/thinInstanceMesh";
  71811. }
  71812. declare module "babylonjs/Morph/index" {
  71813. export * from "babylonjs/Morph/morphTarget";
  71814. export * from "babylonjs/Morph/morphTargetManager";
  71815. }
  71816. declare module "babylonjs/Navigation/INavigationEngine" {
  71817. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71818. import { Vector3 } from "babylonjs/Maths/math";
  71819. import { Mesh } from "babylonjs/Meshes/mesh";
  71820. import { Scene } from "babylonjs/scene";
  71821. /**
  71822. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71823. */
  71824. export interface INavigationEnginePlugin {
  71825. /**
  71826. * plugin name
  71827. */
  71828. name: string;
  71829. /**
  71830. * Creates a navigation mesh
  71831. * @param meshes array of all the geometry used to compute the navigatio mesh
  71832. * @param parameters bunch of parameters used to filter geometry
  71833. */
  71834. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71835. /**
  71836. * Create a navigation mesh debug mesh
  71837. * @param scene is where the mesh will be added
  71838. * @returns debug display mesh
  71839. */
  71840. createDebugNavMesh(scene: Scene): Mesh;
  71841. /**
  71842. * Get a navigation mesh constrained position, closest to the parameter position
  71843. * @param position world position
  71844. * @returns the closest point to position constrained by the navigation mesh
  71845. */
  71846. getClosestPoint(position: Vector3): Vector3;
  71847. /**
  71848. * Get a navigation mesh constrained position, closest to the parameter position
  71849. * @param position world position
  71850. * @param result output the closest point to position constrained by the navigation mesh
  71851. */
  71852. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71853. /**
  71854. * Get a navigation mesh constrained position, within a particular radius
  71855. * @param position world position
  71856. * @param maxRadius the maximum distance to the constrained world position
  71857. * @returns the closest point to position constrained by the navigation mesh
  71858. */
  71859. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71860. /**
  71861. * Get a navigation mesh constrained position, within a particular radius
  71862. * @param position world position
  71863. * @param maxRadius the maximum distance to the constrained world position
  71864. * @param result output the closest point to position constrained by the navigation mesh
  71865. */
  71866. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71867. /**
  71868. * Compute the final position from a segment made of destination-position
  71869. * @param position world position
  71870. * @param destination world position
  71871. * @returns the resulting point along the navmesh
  71872. */
  71873. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71874. /**
  71875. * Compute the final position from a segment made of destination-position
  71876. * @param position world position
  71877. * @param destination world position
  71878. * @param result output the resulting point along the navmesh
  71879. */
  71880. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71881. /**
  71882. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71883. * @param start world position
  71884. * @param end world position
  71885. * @returns array containing world position composing the path
  71886. */
  71887. computePath(start: Vector3, end: Vector3): Vector3[];
  71888. /**
  71889. * If this plugin is supported
  71890. * @returns true if plugin is supported
  71891. */
  71892. isSupported(): boolean;
  71893. /**
  71894. * Create a new Crowd so you can add agents
  71895. * @param maxAgents the maximum agent count in the crowd
  71896. * @param maxAgentRadius the maximum radius an agent can have
  71897. * @param scene to attach the crowd to
  71898. * @returns the crowd you can add agents to
  71899. */
  71900. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71901. /**
  71902. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71903. * The queries will try to find a solution within those bounds
  71904. * default is (1,1,1)
  71905. * @param extent x,y,z value that define the extent around the queries point of reference
  71906. */
  71907. setDefaultQueryExtent(extent: Vector3): void;
  71908. /**
  71909. * Get the Bounding box extent specified by setDefaultQueryExtent
  71910. * @returns the box extent values
  71911. */
  71912. getDefaultQueryExtent(): Vector3;
  71913. /**
  71914. * build the navmesh from a previously saved state using getNavmeshData
  71915. * @param data the Uint8Array returned by getNavmeshData
  71916. */
  71917. buildFromNavmeshData(data: Uint8Array): void;
  71918. /**
  71919. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71920. * @returns data the Uint8Array that can be saved and reused
  71921. */
  71922. getNavmeshData(): Uint8Array;
  71923. /**
  71924. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71925. * @param result output the box extent values
  71926. */
  71927. getDefaultQueryExtentToRef(result: Vector3): void;
  71928. /**
  71929. * Set the time step of the navigation tick update.
  71930. * Default is 1/60.
  71931. * A value of 0 will disable fixed time update
  71932. * @param newTimeStep the new timestep to apply to this world.
  71933. */
  71934. setTimeStep(newTimeStep: number): void;
  71935. /**
  71936. * Get the time step of the navigation tick update.
  71937. * @returns the current time step
  71938. */
  71939. getTimeStep(): number;
  71940. /**
  71941. * If delta time in navigation tick update is greater than the time step
  71942. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71943. * they will be discarded.
  71944. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71945. * @param newStepCount the maximum number of iterations
  71946. */
  71947. setMaximumSubStepCount(newStepCount: number): void;
  71948. /**
  71949. * Get the maximum number of iterations per navigation tick update
  71950. * @returns the maximum number of iterations
  71951. */
  71952. getMaximumSubStepCount(): number;
  71953. /**
  71954. * Release all resources
  71955. */
  71956. dispose(): void;
  71957. }
  71958. /**
  71959. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71960. */
  71961. export interface ICrowd {
  71962. /**
  71963. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71964. * You can attach anything to that node. The node position is updated in the scene update tick.
  71965. * @param pos world position that will be constrained by the navigation mesh
  71966. * @param parameters agent parameters
  71967. * @param transform hooked to the agent that will be update by the scene
  71968. * @returns agent index
  71969. */
  71970. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71971. /**
  71972. * Returns the agent position in world space
  71973. * @param index agent index returned by addAgent
  71974. * @returns world space position
  71975. */
  71976. getAgentPosition(index: number): Vector3;
  71977. /**
  71978. * Gets the agent position result in world space
  71979. * @param index agent index returned by addAgent
  71980. * @param result output world space position
  71981. */
  71982. getAgentPositionToRef(index: number, result: Vector3): void;
  71983. /**
  71984. * Gets the agent velocity in world space
  71985. * @param index agent index returned by addAgent
  71986. * @returns world space velocity
  71987. */
  71988. getAgentVelocity(index: number): Vector3;
  71989. /**
  71990. * Gets the agent velocity result in world space
  71991. * @param index agent index returned by addAgent
  71992. * @param result output world space velocity
  71993. */
  71994. getAgentVelocityToRef(index: number, result: Vector3): void;
  71995. /**
  71996. * Gets the agent next target point on the path
  71997. * @param index agent index returned by addAgent
  71998. * @returns world space position
  71999. */
  72000. getAgentNextTargetPath(index: number): Vector3;
  72001. /**
  72002. * Gets the agent state
  72003. * @param index agent index returned by addAgent
  72004. * @returns agent state
  72005. */
  72006. getAgentState(index: number): number;
  72007. /**
  72008. * returns true if the agent in over an off mesh link connection
  72009. * @param index agent index returned by addAgent
  72010. * @returns true if over an off mesh link connection
  72011. */
  72012. overOffmeshConnection(index: number): boolean;
  72013. /**
  72014. * Gets the agent next target point on the path
  72015. * @param index agent index returned by addAgent
  72016. * @param result output world space position
  72017. */
  72018. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72019. /**
  72020. * remove a particular agent previously created
  72021. * @param index agent index returned by addAgent
  72022. */
  72023. removeAgent(index: number): void;
  72024. /**
  72025. * get the list of all agents attached to this crowd
  72026. * @returns list of agent indices
  72027. */
  72028. getAgents(): number[];
  72029. /**
  72030. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72031. * @param deltaTime in seconds
  72032. */
  72033. update(deltaTime: number): void;
  72034. /**
  72035. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72036. * @param index agent index returned by addAgent
  72037. * @param destination targeted world position
  72038. */
  72039. agentGoto(index: number, destination: Vector3): void;
  72040. /**
  72041. * Teleport the agent to a new position
  72042. * @param index agent index returned by addAgent
  72043. * @param destination targeted world position
  72044. */
  72045. agentTeleport(index: number, destination: Vector3): void;
  72046. /**
  72047. * Update agent parameters
  72048. * @param index agent index returned by addAgent
  72049. * @param parameters agent parameters
  72050. */
  72051. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72052. /**
  72053. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72054. * The queries will try to find a solution within those bounds
  72055. * default is (1,1,1)
  72056. * @param extent x,y,z value that define the extent around the queries point of reference
  72057. */
  72058. setDefaultQueryExtent(extent: Vector3): void;
  72059. /**
  72060. * Get the Bounding box extent specified by setDefaultQueryExtent
  72061. * @returns the box extent values
  72062. */
  72063. getDefaultQueryExtent(): Vector3;
  72064. /**
  72065. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72066. * @param result output the box extent values
  72067. */
  72068. getDefaultQueryExtentToRef(result: Vector3): void;
  72069. /**
  72070. * Release all resources
  72071. */
  72072. dispose(): void;
  72073. }
  72074. /**
  72075. * Configures an agent
  72076. */
  72077. export interface IAgentParameters {
  72078. /**
  72079. * Agent radius. [Limit: >= 0]
  72080. */
  72081. radius: number;
  72082. /**
  72083. * Agent height. [Limit: > 0]
  72084. */
  72085. height: number;
  72086. /**
  72087. * Maximum allowed acceleration. [Limit: >= 0]
  72088. */
  72089. maxAcceleration: number;
  72090. /**
  72091. * Maximum allowed speed. [Limit: >= 0]
  72092. */
  72093. maxSpeed: number;
  72094. /**
  72095. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  72096. */
  72097. collisionQueryRange: number;
  72098. /**
  72099. * The path visibility optimization range. [Limit: > 0]
  72100. */
  72101. pathOptimizationRange: number;
  72102. /**
  72103. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  72104. */
  72105. separationWeight: number;
  72106. }
  72107. /**
  72108. * Configures the navigation mesh creation
  72109. */
  72110. export interface INavMeshParameters {
  72111. /**
  72112. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  72113. */
  72114. cs: number;
  72115. /**
  72116. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  72117. */
  72118. ch: number;
  72119. /**
  72120. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  72121. */
  72122. walkableSlopeAngle: number;
  72123. /**
  72124. * Minimum floor to 'ceiling' height that will still allow the floor area to
  72125. * be considered walkable. [Limit: >= 3] [Units: vx]
  72126. */
  72127. walkableHeight: number;
  72128. /**
  72129. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  72130. */
  72131. walkableClimb: number;
  72132. /**
  72133. * The distance to erode/shrink the walkable area of the heightfield away from
  72134. * obstructions. [Limit: >=0] [Units: vx]
  72135. */
  72136. walkableRadius: number;
  72137. /**
  72138. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  72139. */
  72140. maxEdgeLen: number;
  72141. /**
  72142. * The maximum distance a simplfied contour's border edges should deviate
  72143. * the original raw contour. [Limit: >=0] [Units: vx]
  72144. */
  72145. maxSimplificationError: number;
  72146. /**
  72147. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  72148. */
  72149. minRegionArea: number;
  72150. /**
  72151. * Any regions with a span count smaller than this value will, if possible,
  72152. * be merged with larger regions. [Limit: >=0] [Units: vx]
  72153. */
  72154. mergeRegionArea: number;
  72155. /**
  72156. * The maximum number of vertices allowed for polygons generated during the
  72157. * contour to polygon conversion process. [Limit: >= 3]
  72158. */
  72159. maxVertsPerPoly: number;
  72160. /**
  72161. * Sets the sampling distance to use when generating the detail mesh.
  72162. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  72163. */
  72164. detailSampleDist: number;
  72165. /**
  72166. * The maximum distance the detail mesh surface should deviate from heightfield
  72167. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  72168. */
  72169. detailSampleMaxError: number;
  72170. }
  72171. }
  72172. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  72173. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  72174. import { Mesh } from "babylonjs/Meshes/mesh";
  72175. import { Scene } from "babylonjs/scene";
  72176. import { Vector3 } from "babylonjs/Maths/math";
  72177. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72178. /**
  72179. * RecastJS navigation plugin
  72180. */
  72181. export class RecastJSPlugin implements INavigationEnginePlugin {
  72182. /**
  72183. * Reference to the Recast library
  72184. */
  72185. bjsRECAST: any;
  72186. /**
  72187. * plugin name
  72188. */
  72189. name: string;
  72190. /**
  72191. * the first navmesh created. We might extend this to support multiple navmeshes
  72192. */
  72193. navMesh: any;
  72194. private _maximumSubStepCount;
  72195. private _timeStep;
  72196. /**
  72197. * Initializes the recastJS plugin
  72198. * @param recastInjection can be used to inject your own recast reference
  72199. */
  72200. constructor(recastInjection?: any);
  72201. /**
  72202. * Set the time step of the navigation tick update.
  72203. * Default is 1/60.
  72204. * A value of 0 will disable fixed time update
  72205. * @param newTimeStep the new timestep to apply to this world.
  72206. */
  72207. setTimeStep(newTimeStep?: number): void;
  72208. /**
  72209. * Get the time step of the navigation tick update.
  72210. * @returns the current time step
  72211. */
  72212. getTimeStep(): number;
  72213. /**
  72214. * If delta time in navigation tick update is greater than the time step
  72215. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72216. * they will be discarded.
  72217. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72218. * @param newStepCount the maximum number of iterations
  72219. */
  72220. setMaximumSubStepCount(newStepCount?: number): void;
  72221. /**
  72222. * Get the maximum number of iterations per navigation tick update
  72223. * @returns the maximum number of iterations
  72224. */
  72225. getMaximumSubStepCount(): number;
  72226. /**
  72227. * Creates a navigation mesh
  72228. * @param meshes array of all the geometry used to compute the navigatio mesh
  72229. * @param parameters bunch of parameters used to filter geometry
  72230. */
  72231. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72232. /**
  72233. * Create a navigation mesh debug mesh
  72234. * @param scene is where the mesh will be added
  72235. * @returns debug display mesh
  72236. */
  72237. createDebugNavMesh(scene: Scene): Mesh;
  72238. /**
  72239. * Get a navigation mesh constrained position, closest to the parameter position
  72240. * @param position world position
  72241. * @returns the closest point to position constrained by the navigation mesh
  72242. */
  72243. getClosestPoint(position: Vector3): Vector3;
  72244. /**
  72245. * Get a navigation mesh constrained position, closest to the parameter position
  72246. * @param position world position
  72247. * @param result output the closest point to position constrained by the navigation mesh
  72248. */
  72249. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72250. /**
  72251. * Get a navigation mesh constrained position, within a particular radius
  72252. * @param position world position
  72253. * @param maxRadius the maximum distance to the constrained world position
  72254. * @returns the closest point to position constrained by the navigation mesh
  72255. */
  72256. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72257. /**
  72258. * Get a navigation mesh constrained position, within a particular radius
  72259. * @param position world position
  72260. * @param maxRadius the maximum distance to the constrained world position
  72261. * @param result output the closest point to position constrained by the navigation mesh
  72262. */
  72263. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72264. /**
  72265. * Compute the final position from a segment made of destination-position
  72266. * @param position world position
  72267. * @param destination world position
  72268. * @returns the resulting point along the navmesh
  72269. */
  72270. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72271. /**
  72272. * Compute the final position from a segment made of destination-position
  72273. * @param position world position
  72274. * @param destination world position
  72275. * @param result output the resulting point along the navmesh
  72276. */
  72277. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72278. /**
  72279. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72280. * @param start world position
  72281. * @param end world position
  72282. * @returns array containing world position composing the path
  72283. */
  72284. computePath(start: Vector3, end: Vector3): Vector3[];
  72285. /**
  72286. * Create a new Crowd so you can add agents
  72287. * @param maxAgents the maximum agent count in the crowd
  72288. * @param maxAgentRadius the maximum radius an agent can have
  72289. * @param scene to attach the crowd to
  72290. * @returns the crowd you can add agents to
  72291. */
  72292. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  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. * build the navmesh from a previously saved state using getNavmeshData
  72307. * @param data the Uint8Array returned by getNavmeshData
  72308. */
  72309. buildFromNavmeshData(data: Uint8Array): void;
  72310. /**
  72311. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72312. * @returns data the Uint8Array that can be saved and reused
  72313. */
  72314. getNavmeshData(): Uint8Array;
  72315. /**
  72316. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72317. * @param result output the box extent values
  72318. */
  72319. getDefaultQueryExtentToRef(result: Vector3): void;
  72320. /**
  72321. * Disposes
  72322. */
  72323. dispose(): void;
  72324. /**
  72325. * If this plugin is supported
  72326. * @returns true if plugin is supported
  72327. */
  72328. isSupported(): boolean;
  72329. }
  72330. /**
  72331. * Recast detour crowd implementation
  72332. */
  72333. export class RecastJSCrowd implements ICrowd {
  72334. /**
  72335. * Recast/detour plugin
  72336. */
  72337. bjsRECASTPlugin: RecastJSPlugin;
  72338. /**
  72339. * Link to the detour crowd
  72340. */
  72341. recastCrowd: any;
  72342. /**
  72343. * One transform per agent
  72344. */
  72345. transforms: TransformNode[];
  72346. /**
  72347. * All agents created
  72348. */
  72349. agents: number[];
  72350. /**
  72351. * Link to the scene is kept to unregister the crowd from the scene
  72352. */
  72353. private _scene;
  72354. /**
  72355. * Observer for crowd updates
  72356. */
  72357. private _onBeforeAnimationsObserver;
  72358. /**
  72359. * Constructor
  72360. * @param plugin recastJS plugin
  72361. * @param maxAgents the maximum agent count in the crowd
  72362. * @param maxAgentRadius the maximum radius an agent can have
  72363. * @param scene to attach the crowd to
  72364. * @returns the crowd you can add agents to
  72365. */
  72366. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72367. /**
  72368. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72369. * You can attach anything to that node. The node position is updated in the scene update tick.
  72370. * @param pos world position that will be constrained by the navigation mesh
  72371. * @param parameters agent parameters
  72372. * @param transform hooked to the agent that will be update by the scene
  72373. * @returns agent index
  72374. */
  72375. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72376. /**
  72377. * Returns the agent position in world space
  72378. * @param index agent index returned by addAgent
  72379. * @returns world space position
  72380. */
  72381. getAgentPosition(index: number): Vector3;
  72382. /**
  72383. * Returns the agent position result in world space
  72384. * @param index agent index returned by addAgent
  72385. * @param result output world space position
  72386. */
  72387. getAgentPositionToRef(index: number, result: Vector3): void;
  72388. /**
  72389. * Returns the agent velocity in world space
  72390. * @param index agent index returned by addAgent
  72391. * @returns world space velocity
  72392. */
  72393. getAgentVelocity(index: number): Vector3;
  72394. /**
  72395. * Returns the agent velocity result in world space
  72396. * @param index agent index returned by addAgent
  72397. * @param result output world space velocity
  72398. */
  72399. getAgentVelocityToRef(index: number, result: Vector3): void;
  72400. /**
  72401. * Returns the agent next target point on the path
  72402. * @param index agent index returned by addAgent
  72403. * @returns world space position
  72404. */
  72405. getAgentNextTargetPath(index: number): Vector3;
  72406. /**
  72407. * Returns the agent next target point on the path
  72408. * @param index agent index returned by addAgent
  72409. * @param result output world space position
  72410. */
  72411. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72412. /**
  72413. * Gets the agent state
  72414. * @param index agent index returned by addAgent
  72415. * @returns agent state
  72416. */
  72417. getAgentState(index: number): number;
  72418. /**
  72419. * returns true if the agent in over an off mesh link connection
  72420. * @param index agent index returned by addAgent
  72421. * @returns true if over an off mesh link connection
  72422. */
  72423. overOffmeshConnection(index: number): boolean;
  72424. /**
  72425. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72426. * @param index agent index returned by addAgent
  72427. * @param destination targeted world position
  72428. */
  72429. agentGoto(index: number, destination: Vector3): void;
  72430. /**
  72431. * Teleport the agent to a new position
  72432. * @param index agent index returned by addAgent
  72433. * @param destination targeted world position
  72434. */
  72435. agentTeleport(index: number, destination: Vector3): void;
  72436. /**
  72437. * Update agent parameters
  72438. * @param index agent index returned by addAgent
  72439. * @param parameters agent parameters
  72440. */
  72441. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72442. /**
  72443. * remove a particular agent previously created
  72444. * @param index agent index returned by addAgent
  72445. */
  72446. removeAgent(index: number): void;
  72447. /**
  72448. * get the list of all agents attached to this crowd
  72449. * @returns list of agent indices
  72450. */
  72451. getAgents(): number[];
  72452. /**
  72453. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72454. * @param deltaTime in seconds
  72455. */
  72456. update(deltaTime: number): void;
  72457. /**
  72458. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72459. * The queries will try to find a solution within those bounds
  72460. * default is (1,1,1)
  72461. * @param extent x,y,z value that define the extent around the queries point of reference
  72462. */
  72463. setDefaultQueryExtent(extent: Vector3): void;
  72464. /**
  72465. * Get the Bounding box extent specified by setDefaultQueryExtent
  72466. * @returns the box extent values
  72467. */
  72468. getDefaultQueryExtent(): Vector3;
  72469. /**
  72470. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72471. * @param result output the box extent values
  72472. */
  72473. getDefaultQueryExtentToRef(result: Vector3): void;
  72474. /**
  72475. * Release all resources
  72476. */
  72477. dispose(): void;
  72478. }
  72479. }
  72480. declare module "babylonjs/Navigation/Plugins/index" {
  72481. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  72482. }
  72483. declare module "babylonjs/Navigation/index" {
  72484. export * from "babylonjs/Navigation/INavigationEngine";
  72485. export * from "babylonjs/Navigation/Plugins/index";
  72486. }
  72487. declare module "babylonjs/Offline/database" {
  72488. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  72489. /**
  72490. * Class used to enable access to IndexedDB
  72491. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72492. */
  72493. export class Database implements IOfflineProvider {
  72494. private _callbackManifestChecked;
  72495. private _currentSceneUrl;
  72496. private _db;
  72497. private _enableSceneOffline;
  72498. private _enableTexturesOffline;
  72499. private _manifestVersionFound;
  72500. private _mustUpdateRessources;
  72501. private _hasReachedQuota;
  72502. private _isSupported;
  72503. private _idbFactory;
  72504. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72505. private static IsUASupportingBlobStorage;
  72506. /**
  72507. * Gets a boolean indicating if Database storate is enabled (off by default)
  72508. */
  72509. static IDBStorageEnabled: boolean;
  72510. /**
  72511. * Gets a boolean indicating if scene must be saved in the database
  72512. */
  72513. get enableSceneOffline(): boolean;
  72514. /**
  72515. * Gets a boolean indicating if textures must be saved in the database
  72516. */
  72517. get enableTexturesOffline(): boolean;
  72518. /**
  72519. * Creates a new Database
  72520. * @param urlToScene defines the url to load the scene
  72521. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72522. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72523. */
  72524. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72525. private static _ParseURL;
  72526. private static _ReturnFullUrlLocation;
  72527. private _checkManifestFile;
  72528. /**
  72529. * Open the database and make it available
  72530. * @param successCallback defines the callback to call on success
  72531. * @param errorCallback defines the callback to call on error
  72532. */
  72533. open(successCallback: () => void, errorCallback: () => void): void;
  72534. /**
  72535. * Loads an image from the database
  72536. * @param url defines the url to load from
  72537. * @param image defines the target DOM image
  72538. */
  72539. loadImage(url: string, image: HTMLImageElement): void;
  72540. private _loadImageFromDBAsync;
  72541. private _saveImageIntoDBAsync;
  72542. private _checkVersionFromDB;
  72543. private _loadVersionFromDBAsync;
  72544. private _saveVersionIntoDBAsync;
  72545. /**
  72546. * Loads a file from database
  72547. * @param url defines the URL to load from
  72548. * @param sceneLoaded defines a callback to call on success
  72549. * @param progressCallBack defines a callback to call when progress changed
  72550. * @param errorCallback defines a callback to call on error
  72551. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72552. */
  72553. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72554. private _loadFileAsync;
  72555. private _saveFileAsync;
  72556. /**
  72557. * Validates if xhr data is correct
  72558. * @param xhr defines the request to validate
  72559. * @param dataType defines the expected data type
  72560. * @returns true if data is correct
  72561. */
  72562. private static _ValidateXHRData;
  72563. }
  72564. }
  72565. declare module "babylonjs/Offline/index" {
  72566. export * from "babylonjs/Offline/database";
  72567. export * from "babylonjs/Offline/IOfflineProvider";
  72568. }
  72569. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  72570. /** @hidden */
  72571. export var gpuUpdateParticlesPixelShader: {
  72572. name: string;
  72573. shader: string;
  72574. };
  72575. }
  72576. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  72577. /** @hidden */
  72578. export var gpuUpdateParticlesVertexShader: {
  72579. name: string;
  72580. shader: string;
  72581. };
  72582. }
  72583. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  72584. /** @hidden */
  72585. export var clipPlaneFragmentDeclaration2: {
  72586. name: string;
  72587. shader: string;
  72588. };
  72589. }
  72590. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  72591. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  72592. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  72593. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72594. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  72595. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  72596. /** @hidden */
  72597. export var gpuRenderParticlesPixelShader: {
  72598. name: string;
  72599. shader: string;
  72600. };
  72601. }
  72602. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  72603. /** @hidden */
  72604. export var clipPlaneVertexDeclaration2: {
  72605. name: string;
  72606. shader: string;
  72607. };
  72608. }
  72609. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  72610. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  72611. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  72612. /** @hidden */
  72613. export var gpuRenderParticlesVertexShader: {
  72614. name: string;
  72615. shader: string;
  72616. };
  72617. }
  72618. declare module "babylonjs/Particles/gpuParticleSystem" {
  72619. import { Nullable } from "babylonjs/types";
  72620. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  72621. import { Observable } from "babylonjs/Misc/observable";
  72622. import { Matrix } from "babylonjs/Maths/math.vector";
  72623. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  72624. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72625. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  72626. import { IDisposable } from "babylonjs/scene";
  72627. import { Effect } from "babylonjs/Materials/effect";
  72628. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72629. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72630. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  72631. import { Scene } from "babylonjs/scene";
  72632. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  72633. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  72634. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  72635. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  72636. /**
  72637. * This represents a GPU particle system in Babylon
  72638. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72639. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72640. */
  72641. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72642. /**
  72643. * The layer mask we are rendering the particles through.
  72644. */
  72645. layerMask: number;
  72646. private _capacity;
  72647. private _activeCount;
  72648. private _currentActiveCount;
  72649. private _accumulatedCount;
  72650. private _renderEffect;
  72651. private _updateEffect;
  72652. private _buffer0;
  72653. private _buffer1;
  72654. private _spriteBuffer;
  72655. private _updateVAO;
  72656. private _renderVAO;
  72657. private _targetIndex;
  72658. private _sourceBuffer;
  72659. private _targetBuffer;
  72660. private _currentRenderId;
  72661. private _started;
  72662. private _stopped;
  72663. private _timeDelta;
  72664. private _randomTexture;
  72665. private _randomTexture2;
  72666. private _attributesStrideSize;
  72667. private _updateEffectOptions;
  72668. private _randomTextureSize;
  72669. private _actualFrame;
  72670. private _customEffect;
  72671. private readonly _rawTextureWidth;
  72672. /**
  72673. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72674. */
  72675. static get IsSupported(): boolean;
  72676. /**
  72677. * An event triggered when the system is disposed.
  72678. */
  72679. onDisposeObservable: Observable<IParticleSystem>;
  72680. /**
  72681. * An event triggered when the system is stopped
  72682. */
  72683. onStoppedObservable: Observable<IParticleSystem>;
  72684. /**
  72685. * Gets the maximum number of particles active at the same time.
  72686. * @returns The max number of active particles.
  72687. */
  72688. getCapacity(): number;
  72689. /**
  72690. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72691. * to override the particles.
  72692. */
  72693. forceDepthWrite: boolean;
  72694. /**
  72695. * Gets or set the number of active particles
  72696. */
  72697. get activeParticleCount(): number;
  72698. set activeParticleCount(value: number);
  72699. private _preWarmDone;
  72700. /**
  72701. * Specifies if the particles are updated in emitter local space or world space.
  72702. */
  72703. isLocal: boolean;
  72704. /** Gets or sets a matrix to use to compute projection */
  72705. defaultProjectionMatrix: Matrix;
  72706. /**
  72707. * Is this system ready to be used/rendered
  72708. * @return true if the system is ready
  72709. */
  72710. isReady(): boolean;
  72711. /**
  72712. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72713. * @returns True if it has been started, otherwise false.
  72714. */
  72715. isStarted(): boolean;
  72716. /**
  72717. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72718. * @returns True if it has been stopped, otherwise false.
  72719. */
  72720. isStopped(): boolean;
  72721. /**
  72722. * Gets a boolean indicating that the system is stopping
  72723. * @returns true if the system is currently stopping
  72724. */
  72725. isStopping(): boolean;
  72726. /**
  72727. * Gets the number of particles active at the same time.
  72728. * @returns The number of active particles.
  72729. */
  72730. getActiveCount(): number;
  72731. /**
  72732. * Starts the particle system and begins to emit
  72733. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72734. */
  72735. start(delay?: number): void;
  72736. /**
  72737. * Stops the particle system.
  72738. */
  72739. stop(): void;
  72740. /**
  72741. * Remove all active particles
  72742. */
  72743. reset(): void;
  72744. /**
  72745. * Returns the string "GPUParticleSystem"
  72746. * @returns a string containing the class name
  72747. */
  72748. getClassName(): string;
  72749. /**
  72750. * Gets the custom effect used to render the particles
  72751. * @param blendMode Blend mode for which the effect should be retrieved
  72752. * @returns The effect
  72753. */
  72754. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72755. /**
  72756. * Sets the custom effect used to render the particles
  72757. * @param effect The effect to set
  72758. * @param blendMode Blend mode for which the effect should be set
  72759. */
  72760. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72761. /** @hidden */
  72762. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72763. /**
  72764. * Observable that will be called just before the particles are drawn
  72765. */
  72766. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72767. /**
  72768. * Gets the name of the particle vertex shader
  72769. */
  72770. get vertexShaderName(): string;
  72771. private _colorGradientsTexture;
  72772. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72773. /**
  72774. * Adds a new color gradient
  72775. * @param gradient defines the gradient to use (between 0 and 1)
  72776. * @param color1 defines the color to affect to the specified gradient
  72777. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72778. * @returns the current particle system
  72779. */
  72780. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72781. private _refreshColorGradient;
  72782. /** Force the system to rebuild all gradients that need to be resync */
  72783. forceRefreshGradients(): void;
  72784. /**
  72785. * Remove a specific color gradient
  72786. * @param gradient defines the gradient to remove
  72787. * @returns the current particle system
  72788. */
  72789. removeColorGradient(gradient: number): GPUParticleSystem;
  72790. private _angularSpeedGradientsTexture;
  72791. private _sizeGradientsTexture;
  72792. private _velocityGradientsTexture;
  72793. private _limitVelocityGradientsTexture;
  72794. private _dragGradientsTexture;
  72795. private _addFactorGradient;
  72796. /**
  72797. * Adds a new size gradient
  72798. * @param gradient defines the gradient to use (between 0 and 1)
  72799. * @param factor defines the size factor to affect to the specified gradient
  72800. * @returns the current particle system
  72801. */
  72802. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72803. /**
  72804. * Remove a specific size gradient
  72805. * @param gradient defines the gradient to remove
  72806. * @returns the current particle system
  72807. */
  72808. removeSizeGradient(gradient: number): GPUParticleSystem;
  72809. private _refreshFactorGradient;
  72810. /**
  72811. * Adds a new angular speed gradient
  72812. * @param gradient defines the gradient to use (between 0 and 1)
  72813. * @param factor defines the angular speed to affect to the specified gradient
  72814. * @returns the current particle system
  72815. */
  72816. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72817. /**
  72818. * Remove a specific angular speed gradient
  72819. * @param gradient defines the gradient to remove
  72820. * @returns the current particle system
  72821. */
  72822. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72823. /**
  72824. * Adds a new velocity gradient
  72825. * @param gradient defines the gradient to use (between 0 and 1)
  72826. * @param factor defines the velocity to affect to the specified gradient
  72827. * @returns the current particle system
  72828. */
  72829. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72830. /**
  72831. * Remove a specific velocity gradient
  72832. * @param gradient defines the gradient to remove
  72833. * @returns the current particle system
  72834. */
  72835. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72836. /**
  72837. * Adds a new limit velocity gradient
  72838. * @param gradient defines the gradient to use (between 0 and 1)
  72839. * @param factor defines the limit velocity value to affect to the specified gradient
  72840. * @returns the current particle system
  72841. */
  72842. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72843. /**
  72844. * Remove a specific limit velocity gradient
  72845. * @param gradient defines the gradient to remove
  72846. * @returns the current particle system
  72847. */
  72848. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72849. /**
  72850. * Adds a new drag gradient
  72851. * @param gradient defines the gradient to use (between 0 and 1)
  72852. * @param factor defines the drag value to affect to the specified gradient
  72853. * @returns the current particle system
  72854. */
  72855. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72856. /**
  72857. * Remove a specific drag gradient
  72858. * @param gradient defines the gradient to remove
  72859. * @returns the current particle system
  72860. */
  72861. removeDragGradient(gradient: number): GPUParticleSystem;
  72862. /**
  72863. * Not supported by GPUParticleSystem
  72864. * @param gradient defines the gradient to use (between 0 and 1)
  72865. * @param factor defines the emit rate value to affect to the specified gradient
  72866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72867. * @returns the current particle system
  72868. */
  72869. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72870. /**
  72871. * Not supported by GPUParticleSystem
  72872. * @param gradient defines the gradient to remove
  72873. * @returns the current particle system
  72874. */
  72875. removeEmitRateGradient(gradient: number): IParticleSystem;
  72876. /**
  72877. * Not supported by GPUParticleSystem
  72878. * @param gradient defines the gradient to use (between 0 and 1)
  72879. * @param factor defines the start size value to affect to the specified gradient
  72880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72881. * @returns the current particle system
  72882. */
  72883. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72884. /**
  72885. * Not supported by GPUParticleSystem
  72886. * @param gradient defines the gradient to remove
  72887. * @returns the current particle system
  72888. */
  72889. removeStartSizeGradient(gradient: number): IParticleSystem;
  72890. /**
  72891. * Not supported by GPUParticleSystem
  72892. * @param gradient defines the gradient to use (between 0 and 1)
  72893. * @param min defines the color remap minimal range
  72894. * @param max defines the color remap maximal range
  72895. * @returns the current particle system
  72896. */
  72897. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72898. /**
  72899. * Not supported by GPUParticleSystem
  72900. * @param gradient defines the gradient to remove
  72901. * @returns the current particle system
  72902. */
  72903. removeColorRemapGradient(): IParticleSystem;
  72904. /**
  72905. * Not supported by GPUParticleSystem
  72906. * @param gradient defines the gradient to use (between 0 and 1)
  72907. * @param min defines the alpha remap minimal range
  72908. * @param max defines the alpha remap maximal range
  72909. * @returns the current particle system
  72910. */
  72911. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72912. /**
  72913. * Not supported by GPUParticleSystem
  72914. * @param gradient defines the gradient to remove
  72915. * @returns the current particle system
  72916. */
  72917. removeAlphaRemapGradient(): IParticleSystem;
  72918. /**
  72919. * Not supported by GPUParticleSystem
  72920. * @param gradient defines the gradient to use (between 0 and 1)
  72921. * @param color defines the color to affect to the specified gradient
  72922. * @returns the current particle system
  72923. */
  72924. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72925. /**
  72926. * Not supported by GPUParticleSystem
  72927. * @param gradient defines the gradient to remove
  72928. * @returns the current particle system
  72929. */
  72930. removeRampGradient(): IParticleSystem;
  72931. /**
  72932. * Not supported by GPUParticleSystem
  72933. * @returns the list of ramp gradients
  72934. */
  72935. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72936. /**
  72937. * Not supported by GPUParticleSystem
  72938. * Gets or sets a boolean indicating that ramp gradients must be used
  72939. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72940. */
  72941. get useRampGradients(): boolean;
  72942. set useRampGradients(value: boolean);
  72943. /**
  72944. * Not supported by GPUParticleSystem
  72945. * @param gradient defines the gradient to use (between 0 and 1)
  72946. * @param factor defines the life time factor to affect to the specified gradient
  72947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72948. * @returns the current particle system
  72949. */
  72950. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72951. /**
  72952. * Not supported by GPUParticleSystem
  72953. * @param gradient defines the gradient to remove
  72954. * @returns the current particle system
  72955. */
  72956. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72957. /**
  72958. * Instantiates a GPU particle system.
  72959. * 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.
  72960. * @param name The name of the particle system
  72961. * @param options The options used to create the system
  72962. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72963. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72964. * @param customEffect a custom effect used to change the way particles are rendered by default
  72965. */
  72966. constructor(name: string, options: Partial<{
  72967. capacity: number;
  72968. randomTextureSize: number;
  72969. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72970. protected _reset(): void;
  72971. private _createUpdateVAO;
  72972. private _createRenderVAO;
  72973. private _initialize;
  72974. /** @hidden */
  72975. _recreateUpdateEffect(): void;
  72976. private _getEffect;
  72977. /**
  72978. * Fill the defines array according to the current settings of the particle system
  72979. * @param defines Array to be updated
  72980. * @param blendMode blend mode to take into account when updating the array
  72981. */
  72982. fillDefines(defines: Array<string>, blendMode?: number): void;
  72983. /**
  72984. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72985. * @param uniforms Uniforms array to fill
  72986. * @param attributes Attributes array to fill
  72987. * @param samplers Samplers array to fill
  72988. */
  72989. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72990. /** @hidden */
  72991. _recreateRenderEffect(): Effect;
  72992. /**
  72993. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72994. * @param preWarm defines if we are in the pre-warmimg phase
  72995. */
  72996. animate(preWarm?: boolean): void;
  72997. private _createFactorGradientTexture;
  72998. private _createSizeGradientTexture;
  72999. private _createAngularSpeedGradientTexture;
  73000. private _createVelocityGradientTexture;
  73001. private _createLimitVelocityGradientTexture;
  73002. private _createDragGradientTexture;
  73003. private _createColorGradientTexture;
  73004. /**
  73005. * Renders the particle system in its current state
  73006. * @param preWarm defines if the system should only update the particles but not render them
  73007. * @returns the current number of particles
  73008. */
  73009. render(preWarm?: boolean): number;
  73010. /**
  73011. * Rebuilds the particle system
  73012. */
  73013. rebuild(): void;
  73014. private _releaseBuffers;
  73015. private _releaseVAOs;
  73016. /**
  73017. * Disposes the particle system and free the associated resources
  73018. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73019. */
  73020. dispose(disposeTexture?: boolean): void;
  73021. /**
  73022. * Clones the particle system.
  73023. * @param name The name of the cloned object
  73024. * @param newEmitter The new emitter to use
  73025. * @returns the cloned particle system
  73026. */
  73027. clone(name: string, newEmitter: any): GPUParticleSystem;
  73028. /**
  73029. * Serializes the particle system to a JSON object
  73030. * @param serializeTexture defines if the texture must be serialized as well
  73031. * @returns the JSON object
  73032. */
  73033. serialize(serializeTexture?: boolean): any;
  73034. /**
  73035. * Parses a JSON object to create a GPU particle system.
  73036. * @param parsedParticleSystem The JSON object to parse
  73037. * @param sceneOrEngine The scene or the engine to create the particle system in
  73038. * @param rootUrl The root url to use to load external dependencies like texture
  73039. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73040. * @returns the parsed GPU particle system
  73041. */
  73042. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  73043. }
  73044. }
  73045. declare module "babylonjs/Particles/particleSystemSet" {
  73046. import { Nullable } from "babylonjs/types";
  73047. import { Color3 } from "babylonjs/Maths/math.color";
  73048. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73050. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73051. import { Scene, IDisposable } from "babylonjs/scene";
  73052. /**
  73053. * Represents a set of particle systems working together to create a specific effect
  73054. */
  73055. export class ParticleSystemSet implements IDisposable {
  73056. /**
  73057. * Gets or sets base Assets URL
  73058. */
  73059. static BaseAssetsUrl: string;
  73060. private _emitterCreationOptions;
  73061. private _emitterNode;
  73062. /**
  73063. * Gets the particle system list
  73064. */
  73065. systems: IParticleSystem[];
  73066. /**
  73067. * Gets the emitter node used with this set
  73068. */
  73069. get emitterNode(): Nullable<TransformNode>;
  73070. /**
  73071. * Creates a new emitter mesh as a sphere
  73072. * @param options defines the options used to create the sphere
  73073. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  73074. * @param scene defines the hosting scene
  73075. */
  73076. setEmitterAsSphere(options: {
  73077. diameter: number;
  73078. segments: number;
  73079. color: Color3;
  73080. }, renderingGroupId: number, scene: Scene): void;
  73081. /**
  73082. * Starts all particle systems of the set
  73083. * @param emitter defines an optional mesh to use as emitter for the particle systems
  73084. */
  73085. start(emitter?: AbstractMesh): void;
  73086. /**
  73087. * Release all associated resources
  73088. */
  73089. dispose(): void;
  73090. /**
  73091. * Serialize the set into a JSON compatible object
  73092. * @param serializeTexture defines if the texture must be serialized as well
  73093. * @returns a JSON compatible representation of the set
  73094. */
  73095. serialize(serializeTexture?: boolean): any;
  73096. /**
  73097. * Parse a new ParticleSystemSet from a serialized source
  73098. * @param data defines a JSON compatible representation of the set
  73099. * @param scene defines the hosting scene
  73100. * @param gpu defines if we want GPU particles or CPU particles
  73101. * @returns a new ParticleSystemSet
  73102. */
  73103. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  73104. }
  73105. }
  73106. declare module "babylonjs/Particles/particleHelper" {
  73107. import { Nullable } from "babylonjs/types";
  73108. import { Scene } from "babylonjs/scene";
  73109. import { Vector3 } from "babylonjs/Maths/math.vector";
  73110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73111. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73112. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  73113. /**
  73114. * This class is made for on one-liner static method to help creating particle system set.
  73115. */
  73116. export class ParticleHelper {
  73117. /**
  73118. * Gets or sets base Assets URL
  73119. */
  73120. static BaseAssetsUrl: string;
  73121. /** Define the Url to load snippets */
  73122. static SnippetUrl: string;
  73123. /**
  73124. * Create a default particle system that you can tweak
  73125. * @param emitter defines the emitter to use
  73126. * @param capacity defines the system capacity (default is 500 particles)
  73127. * @param scene defines the hosting scene
  73128. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  73129. * @returns the new Particle system
  73130. */
  73131. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  73132. /**
  73133. * This is the main static method (one-liner) of this helper to create different particle systems
  73134. * @param type This string represents the type to the particle system to create
  73135. * @param scene The scene where the particle system should live
  73136. * @param gpu If the system will use gpu
  73137. * @returns the ParticleSystemSet created
  73138. */
  73139. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  73140. /**
  73141. * Static function used to export a particle system to a ParticleSystemSet variable.
  73142. * Please note that the emitter shape is not exported
  73143. * @param systems defines the particle systems to export
  73144. * @returns the created particle system set
  73145. */
  73146. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  73147. /**
  73148. * Creates a particle system from a snippet saved in a remote file
  73149. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  73150. * @param url defines the url to load from
  73151. * @param scene defines the hosting scene
  73152. * @param gpu If the system will use gpu
  73153. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73154. * @returns a promise that will resolve to the new particle system
  73155. */
  73156. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73157. /**
  73158. * Creates a particle system from a snippet saved by the particle system editor
  73159. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  73160. * @param scene defines the hosting scene
  73161. * @param gpu If the system will use gpu
  73162. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73163. * @returns a promise that will resolve to the new particle system
  73164. */
  73165. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73166. }
  73167. }
  73168. declare module "babylonjs/Particles/particleSystemComponent" {
  73169. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73170. import { Effect } from "babylonjs/Materials/effect";
  73171. import "babylonjs/Shaders/particles.vertex";
  73172. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  73173. module "babylonjs/Engines/engine" {
  73174. interface Engine {
  73175. /**
  73176. * Create an effect to use with particle systems.
  73177. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  73178. * the particle system for which you want to create a custom effect in the last parameter
  73179. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  73180. * @param uniformsNames defines a list of attribute names
  73181. * @param samplers defines an array of string used to represent textures
  73182. * @param defines defines the string containing the defines to use to compile the shaders
  73183. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  73184. * @param onCompiled defines a function to call when the effect creation is successful
  73185. * @param onError defines a function to call when the effect creation has failed
  73186. * @param particleSystem the particle system you want to create the effect for
  73187. * @returns the new Effect
  73188. */
  73189. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  73190. }
  73191. }
  73192. module "babylonjs/Meshes/mesh" {
  73193. interface Mesh {
  73194. /**
  73195. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  73196. * @returns an array of IParticleSystem
  73197. */
  73198. getEmittedParticleSystems(): IParticleSystem[];
  73199. /**
  73200. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  73201. * @returns an array of IParticleSystem
  73202. */
  73203. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  73204. }
  73205. }
  73206. }
  73207. declare module "babylonjs/Particles/pointsCloudSystem" {
  73208. import { Color4 } from "babylonjs/Maths/math";
  73209. import { Mesh } from "babylonjs/Meshes/mesh";
  73210. import { Scene, IDisposable } from "babylonjs/scene";
  73211. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  73212. /** Defines the 4 color options */
  73213. export enum PointColor {
  73214. /** color value */
  73215. Color = 2,
  73216. /** uv value */
  73217. UV = 1,
  73218. /** random value */
  73219. Random = 0,
  73220. /** stated value */
  73221. Stated = 3
  73222. }
  73223. /**
  73224. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  73225. * 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.
  73226. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  73227. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  73228. *
  73229. * Full documentation here : TO BE ENTERED
  73230. */
  73231. export class PointsCloudSystem implements IDisposable {
  73232. /**
  73233. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  73234. * Example : var p = SPS.particles[i];
  73235. */
  73236. particles: CloudPoint[];
  73237. /**
  73238. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  73239. */
  73240. nbParticles: number;
  73241. /**
  73242. * This a counter for your own usage. It's not set by any SPS functions.
  73243. */
  73244. counter: number;
  73245. /**
  73246. * The PCS name. This name is also given to the underlying mesh.
  73247. */
  73248. name: string;
  73249. /**
  73250. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  73251. */
  73252. mesh: Mesh;
  73253. /**
  73254. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  73255. * Please read :
  73256. */
  73257. vars: any;
  73258. /**
  73259. * @hidden
  73260. */
  73261. _size: number;
  73262. private _scene;
  73263. private _promises;
  73264. private _positions;
  73265. private _indices;
  73266. private _normals;
  73267. private _colors;
  73268. private _uvs;
  73269. private _indices32;
  73270. private _positions32;
  73271. private _colors32;
  73272. private _uvs32;
  73273. private _updatable;
  73274. private _isVisibilityBoxLocked;
  73275. private _alwaysVisible;
  73276. private _groups;
  73277. private _groupCounter;
  73278. private _computeParticleColor;
  73279. private _computeParticleTexture;
  73280. private _computeParticleRotation;
  73281. private _computeBoundingBox;
  73282. private _isReady;
  73283. /**
  73284. * Creates a PCS (Points Cloud System) object
  73285. * @param name (String) is the PCS name, this will be the underlying mesh name
  73286. * @param pointSize (number) is the size for each point
  73287. * @param scene (Scene) is the scene in which the PCS is added
  73288. * @param options defines the options of the PCS e.g.
  73289. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73290. */
  73291. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73292. updatable?: boolean;
  73293. });
  73294. /**
  73295. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73296. * If no points were added to the PCS, the returned mesh is just a single point.
  73297. * @returns a promise for the created mesh
  73298. */
  73299. buildMeshAsync(): Promise<Mesh>;
  73300. /**
  73301. * @hidden
  73302. */
  73303. private _buildMesh;
  73304. private _addParticle;
  73305. private _randomUnitVector;
  73306. private _getColorIndicesForCoord;
  73307. private _setPointsColorOrUV;
  73308. private _colorFromTexture;
  73309. private _calculateDensity;
  73310. /**
  73311. * Adds points to the PCS in random positions within a unit sphere
  73312. * @param nb (positive integer) the number of particles to be created from this model
  73313. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73314. * @returns the number of groups in the system
  73315. */
  73316. addPoints(nb: number, pointFunction?: any): number;
  73317. /**
  73318. * Adds points to the PCS from the surface of the model shape
  73319. * @param mesh is any Mesh object that will be used as a surface model for the points
  73320. * @param nb (positive integer) the number of particles to be created from this model
  73321. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73322. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73323. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73324. * @returns the number of groups in the system
  73325. */
  73326. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73327. /**
  73328. * Adds points to the PCS inside the model shape
  73329. * @param mesh is any Mesh object that will be used as a surface model for the points
  73330. * @param nb (positive integer) the number of particles to be created from this model
  73331. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73332. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73333. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73334. * @returns the number of groups in the system
  73335. */
  73336. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73337. /**
  73338. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73339. * This method calls `updateParticle()` for each particle of the SPS.
  73340. * For an animated SPS, it is usually called within the render loop.
  73341. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73342. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73343. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73344. * @returns the PCS.
  73345. */
  73346. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73347. /**
  73348. * Disposes the PCS.
  73349. */
  73350. dispose(): void;
  73351. /**
  73352. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  73353. * doc :
  73354. * @returns the PCS.
  73355. */
  73356. refreshVisibleSize(): PointsCloudSystem;
  73357. /**
  73358. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73359. * @param size the size (float) of the visibility box
  73360. * note : this doesn't lock the PCS mesh bounding box.
  73361. * doc :
  73362. */
  73363. setVisibilityBox(size: number): void;
  73364. /**
  73365. * Gets whether the PCS is always visible or not
  73366. * doc :
  73367. */
  73368. get isAlwaysVisible(): boolean;
  73369. /**
  73370. * Sets the PCS as always visible or not
  73371. * doc :
  73372. */
  73373. set isAlwaysVisible(val: boolean);
  73374. /**
  73375. * Tells to `setParticles()` to compute the particle rotations or not
  73376. * Default value : false. The PCS is faster when it's set to false
  73377. * Note : particle rotations are only applied to parent particles
  73378. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73379. */
  73380. set computeParticleRotation(val: boolean);
  73381. /**
  73382. * Tells to `setParticles()` to compute the particle colors or not.
  73383. * Default value : true. The PCS is faster when it's set to false.
  73384. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73385. */
  73386. set computeParticleColor(val: boolean);
  73387. set computeParticleTexture(val: boolean);
  73388. /**
  73389. * Gets if `setParticles()` computes the particle colors or not.
  73390. * Default value : false. The PCS is faster when it's set to false.
  73391. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73392. */
  73393. get computeParticleColor(): boolean;
  73394. /**
  73395. * Gets if `setParticles()` computes the particle textures or not.
  73396. * Default value : false. The PCS is faster when it's set to false.
  73397. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73398. */
  73399. get computeParticleTexture(): boolean;
  73400. /**
  73401. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73402. */
  73403. set computeBoundingBox(val: boolean);
  73404. /**
  73405. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73406. */
  73407. get computeBoundingBox(): boolean;
  73408. /**
  73409. * This function does nothing. It may be overwritten to set all the particle first values.
  73410. * The PCS doesn't call this function, you may have to call it by your own.
  73411. * doc :
  73412. */
  73413. initParticles(): void;
  73414. /**
  73415. * This function does nothing. It may be overwritten to recycle a particle
  73416. * The PCS doesn't call this function, you can to call it
  73417. * doc :
  73418. * @param particle The particle to recycle
  73419. * @returns the recycled particle
  73420. */
  73421. recycleParticle(particle: CloudPoint): CloudPoint;
  73422. /**
  73423. * Updates a particle : this function should be overwritten by the user.
  73424. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73425. * doc :
  73426. * @example : just set a particle position or velocity and recycle conditions
  73427. * @param particle The particle to update
  73428. * @returns the updated particle
  73429. */
  73430. updateParticle(particle: CloudPoint): CloudPoint;
  73431. /**
  73432. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73433. * This does nothing and may be overwritten by the user.
  73434. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73435. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73436. * @param update the boolean update value actually passed to setParticles()
  73437. */
  73438. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73439. /**
  73440. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73441. * This will be passed three parameters.
  73442. * This does nothing and may be overwritten by the user.
  73443. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73444. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73445. * @param update the boolean update value actually passed to setParticles()
  73446. */
  73447. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73448. }
  73449. }
  73450. declare module "babylonjs/Particles/cloudPoint" {
  73451. import { Nullable } from "babylonjs/types";
  73452. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  73453. import { Mesh } from "babylonjs/Meshes/mesh";
  73454. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  73455. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  73456. /**
  73457. * Represents one particle of a points cloud system.
  73458. */
  73459. export class CloudPoint {
  73460. /**
  73461. * particle global index
  73462. */
  73463. idx: number;
  73464. /**
  73465. * The color of the particle
  73466. */
  73467. color: Nullable<Color4>;
  73468. /**
  73469. * The world space position of the particle.
  73470. */
  73471. position: Vector3;
  73472. /**
  73473. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73474. */
  73475. rotation: Vector3;
  73476. /**
  73477. * The world space rotation quaternion of the particle.
  73478. */
  73479. rotationQuaternion: Nullable<Quaternion>;
  73480. /**
  73481. * The uv of the particle.
  73482. */
  73483. uv: Nullable<Vector2>;
  73484. /**
  73485. * The current speed of the particle.
  73486. */
  73487. velocity: Vector3;
  73488. /**
  73489. * The pivot point in the particle local space.
  73490. */
  73491. pivot: Vector3;
  73492. /**
  73493. * Must the particle be translated from its pivot point in its local space ?
  73494. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73495. * Default : false
  73496. */
  73497. translateFromPivot: boolean;
  73498. /**
  73499. * Index of this particle in the global "positions" array (Internal use)
  73500. * @hidden
  73501. */
  73502. _pos: number;
  73503. /**
  73504. * @hidden Index of this particle in the global "indices" array (Internal use)
  73505. */
  73506. _ind: number;
  73507. /**
  73508. * Group this particle belongs to
  73509. */
  73510. _group: PointsGroup;
  73511. /**
  73512. * Group id of this particle
  73513. */
  73514. groupId: number;
  73515. /**
  73516. * Index of the particle in its group id (Internal use)
  73517. */
  73518. idxInGroup: number;
  73519. /**
  73520. * @hidden Particle BoundingInfo object (Internal use)
  73521. */
  73522. _boundingInfo: BoundingInfo;
  73523. /**
  73524. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73525. */
  73526. _pcs: PointsCloudSystem;
  73527. /**
  73528. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73529. */
  73530. _stillInvisible: boolean;
  73531. /**
  73532. * @hidden Last computed particle rotation matrix
  73533. */
  73534. _rotationMatrix: number[];
  73535. /**
  73536. * Parent particle Id, if any.
  73537. * Default null.
  73538. */
  73539. parentId: Nullable<number>;
  73540. /**
  73541. * @hidden Internal global position in the PCS.
  73542. */
  73543. _globalPosition: Vector3;
  73544. /**
  73545. * Creates a Point Cloud object.
  73546. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73547. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73548. * @param group (PointsGroup) is the group the particle belongs to
  73549. * @param groupId (integer) is the group identifier in the PCS.
  73550. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73551. * @param pcs defines the PCS it is associated to
  73552. */
  73553. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73554. /**
  73555. * get point size
  73556. */
  73557. get size(): Vector3;
  73558. /**
  73559. * Set point size
  73560. */
  73561. set size(scale: Vector3);
  73562. /**
  73563. * Legacy support, changed quaternion to rotationQuaternion
  73564. */
  73565. get quaternion(): Nullable<Quaternion>;
  73566. /**
  73567. * Legacy support, changed quaternion to rotationQuaternion
  73568. */
  73569. set quaternion(q: Nullable<Quaternion>);
  73570. /**
  73571. * Returns a boolean. True if the particle intersects a mesh, else false
  73572. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73573. * @param target is the object (point or mesh) what the intersection is computed against
  73574. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  73575. * @returns true if it intersects
  73576. */
  73577. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73578. /**
  73579. * get the rotation matrix of the particle
  73580. * @hidden
  73581. */
  73582. getRotationMatrix(m: Matrix): void;
  73583. }
  73584. /**
  73585. * Represents a group of points in a points cloud system
  73586. * * PCS internal tool, don't use it manually.
  73587. */
  73588. export class PointsGroup {
  73589. /**
  73590. * The group id
  73591. * @hidden
  73592. */
  73593. groupID: number;
  73594. /**
  73595. * image data for group (internal use)
  73596. * @hidden
  73597. */
  73598. _groupImageData: Nullable<ArrayBufferView>;
  73599. /**
  73600. * Image Width (internal use)
  73601. * @hidden
  73602. */
  73603. _groupImgWidth: number;
  73604. /**
  73605. * Image Height (internal use)
  73606. * @hidden
  73607. */
  73608. _groupImgHeight: number;
  73609. /**
  73610. * Custom position function (internal use)
  73611. * @hidden
  73612. */
  73613. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73614. /**
  73615. * density per facet for surface points
  73616. * @hidden
  73617. */
  73618. _groupDensity: number[];
  73619. /**
  73620. * Only when points are colored by texture carries pointer to texture list array
  73621. * @hidden
  73622. */
  73623. _textureNb: number;
  73624. /**
  73625. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73626. * PCS internal tool, don't use it manually.
  73627. * @hidden
  73628. */
  73629. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73630. }
  73631. }
  73632. declare module "babylonjs/Particles/index" {
  73633. export * from "babylonjs/Particles/baseParticleSystem";
  73634. export * from "babylonjs/Particles/EmitterTypes/index";
  73635. export * from "babylonjs/Particles/gpuParticleSystem";
  73636. export * from "babylonjs/Particles/IParticleSystem";
  73637. export * from "babylonjs/Particles/particle";
  73638. export * from "babylonjs/Particles/particleHelper";
  73639. export * from "babylonjs/Particles/particleSystem";
  73640. import "babylonjs/Particles/particleSystemComponent";
  73641. export * from "babylonjs/Particles/particleSystemComponent";
  73642. export * from "babylonjs/Particles/particleSystemSet";
  73643. export * from "babylonjs/Particles/solidParticle";
  73644. export * from "babylonjs/Particles/solidParticleSystem";
  73645. export * from "babylonjs/Particles/cloudPoint";
  73646. export * from "babylonjs/Particles/pointsCloudSystem";
  73647. export * from "babylonjs/Particles/subEmitter";
  73648. }
  73649. declare module "babylonjs/Physics/physicsEngineComponent" {
  73650. import { Nullable } from "babylonjs/types";
  73651. import { Observable, Observer } from "babylonjs/Misc/observable";
  73652. import { Vector3 } from "babylonjs/Maths/math.vector";
  73653. import { Mesh } from "babylonjs/Meshes/mesh";
  73654. import { ISceneComponent } from "babylonjs/sceneComponent";
  73655. import { Scene } from "babylonjs/scene";
  73656. import { Node } from "babylonjs/node";
  73657. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  73658. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73659. module "babylonjs/scene" {
  73660. interface Scene {
  73661. /** @hidden (Backing field) */
  73662. _physicsEngine: Nullable<IPhysicsEngine>;
  73663. /** @hidden */
  73664. _physicsTimeAccumulator: number;
  73665. /**
  73666. * Gets the current physics engine
  73667. * @returns a IPhysicsEngine or null if none attached
  73668. */
  73669. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73670. /**
  73671. * Enables physics to the current scene
  73672. * @param gravity defines the scene's gravity for the physics engine
  73673. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73674. * @return a boolean indicating if the physics engine was initialized
  73675. */
  73676. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73677. /**
  73678. * Disables and disposes the physics engine associated with the scene
  73679. */
  73680. disablePhysicsEngine(): void;
  73681. /**
  73682. * Gets a boolean indicating if there is an active physics engine
  73683. * @returns a boolean indicating if there is an active physics engine
  73684. */
  73685. isPhysicsEnabled(): boolean;
  73686. /**
  73687. * Deletes a physics compound impostor
  73688. * @param compound defines the compound to delete
  73689. */
  73690. deleteCompoundImpostor(compound: any): void;
  73691. /**
  73692. * An event triggered when physic simulation is about to be run
  73693. */
  73694. onBeforePhysicsObservable: Observable<Scene>;
  73695. /**
  73696. * An event triggered when physic simulation has been done
  73697. */
  73698. onAfterPhysicsObservable: Observable<Scene>;
  73699. }
  73700. }
  73701. module "babylonjs/Meshes/abstractMesh" {
  73702. interface AbstractMesh {
  73703. /** @hidden */
  73704. _physicsImpostor: Nullable<PhysicsImpostor>;
  73705. /**
  73706. * Gets or sets impostor used for physic simulation
  73707. * @see https://doc.babylonjs.com/features/physics_engine
  73708. */
  73709. physicsImpostor: Nullable<PhysicsImpostor>;
  73710. /**
  73711. * Gets the current physics impostor
  73712. * @see https://doc.babylonjs.com/features/physics_engine
  73713. * @returns a physics impostor or null
  73714. */
  73715. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73716. /** Apply a physic impulse to the mesh
  73717. * @param force defines the force to apply
  73718. * @param contactPoint defines where to apply the force
  73719. * @returns the current mesh
  73720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73721. */
  73722. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73723. /**
  73724. * Creates a physic joint between two meshes
  73725. * @param otherMesh defines the other mesh to use
  73726. * @param pivot1 defines the pivot to use on this mesh
  73727. * @param pivot2 defines the pivot to use on the other mesh
  73728. * @param options defines additional options (can be plugin dependent)
  73729. * @returns the current mesh
  73730. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73731. */
  73732. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73733. /** @hidden */
  73734. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73735. }
  73736. }
  73737. /**
  73738. * Defines the physics engine scene component responsible to manage a physics engine
  73739. */
  73740. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73741. /**
  73742. * The component name helpful to identify the component in the list of scene components.
  73743. */
  73744. readonly name: string;
  73745. /**
  73746. * The scene the component belongs to.
  73747. */
  73748. scene: Scene;
  73749. /**
  73750. * Creates a new instance of the component for the given scene
  73751. * @param scene Defines the scene to register the component in
  73752. */
  73753. constructor(scene: Scene);
  73754. /**
  73755. * Registers the component in a given scene
  73756. */
  73757. register(): void;
  73758. /**
  73759. * Rebuilds the elements related to this component in case of
  73760. * context lost for instance.
  73761. */
  73762. rebuild(): void;
  73763. /**
  73764. * Disposes the component and the associated ressources
  73765. */
  73766. dispose(): void;
  73767. }
  73768. }
  73769. declare module "babylonjs/Physics/physicsHelper" {
  73770. import { Nullable } from "babylonjs/types";
  73771. import { Vector3 } from "babylonjs/Maths/math.vector";
  73772. import { Mesh } from "babylonjs/Meshes/mesh";
  73773. import { Scene } from "babylonjs/scene";
  73774. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73775. /**
  73776. * A helper for physics simulations
  73777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73778. */
  73779. export class PhysicsHelper {
  73780. private _scene;
  73781. private _physicsEngine;
  73782. /**
  73783. * Initializes the Physics helper
  73784. * @param scene Babylon.js scene
  73785. */
  73786. constructor(scene: Scene);
  73787. /**
  73788. * Applies a radial explosion impulse
  73789. * @param origin the origin of the explosion
  73790. * @param radiusOrEventOptions the radius or the options of radial explosion
  73791. * @param strength the explosion strength
  73792. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73793. * @returns A physics radial explosion event, or null
  73794. */
  73795. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73796. /**
  73797. * Applies a radial explosion force
  73798. * @param origin the origin of the explosion
  73799. * @param radiusOrEventOptions the radius or the options of radial explosion
  73800. * @param strength the explosion strength
  73801. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73802. * @returns A physics radial explosion event, or null
  73803. */
  73804. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73805. /**
  73806. * Creates a gravitational field
  73807. * @param origin the origin of the explosion
  73808. * @param radiusOrEventOptions the radius or the options of radial explosion
  73809. * @param strength the explosion strength
  73810. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73811. * @returns A physics gravitational field event, or null
  73812. */
  73813. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73814. /**
  73815. * Creates a physics updraft event
  73816. * @param origin the origin of the updraft
  73817. * @param radiusOrEventOptions the radius or the options of the updraft
  73818. * @param strength the strength of the updraft
  73819. * @param height the height of the updraft
  73820. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73821. * @returns A physics updraft event, or null
  73822. */
  73823. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73824. /**
  73825. * Creates a physics vortex event
  73826. * @param origin the of the vortex
  73827. * @param radiusOrEventOptions the radius or the options of the vortex
  73828. * @param strength the strength of the vortex
  73829. * @param height the height of the vortex
  73830. * @returns a Physics vortex event, or null
  73831. * A physics vortex event or null
  73832. */
  73833. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73834. }
  73835. /**
  73836. * Represents a physics radial explosion event
  73837. */
  73838. class PhysicsRadialExplosionEvent {
  73839. private _scene;
  73840. private _options;
  73841. private _sphere;
  73842. private _dataFetched;
  73843. /**
  73844. * Initializes a radial explosioin event
  73845. * @param _scene BabylonJS scene
  73846. * @param _options The options for the vortex event
  73847. */
  73848. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73849. /**
  73850. * Returns the data related to the radial explosion event (sphere).
  73851. * @returns The radial explosion event data
  73852. */
  73853. getData(): PhysicsRadialExplosionEventData;
  73854. /**
  73855. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73856. * @param impostor A physics imposter
  73857. * @param origin the origin of the explosion
  73858. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73859. */
  73860. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73861. /**
  73862. * Triggers affecterd impostors callbacks
  73863. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73864. */
  73865. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73866. /**
  73867. * Disposes the sphere.
  73868. * @param force Specifies if the sphere should be disposed by force
  73869. */
  73870. dispose(force?: boolean): void;
  73871. /*** Helpers ***/
  73872. private _prepareSphere;
  73873. private _intersectsWithSphere;
  73874. }
  73875. /**
  73876. * Represents a gravitational field event
  73877. */
  73878. class PhysicsGravitationalFieldEvent {
  73879. private _physicsHelper;
  73880. private _scene;
  73881. private _origin;
  73882. private _options;
  73883. private _tickCallback;
  73884. private _sphere;
  73885. private _dataFetched;
  73886. /**
  73887. * Initializes the physics gravitational field event
  73888. * @param _physicsHelper A physics helper
  73889. * @param _scene BabylonJS scene
  73890. * @param _origin The origin position of the gravitational field event
  73891. * @param _options The options for the vortex event
  73892. */
  73893. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73894. /**
  73895. * Returns the data related to the gravitational field event (sphere).
  73896. * @returns A gravitational field event
  73897. */
  73898. getData(): PhysicsGravitationalFieldEventData;
  73899. /**
  73900. * Enables the gravitational field.
  73901. */
  73902. enable(): void;
  73903. /**
  73904. * Disables the gravitational field.
  73905. */
  73906. disable(): void;
  73907. /**
  73908. * Disposes the sphere.
  73909. * @param force The force to dispose from the gravitational field event
  73910. */
  73911. dispose(force?: boolean): void;
  73912. private _tick;
  73913. }
  73914. /**
  73915. * Represents a physics updraft event
  73916. */
  73917. class PhysicsUpdraftEvent {
  73918. private _scene;
  73919. private _origin;
  73920. private _options;
  73921. private _physicsEngine;
  73922. private _originTop;
  73923. private _originDirection;
  73924. private _tickCallback;
  73925. private _cylinder;
  73926. private _cylinderPosition;
  73927. private _dataFetched;
  73928. /**
  73929. * Initializes the physics updraft event
  73930. * @param _scene BabylonJS scene
  73931. * @param _origin The origin position of the updraft
  73932. * @param _options The options for the updraft event
  73933. */
  73934. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73935. /**
  73936. * Returns the data related to the updraft event (cylinder).
  73937. * @returns A physics updraft event
  73938. */
  73939. getData(): PhysicsUpdraftEventData;
  73940. /**
  73941. * Enables the updraft.
  73942. */
  73943. enable(): void;
  73944. /**
  73945. * Disables the updraft.
  73946. */
  73947. disable(): void;
  73948. /**
  73949. * Disposes the cylinder.
  73950. * @param force Specifies if the updraft should be disposed by force
  73951. */
  73952. dispose(force?: boolean): void;
  73953. private getImpostorHitData;
  73954. private _tick;
  73955. /*** Helpers ***/
  73956. private _prepareCylinder;
  73957. private _intersectsWithCylinder;
  73958. }
  73959. /**
  73960. * Represents a physics vortex event
  73961. */
  73962. class PhysicsVortexEvent {
  73963. private _scene;
  73964. private _origin;
  73965. private _options;
  73966. private _physicsEngine;
  73967. private _originTop;
  73968. private _tickCallback;
  73969. private _cylinder;
  73970. private _cylinderPosition;
  73971. private _dataFetched;
  73972. /**
  73973. * Initializes the physics vortex event
  73974. * @param _scene The BabylonJS scene
  73975. * @param _origin The origin position of the vortex
  73976. * @param _options The options for the vortex event
  73977. */
  73978. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73979. /**
  73980. * Returns the data related to the vortex event (cylinder).
  73981. * @returns The physics vortex event data
  73982. */
  73983. getData(): PhysicsVortexEventData;
  73984. /**
  73985. * Enables the vortex.
  73986. */
  73987. enable(): void;
  73988. /**
  73989. * Disables the cortex.
  73990. */
  73991. disable(): void;
  73992. /**
  73993. * Disposes the sphere.
  73994. * @param force
  73995. */
  73996. dispose(force?: boolean): void;
  73997. private getImpostorHitData;
  73998. private _tick;
  73999. /*** Helpers ***/
  74000. private _prepareCylinder;
  74001. private _intersectsWithCylinder;
  74002. }
  74003. /**
  74004. * Options fot the radial explosion event
  74005. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74006. */
  74007. export class PhysicsRadialExplosionEventOptions {
  74008. /**
  74009. * The radius of the sphere for the radial explosion.
  74010. */
  74011. radius: number;
  74012. /**
  74013. * The strenth of the explosion.
  74014. */
  74015. strength: number;
  74016. /**
  74017. * The strenght of the force in correspondence to the distance of the affected object
  74018. */
  74019. falloff: PhysicsRadialImpulseFalloff;
  74020. /**
  74021. * Sphere options for the radial explosion.
  74022. */
  74023. sphere: {
  74024. segments: number;
  74025. diameter: number;
  74026. };
  74027. /**
  74028. * Sphere options for the radial explosion.
  74029. */
  74030. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  74031. }
  74032. /**
  74033. * Options fot the updraft event
  74034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74035. */
  74036. export class PhysicsUpdraftEventOptions {
  74037. /**
  74038. * The radius of the cylinder for the vortex
  74039. */
  74040. radius: number;
  74041. /**
  74042. * The strenth of the updraft.
  74043. */
  74044. strength: number;
  74045. /**
  74046. * The height of the cylinder for the updraft.
  74047. */
  74048. height: number;
  74049. /**
  74050. * The mode for the the updraft.
  74051. */
  74052. updraftMode: PhysicsUpdraftMode;
  74053. }
  74054. /**
  74055. * Options fot the vortex event
  74056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74057. */
  74058. export class PhysicsVortexEventOptions {
  74059. /**
  74060. * The radius of the cylinder for the vortex
  74061. */
  74062. radius: number;
  74063. /**
  74064. * The strenth of the vortex.
  74065. */
  74066. strength: number;
  74067. /**
  74068. * The height of the cylinder for the vortex.
  74069. */
  74070. height: number;
  74071. /**
  74072. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  74073. */
  74074. centripetalForceThreshold: number;
  74075. /**
  74076. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  74077. */
  74078. centripetalForceMultiplier: number;
  74079. /**
  74080. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  74081. */
  74082. centrifugalForceMultiplier: number;
  74083. /**
  74084. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  74085. */
  74086. updraftForceMultiplier: number;
  74087. }
  74088. /**
  74089. * The strenght of the force in correspondence to the distance of the affected object
  74090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74091. */
  74092. export enum PhysicsRadialImpulseFalloff {
  74093. /** Defines that impulse is constant in strength across it's whole radius */
  74094. Constant = 0,
  74095. /** Defines that impulse gets weaker if it's further from the origin */
  74096. Linear = 1
  74097. }
  74098. /**
  74099. * The strength of the force in correspondence to the distance of the affected object
  74100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74101. */
  74102. export enum PhysicsUpdraftMode {
  74103. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  74104. Center = 0,
  74105. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  74106. Perpendicular = 1
  74107. }
  74108. /**
  74109. * Interface for a physics hit data
  74110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74111. */
  74112. export interface PhysicsHitData {
  74113. /**
  74114. * The force applied at the contact point
  74115. */
  74116. force: Vector3;
  74117. /**
  74118. * The contact point
  74119. */
  74120. contactPoint: Vector3;
  74121. /**
  74122. * The distance from the origin to the contact point
  74123. */
  74124. distanceFromOrigin: number;
  74125. }
  74126. /**
  74127. * Interface for radial explosion event data
  74128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74129. */
  74130. export interface PhysicsRadialExplosionEventData {
  74131. /**
  74132. * A sphere used for the radial explosion event
  74133. */
  74134. sphere: Mesh;
  74135. }
  74136. /**
  74137. * Interface for gravitational field event data
  74138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74139. */
  74140. export interface PhysicsGravitationalFieldEventData {
  74141. /**
  74142. * A sphere mesh used for the gravitational field event
  74143. */
  74144. sphere: Mesh;
  74145. }
  74146. /**
  74147. * Interface for updraft event data
  74148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74149. */
  74150. export interface PhysicsUpdraftEventData {
  74151. /**
  74152. * A cylinder used for the updraft event
  74153. */
  74154. cylinder: Mesh;
  74155. }
  74156. /**
  74157. * Interface for vortex event data
  74158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74159. */
  74160. export interface PhysicsVortexEventData {
  74161. /**
  74162. * A cylinder used for the vortex event
  74163. */
  74164. cylinder: Mesh;
  74165. }
  74166. /**
  74167. * Interface for an affected physics impostor
  74168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74169. */
  74170. export interface PhysicsAffectedImpostorWithData {
  74171. /**
  74172. * The impostor affected by the effect
  74173. */
  74174. impostor: PhysicsImpostor;
  74175. /**
  74176. * The data about the hit/horce from the explosion
  74177. */
  74178. hitData: PhysicsHitData;
  74179. }
  74180. }
  74181. declare module "babylonjs/Physics/Plugins/index" {
  74182. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  74183. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  74184. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  74185. }
  74186. declare module "babylonjs/Physics/index" {
  74187. export * from "babylonjs/Physics/IPhysicsEngine";
  74188. export * from "babylonjs/Physics/physicsEngine";
  74189. export * from "babylonjs/Physics/physicsEngineComponent";
  74190. export * from "babylonjs/Physics/physicsHelper";
  74191. export * from "babylonjs/Physics/physicsImpostor";
  74192. export * from "babylonjs/Physics/physicsJoint";
  74193. export * from "babylonjs/Physics/Plugins/index";
  74194. }
  74195. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  74196. /** @hidden */
  74197. export var blackAndWhitePixelShader: {
  74198. name: string;
  74199. shader: string;
  74200. };
  74201. }
  74202. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  74203. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74204. import { Camera } from "babylonjs/Cameras/camera";
  74205. import { Engine } from "babylonjs/Engines/engine";
  74206. import "babylonjs/Shaders/blackAndWhite.fragment";
  74207. import { Nullable } from "babylonjs/types";
  74208. import { Scene } from "babylonjs/scene";
  74209. /**
  74210. * Post process used to render in black and white
  74211. */
  74212. export class BlackAndWhitePostProcess extends PostProcess {
  74213. /**
  74214. * Linear about to convert he result to black and white (default: 1)
  74215. */
  74216. degree: number;
  74217. /**
  74218. * Gets a string identifying the name of the class
  74219. * @returns "BlackAndWhitePostProcess" string
  74220. */
  74221. getClassName(): string;
  74222. /**
  74223. * Creates a black and white post process
  74224. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  74225. * @param name The name of the effect.
  74226. * @param options The required width/height ratio to downsize to before computing the render pass.
  74227. * @param camera The camera to apply the render pass to.
  74228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74229. * @param engine The engine which the post process will be applied. (default: current engine)
  74230. * @param reusable If the post process can be reused on the same frame. (default: false)
  74231. */
  74232. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74233. /** @hidden */
  74234. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  74235. }
  74236. }
  74237. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  74238. import { Nullable } from "babylonjs/types";
  74239. import { Camera } from "babylonjs/Cameras/camera";
  74240. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74241. import { Engine } from "babylonjs/Engines/engine";
  74242. /**
  74243. * This represents a set of one or more post processes in Babylon.
  74244. * A post process can be used to apply a shader to a texture after it is rendered.
  74245. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74246. */
  74247. export class PostProcessRenderEffect {
  74248. private _postProcesses;
  74249. private _getPostProcesses;
  74250. private _singleInstance;
  74251. private _cameras;
  74252. private _indicesForCamera;
  74253. /**
  74254. * Name of the effect
  74255. * @hidden
  74256. */
  74257. _name: string;
  74258. /**
  74259. * Instantiates a post process render effect.
  74260. * A post process can be used to apply a shader to a texture after it is rendered.
  74261. * @param engine The engine the effect is tied to
  74262. * @param name The name of the effect
  74263. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  74264. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  74265. */
  74266. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  74267. /**
  74268. * Checks if all the post processes in the effect are supported.
  74269. */
  74270. get isSupported(): boolean;
  74271. /**
  74272. * Updates the current state of the effect
  74273. * @hidden
  74274. */
  74275. _update(): void;
  74276. /**
  74277. * Attaches the effect on cameras
  74278. * @param cameras The camera to attach to.
  74279. * @hidden
  74280. */
  74281. _attachCameras(cameras: Camera): void;
  74282. /**
  74283. * Attaches the effect on cameras
  74284. * @param cameras The camera to attach to.
  74285. * @hidden
  74286. */
  74287. _attachCameras(cameras: Camera[]): void;
  74288. /**
  74289. * Detaches the effect on cameras
  74290. * @param cameras The camera to detatch from.
  74291. * @hidden
  74292. */
  74293. _detachCameras(cameras: Camera): void;
  74294. /**
  74295. * Detatches the effect on cameras
  74296. * @param cameras The camera to detatch from.
  74297. * @hidden
  74298. */
  74299. _detachCameras(cameras: Camera[]): void;
  74300. /**
  74301. * Enables the effect on given cameras
  74302. * @param cameras The camera to enable.
  74303. * @hidden
  74304. */
  74305. _enable(cameras: Camera): void;
  74306. /**
  74307. * Enables the effect on given cameras
  74308. * @param cameras The camera to enable.
  74309. * @hidden
  74310. */
  74311. _enable(cameras: Nullable<Camera[]>): void;
  74312. /**
  74313. * Disables the effect on the given cameras
  74314. * @param cameras The camera to disable.
  74315. * @hidden
  74316. */
  74317. _disable(cameras: Camera): void;
  74318. /**
  74319. * Disables the effect on the given cameras
  74320. * @param cameras The camera to disable.
  74321. * @hidden
  74322. */
  74323. _disable(cameras: Nullable<Camera[]>): void;
  74324. /**
  74325. * Gets a list of the post processes contained in the effect.
  74326. * @param camera The camera to get the post processes on.
  74327. * @returns The list of the post processes in the effect.
  74328. */
  74329. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74330. }
  74331. }
  74332. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  74333. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74334. /** @hidden */
  74335. export var extractHighlightsPixelShader: {
  74336. name: string;
  74337. shader: string;
  74338. };
  74339. }
  74340. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  74341. import { Nullable } from "babylonjs/types";
  74342. import { Camera } from "babylonjs/Cameras/camera";
  74343. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74344. import { Engine } from "babylonjs/Engines/engine";
  74345. import "babylonjs/Shaders/extractHighlights.fragment";
  74346. /**
  74347. * 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.
  74348. */
  74349. export class ExtractHighlightsPostProcess extends PostProcess {
  74350. /**
  74351. * The luminance threshold, pixels below this value will be set to black.
  74352. */
  74353. threshold: number;
  74354. /** @hidden */
  74355. _exposure: number;
  74356. /**
  74357. * Post process which has the input texture to be used when performing highlight extraction
  74358. * @hidden
  74359. */
  74360. _inputPostProcess: Nullable<PostProcess>;
  74361. /**
  74362. * Gets a string identifying the name of the class
  74363. * @returns "ExtractHighlightsPostProcess" string
  74364. */
  74365. getClassName(): string;
  74366. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74367. }
  74368. }
  74369. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  74370. /** @hidden */
  74371. export var bloomMergePixelShader: {
  74372. name: string;
  74373. shader: string;
  74374. };
  74375. }
  74376. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  74377. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74378. import { Nullable } from "babylonjs/types";
  74379. import { Engine } from "babylonjs/Engines/engine";
  74380. import { Camera } from "babylonjs/Cameras/camera";
  74381. import "babylonjs/Shaders/bloomMerge.fragment";
  74382. /**
  74383. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74384. */
  74385. export class BloomMergePostProcess extends PostProcess {
  74386. /** Weight of the bloom to be added to the original input. */
  74387. weight: number;
  74388. /**
  74389. * Gets a string identifying the name of the class
  74390. * @returns "BloomMergePostProcess" string
  74391. */
  74392. getClassName(): string;
  74393. /**
  74394. * Creates a new instance of @see BloomMergePostProcess
  74395. * @param name The name of the effect.
  74396. * @param originalFromInput Post process which's input will be used for the merge.
  74397. * @param blurred Blurred highlights post process which's output will be used.
  74398. * @param weight Weight of the bloom to be added to the original input.
  74399. * @param options The required width/height ratio to downsize to before computing the render pass.
  74400. * @param camera The camera to apply the render pass to.
  74401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74402. * @param engine The engine which the post process will be applied. (default: current engine)
  74403. * @param reusable If the post process can be reused on the same frame. (default: false)
  74404. * @param textureType Type of textures used when performing the post process. (default: 0)
  74405. * @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)
  74406. */
  74407. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74408. /** Weight of the bloom to be added to the original input. */
  74409. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74410. }
  74411. }
  74412. declare module "babylonjs/PostProcesses/bloomEffect" {
  74413. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74414. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74415. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74416. import { Camera } from "babylonjs/Cameras/camera";
  74417. import { Scene } from "babylonjs/scene";
  74418. /**
  74419. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74420. */
  74421. export class BloomEffect extends PostProcessRenderEffect {
  74422. private bloomScale;
  74423. /**
  74424. * @hidden Internal
  74425. */
  74426. _effects: Array<PostProcess>;
  74427. /**
  74428. * @hidden Internal
  74429. */
  74430. _downscale: ExtractHighlightsPostProcess;
  74431. private _blurX;
  74432. private _blurY;
  74433. private _merge;
  74434. /**
  74435. * The luminance threshold to find bright areas of the image to bloom.
  74436. */
  74437. get threshold(): number;
  74438. set threshold(value: number);
  74439. /**
  74440. * The strength of the bloom.
  74441. */
  74442. get weight(): number;
  74443. set weight(value: number);
  74444. /**
  74445. * Specifies the size of the bloom blur kernel, relative to the final output size
  74446. */
  74447. get kernel(): number;
  74448. set kernel(value: number);
  74449. /**
  74450. * Creates a new instance of @see BloomEffect
  74451. * @param scene The scene the effect belongs to.
  74452. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74453. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74454. * @param bloomWeight The the strength of bloom.
  74455. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74456. * @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)
  74457. */
  74458. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74459. /**
  74460. * Disposes each of the internal effects for a given camera.
  74461. * @param camera The camera to dispose the effect on.
  74462. */
  74463. disposeEffects(camera: Camera): void;
  74464. /**
  74465. * @hidden Internal
  74466. */
  74467. _updateEffects(): void;
  74468. /**
  74469. * Internal
  74470. * @returns if all the contained post processes are ready.
  74471. * @hidden
  74472. */
  74473. _isReady(): boolean;
  74474. }
  74475. }
  74476. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  74477. /** @hidden */
  74478. export var chromaticAberrationPixelShader: {
  74479. name: string;
  74480. shader: string;
  74481. };
  74482. }
  74483. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  74484. import { Vector2 } from "babylonjs/Maths/math.vector";
  74485. import { Nullable } from "babylonjs/types";
  74486. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74487. import { Camera } from "babylonjs/Cameras/camera";
  74488. import { Engine } from "babylonjs/Engines/engine";
  74489. import "babylonjs/Shaders/chromaticAberration.fragment";
  74490. import { Scene } from "babylonjs/scene";
  74491. /**
  74492. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74493. */
  74494. export class ChromaticAberrationPostProcess extends PostProcess {
  74495. /**
  74496. * The amount of seperation of rgb channels (default: 30)
  74497. */
  74498. aberrationAmount: number;
  74499. /**
  74500. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74501. */
  74502. radialIntensity: number;
  74503. /**
  74504. * 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))
  74505. */
  74506. direction: Vector2;
  74507. /**
  74508. * 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))
  74509. */
  74510. centerPosition: Vector2;
  74511. /** The width of the screen to apply the effect on */
  74512. screenWidth: number;
  74513. /** The height of the screen to apply the effect on */
  74514. screenHeight: number;
  74515. /**
  74516. * Gets a string identifying the name of the class
  74517. * @returns "ChromaticAberrationPostProcess" string
  74518. */
  74519. getClassName(): string;
  74520. /**
  74521. * Creates a new instance ChromaticAberrationPostProcess
  74522. * @param name The name of the effect.
  74523. * @param screenWidth The width of the screen to apply the effect on.
  74524. * @param screenHeight The height of the screen to apply the effect on.
  74525. * @param options The required width/height ratio to downsize to before computing the render pass.
  74526. * @param camera The camera to apply the render pass to.
  74527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74528. * @param engine The engine which the post process will be applied. (default: current engine)
  74529. * @param reusable If the post process can be reused on the same frame. (default: false)
  74530. * @param textureType Type of textures used when performing the post process. (default: 0)
  74531. * @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)
  74532. */
  74533. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74534. /** @hidden */
  74535. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74536. }
  74537. }
  74538. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  74539. /** @hidden */
  74540. export var circleOfConfusionPixelShader: {
  74541. name: string;
  74542. shader: string;
  74543. };
  74544. }
  74545. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  74546. import { Nullable } from "babylonjs/types";
  74547. import { Engine } from "babylonjs/Engines/engine";
  74548. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74549. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74550. import { Camera } from "babylonjs/Cameras/camera";
  74551. import "babylonjs/Shaders/circleOfConfusion.fragment";
  74552. /**
  74553. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74554. */
  74555. export class CircleOfConfusionPostProcess extends PostProcess {
  74556. /**
  74557. * 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.
  74558. */
  74559. lensSize: number;
  74560. /**
  74561. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74562. */
  74563. fStop: number;
  74564. /**
  74565. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74566. */
  74567. focusDistance: number;
  74568. /**
  74569. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74570. */
  74571. focalLength: number;
  74572. /**
  74573. * Gets a string identifying the name of the class
  74574. * @returns "CircleOfConfusionPostProcess" string
  74575. */
  74576. getClassName(): string;
  74577. private _depthTexture;
  74578. /**
  74579. * Creates a new instance CircleOfConfusionPostProcess
  74580. * @param name The name of the effect.
  74581. * @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.
  74582. * @param options The required width/height ratio to downsize to before computing the render pass.
  74583. * @param camera The camera to apply the render pass to.
  74584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74585. * @param engine The engine which the post process will be applied. (default: current engine)
  74586. * @param reusable If the post process can be reused on the same frame. (default: false)
  74587. * @param textureType Type of textures used when performing the post process. (default: 0)
  74588. * @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)
  74589. */
  74590. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74591. /**
  74592. * 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.
  74593. */
  74594. set depthTexture(value: RenderTargetTexture);
  74595. }
  74596. }
  74597. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  74598. /** @hidden */
  74599. export var colorCorrectionPixelShader: {
  74600. name: string;
  74601. shader: string;
  74602. };
  74603. }
  74604. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  74605. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74606. import { Engine } from "babylonjs/Engines/engine";
  74607. import { Camera } from "babylonjs/Cameras/camera";
  74608. import "babylonjs/Shaders/colorCorrection.fragment";
  74609. import { Nullable } from "babylonjs/types";
  74610. import { Scene } from "babylonjs/scene";
  74611. /**
  74612. *
  74613. * This post-process allows the modification of rendered colors by using
  74614. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74615. *
  74616. * The object needs to be provided an url to a texture containing the color
  74617. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74618. * Use an image editing software to tweak the LUT to match your needs.
  74619. *
  74620. * For an example of a color LUT, see here:
  74621. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74622. * For explanations on color grading, see here:
  74623. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74624. *
  74625. */
  74626. export class ColorCorrectionPostProcess extends PostProcess {
  74627. private _colorTableTexture;
  74628. /**
  74629. * Gets the color table url used to create the LUT texture
  74630. */
  74631. colorTableUrl: string;
  74632. /**
  74633. * Gets a string identifying the name of the class
  74634. * @returns "ColorCorrectionPostProcess" string
  74635. */
  74636. getClassName(): string;
  74637. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74638. /** @hidden */
  74639. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74640. }
  74641. }
  74642. declare module "babylonjs/Shaders/convolution.fragment" {
  74643. /** @hidden */
  74644. export var convolutionPixelShader: {
  74645. name: string;
  74646. shader: string;
  74647. };
  74648. }
  74649. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  74650. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74651. import { Nullable } from "babylonjs/types";
  74652. import { Camera } from "babylonjs/Cameras/camera";
  74653. import { Engine } from "babylonjs/Engines/engine";
  74654. import "babylonjs/Shaders/convolution.fragment";
  74655. import { Scene } from "babylonjs/scene";
  74656. /**
  74657. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74658. * input texture to perform effects such as edge detection or sharpening
  74659. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74660. */
  74661. export class ConvolutionPostProcess extends PostProcess {
  74662. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74663. kernel: number[];
  74664. /**
  74665. * Gets a string identifying the name of the class
  74666. * @returns "ConvolutionPostProcess" string
  74667. */
  74668. getClassName(): string;
  74669. /**
  74670. * Creates a new instance ConvolutionPostProcess
  74671. * @param name The name of the effect.
  74672. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74673. * @param options The required width/height ratio to downsize to before computing the render pass.
  74674. * @param camera The camera to apply the render pass to.
  74675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74676. * @param engine The engine which the post process will be applied. (default: current engine)
  74677. * @param reusable If the post process can be reused on the same frame. (default: false)
  74678. * @param textureType Type of textures used when performing the post process. (default: 0)
  74679. */
  74680. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74681. /** @hidden */
  74682. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74683. /**
  74684. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74685. */
  74686. static EdgeDetect0Kernel: number[];
  74687. /**
  74688. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74689. */
  74690. static EdgeDetect1Kernel: number[];
  74691. /**
  74692. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74693. */
  74694. static EdgeDetect2Kernel: number[];
  74695. /**
  74696. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74697. */
  74698. static SharpenKernel: number[];
  74699. /**
  74700. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74701. */
  74702. static EmbossKernel: number[];
  74703. /**
  74704. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74705. */
  74706. static GaussianKernel: number[];
  74707. }
  74708. }
  74709. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  74710. import { Nullable } from "babylonjs/types";
  74711. import { Vector2 } from "babylonjs/Maths/math.vector";
  74712. import { Camera } from "babylonjs/Cameras/camera";
  74713. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74714. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74715. import { Engine } from "babylonjs/Engines/engine";
  74716. import { Scene } from "babylonjs/scene";
  74717. /**
  74718. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74719. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74720. * based on samples that have a large difference in distance than the center pixel.
  74721. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74722. */
  74723. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74724. /**
  74725. * The direction the blur should be applied
  74726. */
  74727. direction: Vector2;
  74728. /**
  74729. * Gets a string identifying the name of the class
  74730. * @returns "DepthOfFieldBlurPostProcess" string
  74731. */
  74732. getClassName(): string;
  74733. /**
  74734. * Creates a new instance CircleOfConfusionPostProcess
  74735. * @param name The name of the effect.
  74736. * @param scene The scene the effect belongs to.
  74737. * @param direction The direction the blur should be applied.
  74738. * @param kernel The size of the kernel used to blur.
  74739. * @param options The required width/height ratio to downsize to before computing the render pass.
  74740. * @param camera The camera to apply the render pass to.
  74741. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74742. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74744. * @param engine The engine which the post process will be applied. (default: current engine)
  74745. * @param reusable If the post process can be reused on the same frame. (default: false)
  74746. * @param textureType Type of textures used when performing the post process. (default: 0)
  74747. * @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)
  74748. */
  74749. 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);
  74750. }
  74751. }
  74752. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  74753. /** @hidden */
  74754. export var depthOfFieldMergePixelShader: {
  74755. name: string;
  74756. shader: string;
  74757. };
  74758. }
  74759. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  74760. import { Nullable } from "babylonjs/types";
  74761. import { Camera } from "babylonjs/Cameras/camera";
  74762. import { Effect } from "babylonjs/Materials/effect";
  74763. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74764. import { Engine } from "babylonjs/Engines/engine";
  74765. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  74766. /**
  74767. * Options to be set when merging outputs from the default pipeline.
  74768. */
  74769. export class DepthOfFieldMergePostProcessOptions {
  74770. /**
  74771. * The original image to merge on top of
  74772. */
  74773. originalFromInput: PostProcess;
  74774. /**
  74775. * Parameters to perform the merge of the depth of field effect
  74776. */
  74777. depthOfField?: {
  74778. circleOfConfusion: PostProcess;
  74779. blurSteps: Array<PostProcess>;
  74780. };
  74781. /**
  74782. * Parameters to perform the merge of bloom effect
  74783. */
  74784. bloom?: {
  74785. blurred: PostProcess;
  74786. weight: number;
  74787. };
  74788. }
  74789. /**
  74790. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74791. */
  74792. export class DepthOfFieldMergePostProcess extends PostProcess {
  74793. private blurSteps;
  74794. /**
  74795. * Gets a string identifying the name of the class
  74796. * @returns "DepthOfFieldMergePostProcess" string
  74797. */
  74798. getClassName(): string;
  74799. /**
  74800. * Creates a new instance of DepthOfFieldMergePostProcess
  74801. * @param name The name of the effect.
  74802. * @param originalFromInput Post process which's input will be used for the merge.
  74803. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74804. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74805. * @param options The required width/height ratio to downsize to before computing the render pass.
  74806. * @param camera The camera to apply the render pass to.
  74807. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74808. * @param engine The engine which the post process will be applied. (default: current engine)
  74809. * @param reusable If the post process can be reused on the same frame. (default: false)
  74810. * @param textureType Type of textures used when performing the post process. (default: 0)
  74811. * @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)
  74812. */
  74813. 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);
  74814. /**
  74815. * Updates the effect with the current post process compile time values and recompiles the shader.
  74816. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74817. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74818. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74819. * @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
  74820. * @param onCompiled Called when the shader has been compiled.
  74821. * @param onError Called if there is an error when compiling a shader.
  74822. */
  74823. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74824. }
  74825. }
  74826. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74827. import { Nullable } from "babylonjs/types";
  74828. import { Camera } from "babylonjs/Cameras/camera";
  74829. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74830. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74831. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74832. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74833. import { Scene } from "babylonjs/scene";
  74834. /**
  74835. * Specifies the level of max blur that should be applied when using the depth of field effect
  74836. */
  74837. export enum DepthOfFieldEffectBlurLevel {
  74838. /**
  74839. * Subtle blur
  74840. */
  74841. Low = 0,
  74842. /**
  74843. * Medium blur
  74844. */
  74845. Medium = 1,
  74846. /**
  74847. * Large blur
  74848. */
  74849. High = 2
  74850. }
  74851. /**
  74852. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74853. */
  74854. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74855. private _circleOfConfusion;
  74856. /**
  74857. * @hidden Internal, blurs from high to low
  74858. */
  74859. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74860. private _depthOfFieldBlurY;
  74861. private _dofMerge;
  74862. /**
  74863. * @hidden Internal post processes in depth of field effect
  74864. */
  74865. _effects: Array<PostProcess>;
  74866. /**
  74867. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74868. */
  74869. set focalLength(value: number);
  74870. get focalLength(): number;
  74871. /**
  74872. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74873. */
  74874. set fStop(value: number);
  74875. get fStop(): number;
  74876. /**
  74877. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74878. */
  74879. set focusDistance(value: number);
  74880. get focusDistance(): number;
  74881. /**
  74882. * 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.
  74883. */
  74884. set lensSize(value: number);
  74885. get lensSize(): number;
  74886. /**
  74887. * Creates a new instance DepthOfFieldEffect
  74888. * @param scene The scene the effect belongs to.
  74889. * @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.
  74890. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74891. * @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)
  74892. */
  74893. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74894. /**
  74895. * Get the current class name of the current effet
  74896. * @returns "DepthOfFieldEffect"
  74897. */
  74898. getClassName(): string;
  74899. /**
  74900. * 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.
  74901. */
  74902. set depthTexture(value: RenderTargetTexture);
  74903. /**
  74904. * Disposes each of the internal effects for a given camera.
  74905. * @param camera The camera to dispose the effect on.
  74906. */
  74907. disposeEffects(camera: Camera): void;
  74908. /**
  74909. * @hidden Internal
  74910. */
  74911. _updateEffects(): void;
  74912. /**
  74913. * Internal
  74914. * @returns if all the contained post processes are ready.
  74915. * @hidden
  74916. */
  74917. _isReady(): boolean;
  74918. }
  74919. }
  74920. declare module "babylonjs/Shaders/displayPass.fragment" {
  74921. /** @hidden */
  74922. export var displayPassPixelShader: {
  74923. name: string;
  74924. shader: string;
  74925. };
  74926. }
  74927. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  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/displayPass.fragment";
  74933. import { Scene } from "babylonjs/scene";
  74934. /**
  74935. * DisplayPassPostProcess which produces an output the same as it's input
  74936. */
  74937. export class DisplayPassPostProcess extends PostProcess {
  74938. /**
  74939. * Gets a string identifying the name of the class
  74940. * @returns "DisplayPassPostProcess" string
  74941. */
  74942. getClassName(): string;
  74943. /**
  74944. * Creates the DisplayPassPostProcess
  74945. * @param name The name of the effect.
  74946. * @param options The required width/height ratio to downsize to before computing the render pass.
  74947. * @param camera The camera to apply the render pass to.
  74948. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74949. * @param engine The engine which the post process will be applied. (default: current engine)
  74950. * @param reusable If the post process can be reused on the same frame. (default: false)
  74951. */
  74952. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74953. /** @hidden */
  74954. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74955. }
  74956. }
  74957. declare module "babylonjs/Shaders/filter.fragment" {
  74958. /** @hidden */
  74959. export var filterPixelShader: {
  74960. name: string;
  74961. shader: string;
  74962. };
  74963. }
  74964. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74965. import { Nullable } from "babylonjs/types";
  74966. import { Matrix } from "babylonjs/Maths/math.vector";
  74967. import { Camera } from "babylonjs/Cameras/camera";
  74968. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74969. import { Engine } from "babylonjs/Engines/engine";
  74970. import "babylonjs/Shaders/filter.fragment";
  74971. import { Scene } from "babylonjs/scene";
  74972. /**
  74973. * Applies a kernel filter to the image
  74974. */
  74975. export class FilterPostProcess extends PostProcess {
  74976. /** The matrix to be applied to the image */
  74977. kernelMatrix: Matrix;
  74978. /**
  74979. * Gets a string identifying the name of the class
  74980. * @returns "FilterPostProcess" string
  74981. */
  74982. getClassName(): string;
  74983. /**
  74984. *
  74985. * @param name The name of the effect.
  74986. * @param kernelMatrix The matrix to be applied to the image
  74987. * @param options The required width/height ratio to downsize to before computing the render pass.
  74988. * @param camera The camera to apply the render pass to.
  74989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74990. * @param engine The engine which the post process will be applied. (default: current engine)
  74991. * @param reusable If the post process can be reused on the same frame. (default: false)
  74992. */
  74993. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74994. /** @hidden */
  74995. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74996. }
  74997. }
  74998. declare module "babylonjs/Shaders/fxaa.fragment" {
  74999. /** @hidden */
  75000. export var fxaaPixelShader: {
  75001. name: string;
  75002. shader: string;
  75003. };
  75004. }
  75005. declare module "babylonjs/Shaders/fxaa.vertex" {
  75006. /** @hidden */
  75007. export var fxaaVertexShader: {
  75008. name: string;
  75009. shader: string;
  75010. };
  75011. }
  75012. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  75013. import { Nullable } from "babylonjs/types";
  75014. import { Camera } from "babylonjs/Cameras/camera";
  75015. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75016. import { Engine } from "babylonjs/Engines/engine";
  75017. import "babylonjs/Shaders/fxaa.fragment";
  75018. import "babylonjs/Shaders/fxaa.vertex";
  75019. import { Scene } from "babylonjs/scene";
  75020. /**
  75021. * Fxaa post process
  75022. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  75023. */
  75024. export class FxaaPostProcess extends PostProcess {
  75025. /**
  75026. * Gets a string identifying the name of the class
  75027. * @returns "FxaaPostProcess" string
  75028. */
  75029. getClassName(): string;
  75030. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  75031. private _getDefines;
  75032. /** @hidden */
  75033. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  75034. }
  75035. }
  75036. declare module "babylonjs/Shaders/grain.fragment" {
  75037. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  75038. /** @hidden */
  75039. export var grainPixelShader: {
  75040. name: string;
  75041. shader: string;
  75042. };
  75043. }
  75044. declare module "babylonjs/PostProcesses/grainPostProcess" {
  75045. import { Nullable } from "babylonjs/types";
  75046. import { Camera } from "babylonjs/Cameras/camera";
  75047. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75048. import { Engine } from "babylonjs/Engines/engine";
  75049. import "babylonjs/Shaders/grain.fragment";
  75050. import { Scene } from "babylonjs/scene";
  75051. /**
  75052. * The GrainPostProcess adds noise to the image at mid luminance levels
  75053. */
  75054. export class GrainPostProcess extends PostProcess {
  75055. /**
  75056. * The intensity of the grain added (default: 30)
  75057. */
  75058. intensity: number;
  75059. /**
  75060. * If the grain should be randomized on every frame
  75061. */
  75062. animated: boolean;
  75063. /**
  75064. * Gets a string identifying the name of the class
  75065. * @returns "GrainPostProcess" string
  75066. */
  75067. getClassName(): string;
  75068. /**
  75069. * Creates a new instance of @see GrainPostProcess
  75070. * @param name The name of the effect.
  75071. * @param options The required width/height ratio to downsize to before computing the render pass.
  75072. * @param camera The camera to apply the render pass to.
  75073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75074. * @param engine The engine which the post process will be applied. (default: current engine)
  75075. * @param reusable If the post process can be reused on the same frame. (default: false)
  75076. * @param textureType Type of textures used when performing the post process. (default: 0)
  75077. * @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)
  75078. */
  75079. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75080. /** @hidden */
  75081. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  75082. }
  75083. }
  75084. declare module "babylonjs/Shaders/highlights.fragment" {
  75085. /** @hidden */
  75086. export var highlightsPixelShader: {
  75087. name: string;
  75088. shader: string;
  75089. };
  75090. }
  75091. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  75092. import { Nullable } from "babylonjs/types";
  75093. import { Camera } from "babylonjs/Cameras/camera";
  75094. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75095. import { Engine } from "babylonjs/Engines/engine";
  75096. import "babylonjs/Shaders/highlights.fragment";
  75097. /**
  75098. * Extracts highlights from the image
  75099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75100. */
  75101. export class HighlightsPostProcess extends PostProcess {
  75102. /**
  75103. * Gets a string identifying the name of the class
  75104. * @returns "HighlightsPostProcess" string
  75105. */
  75106. getClassName(): string;
  75107. /**
  75108. * Extracts highlights from the image
  75109. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75110. * @param name The name of the effect.
  75111. * @param options The required width/height ratio to downsize to before computing the render pass.
  75112. * @param camera The camera to apply the render pass to.
  75113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75114. * @param engine The engine which the post process will be applied. (default: current engine)
  75115. * @param reusable If the post process can be reused on the same frame. (default: false)
  75116. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  75117. */
  75118. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  75119. }
  75120. }
  75121. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  75122. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75123. /**
  75124. * Contains all parameters needed for the prepass to perform
  75125. * motion blur
  75126. */
  75127. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  75128. /**
  75129. * Is motion blur enabled
  75130. */
  75131. enabled: boolean;
  75132. /**
  75133. * Name of the configuration
  75134. */
  75135. name: string;
  75136. /**
  75137. * Textures that should be present in the MRT for this effect to work
  75138. */
  75139. readonly texturesRequired: number[];
  75140. }
  75141. }
  75142. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  75143. import { Nullable } from "babylonjs/types";
  75144. import { Scene } from "babylonjs/scene";
  75145. import { ISceneComponent } from "babylonjs/sceneComponent";
  75146. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  75147. module "babylonjs/scene" {
  75148. interface Scene {
  75149. /** @hidden (Backing field) */
  75150. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75151. /**
  75152. * Gets or Sets the current geometry buffer associated to the scene.
  75153. */
  75154. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75155. /**
  75156. * Enables a GeometryBufferRender and associates it with the scene
  75157. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  75158. * @returns the GeometryBufferRenderer
  75159. */
  75160. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  75161. /**
  75162. * Disables the GeometryBufferRender associated with the scene
  75163. */
  75164. disableGeometryBufferRenderer(): void;
  75165. }
  75166. }
  75167. /**
  75168. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75169. * in several rendering techniques.
  75170. */
  75171. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  75172. /**
  75173. * The component name helpful to identify the component in the list of scene components.
  75174. */
  75175. readonly name: string;
  75176. /**
  75177. * The scene the component belongs to.
  75178. */
  75179. scene: Scene;
  75180. /**
  75181. * Creates a new instance of the component for the given scene
  75182. * @param scene Defines the scene to register the component in
  75183. */
  75184. constructor(scene: Scene);
  75185. /**
  75186. * Registers the component in a given scene
  75187. */
  75188. register(): void;
  75189. /**
  75190. * Rebuilds the elements related to this component in case of
  75191. * context lost for instance.
  75192. */
  75193. rebuild(): void;
  75194. /**
  75195. * Disposes the component and the associated ressources
  75196. */
  75197. dispose(): void;
  75198. private _gatherRenderTargets;
  75199. }
  75200. }
  75201. declare module "babylonjs/Shaders/motionBlur.fragment" {
  75202. /** @hidden */
  75203. export var motionBlurPixelShader: {
  75204. name: string;
  75205. shader: string;
  75206. };
  75207. }
  75208. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  75209. import { Nullable } from "babylonjs/types";
  75210. import { Camera } from "babylonjs/Cameras/camera";
  75211. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75213. import "babylonjs/Animations/animatable";
  75214. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75215. import "babylonjs/Shaders/motionBlur.fragment";
  75216. import { Engine } from "babylonjs/Engines/engine";
  75217. import { Scene } from "babylonjs/scene";
  75218. /**
  75219. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  75220. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  75221. * As an example, all you have to do is to create the post-process:
  75222. * var mb = new BABYLON.MotionBlurPostProcess(
  75223. * 'mb', // The name of the effect.
  75224. * scene, // The scene containing the objects to blur according to their velocity.
  75225. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  75226. * camera // The camera to apply the render pass to.
  75227. * );
  75228. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  75229. */
  75230. export class MotionBlurPostProcess extends PostProcess {
  75231. /**
  75232. * Defines how much the image is blurred by the movement. Default value is equal to 1
  75233. */
  75234. motionStrength: number;
  75235. /**
  75236. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  75237. */
  75238. get motionBlurSamples(): number;
  75239. /**
  75240. * Sets the number of iterations to be used for motion blur quality
  75241. */
  75242. set motionBlurSamples(samples: number);
  75243. private _motionBlurSamples;
  75244. /**
  75245. * Gets wether or not the motion blur post-process is in object based mode.
  75246. */
  75247. get isObjectBased(): boolean;
  75248. /**
  75249. * Sets wether or not the motion blur post-process is in object based mode.
  75250. */
  75251. set isObjectBased(value: boolean);
  75252. private _isObjectBased;
  75253. private _forceGeometryBuffer;
  75254. private _geometryBufferRenderer;
  75255. private _prePassRenderer;
  75256. private _invViewProjection;
  75257. private _previousViewProjection;
  75258. /**
  75259. * Gets a string identifying the name of the class
  75260. * @returns "MotionBlurPostProcess" string
  75261. */
  75262. getClassName(): string;
  75263. /**
  75264. * Creates a new instance MotionBlurPostProcess
  75265. * @param name The name of the effect.
  75266. * @param scene The scene containing the objects to blur according to their velocity.
  75267. * @param options The required width/height ratio to downsize to before computing the render pass.
  75268. * @param camera The camera to apply the render pass to.
  75269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75270. * @param engine The engine which the post process will be applied. (default: current engine)
  75271. * @param reusable If the post process can be reused on the same frame. (default: false)
  75272. * @param textureType Type of textures used when performing the post process. (default: 0)
  75273. * @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: true)
  75274. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75275. */
  75276. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75277. /**
  75278. * Excludes the given skinned mesh from computing bones velocities.
  75279. * 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.
  75280. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  75281. */
  75282. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75283. /**
  75284. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  75285. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  75286. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  75287. */
  75288. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75289. /**
  75290. * Disposes the post process.
  75291. * @param camera The camera to dispose the post process on.
  75292. */
  75293. dispose(camera?: Camera): void;
  75294. /**
  75295. * Called on the mode changed (object based or screen based).
  75296. */
  75297. private _applyMode;
  75298. /**
  75299. * Called on the effect is applied when the motion blur post-process is in object based mode.
  75300. */
  75301. private _onApplyObjectBased;
  75302. /**
  75303. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  75304. */
  75305. private _onApplyScreenBased;
  75306. /**
  75307. * Called on the effect must be updated (changed mode, samples count, etc.).
  75308. */
  75309. private _updateEffect;
  75310. /** @hidden */
  75311. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  75312. }
  75313. }
  75314. declare module "babylonjs/Shaders/refraction.fragment" {
  75315. /** @hidden */
  75316. export var refractionPixelShader: {
  75317. name: string;
  75318. shader: string;
  75319. };
  75320. }
  75321. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  75322. import { Color3 } from "babylonjs/Maths/math.color";
  75323. import { Camera } from "babylonjs/Cameras/camera";
  75324. import { Texture } from "babylonjs/Materials/Textures/texture";
  75325. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75326. import { Engine } from "babylonjs/Engines/engine";
  75327. import "babylonjs/Shaders/refraction.fragment";
  75328. import { Scene } from "babylonjs/scene";
  75329. /**
  75330. * Post process which applies a refractin texture
  75331. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75332. */
  75333. export class RefractionPostProcess extends PostProcess {
  75334. private _refTexture;
  75335. private _ownRefractionTexture;
  75336. /** the base color of the refraction (used to taint the rendering) */
  75337. color: Color3;
  75338. /** simulated refraction depth */
  75339. depth: number;
  75340. /** the coefficient of the base color (0 to remove base color tainting) */
  75341. colorLevel: number;
  75342. /** Gets the url used to load the refraction texture */
  75343. refractionTextureUrl: string;
  75344. /**
  75345. * Gets or sets the refraction texture
  75346. * Please note that you are responsible for disposing the texture if you set it manually
  75347. */
  75348. get refractionTexture(): Texture;
  75349. set refractionTexture(value: Texture);
  75350. /**
  75351. * Gets a string identifying the name of the class
  75352. * @returns "RefractionPostProcess" string
  75353. */
  75354. getClassName(): string;
  75355. /**
  75356. * Initializes the RefractionPostProcess
  75357. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75358. * @param name The name of the effect.
  75359. * @param refractionTextureUrl Url of the refraction texture to use
  75360. * @param color the base color of the refraction (used to taint the rendering)
  75361. * @param depth simulated refraction depth
  75362. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  75363. * @param camera The camera to apply the render pass to.
  75364. * @param options The required width/height ratio to downsize to before computing the render pass.
  75365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75366. * @param engine The engine which the post process will be applied. (default: current engine)
  75367. * @param reusable If the post process can be reused on the same frame. (default: false)
  75368. */
  75369. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75370. /**
  75371. * Disposes of the post process
  75372. * @param camera Camera to dispose post process on
  75373. */
  75374. dispose(camera: Camera): void;
  75375. /** @hidden */
  75376. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  75377. }
  75378. }
  75379. declare module "babylonjs/Shaders/sharpen.fragment" {
  75380. /** @hidden */
  75381. export var sharpenPixelShader: {
  75382. name: string;
  75383. shader: string;
  75384. };
  75385. }
  75386. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  75387. import { Nullable } from "babylonjs/types";
  75388. import { Camera } from "babylonjs/Cameras/camera";
  75389. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75390. import "babylonjs/Shaders/sharpen.fragment";
  75391. import { Engine } from "babylonjs/Engines/engine";
  75392. import { Scene } from "babylonjs/scene";
  75393. /**
  75394. * The SharpenPostProcess applies a sharpen kernel to every pixel
  75395. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  75396. */
  75397. export class SharpenPostProcess extends PostProcess {
  75398. /**
  75399. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  75400. */
  75401. colorAmount: number;
  75402. /**
  75403. * How much sharpness should be applied (default: 0.3)
  75404. */
  75405. edgeAmount: number;
  75406. /**
  75407. * Gets a string identifying the name of the class
  75408. * @returns "SharpenPostProcess" string
  75409. */
  75410. getClassName(): string;
  75411. /**
  75412. * Creates a new instance ConvolutionPostProcess
  75413. * @param name The name of the effect.
  75414. * @param options The required width/height ratio to downsize to before computing the render pass.
  75415. * @param camera The camera to apply the render pass to.
  75416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75417. * @param engine The engine which the post process will be applied. (default: current engine)
  75418. * @param reusable If the post process can be reused on the same frame. (default: false)
  75419. * @param textureType Type of textures used when performing the post process. (default: 0)
  75420. * @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)
  75421. */
  75422. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75423. /** @hidden */
  75424. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  75425. }
  75426. }
  75427. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  75428. import { Nullable } from "babylonjs/types";
  75429. import { Camera } from "babylonjs/Cameras/camera";
  75430. import { Engine } from "babylonjs/Engines/engine";
  75431. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75432. import { IInspectable } from "babylonjs/Misc/iInspectable";
  75433. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75434. /**
  75435. * PostProcessRenderPipeline
  75436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75437. */
  75438. export class PostProcessRenderPipeline {
  75439. private engine;
  75440. private _renderEffects;
  75441. private _renderEffectsForIsolatedPass;
  75442. /**
  75443. * List of inspectable custom properties (used by the Inspector)
  75444. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75445. */
  75446. inspectableCustomProperties: IInspectable[];
  75447. /**
  75448. * @hidden
  75449. */
  75450. protected _cameras: Camera[];
  75451. /** @hidden */
  75452. _name: string;
  75453. /**
  75454. * Gets pipeline name
  75455. */
  75456. get name(): string;
  75457. /** Gets the list of attached cameras */
  75458. get cameras(): Camera[];
  75459. /**
  75460. * Initializes a PostProcessRenderPipeline
  75461. * @param engine engine to add the pipeline to
  75462. * @param name name of the pipeline
  75463. */
  75464. constructor(engine: Engine, name: string);
  75465. /**
  75466. * Gets the class name
  75467. * @returns "PostProcessRenderPipeline"
  75468. */
  75469. getClassName(): string;
  75470. /**
  75471. * If all the render effects in the pipeline are supported
  75472. */
  75473. get isSupported(): boolean;
  75474. /**
  75475. * Adds an effect to the pipeline
  75476. * @param renderEffect the effect to add
  75477. */
  75478. addEffect(renderEffect: PostProcessRenderEffect): void;
  75479. /** @hidden */
  75480. _rebuild(): void;
  75481. /** @hidden */
  75482. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75483. /** @hidden */
  75484. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75485. /** @hidden */
  75486. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75487. /** @hidden */
  75488. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75489. /** @hidden */
  75490. _attachCameras(cameras: Camera, unique: boolean): void;
  75491. /** @hidden */
  75492. _attachCameras(cameras: Camera[], unique: boolean): void;
  75493. /** @hidden */
  75494. _detachCameras(cameras: Camera): void;
  75495. /** @hidden */
  75496. _detachCameras(cameras: Nullable<Camera[]>): void;
  75497. /** @hidden */
  75498. _update(): void;
  75499. /** @hidden */
  75500. _reset(): void;
  75501. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75502. /**
  75503. * Sets the required values to the prepass renderer.
  75504. * @param prePassRenderer defines the prepass renderer to setup.
  75505. * @returns true if the pre pass is needed.
  75506. */
  75507. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75508. /**
  75509. * Disposes of the pipeline
  75510. */
  75511. dispose(): void;
  75512. }
  75513. }
  75514. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  75515. import { Camera } from "babylonjs/Cameras/camera";
  75516. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75517. /**
  75518. * PostProcessRenderPipelineManager class
  75519. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75520. */
  75521. export class PostProcessRenderPipelineManager {
  75522. private _renderPipelines;
  75523. /**
  75524. * Initializes a PostProcessRenderPipelineManager
  75525. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75526. */
  75527. constructor();
  75528. /**
  75529. * Gets the list of supported render pipelines
  75530. */
  75531. get supportedPipelines(): PostProcessRenderPipeline[];
  75532. /**
  75533. * Adds a pipeline to the manager
  75534. * @param renderPipeline The pipeline to add
  75535. */
  75536. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75537. /**
  75538. * Attaches a camera to the pipeline
  75539. * @param renderPipelineName The name of the pipeline to attach to
  75540. * @param cameras the camera to attach
  75541. * @param unique if the camera can be attached multiple times to the pipeline
  75542. */
  75543. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75544. /**
  75545. * Detaches a camera from the pipeline
  75546. * @param renderPipelineName The name of the pipeline to detach from
  75547. * @param cameras the camera to detach
  75548. */
  75549. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75550. /**
  75551. * Enables an effect by name on a pipeline
  75552. * @param renderPipelineName the name of the pipeline to enable the effect in
  75553. * @param renderEffectName the name of the effect to enable
  75554. * @param cameras the cameras that the effect should be enabled on
  75555. */
  75556. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75557. /**
  75558. * Disables an effect by name on a pipeline
  75559. * @param renderPipelineName the name of the pipeline to disable the effect in
  75560. * @param renderEffectName the name of the effect to disable
  75561. * @param cameras the cameras that the effect should be disabled on
  75562. */
  75563. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75564. /**
  75565. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75566. */
  75567. update(): void;
  75568. /** @hidden */
  75569. _rebuild(): void;
  75570. /**
  75571. * Disposes of the manager and pipelines
  75572. */
  75573. dispose(): void;
  75574. }
  75575. }
  75576. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  75577. import { ISceneComponent } from "babylonjs/sceneComponent";
  75578. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75579. import { Scene } from "babylonjs/scene";
  75580. module "babylonjs/scene" {
  75581. interface Scene {
  75582. /** @hidden (Backing field) */
  75583. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75584. /**
  75585. * Gets the postprocess render pipeline manager
  75586. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75587. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75588. */
  75589. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75590. }
  75591. }
  75592. /**
  75593. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75594. */
  75595. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75596. /**
  75597. * The component name helpfull to identify the component in the list of scene components.
  75598. */
  75599. readonly name: string;
  75600. /**
  75601. * The scene the component belongs to.
  75602. */
  75603. scene: Scene;
  75604. /**
  75605. * Creates a new instance of the component for the given scene
  75606. * @param scene Defines the scene to register the component in
  75607. */
  75608. constructor(scene: Scene);
  75609. /**
  75610. * Registers the component in a given scene
  75611. */
  75612. register(): void;
  75613. /**
  75614. * Rebuilds the elements related to this component in case of
  75615. * context lost for instance.
  75616. */
  75617. rebuild(): void;
  75618. /**
  75619. * Disposes the component and the associated ressources
  75620. */
  75621. dispose(): void;
  75622. private _gatherRenderTargets;
  75623. }
  75624. }
  75625. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  75626. import { Nullable } from "babylonjs/types";
  75627. import { Observable } from "babylonjs/Misc/observable";
  75628. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75629. import { Camera } from "babylonjs/Cameras/camera";
  75630. import { IDisposable } from "babylonjs/scene";
  75631. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  75632. import { Scene } from "babylonjs/scene";
  75633. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  75634. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75635. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75636. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  75637. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75638. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75639. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  75640. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75641. import { Animation } from "babylonjs/Animations/animation";
  75642. /**
  75643. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75644. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75645. */
  75646. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75647. private _scene;
  75648. private _camerasToBeAttached;
  75649. /**
  75650. * ID of the sharpen post process,
  75651. */
  75652. private readonly SharpenPostProcessId;
  75653. /**
  75654. * @ignore
  75655. * ID of the image processing post process;
  75656. */
  75657. readonly ImageProcessingPostProcessId: string;
  75658. /**
  75659. * @ignore
  75660. * ID of the Fast Approximate Anti-Aliasing post process;
  75661. */
  75662. readonly FxaaPostProcessId: string;
  75663. /**
  75664. * ID of the chromatic aberration post process,
  75665. */
  75666. private readonly ChromaticAberrationPostProcessId;
  75667. /**
  75668. * ID of the grain post process
  75669. */
  75670. private readonly GrainPostProcessId;
  75671. /**
  75672. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75673. */
  75674. sharpen: SharpenPostProcess;
  75675. private _sharpenEffect;
  75676. private bloom;
  75677. /**
  75678. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75679. */
  75680. depthOfField: DepthOfFieldEffect;
  75681. /**
  75682. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75683. */
  75684. fxaa: FxaaPostProcess;
  75685. /**
  75686. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75687. */
  75688. imageProcessing: ImageProcessingPostProcess;
  75689. /**
  75690. * Chromatic aberration post process which will shift rgb colors in the image
  75691. */
  75692. chromaticAberration: ChromaticAberrationPostProcess;
  75693. private _chromaticAberrationEffect;
  75694. /**
  75695. * Grain post process which add noise to the image
  75696. */
  75697. grain: GrainPostProcess;
  75698. private _grainEffect;
  75699. /**
  75700. * Glow post process which adds a glow to emissive areas of the image
  75701. */
  75702. private _glowLayer;
  75703. /**
  75704. * Animations which can be used to tweak settings over a period of time
  75705. */
  75706. animations: Animation[];
  75707. private _imageProcessingConfigurationObserver;
  75708. private _sharpenEnabled;
  75709. private _bloomEnabled;
  75710. private _depthOfFieldEnabled;
  75711. private _depthOfFieldBlurLevel;
  75712. private _fxaaEnabled;
  75713. private _imageProcessingEnabled;
  75714. private _defaultPipelineTextureType;
  75715. private _bloomScale;
  75716. private _chromaticAberrationEnabled;
  75717. private _grainEnabled;
  75718. private _buildAllowed;
  75719. /**
  75720. * This is triggered each time the pipeline has been built.
  75721. */
  75722. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75723. /**
  75724. * Gets active scene
  75725. */
  75726. get scene(): Scene;
  75727. /**
  75728. * Enable or disable the sharpen process from the pipeline
  75729. */
  75730. set sharpenEnabled(enabled: boolean);
  75731. get sharpenEnabled(): boolean;
  75732. private _resizeObserver;
  75733. private _hardwareScaleLevel;
  75734. private _bloomKernel;
  75735. /**
  75736. * Specifies the size of the bloom blur kernel, relative to the final output size
  75737. */
  75738. get bloomKernel(): number;
  75739. set bloomKernel(value: number);
  75740. /**
  75741. * Specifies the weight of the bloom in the final rendering
  75742. */
  75743. private _bloomWeight;
  75744. /**
  75745. * Specifies the luma threshold for the area that will be blurred by the bloom
  75746. */
  75747. private _bloomThreshold;
  75748. private _hdr;
  75749. /**
  75750. * The strength of the bloom.
  75751. */
  75752. set bloomWeight(value: number);
  75753. get bloomWeight(): number;
  75754. /**
  75755. * The strength of the bloom.
  75756. */
  75757. set bloomThreshold(value: number);
  75758. get bloomThreshold(): number;
  75759. /**
  75760. * The scale of the bloom, lower value will provide better performance.
  75761. */
  75762. set bloomScale(value: number);
  75763. get bloomScale(): number;
  75764. /**
  75765. * Enable or disable the bloom from the pipeline
  75766. */
  75767. set bloomEnabled(enabled: boolean);
  75768. get bloomEnabled(): boolean;
  75769. private _rebuildBloom;
  75770. /**
  75771. * If the depth of field is enabled.
  75772. */
  75773. get depthOfFieldEnabled(): boolean;
  75774. set depthOfFieldEnabled(enabled: boolean);
  75775. /**
  75776. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75777. */
  75778. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75779. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75780. /**
  75781. * If the anti aliasing is enabled.
  75782. */
  75783. set fxaaEnabled(enabled: boolean);
  75784. get fxaaEnabled(): boolean;
  75785. private _samples;
  75786. /**
  75787. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75788. */
  75789. set samples(sampleCount: number);
  75790. get samples(): number;
  75791. /**
  75792. * If image processing is enabled.
  75793. */
  75794. set imageProcessingEnabled(enabled: boolean);
  75795. get imageProcessingEnabled(): boolean;
  75796. /**
  75797. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75798. */
  75799. set glowLayerEnabled(enabled: boolean);
  75800. get glowLayerEnabled(): boolean;
  75801. /**
  75802. * Gets the glow layer (or null if not defined)
  75803. */
  75804. get glowLayer(): Nullable<GlowLayer>;
  75805. /**
  75806. * Enable or disable the chromaticAberration process from the pipeline
  75807. */
  75808. set chromaticAberrationEnabled(enabled: boolean);
  75809. get chromaticAberrationEnabled(): boolean;
  75810. /**
  75811. * Enable or disable the grain process from the pipeline
  75812. */
  75813. set grainEnabled(enabled: boolean);
  75814. get grainEnabled(): boolean;
  75815. /**
  75816. * @constructor
  75817. * @param name - The rendering pipeline name (default: "")
  75818. * @param hdr - If high dynamic range textures should be used (default: true)
  75819. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75820. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75821. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75822. */
  75823. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75824. /**
  75825. * Get the class name
  75826. * @returns "DefaultRenderingPipeline"
  75827. */
  75828. getClassName(): string;
  75829. /**
  75830. * Force the compilation of the entire pipeline.
  75831. */
  75832. prepare(): void;
  75833. private _hasCleared;
  75834. private _prevPostProcess;
  75835. private _prevPrevPostProcess;
  75836. private _setAutoClearAndTextureSharing;
  75837. private _depthOfFieldSceneObserver;
  75838. private _buildPipeline;
  75839. private _disposePostProcesses;
  75840. /**
  75841. * Adds a camera to the pipeline
  75842. * @param camera the camera to be added
  75843. */
  75844. addCamera(camera: Camera): void;
  75845. /**
  75846. * Removes a camera from the pipeline
  75847. * @param camera the camera to remove
  75848. */
  75849. removeCamera(camera: Camera): void;
  75850. /**
  75851. * Dispose of the pipeline and stop all post processes
  75852. */
  75853. dispose(): void;
  75854. /**
  75855. * Serialize the rendering pipeline (Used when exporting)
  75856. * @returns the serialized object
  75857. */
  75858. serialize(): any;
  75859. /**
  75860. * Parse the serialized pipeline
  75861. * @param source Source pipeline.
  75862. * @param scene The scene to load the pipeline to.
  75863. * @param rootUrl The URL of the serialized pipeline.
  75864. * @returns An instantiated pipeline from the serialized object.
  75865. */
  75866. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75867. }
  75868. }
  75869. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75870. /** @hidden */
  75871. export var lensHighlightsPixelShader: {
  75872. name: string;
  75873. shader: string;
  75874. };
  75875. }
  75876. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75877. /** @hidden */
  75878. export var depthOfFieldPixelShader: {
  75879. name: string;
  75880. shader: string;
  75881. };
  75882. }
  75883. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75884. import { Camera } from "babylonjs/Cameras/camera";
  75885. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75886. import { Scene } from "babylonjs/scene";
  75887. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75888. import "babylonjs/Shaders/chromaticAberration.fragment";
  75889. import "babylonjs/Shaders/lensHighlights.fragment";
  75890. import "babylonjs/Shaders/depthOfField.fragment";
  75891. /**
  75892. * BABYLON.JS Chromatic Aberration GLSL Shader
  75893. * Author: Olivier Guyot
  75894. * Separates very slightly R, G and B colors on the edges of the screen
  75895. * Inspired by Francois Tarlier & Martins Upitis
  75896. */
  75897. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75898. /**
  75899. * @ignore
  75900. * The chromatic aberration PostProcess id in the pipeline
  75901. */
  75902. LensChromaticAberrationEffect: string;
  75903. /**
  75904. * @ignore
  75905. * The highlights enhancing PostProcess id in the pipeline
  75906. */
  75907. HighlightsEnhancingEffect: string;
  75908. /**
  75909. * @ignore
  75910. * The depth-of-field PostProcess id in the pipeline
  75911. */
  75912. LensDepthOfFieldEffect: string;
  75913. private _scene;
  75914. private _depthTexture;
  75915. private _grainTexture;
  75916. private _chromaticAberrationPostProcess;
  75917. private _highlightsPostProcess;
  75918. private _depthOfFieldPostProcess;
  75919. private _edgeBlur;
  75920. private _grainAmount;
  75921. private _chromaticAberration;
  75922. private _distortion;
  75923. private _highlightsGain;
  75924. private _highlightsThreshold;
  75925. private _dofDistance;
  75926. private _dofAperture;
  75927. private _dofDarken;
  75928. private _dofPentagon;
  75929. private _blurNoise;
  75930. /**
  75931. * @constructor
  75932. *
  75933. * Effect parameters are as follow:
  75934. * {
  75935. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75936. * edge_blur: number; // from 0 to x (1 for realism)
  75937. * distortion: number; // from 0 to x (1 for realism)
  75938. * grain_amount: number; // from 0 to 1
  75939. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75940. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75941. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75942. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75943. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75944. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75945. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75946. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75947. * }
  75948. * Note: if an effect parameter is unset, effect is disabled
  75949. *
  75950. * @param name The rendering pipeline name
  75951. * @param parameters - An object containing all parameters (see above)
  75952. * @param scene The scene linked to this pipeline
  75953. * @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)
  75954. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75955. */
  75956. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75957. /**
  75958. * Get the class name
  75959. * @returns "LensRenderingPipeline"
  75960. */
  75961. getClassName(): string;
  75962. /**
  75963. * Gets associated scene
  75964. */
  75965. get scene(): Scene;
  75966. /**
  75967. * Gets or sets the edge blur
  75968. */
  75969. get edgeBlur(): number;
  75970. set edgeBlur(value: number);
  75971. /**
  75972. * Gets or sets the grain amount
  75973. */
  75974. get grainAmount(): number;
  75975. set grainAmount(value: number);
  75976. /**
  75977. * Gets or sets the chromatic aberration amount
  75978. */
  75979. get chromaticAberration(): number;
  75980. set chromaticAberration(value: number);
  75981. /**
  75982. * Gets or sets the depth of field aperture
  75983. */
  75984. get dofAperture(): number;
  75985. set dofAperture(value: number);
  75986. /**
  75987. * Gets or sets the edge distortion
  75988. */
  75989. get edgeDistortion(): number;
  75990. set edgeDistortion(value: number);
  75991. /**
  75992. * Gets or sets the depth of field distortion
  75993. */
  75994. get dofDistortion(): number;
  75995. set dofDistortion(value: number);
  75996. /**
  75997. * Gets or sets the darken out of focus amount
  75998. */
  75999. get darkenOutOfFocus(): number;
  76000. set darkenOutOfFocus(value: number);
  76001. /**
  76002. * Gets or sets a boolean indicating if blur noise is enabled
  76003. */
  76004. get blurNoise(): boolean;
  76005. set blurNoise(value: boolean);
  76006. /**
  76007. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  76008. */
  76009. get pentagonBokeh(): boolean;
  76010. set pentagonBokeh(value: boolean);
  76011. /**
  76012. * Gets or sets the highlight grain amount
  76013. */
  76014. get highlightsGain(): number;
  76015. set highlightsGain(value: number);
  76016. /**
  76017. * Gets or sets the highlight threshold
  76018. */
  76019. get highlightsThreshold(): number;
  76020. set highlightsThreshold(value: number);
  76021. /**
  76022. * Sets the amount of blur at the edges
  76023. * @param amount blur amount
  76024. */
  76025. setEdgeBlur(amount: number): void;
  76026. /**
  76027. * Sets edge blur to 0
  76028. */
  76029. disableEdgeBlur(): void;
  76030. /**
  76031. * Sets the amout of grain
  76032. * @param amount Amount of grain
  76033. */
  76034. setGrainAmount(amount: number): void;
  76035. /**
  76036. * Set grain amount to 0
  76037. */
  76038. disableGrain(): void;
  76039. /**
  76040. * Sets the chromatic aberration amount
  76041. * @param amount amount of chromatic aberration
  76042. */
  76043. setChromaticAberration(amount: number): void;
  76044. /**
  76045. * Sets chromatic aberration amount to 0
  76046. */
  76047. disableChromaticAberration(): void;
  76048. /**
  76049. * Sets the EdgeDistortion amount
  76050. * @param amount amount of EdgeDistortion
  76051. */
  76052. setEdgeDistortion(amount: number): void;
  76053. /**
  76054. * Sets edge distortion to 0
  76055. */
  76056. disableEdgeDistortion(): void;
  76057. /**
  76058. * Sets the FocusDistance amount
  76059. * @param amount amount of FocusDistance
  76060. */
  76061. setFocusDistance(amount: number): void;
  76062. /**
  76063. * Disables depth of field
  76064. */
  76065. disableDepthOfField(): void;
  76066. /**
  76067. * Sets the Aperture amount
  76068. * @param amount amount of Aperture
  76069. */
  76070. setAperture(amount: number): void;
  76071. /**
  76072. * Sets the DarkenOutOfFocus amount
  76073. * @param amount amount of DarkenOutOfFocus
  76074. */
  76075. setDarkenOutOfFocus(amount: number): void;
  76076. private _pentagonBokehIsEnabled;
  76077. /**
  76078. * Creates a pentagon bokeh effect
  76079. */
  76080. enablePentagonBokeh(): void;
  76081. /**
  76082. * Disables the pentagon bokeh effect
  76083. */
  76084. disablePentagonBokeh(): void;
  76085. /**
  76086. * Enables noise blur
  76087. */
  76088. enableNoiseBlur(): void;
  76089. /**
  76090. * Disables noise blur
  76091. */
  76092. disableNoiseBlur(): void;
  76093. /**
  76094. * Sets the HighlightsGain amount
  76095. * @param amount amount of HighlightsGain
  76096. */
  76097. setHighlightsGain(amount: number): void;
  76098. /**
  76099. * Sets the HighlightsThreshold amount
  76100. * @param amount amount of HighlightsThreshold
  76101. */
  76102. setHighlightsThreshold(amount: number): void;
  76103. /**
  76104. * Disables highlights
  76105. */
  76106. disableHighlights(): void;
  76107. /**
  76108. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76109. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  76110. */
  76111. dispose(disableDepthRender?: boolean): void;
  76112. private _createChromaticAberrationPostProcess;
  76113. private _createHighlightsPostProcess;
  76114. private _createDepthOfFieldPostProcess;
  76115. private _createGrainTexture;
  76116. }
  76117. }
  76118. declare module "babylonjs/Rendering/ssao2Configuration" {
  76119. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76120. /**
  76121. * Contains all parameters needed for the prepass to perform
  76122. * screen space subsurface scattering
  76123. */
  76124. export class SSAO2Configuration implements PrePassEffectConfiguration {
  76125. /**
  76126. * Is subsurface enabled
  76127. */
  76128. enabled: boolean;
  76129. /**
  76130. * Name of the configuration
  76131. */
  76132. name: string;
  76133. /**
  76134. * Textures that should be present in the MRT for this effect to work
  76135. */
  76136. readonly texturesRequired: number[];
  76137. }
  76138. }
  76139. declare module "babylonjs/Shaders/ssao2.fragment" {
  76140. /** @hidden */
  76141. export var ssao2PixelShader: {
  76142. name: string;
  76143. shader: string;
  76144. };
  76145. }
  76146. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  76147. /** @hidden */
  76148. export var ssaoCombinePixelShader: {
  76149. name: string;
  76150. shader: string;
  76151. };
  76152. }
  76153. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  76154. import { Camera } from "babylonjs/Cameras/camera";
  76155. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76156. import { Scene } from "babylonjs/scene";
  76157. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76158. import "babylonjs/Shaders/ssao2.fragment";
  76159. import "babylonjs/Shaders/ssaoCombine.fragment";
  76160. /**
  76161. * Render pipeline to produce ssao effect
  76162. */
  76163. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  76164. /**
  76165. * @ignore
  76166. * The PassPostProcess id in the pipeline that contains the original scene color
  76167. */
  76168. SSAOOriginalSceneColorEffect: string;
  76169. /**
  76170. * @ignore
  76171. * The SSAO PostProcess id in the pipeline
  76172. */
  76173. SSAORenderEffect: string;
  76174. /**
  76175. * @ignore
  76176. * The horizontal blur PostProcess id in the pipeline
  76177. */
  76178. SSAOBlurHRenderEffect: string;
  76179. /**
  76180. * @ignore
  76181. * The vertical blur PostProcess id in the pipeline
  76182. */
  76183. SSAOBlurVRenderEffect: string;
  76184. /**
  76185. * @ignore
  76186. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76187. */
  76188. SSAOCombineRenderEffect: string;
  76189. /**
  76190. * The output strength of the SSAO post-process. Default value is 1.0.
  76191. */
  76192. totalStrength: number;
  76193. /**
  76194. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  76195. */
  76196. maxZ: number;
  76197. /**
  76198. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  76199. */
  76200. minZAspect: number;
  76201. private _samples;
  76202. /**
  76203. * Number of samples used for the SSAO calculations. Default value is 8
  76204. */
  76205. set samples(n: number);
  76206. get samples(): number;
  76207. private _textureSamples;
  76208. /**
  76209. * Number of samples to use for antialiasing
  76210. */
  76211. set textureSamples(n: number);
  76212. get textureSamples(): number;
  76213. /**
  76214. * Force rendering the geometry through geometry buffer
  76215. */
  76216. private _forceGeometryBuffer;
  76217. /**
  76218. * Ratio object used for SSAO ratio and blur ratio
  76219. */
  76220. private _ratio;
  76221. /**
  76222. * Dynamically generated sphere sampler.
  76223. */
  76224. private _sampleSphere;
  76225. /**
  76226. * Blur filter offsets
  76227. */
  76228. private _samplerOffsets;
  76229. private _expensiveBlur;
  76230. /**
  76231. * If bilateral blur should be used
  76232. */
  76233. set expensiveBlur(b: boolean);
  76234. get expensiveBlur(): boolean;
  76235. /**
  76236. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  76237. */
  76238. radius: number;
  76239. /**
  76240. * The base color of the SSAO post-process
  76241. * The final result is "base + ssao" between [0, 1]
  76242. */
  76243. base: number;
  76244. /**
  76245. * Support test.
  76246. */
  76247. static get IsSupported(): boolean;
  76248. private _scene;
  76249. private _randomTexture;
  76250. private _originalColorPostProcess;
  76251. private _ssaoPostProcess;
  76252. private _blurHPostProcess;
  76253. private _blurVPostProcess;
  76254. private _ssaoCombinePostProcess;
  76255. private _prePassRenderer;
  76256. /**
  76257. * Gets active scene
  76258. */
  76259. get scene(): Scene;
  76260. /**
  76261. * @constructor
  76262. * @param name The rendering pipeline name
  76263. * @param scene The scene linked to this pipeline
  76264. * @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 }
  76265. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76266. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  76267. */
  76268. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  76269. /**
  76270. * Get the class name
  76271. * @returns "SSAO2RenderingPipeline"
  76272. */
  76273. getClassName(): string;
  76274. /**
  76275. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76276. */
  76277. dispose(disableGeometryBufferRenderer?: boolean): void;
  76278. private _createBlurPostProcess;
  76279. /** @hidden */
  76280. _rebuild(): void;
  76281. private _bits;
  76282. private _radicalInverse_VdC;
  76283. private _hammersley;
  76284. private _hemisphereSample_uniform;
  76285. private _generateHemisphere;
  76286. private _getDefinesForSSAO;
  76287. private _createSSAOPostProcess;
  76288. private _createSSAOCombinePostProcess;
  76289. private _createRandomTexture;
  76290. /**
  76291. * Serialize the rendering pipeline (Used when exporting)
  76292. * @returns the serialized object
  76293. */
  76294. serialize(): any;
  76295. /**
  76296. * Parse the serialized pipeline
  76297. * @param source Source pipeline.
  76298. * @param scene The scene to load the pipeline to.
  76299. * @param rootUrl The URL of the serialized pipeline.
  76300. * @returns An instantiated pipeline from the serialized object.
  76301. */
  76302. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  76303. }
  76304. }
  76305. declare module "babylonjs/Shaders/ssao.fragment" {
  76306. /** @hidden */
  76307. export var ssaoPixelShader: {
  76308. name: string;
  76309. shader: string;
  76310. };
  76311. }
  76312. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  76313. import { Camera } from "babylonjs/Cameras/camera";
  76314. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76315. import { Scene } from "babylonjs/scene";
  76316. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76317. import "babylonjs/Shaders/ssao.fragment";
  76318. import "babylonjs/Shaders/ssaoCombine.fragment";
  76319. /**
  76320. * Render pipeline to produce ssao effect
  76321. */
  76322. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  76323. /**
  76324. * @ignore
  76325. * The PassPostProcess id in the pipeline that contains the original scene color
  76326. */
  76327. SSAOOriginalSceneColorEffect: string;
  76328. /**
  76329. * @ignore
  76330. * The SSAO PostProcess id in the pipeline
  76331. */
  76332. SSAORenderEffect: string;
  76333. /**
  76334. * @ignore
  76335. * The horizontal blur PostProcess id in the pipeline
  76336. */
  76337. SSAOBlurHRenderEffect: string;
  76338. /**
  76339. * @ignore
  76340. * The vertical blur PostProcess id in the pipeline
  76341. */
  76342. SSAOBlurVRenderEffect: string;
  76343. /**
  76344. * @ignore
  76345. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76346. */
  76347. SSAOCombineRenderEffect: string;
  76348. /**
  76349. * The output strength of the SSAO post-process. Default value is 1.0.
  76350. */
  76351. totalStrength: number;
  76352. /**
  76353. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  76354. */
  76355. radius: number;
  76356. /**
  76357. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  76358. * Must not be equal to fallOff and superior to fallOff.
  76359. * Default value is 0.0075
  76360. */
  76361. area: number;
  76362. /**
  76363. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  76364. * Must not be equal to area and inferior to area.
  76365. * Default value is 0.000001
  76366. */
  76367. fallOff: number;
  76368. /**
  76369. * The base color of the SSAO post-process
  76370. * The final result is "base + ssao" between [0, 1]
  76371. */
  76372. base: number;
  76373. private _scene;
  76374. private _depthTexture;
  76375. private _randomTexture;
  76376. private _originalColorPostProcess;
  76377. private _ssaoPostProcess;
  76378. private _blurHPostProcess;
  76379. private _blurVPostProcess;
  76380. private _ssaoCombinePostProcess;
  76381. private _firstUpdate;
  76382. /**
  76383. * Gets active scene
  76384. */
  76385. get scene(): Scene;
  76386. /**
  76387. * @constructor
  76388. * @param name - The rendering pipeline name
  76389. * @param scene - The scene linked to this pipeline
  76390. * @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 }
  76391. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  76392. */
  76393. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  76394. /**
  76395. * Get the class name
  76396. * @returns "SSAORenderingPipeline"
  76397. */
  76398. getClassName(): string;
  76399. /**
  76400. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76401. */
  76402. dispose(disableDepthRender?: boolean): void;
  76403. private _createBlurPostProcess;
  76404. /** @hidden */
  76405. _rebuild(): void;
  76406. private _createSSAOPostProcess;
  76407. private _createSSAOCombinePostProcess;
  76408. private _createRandomTexture;
  76409. }
  76410. }
  76411. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  76412. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76413. /**
  76414. * Contains all parameters needed for the prepass to perform
  76415. * screen space reflections
  76416. */
  76417. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  76418. /**
  76419. * Is ssr enabled
  76420. */
  76421. enabled: boolean;
  76422. /**
  76423. * Name of the configuration
  76424. */
  76425. name: string;
  76426. /**
  76427. * Textures that should be present in the MRT for this effect to work
  76428. */
  76429. readonly texturesRequired: number[];
  76430. }
  76431. }
  76432. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  76433. /** @hidden */
  76434. export var screenSpaceReflectionPixelShader: {
  76435. name: string;
  76436. shader: string;
  76437. };
  76438. }
  76439. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  76440. import { Nullable } from "babylonjs/types";
  76441. import { Camera } from "babylonjs/Cameras/camera";
  76442. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76443. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  76444. import { Engine } from "babylonjs/Engines/engine";
  76445. import { Scene } from "babylonjs/scene";
  76446. /**
  76447. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76448. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76449. */
  76450. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76451. /**
  76452. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76453. */
  76454. threshold: number;
  76455. /**
  76456. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76457. */
  76458. strength: number;
  76459. /**
  76460. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76461. */
  76462. reflectionSpecularFalloffExponent: number;
  76463. /**
  76464. * 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]
  76465. */
  76466. step: number;
  76467. /**
  76468. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76469. */
  76470. roughnessFactor: number;
  76471. private _forceGeometryBuffer;
  76472. private _geometryBufferRenderer;
  76473. private _prePassRenderer;
  76474. private _enableSmoothReflections;
  76475. private _reflectionSamples;
  76476. private _smoothSteps;
  76477. /**
  76478. * Gets a string identifying the name of the class
  76479. * @returns "ScreenSpaceReflectionPostProcess" string
  76480. */
  76481. getClassName(): string;
  76482. /**
  76483. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76484. * @param name The name of the effect.
  76485. * @param scene The scene containing the objects to calculate reflections.
  76486. * @param options The required width/height ratio to downsize to before computing the render pass.
  76487. * @param camera The camera to apply the render pass to.
  76488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76489. * @param engine The engine which the post process will be applied. (default: current engine)
  76490. * @param reusable If the post process can be reused on the same frame. (default: false)
  76491. * @param textureType Type of textures used when performing the post process. (default: 0)
  76492. * @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: true)
  76493. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76494. */
  76495. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76496. /**
  76497. * Gets wether or not smoothing reflections is enabled.
  76498. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76499. */
  76500. get enableSmoothReflections(): boolean;
  76501. /**
  76502. * Sets wether or not smoothing reflections is enabled.
  76503. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76504. */
  76505. set enableSmoothReflections(enabled: boolean);
  76506. /**
  76507. * Gets the number of samples taken while computing reflections. More samples count is high,
  76508. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76509. */
  76510. get reflectionSamples(): number;
  76511. /**
  76512. * Sets the number of samples taken while computing reflections. More samples count is high,
  76513. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76514. */
  76515. set reflectionSamples(samples: number);
  76516. /**
  76517. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76518. * more the post-process will require GPU power and can generate a drop in FPS.
  76519. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76520. */
  76521. get smoothSteps(): number;
  76522. set smoothSteps(steps: number);
  76523. private _updateEffectDefines;
  76524. /** @hidden */
  76525. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76526. }
  76527. }
  76528. declare module "babylonjs/Shaders/standard.fragment" {
  76529. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  76530. /** @hidden */
  76531. export var standardPixelShader: {
  76532. name: string;
  76533. shader: string;
  76534. };
  76535. }
  76536. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  76537. import { Nullable } from "babylonjs/types";
  76538. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76539. import { Camera } from "babylonjs/Cameras/camera";
  76540. import { Texture } from "babylonjs/Materials/Textures/texture";
  76541. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76542. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76543. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  76544. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  76545. import { IDisposable } from "babylonjs/scene";
  76546. import { SpotLight } from "babylonjs/Lights/spotLight";
  76547. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  76548. import { Scene } from "babylonjs/scene";
  76549. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76550. import { Animation } from "babylonjs/Animations/animation";
  76551. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76552. import "babylonjs/Shaders/standard.fragment";
  76553. /**
  76554. * Standard rendering pipeline
  76555. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76556. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76557. */
  76558. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76559. /**
  76560. * Public members
  76561. */
  76562. /**
  76563. * Post-process which contains the original scene color before the pipeline applies all the effects
  76564. */
  76565. originalPostProcess: Nullable<PostProcess>;
  76566. /**
  76567. * Post-process used to down scale an image x4
  76568. */
  76569. downSampleX4PostProcess: Nullable<PostProcess>;
  76570. /**
  76571. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76572. */
  76573. brightPassPostProcess: Nullable<PostProcess>;
  76574. /**
  76575. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76576. */
  76577. blurHPostProcesses: PostProcess[];
  76578. /**
  76579. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76580. */
  76581. blurVPostProcesses: PostProcess[];
  76582. /**
  76583. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76584. */
  76585. textureAdderPostProcess: Nullable<PostProcess>;
  76586. /**
  76587. * Post-process used to create volumetric lighting effect
  76588. */
  76589. volumetricLightPostProcess: Nullable<PostProcess>;
  76590. /**
  76591. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76592. */
  76593. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76594. /**
  76595. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76596. */
  76597. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76598. /**
  76599. * Post-process used to merge the volumetric light effect and the real scene color
  76600. */
  76601. volumetricLightMergePostProces: Nullable<PostProcess>;
  76602. /**
  76603. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76604. */
  76605. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76606. /**
  76607. * Base post-process used to calculate the average luminance of the final image for HDR
  76608. */
  76609. luminancePostProcess: Nullable<PostProcess>;
  76610. /**
  76611. * Post-processes used to create down sample post-processes in order to get
  76612. * the average luminance of the final image for HDR
  76613. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76614. */
  76615. luminanceDownSamplePostProcesses: PostProcess[];
  76616. /**
  76617. * Post-process used to create a HDR effect (light adaptation)
  76618. */
  76619. hdrPostProcess: Nullable<PostProcess>;
  76620. /**
  76621. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76622. */
  76623. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76624. /**
  76625. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76626. */
  76627. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76628. /**
  76629. * Post-process used to merge the final HDR post-process and the real scene color
  76630. */
  76631. hdrFinalPostProcess: Nullable<PostProcess>;
  76632. /**
  76633. * Post-process used to create a lens flare effect
  76634. */
  76635. lensFlarePostProcess: Nullable<PostProcess>;
  76636. /**
  76637. * Post-process that merges the result of the lens flare post-process and the real scene color
  76638. */
  76639. lensFlareComposePostProcess: Nullable<PostProcess>;
  76640. /**
  76641. * Post-process used to create a motion blur effect
  76642. */
  76643. motionBlurPostProcess: Nullable<PostProcess>;
  76644. /**
  76645. * Post-process used to create a depth of field effect
  76646. */
  76647. depthOfFieldPostProcess: Nullable<PostProcess>;
  76648. /**
  76649. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  76650. */
  76651. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76652. /**
  76653. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76654. */
  76655. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76656. /**
  76657. * Represents the brightness threshold in order to configure the illuminated surfaces
  76658. */
  76659. brightThreshold: number;
  76660. /**
  76661. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76662. */
  76663. blurWidth: number;
  76664. /**
  76665. * Sets if the blur for highlighted surfaces must be only horizontal
  76666. */
  76667. horizontalBlur: boolean;
  76668. /**
  76669. * Gets the overall exposure used by the pipeline
  76670. */
  76671. get exposure(): number;
  76672. /**
  76673. * Sets the overall exposure used by the pipeline
  76674. */
  76675. set exposure(value: number);
  76676. /**
  76677. * Texture used typically to simulate "dirty" on camera lens
  76678. */
  76679. lensTexture: Nullable<Texture>;
  76680. /**
  76681. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76682. */
  76683. volumetricLightCoefficient: number;
  76684. /**
  76685. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76686. */
  76687. volumetricLightPower: number;
  76688. /**
  76689. * Used the set the blur intensity to smooth the volumetric lights
  76690. */
  76691. volumetricLightBlurScale: number;
  76692. /**
  76693. * Light (spot or directional) used to generate the volumetric lights rays
  76694. * The source light must have a shadow generate so the pipeline can get its
  76695. * depth map
  76696. */
  76697. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76698. /**
  76699. * For eye adaptation, represents the minimum luminance the eye can see
  76700. */
  76701. hdrMinimumLuminance: number;
  76702. /**
  76703. * For eye adaptation, represents the decrease luminance speed
  76704. */
  76705. hdrDecreaseRate: number;
  76706. /**
  76707. * For eye adaptation, represents the increase luminance speed
  76708. */
  76709. hdrIncreaseRate: number;
  76710. /**
  76711. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76712. */
  76713. get hdrAutoExposure(): boolean;
  76714. /**
  76715. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76716. */
  76717. set hdrAutoExposure(value: boolean);
  76718. /**
  76719. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76720. */
  76721. lensColorTexture: Nullable<Texture>;
  76722. /**
  76723. * The overall strengh for the lens flare effect
  76724. */
  76725. lensFlareStrength: number;
  76726. /**
  76727. * Dispersion coefficient for lens flare ghosts
  76728. */
  76729. lensFlareGhostDispersal: number;
  76730. /**
  76731. * Main lens flare halo width
  76732. */
  76733. lensFlareHaloWidth: number;
  76734. /**
  76735. * Based on the lens distortion effect, defines how much the lens flare result
  76736. * is distorted
  76737. */
  76738. lensFlareDistortionStrength: number;
  76739. /**
  76740. * Configures the blur intensity used for for lens flare (halo)
  76741. */
  76742. lensFlareBlurWidth: number;
  76743. /**
  76744. * Lens star texture must be used to simulate rays on the flares and is available
  76745. * in the documentation
  76746. */
  76747. lensStarTexture: Nullable<Texture>;
  76748. /**
  76749. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76750. * flare effect by taking account of the dirt texture
  76751. */
  76752. lensFlareDirtTexture: Nullable<Texture>;
  76753. /**
  76754. * Represents the focal length for the depth of field effect
  76755. */
  76756. depthOfFieldDistance: number;
  76757. /**
  76758. * Represents the blur intensity for the blurred part of the depth of field effect
  76759. */
  76760. depthOfFieldBlurWidth: number;
  76761. /**
  76762. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76763. */
  76764. get motionStrength(): number;
  76765. /**
  76766. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76767. */
  76768. set motionStrength(strength: number);
  76769. /**
  76770. * Gets wether or not the motion blur post-process is object based or screen based.
  76771. */
  76772. get objectBasedMotionBlur(): boolean;
  76773. /**
  76774. * Sets wether or not the motion blur post-process should be object based or screen based
  76775. */
  76776. set objectBasedMotionBlur(value: boolean);
  76777. /**
  76778. * List of animations for the pipeline (IAnimatable implementation)
  76779. */
  76780. animations: Animation[];
  76781. /**
  76782. * Private members
  76783. */
  76784. private _scene;
  76785. private _currentDepthOfFieldSource;
  76786. private _basePostProcess;
  76787. private _fixedExposure;
  76788. private _currentExposure;
  76789. private _hdrAutoExposure;
  76790. private _hdrCurrentLuminance;
  76791. private _motionStrength;
  76792. private _isObjectBasedMotionBlur;
  76793. private _floatTextureType;
  76794. private _camerasToBeAttached;
  76795. private _ratio;
  76796. private _bloomEnabled;
  76797. private _depthOfFieldEnabled;
  76798. private _vlsEnabled;
  76799. private _lensFlareEnabled;
  76800. private _hdrEnabled;
  76801. private _motionBlurEnabled;
  76802. private _fxaaEnabled;
  76803. private _screenSpaceReflectionsEnabled;
  76804. private _motionBlurSamples;
  76805. private _volumetricLightStepsCount;
  76806. private _samples;
  76807. /**
  76808. * @ignore
  76809. * Specifies if the bloom pipeline is enabled
  76810. */
  76811. get BloomEnabled(): boolean;
  76812. set BloomEnabled(enabled: boolean);
  76813. /**
  76814. * @ignore
  76815. * Specifies if the depth of field pipeline is enabed
  76816. */
  76817. get DepthOfFieldEnabled(): boolean;
  76818. set DepthOfFieldEnabled(enabled: boolean);
  76819. /**
  76820. * @ignore
  76821. * Specifies if the lens flare pipeline is enabed
  76822. */
  76823. get LensFlareEnabled(): boolean;
  76824. set LensFlareEnabled(enabled: boolean);
  76825. /**
  76826. * @ignore
  76827. * Specifies if the HDR pipeline is enabled
  76828. */
  76829. get HDREnabled(): boolean;
  76830. set HDREnabled(enabled: boolean);
  76831. /**
  76832. * @ignore
  76833. * Specifies if the volumetric lights scattering effect is enabled
  76834. */
  76835. get VLSEnabled(): boolean;
  76836. set VLSEnabled(enabled: boolean);
  76837. /**
  76838. * @ignore
  76839. * Specifies if the motion blur effect is enabled
  76840. */
  76841. get MotionBlurEnabled(): boolean;
  76842. set MotionBlurEnabled(enabled: boolean);
  76843. /**
  76844. * Specifies if anti-aliasing is enabled
  76845. */
  76846. get fxaaEnabled(): boolean;
  76847. set fxaaEnabled(enabled: boolean);
  76848. /**
  76849. * Specifies if screen space reflections are enabled.
  76850. */
  76851. get screenSpaceReflectionsEnabled(): boolean;
  76852. set screenSpaceReflectionsEnabled(enabled: boolean);
  76853. /**
  76854. * Specifies the number of steps used to calculate the volumetric lights
  76855. * Typically in interval [50, 200]
  76856. */
  76857. get volumetricLightStepsCount(): number;
  76858. set volumetricLightStepsCount(count: number);
  76859. /**
  76860. * Specifies the number of samples used for the motion blur effect
  76861. * Typically in interval [16, 64]
  76862. */
  76863. get motionBlurSamples(): number;
  76864. set motionBlurSamples(samples: number);
  76865. /**
  76866. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76867. */
  76868. get samples(): number;
  76869. set samples(sampleCount: number);
  76870. /**
  76871. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76872. * @constructor
  76873. * @param name The rendering pipeline name
  76874. * @param scene The scene linked to this pipeline
  76875. * @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)
  76876. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76877. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76878. */
  76879. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76880. private _buildPipeline;
  76881. private _createDownSampleX4PostProcess;
  76882. private _createBrightPassPostProcess;
  76883. private _createBlurPostProcesses;
  76884. private _createTextureAdderPostProcess;
  76885. private _createVolumetricLightPostProcess;
  76886. private _createLuminancePostProcesses;
  76887. private _createHdrPostProcess;
  76888. private _createLensFlarePostProcess;
  76889. private _createDepthOfFieldPostProcess;
  76890. private _createMotionBlurPostProcess;
  76891. private _getDepthTexture;
  76892. private _disposePostProcesses;
  76893. /**
  76894. * Dispose of the pipeline and stop all post processes
  76895. */
  76896. dispose(): void;
  76897. /**
  76898. * Serialize the rendering pipeline (Used when exporting)
  76899. * @returns the serialized object
  76900. */
  76901. serialize(): any;
  76902. /**
  76903. * Parse the serialized pipeline
  76904. * @param source Source pipeline.
  76905. * @param scene The scene to load the pipeline to.
  76906. * @param rootUrl The URL of the serialized pipeline.
  76907. * @returns An instantiated pipeline from the serialized object.
  76908. */
  76909. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76910. /**
  76911. * Luminance steps
  76912. */
  76913. static LuminanceSteps: number;
  76914. }
  76915. }
  76916. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76917. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76918. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76919. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76920. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76921. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76922. }
  76923. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76924. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76925. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76926. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76927. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76928. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76929. }
  76930. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76931. /** @hidden */
  76932. export var stereoscopicInterlacePixelShader: {
  76933. name: string;
  76934. shader: string;
  76935. };
  76936. }
  76937. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76938. import { Camera } from "babylonjs/Cameras/camera";
  76939. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76940. import { Engine } from "babylonjs/Engines/engine";
  76941. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76942. /**
  76943. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76944. */
  76945. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76946. private _stepSize;
  76947. private _passedProcess;
  76948. /**
  76949. * Gets a string identifying the name of the class
  76950. * @returns "StereoscopicInterlacePostProcessI" string
  76951. */
  76952. getClassName(): string;
  76953. /**
  76954. * Initializes a StereoscopicInterlacePostProcessI
  76955. * @param name The name of the effect.
  76956. * @param rigCameras The rig cameras to be appled to the post process
  76957. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76958. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76960. * @param engine The engine which the post process will be applied. (default: current engine)
  76961. * @param reusable If the post process can be reused on the same frame. (default: false)
  76962. */
  76963. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76964. }
  76965. /**
  76966. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76967. */
  76968. export class StereoscopicInterlacePostProcess extends PostProcess {
  76969. private _stepSize;
  76970. private _passedProcess;
  76971. /**
  76972. * Gets a string identifying the name of the class
  76973. * @returns "StereoscopicInterlacePostProcess" string
  76974. */
  76975. getClassName(): string;
  76976. /**
  76977. * Initializes a StereoscopicInterlacePostProcess
  76978. * @param name The name of the effect.
  76979. * @param rigCameras The rig cameras to be appled to the post process
  76980. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76982. * @param engine The engine which the post process will be applied. (default: current engine)
  76983. * @param reusable If the post process can be reused on the same frame. (default: false)
  76984. */
  76985. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76986. }
  76987. }
  76988. declare module "babylonjs/Shaders/tonemap.fragment" {
  76989. /** @hidden */
  76990. export var tonemapPixelShader: {
  76991. name: string;
  76992. shader: string;
  76993. };
  76994. }
  76995. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76996. import { Camera } from "babylonjs/Cameras/camera";
  76997. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76998. import "babylonjs/Shaders/tonemap.fragment";
  76999. import { Engine } from "babylonjs/Engines/engine";
  77000. /** Defines operator used for tonemapping */
  77001. export enum TonemappingOperator {
  77002. /** Hable */
  77003. Hable = 0,
  77004. /** Reinhard */
  77005. Reinhard = 1,
  77006. /** HejiDawson */
  77007. HejiDawson = 2,
  77008. /** Photographic */
  77009. Photographic = 3
  77010. }
  77011. /**
  77012. * Defines a post process to apply tone mapping
  77013. */
  77014. export class TonemapPostProcess extends PostProcess {
  77015. private _operator;
  77016. /** Defines the required exposure adjustement */
  77017. exposureAdjustment: number;
  77018. /**
  77019. * Gets a string identifying the name of the class
  77020. * @returns "TonemapPostProcess" string
  77021. */
  77022. getClassName(): string;
  77023. /**
  77024. * Creates a new TonemapPostProcess
  77025. * @param name defines the name of the postprocess
  77026. * @param _operator defines the operator to use
  77027. * @param exposureAdjustment defines the required exposure adjustement
  77028. * @param camera defines the camera to use (can be null)
  77029. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  77030. * @param engine defines the hosting engine (can be ignore if camera is set)
  77031. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77032. */
  77033. constructor(name: string, _operator: TonemappingOperator,
  77034. /** Defines the required exposure adjustement */
  77035. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  77036. }
  77037. }
  77038. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  77039. /** @hidden */
  77040. export var volumetricLightScatteringPixelShader: {
  77041. name: string;
  77042. shader: string;
  77043. };
  77044. }
  77045. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  77046. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77047. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77048. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77049. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77050. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77051. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77052. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77053. /** @hidden */
  77054. export var volumetricLightScatteringPassVertexShader: {
  77055. name: string;
  77056. shader: string;
  77057. };
  77058. }
  77059. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  77060. /** @hidden */
  77061. export var volumetricLightScatteringPassPixelShader: {
  77062. name: string;
  77063. shader: string;
  77064. };
  77065. }
  77066. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  77067. import { Vector3 } from "babylonjs/Maths/math.vector";
  77068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77069. import { Mesh } from "babylonjs/Meshes/mesh";
  77070. import { Camera } from "babylonjs/Cameras/camera";
  77071. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77072. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77073. import { Scene } from "babylonjs/scene";
  77074. import "babylonjs/Meshes/Builders/planeBuilder";
  77075. import "babylonjs/Shaders/depth.vertex";
  77076. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  77077. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  77078. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  77079. import { Engine } from "babylonjs/Engines/engine";
  77080. /**
  77081. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  77082. */
  77083. export class VolumetricLightScatteringPostProcess extends PostProcess {
  77084. private _volumetricLightScatteringPass;
  77085. private _volumetricLightScatteringRTT;
  77086. private _viewPort;
  77087. private _screenCoordinates;
  77088. private _cachedDefines;
  77089. /**
  77090. * If not undefined, the mesh position is computed from the attached node position
  77091. */
  77092. attachedNode: {
  77093. position: Vector3;
  77094. };
  77095. /**
  77096. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  77097. */
  77098. customMeshPosition: Vector3;
  77099. /**
  77100. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  77101. */
  77102. useCustomMeshPosition: boolean;
  77103. /**
  77104. * If the post-process should inverse the light scattering direction
  77105. */
  77106. invert: boolean;
  77107. /**
  77108. * The internal mesh used by the post-process
  77109. */
  77110. mesh: Mesh;
  77111. /**
  77112. * @hidden
  77113. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  77114. */
  77115. get useDiffuseColor(): boolean;
  77116. set useDiffuseColor(useDiffuseColor: boolean);
  77117. /**
  77118. * Array containing the excluded meshes not rendered in the internal pass
  77119. */
  77120. excludedMeshes: AbstractMesh[];
  77121. /**
  77122. * Controls the overall intensity of the post-process
  77123. */
  77124. exposure: number;
  77125. /**
  77126. * Dissipates each sample's contribution in range [0, 1]
  77127. */
  77128. decay: number;
  77129. /**
  77130. * Controls the overall intensity of each sample
  77131. */
  77132. weight: number;
  77133. /**
  77134. * Controls the density of each sample
  77135. */
  77136. density: number;
  77137. /**
  77138. * @constructor
  77139. * @param name The post-process name
  77140. * @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)
  77141. * @param camera The camera that the post-process will be attached to
  77142. * @param mesh The mesh used to create the light scattering
  77143. * @param samples The post-process quality, default 100
  77144. * @param samplingModeThe post-process filtering mode
  77145. * @param engine The babylon engine
  77146. * @param reusable If the post-process is reusable
  77147. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  77148. */
  77149. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  77150. /**
  77151. * Returns the string "VolumetricLightScatteringPostProcess"
  77152. * @returns "VolumetricLightScatteringPostProcess"
  77153. */
  77154. getClassName(): string;
  77155. private _isReady;
  77156. /**
  77157. * Sets the new light position for light scattering effect
  77158. * @param position The new custom light position
  77159. */
  77160. setCustomMeshPosition(position: Vector3): void;
  77161. /**
  77162. * Returns the light position for light scattering effect
  77163. * @return Vector3 The custom light position
  77164. */
  77165. getCustomMeshPosition(): Vector3;
  77166. /**
  77167. * Disposes the internal assets and detaches the post-process from the camera
  77168. */
  77169. dispose(camera: Camera): void;
  77170. /**
  77171. * Returns the render target texture used by the post-process
  77172. * @return the render target texture used by the post-process
  77173. */
  77174. getPass(): RenderTargetTexture;
  77175. private _meshExcluded;
  77176. private _createPass;
  77177. private _updateMeshScreenCoordinates;
  77178. /**
  77179. * Creates a default mesh for the Volumeric Light Scattering post-process
  77180. * @param name The mesh name
  77181. * @param scene The scene where to create the mesh
  77182. * @return the default mesh
  77183. */
  77184. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  77185. }
  77186. }
  77187. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  77188. /** @hidden */
  77189. export var screenSpaceCurvaturePixelShader: {
  77190. name: string;
  77191. shader: string;
  77192. };
  77193. }
  77194. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  77195. import { Nullable } from "babylonjs/types";
  77196. import { Camera } from "babylonjs/Cameras/camera";
  77197. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77198. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77199. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  77200. import { Engine } from "babylonjs/Engines/engine";
  77201. import { Scene } from "babylonjs/scene";
  77202. /**
  77203. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  77204. */
  77205. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  77206. /**
  77207. * Defines how much ridge the curvature effect displays.
  77208. */
  77209. ridge: number;
  77210. /**
  77211. * Defines how much valley the curvature effect displays.
  77212. */
  77213. valley: number;
  77214. private _geometryBufferRenderer;
  77215. /**
  77216. * Gets a string identifying the name of the class
  77217. * @returns "ScreenSpaceCurvaturePostProcess" string
  77218. */
  77219. getClassName(): string;
  77220. /**
  77221. * Creates a new instance ScreenSpaceCurvaturePostProcess
  77222. * @param name The name of the effect.
  77223. * @param scene The scene containing the objects to blur according to their velocity.
  77224. * @param options The required width/height ratio to downsize to before computing the render pass.
  77225. * @param camera The camera to apply the render pass to.
  77226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77227. * @param engine The engine which the post process will be applied. (default: current engine)
  77228. * @param reusable If the post process can be reused on the same frame. (default: false)
  77229. * @param textureType Type of textures used when performing the post process. (default: 0)
  77230. * @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)
  77231. */
  77232. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77233. /**
  77234. * Support test.
  77235. */
  77236. static get IsSupported(): boolean;
  77237. /** @hidden */
  77238. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  77239. }
  77240. }
  77241. declare module "babylonjs/PostProcesses/index" {
  77242. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  77243. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  77244. export * from "babylonjs/PostProcesses/bloomEffect";
  77245. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  77246. export * from "babylonjs/PostProcesses/blurPostProcess";
  77247. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  77248. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  77249. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  77250. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  77251. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  77252. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  77253. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  77254. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  77255. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77256. export * from "babylonjs/PostProcesses/filterPostProcess";
  77257. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  77258. export * from "babylonjs/PostProcesses/grainPostProcess";
  77259. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  77260. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  77261. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  77262. export * from "babylonjs/PostProcesses/passPostProcess";
  77263. export * from "babylonjs/PostProcesses/postProcess";
  77264. export * from "babylonjs/PostProcesses/postProcessManager";
  77265. export * from "babylonjs/PostProcesses/refractionPostProcess";
  77266. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  77267. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  77268. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  77269. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  77270. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  77271. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  77272. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  77273. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  77274. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  77275. }
  77276. declare module "babylonjs/Probes/index" {
  77277. export * from "babylonjs/Probes/reflectionProbe";
  77278. }
  77279. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  77280. import { Scene } from "babylonjs/scene";
  77281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77282. import { SmartArray } from "babylonjs/Misc/smartArray";
  77283. import { ISceneComponent } from "babylonjs/sceneComponent";
  77284. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  77285. import "babylonjs/Meshes/Builders/boxBuilder";
  77286. import "babylonjs/Shaders/color.fragment";
  77287. import "babylonjs/Shaders/color.vertex";
  77288. import { Color3 } from "babylonjs/Maths/math.color";
  77289. import { Observable } from "babylonjs/Misc/observable";
  77290. module "babylonjs/scene" {
  77291. interface Scene {
  77292. /** @hidden (Backing field) */
  77293. _boundingBoxRenderer: BoundingBoxRenderer;
  77294. /** @hidden (Backing field) */
  77295. _forceShowBoundingBoxes: boolean;
  77296. /**
  77297. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  77298. */
  77299. forceShowBoundingBoxes: boolean;
  77300. /**
  77301. * Gets the bounding box renderer associated with the scene
  77302. * @returns a BoundingBoxRenderer
  77303. */
  77304. getBoundingBoxRenderer(): BoundingBoxRenderer;
  77305. }
  77306. }
  77307. module "babylonjs/Meshes/abstractMesh" {
  77308. interface AbstractMesh {
  77309. /** @hidden (Backing field) */
  77310. _showBoundingBox: boolean;
  77311. /**
  77312. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  77313. */
  77314. showBoundingBox: boolean;
  77315. }
  77316. }
  77317. /**
  77318. * Component responsible of rendering the bounding box of the meshes in a scene.
  77319. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  77320. */
  77321. export class BoundingBoxRenderer implements ISceneComponent {
  77322. /**
  77323. * The component name helpfull to identify the component in the list of scene components.
  77324. */
  77325. readonly name: string;
  77326. /**
  77327. * The scene the component belongs to.
  77328. */
  77329. scene: Scene;
  77330. /**
  77331. * Color of the bounding box lines placed in front of an object
  77332. */
  77333. frontColor: Color3;
  77334. /**
  77335. * Color of the bounding box lines placed behind an object
  77336. */
  77337. backColor: Color3;
  77338. /**
  77339. * Defines if the renderer should show the back lines or not
  77340. */
  77341. showBackLines: boolean;
  77342. /**
  77343. * Observable raised before rendering a bounding box
  77344. */
  77345. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  77346. /**
  77347. * Observable raised after rendering a bounding box
  77348. */
  77349. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  77350. /**
  77351. * Observable raised after resources are created
  77352. */
  77353. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  77354. /**
  77355. * When false, no bounding boxes will be rendered
  77356. */
  77357. enabled: boolean;
  77358. /**
  77359. * @hidden
  77360. */
  77361. renderList: SmartArray<BoundingBox>;
  77362. private _colorShader;
  77363. private _vertexBuffers;
  77364. private _indexBuffer;
  77365. private _fillIndexBuffer;
  77366. private _fillIndexData;
  77367. /**
  77368. * Instantiates a new bounding box renderer in a scene.
  77369. * @param scene the scene the renderer renders in
  77370. */
  77371. constructor(scene: Scene);
  77372. /**
  77373. * Registers the component in a given scene
  77374. */
  77375. register(): void;
  77376. private _evaluateSubMesh;
  77377. private _preActiveMesh;
  77378. private _prepareResources;
  77379. private _createIndexBuffer;
  77380. /**
  77381. * Rebuilds the elements related to this component in case of
  77382. * context lost for instance.
  77383. */
  77384. rebuild(): void;
  77385. /**
  77386. * @hidden
  77387. */
  77388. reset(): void;
  77389. /**
  77390. * Render the bounding boxes of a specific rendering group
  77391. * @param renderingGroupId defines the rendering group to render
  77392. */
  77393. render(renderingGroupId: number): void;
  77394. /**
  77395. * In case of occlusion queries, we can render the occlusion bounding box through this method
  77396. * @param mesh Define the mesh to render the occlusion bounding box for
  77397. */
  77398. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  77399. /**
  77400. * Dispose and release the resources attached to this renderer.
  77401. */
  77402. dispose(): void;
  77403. }
  77404. }
  77405. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  77406. import { Nullable } from "babylonjs/types";
  77407. import { Scene } from "babylonjs/scene";
  77408. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  77409. import { Camera } from "babylonjs/Cameras/camera";
  77410. import { ISceneComponent } from "babylonjs/sceneComponent";
  77411. module "babylonjs/scene" {
  77412. interface Scene {
  77413. /** @hidden (Backing field) */
  77414. _depthRenderer: {
  77415. [id: string]: DepthRenderer;
  77416. };
  77417. /**
  77418. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  77419. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  77420. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  77421. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  77422. * @returns the created depth renderer
  77423. */
  77424. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  77425. /**
  77426. * Disables a depth renderer for a given camera
  77427. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  77428. */
  77429. disableDepthRenderer(camera?: Nullable<Camera>): void;
  77430. }
  77431. }
  77432. /**
  77433. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  77434. * in several rendering techniques.
  77435. */
  77436. export class DepthRendererSceneComponent implements ISceneComponent {
  77437. /**
  77438. * The component name helpfull to identify the component in the list of scene components.
  77439. */
  77440. readonly name: string;
  77441. /**
  77442. * The scene the component belongs to.
  77443. */
  77444. scene: Scene;
  77445. /**
  77446. * Creates a new instance of the component for the given scene
  77447. * @param scene Defines the scene to register the component in
  77448. */
  77449. constructor(scene: Scene);
  77450. /**
  77451. * Registers the component in a given scene
  77452. */
  77453. register(): void;
  77454. /**
  77455. * Rebuilds the elements related to this component in case of
  77456. * context lost for instance.
  77457. */
  77458. rebuild(): void;
  77459. /**
  77460. * Disposes the component and the associated ressources
  77461. */
  77462. dispose(): void;
  77463. private _gatherRenderTargets;
  77464. private _gatherActiveCameraRenderTargets;
  77465. }
  77466. }
  77467. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  77468. import { Nullable } from "babylonjs/types";
  77469. import { Scene } from "babylonjs/scene";
  77470. import { ISceneComponent } from "babylonjs/sceneComponent";
  77471. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  77472. module "babylonjs/abstractScene" {
  77473. interface AbstractScene {
  77474. /** @hidden (Backing field) */
  77475. _prePassRenderer: Nullable<PrePassRenderer>;
  77476. /**
  77477. * Gets or Sets the current prepass renderer associated to the scene.
  77478. */
  77479. prePassRenderer: Nullable<PrePassRenderer>;
  77480. /**
  77481. * Enables the prepass and associates it with the scene
  77482. * @returns the PrePassRenderer
  77483. */
  77484. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77485. /**
  77486. * Disables the prepass associated with the scene
  77487. */
  77488. disablePrePassRenderer(): void;
  77489. }
  77490. }
  77491. /**
  77492. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77493. * in several rendering techniques.
  77494. */
  77495. export class PrePassRendererSceneComponent implements ISceneComponent {
  77496. /**
  77497. * The component name helpful to identify the component in the list of scene components.
  77498. */
  77499. readonly name: string;
  77500. /**
  77501. * The scene the component belongs to.
  77502. */
  77503. scene: Scene;
  77504. /**
  77505. * Creates a new instance of the component for the given scene
  77506. * @param scene Defines the scene to register the component in
  77507. */
  77508. constructor(scene: Scene);
  77509. /**
  77510. * Registers the component in a given scene
  77511. */
  77512. register(): void;
  77513. private _beforeCameraDraw;
  77514. private _afterCameraDraw;
  77515. private _beforeClearStage;
  77516. private _beforeRenderingMeshStage;
  77517. private _afterRenderingMeshStage;
  77518. /**
  77519. * Rebuilds the elements related to this component in case of
  77520. * context lost for instance.
  77521. */
  77522. rebuild(): void;
  77523. /**
  77524. * Disposes the component and the associated ressources
  77525. */
  77526. dispose(): void;
  77527. }
  77528. }
  77529. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  77530. /** @hidden */
  77531. export var fibonacci: {
  77532. name: string;
  77533. shader: string;
  77534. };
  77535. }
  77536. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  77537. /** @hidden */
  77538. export var diffusionProfile: {
  77539. name: string;
  77540. shader: string;
  77541. };
  77542. }
  77543. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  77544. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  77545. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77546. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  77547. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  77548. /** @hidden */
  77549. export var subSurfaceScatteringPixelShader: {
  77550. name: string;
  77551. shader: string;
  77552. };
  77553. }
  77554. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  77555. import { Nullable } from "babylonjs/types";
  77556. import { Camera } from "babylonjs/Cameras/camera";
  77557. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77558. import { Engine } from "babylonjs/Engines/engine";
  77559. import { Scene } from "babylonjs/scene";
  77560. import "babylonjs/Shaders/imageProcessing.fragment";
  77561. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  77562. import "babylonjs/Shaders/postprocess.vertex";
  77563. /**
  77564. * Sub surface scattering post process
  77565. */
  77566. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77567. /**
  77568. * Gets a string identifying the name of the class
  77569. * @returns "SubSurfaceScatteringPostProcess" string
  77570. */
  77571. getClassName(): string;
  77572. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77573. }
  77574. }
  77575. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  77576. import { Scene } from "babylonjs/scene";
  77577. import { Color3 } from "babylonjs/Maths/math.color";
  77578. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  77579. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77580. /**
  77581. * Contains all parameters needed for the prepass to perform
  77582. * screen space subsurface scattering
  77583. */
  77584. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77585. /** @hidden */
  77586. static _SceneComponentInitialization: (scene: Scene) => void;
  77587. private _ssDiffusionS;
  77588. private _ssFilterRadii;
  77589. private _ssDiffusionD;
  77590. /**
  77591. * Post process to attach for screen space subsurface scattering
  77592. */
  77593. postProcess: SubSurfaceScatteringPostProcess;
  77594. /**
  77595. * Diffusion profile color for subsurface scattering
  77596. */
  77597. get ssDiffusionS(): number[];
  77598. /**
  77599. * Diffusion profile max color channel value for subsurface scattering
  77600. */
  77601. get ssDiffusionD(): number[];
  77602. /**
  77603. * Diffusion profile filter radius for subsurface scattering
  77604. */
  77605. get ssFilterRadii(): number[];
  77606. /**
  77607. * Is subsurface enabled
  77608. */
  77609. enabled: boolean;
  77610. /**
  77611. * Name of the configuration
  77612. */
  77613. name: string;
  77614. /**
  77615. * Diffusion profile colors for subsurface scattering
  77616. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77617. * See ...
  77618. * Note that you can only store up to 5 of them
  77619. */
  77620. ssDiffusionProfileColors: Color3[];
  77621. /**
  77622. * Defines the ratio real world => scene units.
  77623. * Used for subsurface scattering
  77624. */
  77625. metersPerUnit: number;
  77626. /**
  77627. * Textures that should be present in the MRT for this effect to work
  77628. */
  77629. readonly texturesRequired: number[];
  77630. private _scene;
  77631. /**
  77632. * Builds a subsurface configuration object
  77633. * @param scene The scene
  77634. */
  77635. constructor(scene: Scene);
  77636. /**
  77637. * Adds a new diffusion profile.
  77638. * Useful for more realistic subsurface scattering on diverse materials.
  77639. * @param color The color of the diffusion profile. Should be the average color of the material.
  77640. * @return The index of the diffusion profile for the material subsurface configuration
  77641. */
  77642. addDiffusionProfile(color: Color3): number;
  77643. /**
  77644. * Creates the sss post process
  77645. * @return The created post process
  77646. */
  77647. createPostProcess(): SubSurfaceScatteringPostProcess;
  77648. /**
  77649. * Deletes all diffusion profiles.
  77650. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77651. */
  77652. clearAllDiffusionProfiles(): void;
  77653. /**
  77654. * Disposes this object
  77655. */
  77656. dispose(): void;
  77657. /**
  77658. * @hidden
  77659. * https://zero-radiance.github.io/post/sampling-diffusion/
  77660. *
  77661. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77662. * ------------------------------------------------------------------------------------
  77663. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77664. * PDF[r, phi, s] = r * R[r, phi, s]
  77665. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77666. * ------------------------------------------------------------------------------------
  77667. * We importance sample the color channel with the widest scattering distance.
  77668. */
  77669. getDiffusionProfileParameters(color: Color3): number;
  77670. /**
  77671. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77672. * 'u' is the random number (the value of the CDF): [0, 1).
  77673. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77674. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77675. */
  77676. private _sampleBurleyDiffusionProfile;
  77677. }
  77678. }
  77679. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  77680. import { Nullable } from "babylonjs/types";
  77681. import { Scene } from "babylonjs/scene";
  77682. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  77683. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  77684. import { AbstractScene } from "babylonjs/abstractScene";
  77685. module "babylonjs/abstractScene" {
  77686. interface AbstractScene {
  77687. /** @hidden (Backing field) */
  77688. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77689. /**
  77690. * Gets or Sets the current prepass renderer associated to the scene.
  77691. */
  77692. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77693. /**
  77694. * Enables the subsurface effect for prepass
  77695. * @returns the SubSurfaceConfiguration
  77696. */
  77697. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77698. /**
  77699. * Disables the subsurface effect for prepass
  77700. */
  77701. disableSubSurfaceForPrePass(): void;
  77702. }
  77703. }
  77704. /**
  77705. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77706. * in several rendering techniques.
  77707. */
  77708. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77709. /**
  77710. * The component name helpful to identify the component in the list of scene components.
  77711. */
  77712. readonly name: string;
  77713. /**
  77714. * The scene the component belongs to.
  77715. */
  77716. scene: Scene;
  77717. /**
  77718. * Creates a new instance of the component for the given scene
  77719. * @param scene Defines the scene to register the component in
  77720. */
  77721. constructor(scene: Scene);
  77722. /**
  77723. * Registers the component in a given scene
  77724. */
  77725. register(): void;
  77726. /**
  77727. * Serializes the component data to the specified json object
  77728. * @param serializationObject The object to serialize to
  77729. */
  77730. serialize(serializationObject: any): void;
  77731. /**
  77732. * Adds all the elements from the container to the scene
  77733. * @param container the container holding the elements
  77734. */
  77735. addFromContainer(container: AbstractScene): void;
  77736. /**
  77737. * Removes all the elements in the container from the scene
  77738. * @param container contains the elements to remove
  77739. * @param dispose if the removed element should be disposed (default: false)
  77740. */
  77741. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77742. /**
  77743. * Rebuilds the elements related to this component in case of
  77744. * context lost for instance.
  77745. */
  77746. rebuild(): void;
  77747. /**
  77748. * Disposes the component and the associated ressources
  77749. */
  77750. dispose(): void;
  77751. }
  77752. }
  77753. declare module "babylonjs/Shaders/outline.fragment" {
  77754. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77755. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  77756. /** @hidden */
  77757. export var outlinePixelShader: {
  77758. name: string;
  77759. shader: string;
  77760. };
  77761. }
  77762. declare module "babylonjs/Shaders/outline.vertex" {
  77763. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77765. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77766. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77767. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77768. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77769. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77770. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77771. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  77772. /** @hidden */
  77773. export var outlineVertexShader: {
  77774. name: string;
  77775. shader: string;
  77776. };
  77777. }
  77778. declare module "babylonjs/Rendering/outlineRenderer" {
  77779. import { SubMesh } from "babylonjs/Meshes/subMesh";
  77780. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  77781. import { Scene } from "babylonjs/scene";
  77782. import { ISceneComponent } from "babylonjs/sceneComponent";
  77783. import "babylonjs/Shaders/outline.fragment";
  77784. import "babylonjs/Shaders/outline.vertex";
  77785. module "babylonjs/scene" {
  77786. interface Scene {
  77787. /** @hidden */
  77788. _outlineRenderer: OutlineRenderer;
  77789. /**
  77790. * Gets the outline renderer associated with the scene
  77791. * @returns a OutlineRenderer
  77792. */
  77793. getOutlineRenderer(): OutlineRenderer;
  77794. }
  77795. }
  77796. module "babylonjs/Meshes/abstractMesh" {
  77797. interface AbstractMesh {
  77798. /** @hidden (Backing field) */
  77799. _renderOutline: boolean;
  77800. /**
  77801. * Gets or sets a boolean indicating if the outline must be rendered as well
  77802. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77803. */
  77804. renderOutline: boolean;
  77805. /** @hidden (Backing field) */
  77806. _renderOverlay: boolean;
  77807. /**
  77808. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77809. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77810. */
  77811. renderOverlay: boolean;
  77812. }
  77813. }
  77814. /**
  77815. * This class is responsible to draw bothe outline/overlay of meshes.
  77816. * It should not be used directly but through the available method on mesh.
  77817. */
  77818. export class OutlineRenderer implements ISceneComponent {
  77819. /**
  77820. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77821. */
  77822. private static _StencilReference;
  77823. /**
  77824. * The name of the component. Each component must have a unique name.
  77825. */
  77826. name: string;
  77827. /**
  77828. * The scene the component belongs to.
  77829. */
  77830. scene: Scene;
  77831. /**
  77832. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77833. */
  77834. zOffset: number;
  77835. private _engine;
  77836. private _effect;
  77837. private _cachedDefines;
  77838. private _savedDepthWrite;
  77839. /**
  77840. * Instantiates a new outline renderer. (There could be only one per scene).
  77841. * @param scene Defines the scene it belongs to
  77842. */
  77843. constructor(scene: Scene);
  77844. /**
  77845. * Register the component to one instance of a scene.
  77846. */
  77847. register(): void;
  77848. /**
  77849. * Rebuilds the elements related to this component in case of
  77850. * context lost for instance.
  77851. */
  77852. rebuild(): void;
  77853. /**
  77854. * Disposes the component and the associated ressources.
  77855. */
  77856. dispose(): void;
  77857. /**
  77858. * Renders the outline in the canvas.
  77859. * @param subMesh Defines the sumesh to render
  77860. * @param batch Defines the batch of meshes in case of instances
  77861. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77862. */
  77863. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77864. /**
  77865. * Returns whether or not the outline renderer is ready for a given submesh.
  77866. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77867. * @param subMesh Defines the submesh to check readyness for
  77868. * @param useInstances Defines wheter wee are trying to render instances or not
  77869. * @returns true if ready otherwise false
  77870. */
  77871. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77872. private _beforeRenderingMesh;
  77873. private _afterRenderingMesh;
  77874. }
  77875. }
  77876. declare module "babylonjs/Rendering/index" {
  77877. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77878. export * from "babylonjs/Rendering/depthRenderer";
  77879. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77880. export * from "babylonjs/Rendering/edgesRenderer";
  77881. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77882. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77883. export * from "babylonjs/Rendering/prePassRenderer";
  77884. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77885. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77886. export * from "babylonjs/Rendering/outlineRenderer";
  77887. export * from "babylonjs/Rendering/renderingGroup";
  77888. export * from "babylonjs/Rendering/renderingManager";
  77889. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77890. }
  77891. declare module "babylonjs/Sprites/ISprites" {
  77892. /**
  77893. * Defines the basic options interface of a Sprite Frame Source Size.
  77894. */
  77895. export interface ISpriteJSONSpriteSourceSize {
  77896. /**
  77897. * number of the original width of the Frame
  77898. */
  77899. w: number;
  77900. /**
  77901. * number of the original height of the Frame
  77902. */
  77903. h: number;
  77904. }
  77905. /**
  77906. * Defines the basic options interface of a Sprite Frame Data.
  77907. */
  77908. export interface ISpriteJSONSpriteFrameData {
  77909. /**
  77910. * number of the x offset of the Frame
  77911. */
  77912. x: number;
  77913. /**
  77914. * number of the y offset of the Frame
  77915. */
  77916. y: number;
  77917. /**
  77918. * number of the width of the Frame
  77919. */
  77920. w: number;
  77921. /**
  77922. * number of the height of the Frame
  77923. */
  77924. h: number;
  77925. }
  77926. /**
  77927. * Defines the basic options interface of a JSON Sprite.
  77928. */
  77929. export interface ISpriteJSONSprite {
  77930. /**
  77931. * string name of the Frame
  77932. */
  77933. filename: string;
  77934. /**
  77935. * ISpriteJSONSpriteFrame basic object of the frame data
  77936. */
  77937. frame: ISpriteJSONSpriteFrameData;
  77938. /**
  77939. * boolean to flag is the frame was rotated.
  77940. */
  77941. rotated: boolean;
  77942. /**
  77943. * boolean to flag is the frame was trimmed.
  77944. */
  77945. trimmed: boolean;
  77946. /**
  77947. * ISpriteJSONSpriteFrame basic object of the source data
  77948. */
  77949. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77950. /**
  77951. * ISpriteJSONSpriteFrame basic object of the source data
  77952. */
  77953. sourceSize: ISpriteJSONSpriteSourceSize;
  77954. }
  77955. /**
  77956. * Defines the basic options interface of a JSON atlas.
  77957. */
  77958. export interface ISpriteJSONAtlas {
  77959. /**
  77960. * Array of objects that contain the frame data.
  77961. */
  77962. frames: Array<ISpriteJSONSprite>;
  77963. /**
  77964. * object basic object containing the sprite meta data.
  77965. */
  77966. meta?: object;
  77967. }
  77968. }
  77969. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77970. /** @hidden */
  77971. export var spriteMapPixelShader: {
  77972. name: string;
  77973. shader: string;
  77974. };
  77975. }
  77976. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77977. /** @hidden */
  77978. export var spriteMapVertexShader: {
  77979. name: string;
  77980. shader: string;
  77981. };
  77982. }
  77983. declare module "babylonjs/Sprites/spriteMap" {
  77984. import { IDisposable, Scene } from "babylonjs/scene";
  77985. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77986. import { Texture } from "babylonjs/Materials/Textures/texture";
  77987. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77988. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77989. import "babylonjs/Meshes/Builders/planeBuilder";
  77990. import "babylonjs/Shaders/spriteMap.fragment";
  77991. import "babylonjs/Shaders/spriteMap.vertex";
  77992. /**
  77993. * Defines the basic options interface of a SpriteMap
  77994. */
  77995. export interface ISpriteMapOptions {
  77996. /**
  77997. * Vector2 of the number of cells in the grid.
  77998. */
  77999. stageSize?: Vector2;
  78000. /**
  78001. * Vector2 of the size of the output plane in World Units.
  78002. */
  78003. outputSize?: Vector2;
  78004. /**
  78005. * Vector3 of the position of the output plane in World Units.
  78006. */
  78007. outputPosition?: Vector3;
  78008. /**
  78009. * Vector3 of the rotation of the output plane.
  78010. */
  78011. outputRotation?: Vector3;
  78012. /**
  78013. * number of layers that the system will reserve in resources.
  78014. */
  78015. layerCount?: number;
  78016. /**
  78017. * number of max animation frames a single cell will reserve in resources.
  78018. */
  78019. maxAnimationFrames?: number;
  78020. /**
  78021. * number cell index of the base tile when the system compiles.
  78022. */
  78023. baseTile?: number;
  78024. /**
  78025. * boolean flip the sprite after its been repositioned by the framing data.
  78026. */
  78027. flipU?: boolean;
  78028. /**
  78029. * Vector3 scalar of the global RGB values of the SpriteMap.
  78030. */
  78031. colorMultiply?: Vector3;
  78032. }
  78033. /**
  78034. * Defines the IDisposable interface in order to be cleanable from resources.
  78035. */
  78036. export interface ISpriteMap extends IDisposable {
  78037. /**
  78038. * String name of the SpriteMap.
  78039. */
  78040. name: string;
  78041. /**
  78042. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  78043. */
  78044. atlasJSON: ISpriteJSONAtlas;
  78045. /**
  78046. * Texture of the SpriteMap.
  78047. */
  78048. spriteSheet: Texture;
  78049. /**
  78050. * The parameters to initialize the SpriteMap with.
  78051. */
  78052. options: ISpriteMapOptions;
  78053. }
  78054. /**
  78055. * Class used to manage a grid restricted sprite deployment on an Output plane.
  78056. */
  78057. export class SpriteMap implements ISpriteMap {
  78058. /** The Name of the spriteMap */
  78059. name: string;
  78060. /** The JSON file with the frame and meta data */
  78061. atlasJSON: ISpriteJSONAtlas;
  78062. /** The systems Sprite Sheet Texture */
  78063. spriteSheet: Texture;
  78064. /** Arguments passed with the Constructor */
  78065. options: ISpriteMapOptions;
  78066. /** Public Sprite Storage array, parsed from atlasJSON */
  78067. sprites: Array<ISpriteJSONSprite>;
  78068. /** Returns the Number of Sprites in the System */
  78069. get spriteCount(): number;
  78070. /** Returns the Position of Output Plane*/
  78071. get position(): Vector3;
  78072. /** Returns the Position of Output Plane*/
  78073. set position(v: Vector3);
  78074. /** Returns the Rotation of Output Plane*/
  78075. get rotation(): Vector3;
  78076. /** Returns the Rotation of Output Plane*/
  78077. set rotation(v: Vector3);
  78078. /** Sets the AnimationMap*/
  78079. get animationMap(): RawTexture;
  78080. /** Sets the AnimationMap*/
  78081. set animationMap(v: RawTexture);
  78082. /** Scene that the SpriteMap was created in */
  78083. private _scene;
  78084. /** Texture Buffer of Float32 that holds tile frame data*/
  78085. private _frameMap;
  78086. /** Texture Buffers of Float32 that holds tileMap data*/
  78087. private _tileMaps;
  78088. /** Texture Buffer of Float32 that holds Animation Data*/
  78089. private _animationMap;
  78090. /** Custom ShaderMaterial Central to the System*/
  78091. private _material;
  78092. /** Custom ShaderMaterial Central to the System*/
  78093. private _output;
  78094. /** Systems Time Ticker*/
  78095. private _time;
  78096. /**
  78097. * Creates a new SpriteMap
  78098. * @param name defines the SpriteMaps Name
  78099. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  78100. * @param spriteSheet is the Texture that the Sprites are on.
  78101. * @param options a basic deployment configuration
  78102. * @param scene The Scene that the map is deployed on
  78103. */
  78104. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  78105. /**
  78106. * Returns tileID location
  78107. * @returns Vector2 the cell position ID
  78108. */
  78109. getTileID(): Vector2;
  78110. /**
  78111. * Gets the UV location of the mouse over the SpriteMap.
  78112. * @returns Vector2 the UV position of the mouse interaction
  78113. */
  78114. getMousePosition(): Vector2;
  78115. /**
  78116. * Creates the "frame" texture Buffer
  78117. * -------------------------------------
  78118. * Structure of frames
  78119. * "filename": "Falling-Water-2.png",
  78120. * "frame": {"x":69,"y":103,"w":24,"h":32},
  78121. * "rotated": true,
  78122. * "trimmed": true,
  78123. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  78124. * "sourceSize": {"w":32,"h":32}
  78125. * @returns RawTexture of the frameMap
  78126. */
  78127. private _createFrameBuffer;
  78128. /**
  78129. * Creates the tileMap texture Buffer
  78130. * @param buffer normally and array of numbers, or a false to generate from scratch
  78131. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  78132. * @returns RawTexture of the tileMap
  78133. */
  78134. private _createTileBuffer;
  78135. /**
  78136. * Modifies the data of the tileMaps
  78137. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  78138. * @param pos is the iVector2 Coordinates of the Tile
  78139. * @param tile The SpriteIndex of the new Tile
  78140. */
  78141. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  78142. /**
  78143. * Creates the animationMap texture Buffer
  78144. * @param buffer normally and array of numbers, or a false to generate from scratch
  78145. * @returns RawTexture of the animationMap
  78146. */
  78147. private _createTileAnimationBuffer;
  78148. /**
  78149. * Modifies the data of the animationMap
  78150. * @param cellID is the Index of the Sprite
  78151. * @param _frame is the target Animation frame
  78152. * @param toCell is the Target Index of the next frame of the animation
  78153. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  78154. * @param speed is a global scalar of the time variable on the map.
  78155. */
  78156. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  78157. /**
  78158. * Exports the .tilemaps file
  78159. */
  78160. saveTileMaps(): void;
  78161. /**
  78162. * Imports the .tilemaps file
  78163. * @param url of the .tilemaps file
  78164. */
  78165. loadTileMaps(url: string): void;
  78166. /**
  78167. * Release associated resources
  78168. */
  78169. dispose(): void;
  78170. }
  78171. }
  78172. declare module "babylonjs/Sprites/spritePackedManager" {
  78173. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  78174. import { Scene } from "babylonjs/scene";
  78175. /**
  78176. * Class used to manage multiple sprites of different sizes on the same spritesheet
  78177. * @see https://doc.babylonjs.com/babylon101/sprites
  78178. */
  78179. export class SpritePackedManager extends SpriteManager {
  78180. /** defines the packed manager's name */
  78181. name: string;
  78182. /**
  78183. * Creates a new sprite manager from a packed sprite sheet
  78184. * @param name defines the manager's name
  78185. * @param imgUrl defines the sprite sheet url
  78186. * @param capacity defines the maximum allowed number of sprites
  78187. * @param scene defines the hosting scene
  78188. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  78189. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78190. * @param samplingMode defines the smapling mode to use with spritesheet
  78191. * @param fromPacked set to true; do not alter
  78192. */
  78193. constructor(
  78194. /** defines the packed manager's name */
  78195. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  78196. }
  78197. }
  78198. declare module "babylonjs/Sprites/index" {
  78199. export * from "babylonjs/Sprites/sprite";
  78200. export * from "babylonjs/Sprites/ISprites";
  78201. export * from "babylonjs/Sprites/spriteManager";
  78202. export * from "babylonjs/Sprites/spriteMap";
  78203. export * from "babylonjs/Sprites/spritePackedManager";
  78204. export * from "babylonjs/Sprites/spriteSceneComponent";
  78205. }
  78206. declare module "babylonjs/States/index" {
  78207. export * from "babylonjs/States/alphaCullingState";
  78208. export * from "babylonjs/States/depthCullingState";
  78209. export * from "babylonjs/States/stencilState";
  78210. }
  78211. declare module "babylonjs/Misc/assetsManager" {
  78212. import { Scene } from "babylonjs/scene";
  78213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78214. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  78215. import { Skeleton } from "babylonjs/Bones/skeleton";
  78216. import { Observable } from "babylonjs/Misc/observable";
  78217. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  78218. import { Texture } from "babylonjs/Materials/Textures/texture";
  78219. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  78220. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  78221. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  78222. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  78223. import { AssetContainer } from "babylonjs/assetContainer";
  78224. /**
  78225. * Defines the list of states available for a task inside a AssetsManager
  78226. */
  78227. export enum AssetTaskState {
  78228. /**
  78229. * Initialization
  78230. */
  78231. INIT = 0,
  78232. /**
  78233. * Running
  78234. */
  78235. RUNNING = 1,
  78236. /**
  78237. * Done
  78238. */
  78239. DONE = 2,
  78240. /**
  78241. * Error
  78242. */
  78243. ERROR = 3
  78244. }
  78245. /**
  78246. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  78247. */
  78248. export abstract class AbstractAssetTask {
  78249. /**
  78250. * Task name
  78251. */ name: string;
  78252. /**
  78253. * Callback called when the task is successful
  78254. */
  78255. onSuccess: (task: any) => void;
  78256. /**
  78257. * Callback called when the task is not successful
  78258. */
  78259. onError: (task: any, message?: string, exception?: any) => void;
  78260. /**
  78261. * Creates a new AssetsManager
  78262. * @param name defines the name of the task
  78263. */
  78264. constructor(
  78265. /**
  78266. * Task name
  78267. */ name: string);
  78268. private _isCompleted;
  78269. private _taskState;
  78270. private _errorObject;
  78271. /**
  78272. * Get if the task is completed
  78273. */
  78274. get isCompleted(): boolean;
  78275. /**
  78276. * Gets the current state of the task
  78277. */
  78278. get taskState(): AssetTaskState;
  78279. /**
  78280. * Gets the current error object (if task is in error)
  78281. */
  78282. get errorObject(): {
  78283. message?: string;
  78284. exception?: any;
  78285. };
  78286. /**
  78287. * Internal only
  78288. * @hidden
  78289. */
  78290. _setErrorObject(message?: string, exception?: any): void;
  78291. /**
  78292. * Execute the current task
  78293. * @param scene defines the scene where you want your assets to be loaded
  78294. * @param onSuccess is a callback called when the task is successfully executed
  78295. * @param onError is a callback called if an error occurs
  78296. */
  78297. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78298. /**
  78299. * Execute the current task
  78300. * @param scene defines the scene where you want your assets to be loaded
  78301. * @param onSuccess is a callback called when the task is successfully executed
  78302. * @param onError is a callback called if an error occurs
  78303. */
  78304. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78305. /**
  78306. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  78307. * This can be used with failed tasks that have the reason for failure fixed.
  78308. */
  78309. reset(): void;
  78310. private onErrorCallback;
  78311. private onDoneCallback;
  78312. }
  78313. /**
  78314. * Define the interface used by progress events raised during assets loading
  78315. */
  78316. export interface IAssetsProgressEvent {
  78317. /**
  78318. * Defines the number of remaining tasks to process
  78319. */
  78320. remainingCount: number;
  78321. /**
  78322. * Defines the total number of tasks
  78323. */
  78324. totalCount: number;
  78325. /**
  78326. * Defines the task that was just processed
  78327. */
  78328. task: AbstractAssetTask;
  78329. }
  78330. /**
  78331. * Class used to share progress information about assets loading
  78332. */
  78333. export class AssetsProgressEvent implements IAssetsProgressEvent {
  78334. /**
  78335. * Defines the number of remaining tasks to process
  78336. */
  78337. remainingCount: number;
  78338. /**
  78339. * Defines the total number of tasks
  78340. */
  78341. totalCount: number;
  78342. /**
  78343. * Defines the task that was just processed
  78344. */
  78345. task: AbstractAssetTask;
  78346. /**
  78347. * Creates a AssetsProgressEvent
  78348. * @param remainingCount defines the number of remaining tasks to process
  78349. * @param totalCount defines the total number of tasks
  78350. * @param task defines the task that was just processed
  78351. */
  78352. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  78353. }
  78354. /**
  78355. * Define a task used by AssetsManager to load assets into a container
  78356. */
  78357. export class ContainerAssetTask extends AbstractAssetTask {
  78358. /**
  78359. * Defines the name of the task
  78360. */
  78361. name: string;
  78362. /**
  78363. * Defines the list of mesh's names you want to load
  78364. */
  78365. meshesNames: any;
  78366. /**
  78367. * Defines the root url to use as a base to load your meshes and associated resources
  78368. */
  78369. rootUrl: string;
  78370. /**
  78371. * Defines the filename or File of the scene to load from
  78372. */
  78373. sceneFilename: string | File;
  78374. /**
  78375. * Get the loaded asset container
  78376. */
  78377. loadedContainer: AssetContainer;
  78378. /**
  78379. * Gets the list of loaded meshes
  78380. */
  78381. loadedMeshes: Array<AbstractMesh>;
  78382. /**
  78383. * Gets the list of loaded particle systems
  78384. */
  78385. loadedParticleSystems: Array<IParticleSystem>;
  78386. /**
  78387. * Gets the list of loaded skeletons
  78388. */
  78389. loadedSkeletons: Array<Skeleton>;
  78390. /**
  78391. * Gets the list of loaded animation groups
  78392. */
  78393. loadedAnimationGroups: Array<AnimationGroup>;
  78394. /**
  78395. * Callback called when the task is successful
  78396. */
  78397. onSuccess: (task: ContainerAssetTask) => void;
  78398. /**
  78399. * Callback called when the task is successful
  78400. */
  78401. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  78402. /**
  78403. * Creates a new ContainerAssetTask
  78404. * @param name defines the name of the task
  78405. * @param meshesNames defines the list of mesh's names you want to load
  78406. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78407. * @param sceneFilename defines the filename or File of the scene to load from
  78408. */
  78409. constructor(
  78410. /**
  78411. * Defines the name of the task
  78412. */
  78413. name: string,
  78414. /**
  78415. * Defines the list of mesh's names you want to load
  78416. */
  78417. meshesNames: any,
  78418. /**
  78419. * Defines the root url to use as a base to load your meshes and associated resources
  78420. */
  78421. rootUrl: string,
  78422. /**
  78423. * Defines the filename or File of the scene to load from
  78424. */
  78425. sceneFilename: string | File);
  78426. /**
  78427. * Execute the current task
  78428. * @param scene defines the scene where you want your assets to be loaded
  78429. * @param onSuccess is a callback called when the task is successfully executed
  78430. * @param onError is a callback called if an error occurs
  78431. */
  78432. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78433. }
  78434. /**
  78435. * Define a task used by AssetsManager to load meshes
  78436. */
  78437. export class MeshAssetTask extends AbstractAssetTask {
  78438. /**
  78439. * Defines the name of the task
  78440. */
  78441. name: string;
  78442. /**
  78443. * Defines the list of mesh's names you want to load
  78444. */
  78445. meshesNames: any;
  78446. /**
  78447. * Defines the root url to use as a base to load your meshes and associated resources
  78448. */
  78449. rootUrl: string;
  78450. /**
  78451. * Defines the filename or File of the scene to load from
  78452. */
  78453. sceneFilename: string | File;
  78454. /**
  78455. * Gets the list of loaded meshes
  78456. */
  78457. loadedMeshes: Array<AbstractMesh>;
  78458. /**
  78459. * Gets the list of loaded particle systems
  78460. */
  78461. loadedParticleSystems: Array<IParticleSystem>;
  78462. /**
  78463. * Gets the list of loaded skeletons
  78464. */
  78465. loadedSkeletons: Array<Skeleton>;
  78466. /**
  78467. * Gets the list of loaded animation groups
  78468. */
  78469. loadedAnimationGroups: Array<AnimationGroup>;
  78470. /**
  78471. * Callback called when the task is successful
  78472. */
  78473. onSuccess: (task: MeshAssetTask) => void;
  78474. /**
  78475. * Callback called when the task is successful
  78476. */
  78477. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78478. /**
  78479. * Creates a new MeshAssetTask
  78480. * @param name defines the name of the task
  78481. * @param meshesNames defines the list of mesh's names you want to load
  78482. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78483. * @param sceneFilename defines the filename or File of the scene to load from
  78484. */
  78485. constructor(
  78486. /**
  78487. * Defines the name of the task
  78488. */
  78489. name: string,
  78490. /**
  78491. * Defines the list of mesh's names you want to load
  78492. */
  78493. meshesNames: any,
  78494. /**
  78495. * Defines the root url to use as a base to load your meshes and associated resources
  78496. */
  78497. rootUrl: string,
  78498. /**
  78499. * Defines the filename or File of the scene to load from
  78500. */
  78501. sceneFilename: string | File);
  78502. /**
  78503. * Execute the current task
  78504. * @param scene defines the scene where you want your assets to be loaded
  78505. * @param onSuccess is a callback called when the task is successfully executed
  78506. * @param onError is a callback called if an error occurs
  78507. */
  78508. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78509. }
  78510. /**
  78511. * Define a task used by AssetsManager to load text content
  78512. */
  78513. export class TextFileAssetTask extends AbstractAssetTask {
  78514. /**
  78515. * Defines the name of the task
  78516. */
  78517. name: string;
  78518. /**
  78519. * Defines the location of the file to load
  78520. */
  78521. url: string;
  78522. /**
  78523. * Gets the loaded text string
  78524. */
  78525. text: string;
  78526. /**
  78527. * Callback called when the task is successful
  78528. */
  78529. onSuccess: (task: TextFileAssetTask) => void;
  78530. /**
  78531. * Callback called when the task is successful
  78532. */
  78533. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78534. /**
  78535. * Creates a new TextFileAssetTask object
  78536. * @param name defines the name of the task
  78537. * @param url defines the location of the file to load
  78538. */
  78539. constructor(
  78540. /**
  78541. * Defines the name of the task
  78542. */
  78543. name: string,
  78544. /**
  78545. * Defines the location of the file to load
  78546. */
  78547. url: string);
  78548. /**
  78549. * Execute the current task
  78550. * @param scene defines the scene where you want your assets to be loaded
  78551. * @param onSuccess is a callback called when the task is successfully executed
  78552. * @param onError is a callback called if an error occurs
  78553. */
  78554. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78555. }
  78556. /**
  78557. * Define a task used by AssetsManager to load binary data
  78558. */
  78559. export class BinaryFileAssetTask extends AbstractAssetTask {
  78560. /**
  78561. * Defines the name of the task
  78562. */
  78563. name: string;
  78564. /**
  78565. * Defines the location of the file to load
  78566. */
  78567. url: string;
  78568. /**
  78569. * Gets the lodaded data (as an array buffer)
  78570. */
  78571. data: ArrayBuffer;
  78572. /**
  78573. * Callback called when the task is successful
  78574. */
  78575. onSuccess: (task: BinaryFileAssetTask) => void;
  78576. /**
  78577. * Callback called when the task is successful
  78578. */
  78579. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78580. /**
  78581. * Creates a new BinaryFileAssetTask object
  78582. * @param name defines the name of the new task
  78583. * @param url defines the location of the file to load
  78584. */
  78585. constructor(
  78586. /**
  78587. * Defines the name of the task
  78588. */
  78589. name: string,
  78590. /**
  78591. * Defines the location of the file to load
  78592. */
  78593. url: string);
  78594. /**
  78595. * Execute the current task
  78596. * @param scene defines the scene where you want your assets to be loaded
  78597. * @param onSuccess is a callback called when the task is successfully executed
  78598. * @param onError is a callback called if an error occurs
  78599. */
  78600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78601. }
  78602. /**
  78603. * Define a task used by AssetsManager to load images
  78604. */
  78605. export class ImageAssetTask extends AbstractAssetTask {
  78606. /**
  78607. * Defines the name of the task
  78608. */
  78609. name: string;
  78610. /**
  78611. * Defines the location of the image to load
  78612. */
  78613. url: string;
  78614. /**
  78615. * Gets the loaded images
  78616. */
  78617. image: HTMLImageElement;
  78618. /**
  78619. * Callback called when the task is successful
  78620. */
  78621. onSuccess: (task: ImageAssetTask) => void;
  78622. /**
  78623. * Callback called when the task is successful
  78624. */
  78625. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78626. /**
  78627. * Creates a new ImageAssetTask
  78628. * @param name defines the name of the task
  78629. * @param url defines the location of the image to load
  78630. */
  78631. constructor(
  78632. /**
  78633. * Defines the name of the task
  78634. */
  78635. name: string,
  78636. /**
  78637. * Defines the location of the image to load
  78638. */
  78639. url: string);
  78640. /**
  78641. * Execute the current task
  78642. * @param scene defines the scene where you want your assets to be loaded
  78643. * @param onSuccess is a callback called when the task is successfully executed
  78644. * @param onError is a callback called if an error occurs
  78645. */
  78646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78647. }
  78648. /**
  78649. * Defines the interface used by texture loading tasks
  78650. */
  78651. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78652. /**
  78653. * Gets the loaded texture
  78654. */
  78655. texture: TEX;
  78656. }
  78657. /**
  78658. * Define a task used by AssetsManager to load 2D textures
  78659. */
  78660. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78661. /**
  78662. * Defines the name of the task
  78663. */
  78664. name: string;
  78665. /**
  78666. * Defines the location of the file to load
  78667. */
  78668. url: string;
  78669. /**
  78670. * Defines if mipmap should not be generated (default is false)
  78671. */
  78672. noMipmap?: boolean | undefined;
  78673. /**
  78674. * Defines if texture must be inverted on Y axis (default is true)
  78675. */
  78676. invertY: boolean;
  78677. /**
  78678. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78679. */
  78680. samplingMode: number;
  78681. /**
  78682. * Gets the loaded texture
  78683. */
  78684. texture: Texture;
  78685. /**
  78686. * Callback called when the task is successful
  78687. */
  78688. onSuccess: (task: TextureAssetTask) => void;
  78689. /**
  78690. * Callback called when the task is successful
  78691. */
  78692. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78693. /**
  78694. * Creates a new TextureAssetTask object
  78695. * @param name defines the name of the task
  78696. * @param url defines the location of the file to load
  78697. * @param noMipmap defines if mipmap should not be generated (default is false)
  78698. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78699. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78700. */
  78701. constructor(
  78702. /**
  78703. * Defines the name of the task
  78704. */
  78705. name: string,
  78706. /**
  78707. * Defines the location of the file to load
  78708. */
  78709. url: string,
  78710. /**
  78711. * Defines if mipmap should not be generated (default is false)
  78712. */
  78713. noMipmap?: boolean | undefined,
  78714. /**
  78715. * Defines if texture must be inverted on Y axis (default is true)
  78716. */
  78717. invertY?: boolean,
  78718. /**
  78719. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78720. */
  78721. samplingMode?: number);
  78722. /**
  78723. * Execute the current task
  78724. * @param scene defines the scene where you want your assets to be loaded
  78725. * @param onSuccess is a callback called when the task is successfully executed
  78726. * @param onError is a callback called if an error occurs
  78727. */
  78728. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78729. }
  78730. /**
  78731. * Define a task used by AssetsManager to load cube textures
  78732. */
  78733. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78734. /**
  78735. * Defines the name of the task
  78736. */
  78737. name: string;
  78738. /**
  78739. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78740. */
  78741. url: string;
  78742. /**
  78743. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78744. */
  78745. extensions?: string[] | undefined;
  78746. /**
  78747. * Defines if mipmaps should not be generated (default is false)
  78748. */
  78749. noMipmap?: boolean | undefined;
  78750. /**
  78751. * Defines the explicit list of files (undefined by default)
  78752. */
  78753. files?: string[] | undefined;
  78754. /**
  78755. * Gets the loaded texture
  78756. */
  78757. texture: CubeTexture;
  78758. /**
  78759. * Callback called when the task is successful
  78760. */
  78761. onSuccess: (task: CubeTextureAssetTask) => void;
  78762. /**
  78763. * Callback called when the task is successful
  78764. */
  78765. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78766. /**
  78767. * Creates a new CubeTextureAssetTask
  78768. * @param name defines the name of the task
  78769. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78770. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78771. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78772. * @param files defines the explicit list of files (undefined by default)
  78773. */
  78774. constructor(
  78775. /**
  78776. * Defines the name of the task
  78777. */
  78778. name: string,
  78779. /**
  78780. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78781. */
  78782. url: string,
  78783. /**
  78784. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78785. */
  78786. extensions?: string[] | undefined,
  78787. /**
  78788. * Defines if mipmaps should not be generated (default is false)
  78789. */
  78790. noMipmap?: boolean | undefined,
  78791. /**
  78792. * Defines the explicit list of files (undefined by default)
  78793. */
  78794. files?: string[] | undefined);
  78795. /**
  78796. * Execute the current task
  78797. * @param scene defines the scene where you want your assets to be loaded
  78798. * @param onSuccess is a callback called when the task is successfully executed
  78799. * @param onError is a callback called if an error occurs
  78800. */
  78801. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78802. }
  78803. /**
  78804. * Define a task used by AssetsManager to load HDR cube textures
  78805. */
  78806. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78807. /**
  78808. * Defines the name of the task
  78809. */
  78810. name: string;
  78811. /**
  78812. * Defines the location of the file to load
  78813. */
  78814. url: string;
  78815. /**
  78816. * Defines the desired size (the more it increases the longer the generation will be)
  78817. */
  78818. size: number;
  78819. /**
  78820. * Defines if mipmaps should not be generated (default is false)
  78821. */
  78822. noMipmap: boolean;
  78823. /**
  78824. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78825. */
  78826. generateHarmonics: boolean;
  78827. /**
  78828. * 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)
  78829. */
  78830. gammaSpace: boolean;
  78831. /**
  78832. * Internal Use Only
  78833. */
  78834. reserved: boolean;
  78835. /**
  78836. * Gets the loaded texture
  78837. */
  78838. texture: HDRCubeTexture;
  78839. /**
  78840. * Callback called when the task is successful
  78841. */
  78842. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78843. /**
  78844. * Callback called when the task is successful
  78845. */
  78846. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78847. /**
  78848. * Creates a new HDRCubeTextureAssetTask object
  78849. * @param name defines the name of the task
  78850. * @param url defines the location of the file to load
  78851. * @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.
  78852. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78853. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78854. * @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)
  78855. * @param reserved Internal use only
  78856. */
  78857. constructor(
  78858. /**
  78859. * Defines the name of the task
  78860. */
  78861. name: string,
  78862. /**
  78863. * Defines the location of the file to load
  78864. */
  78865. url: string,
  78866. /**
  78867. * Defines the desired size (the more it increases the longer the generation will be)
  78868. */
  78869. size: number,
  78870. /**
  78871. * Defines if mipmaps should not be generated (default is false)
  78872. */
  78873. noMipmap?: boolean,
  78874. /**
  78875. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78876. */
  78877. generateHarmonics?: boolean,
  78878. /**
  78879. * 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)
  78880. */
  78881. gammaSpace?: boolean,
  78882. /**
  78883. * Internal Use Only
  78884. */
  78885. reserved?: boolean);
  78886. /**
  78887. * Execute the current task
  78888. * @param scene defines the scene where you want your assets to be loaded
  78889. * @param onSuccess is a callback called when the task is successfully executed
  78890. * @param onError is a callback called if an error occurs
  78891. */
  78892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78893. }
  78894. /**
  78895. * Define a task used by AssetsManager to load Equirectangular cube textures
  78896. */
  78897. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78898. /**
  78899. * Defines the name of the task
  78900. */
  78901. name: string;
  78902. /**
  78903. * Defines the location of the file to load
  78904. */
  78905. url: string;
  78906. /**
  78907. * Defines the desired size (the more it increases the longer the generation will be)
  78908. */
  78909. size: number;
  78910. /**
  78911. * Defines if mipmaps should not be generated (default is false)
  78912. */
  78913. noMipmap: boolean;
  78914. /**
  78915. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78916. * but the standard material would require them in Gamma space) (default is true)
  78917. */
  78918. gammaSpace: boolean;
  78919. /**
  78920. * Gets the loaded texture
  78921. */
  78922. texture: EquiRectangularCubeTexture;
  78923. /**
  78924. * Callback called when the task is successful
  78925. */
  78926. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78927. /**
  78928. * Callback called when the task is successful
  78929. */
  78930. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78931. /**
  78932. * Creates a new EquiRectangularCubeTextureAssetTask object
  78933. * @param name defines the name of the task
  78934. * @param url defines the location of the file to load
  78935. * @param size defines the desired size (the more it increases the longer the generation will be)
  78936. * If the size is omitted this implies you are using a preprocessed cubemap.
  78937. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78938. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78939. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78940. * (default is true)
  78941. */
  78942. constructor(
  78943. /**
  78944. * Defines the name of the task
  78945. */
  78946. name: string,
  78947. /**
  78948. * Defines the location of the file to load
  78949. */
  78950. url: string,
  78951. /**
  78952. * Defines the desired size (the more it increases the longer the generation will be)
  78953. */
  78954. size: number,
  78955. /**
  78956. * Defines if mipmaps should not be generated (default is false)
  78957. */
  78958. noMipmap?: boolean,
  78959. /**
  78960. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78961. * but the standard material would require them in Gamma space) (default is true)
  78962. */
  78963. gammaSpace?: boolean);
  78964. /**
  78965. * Execute the current task
  78966. * @param scene defines the scene where you want your assets to be loaded
  78967. * @param onSuccess is a callback called when the task is successfully executed
  78968. * @param onError is a callback called if an error occurs
  78969. */
  78970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78971. }
  78972. /**
  78973. * This class can be used to easily import assets into a scene
  78974. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78975. */
  78976. export class AssetsManager {
  78977. private _scene;
  78978. private _isLoading;
  78979. protected _tasks: AbstractAssetTask[];
  78980. protected _waitingTasksCount: number;
  78981. protected _totalTasksCount: number;
  78982. /**
  78983. * Callback called when all tasks are processed
  78984. */
  78985. onFinish: (tasks: AbstractAssetTask[]) => void;
  78986. /**
  78987. * Callback called when a task is successful
  78988. */
  78989. onTaskSuccess: (task: AbstractAssetTask) => void;
  78990. /**
  78991. * Callback called when a task had an error
  78992. */
  78993. onTaskError: (task: AbstractAssetTask) => void;
  78994. /**
  78995. * Callback called when a task is done (whatever the result is)
  78996. */
  78997. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78998. /**
  78999. * Observable called when all tasks are processed
  79000. */
  79001. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  79002. /**
  79003. * Observable called when a task had an error
  79004. */
  79005. onTaskErrorObservable: Observable<AbstractAssetTask>;
  79006. /**
  79007. * Observable called when all tasks were executed
  79008. */
  79009. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  79010. /**
  79011. * Observable called when a task is done (whatever the result is)
  79012. */
  79013. onProgressObservable: Observable<IAssetsProgressEvent>;
  79014. /**
  79015. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  79016. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  79017. */
  79018. useDefaultLoadingScreen: boolean;
  79019. /**
  79020. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  79021. * when all assets have been downloaded.
  79022. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  79023. */
  79024. autoHideLoadingUI: boolean;
  79025. /**
  79026. * Creates a new AssetsManager
  79027. * @param scene defines the scene to work on
  79028. */
  79029. constructor(scene: Scene);
  79030. /**
  79031. * Add a ContainerAssetTask to the list of active tasks
  79032. * @param taskName defines the name of the new task
  79033. * @param meshesNames defines the name of meshes to load
  79034. * @param rootUrl defines the root url to use to locate files
  79035. * @param sceneFilename defines the filename of the scene file
  79036. * @returns a new ContainerAssetTask object
  79037. */
  79038. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  79039. /**
  79040. * Add a MeshAssetTask to the list of active tasks
  79041. * @param taskName defines the name of the new task
  79042. * @param meshesNames defines the name of meshes to load
  79043. * @param rootUrl defines the root url to use to locate files
  79044. * @param sceneFilename defines the filename of the scene file
  79045. * @returns a new MeshAssetTask object
  79046. */
  79047. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  79048. /**
  79049. * Add a TextFileAssetTask to the list of active tasks
  79050. * @param taskName defines the name of the new task
  79051. * @param url defines the url of the file to load
  79052. * @returns a new TextFileAssetTask object
  79053. */
  79054. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  79055. /**
  79056. * Add a BinaryFileAssetTask to the list of active tasks
  79057. * @param taskName defines the name of the new task
  79058. * @param url defines the url of the file to load
  79059. * @returns a new BinaryFileAssetTask object
  79060. */
  79061. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  79062. /**
  79063. * Add a ImageAssetTask to the list of active tasks
  79064. * @param taskName defines the name of the new task
  79065. * @param url defines the url of the file to load
  79066. * @returns a new ImageAssetTask object
  79067. */
  79068. addImageTask(taskName: string, url: string): ImageAssetTask;
  79069. /**
  79070. * Add a TextureAssetTask to the list of active tasks
  79071. * @param taskName defines the name of the new task
  79072. * @param url defines the url of the file to load
  79073. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79074. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  79075. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  79076. * @returns a new TextureAssetTask object
  79077. */
  79078. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  79079. /**
  79080. * Add a CubeTextureAssetTask to the list of active tasks
  79081. * @param taskName defines the name of the new task
  79082. * @param url defines the url of the file to load
  79083. * @param extensions defines the extension to use to load the cube map (can be null)
  79084. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79085. * @param files defines the list of files to load (can be null)
  79086. * @returns a new CubeTextureAssetTask object
  79087. */
  79088. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  79089. /**
  79090. *
  79091. * Add a HDRCubeTextureAssetTask to the list of active tasks
  79092. * @param taskName defines the name of the new task
  79093. * @param url defines the url of the file to load
  79094. * @param size defines the size you want for the cubemap (can be null)
  79095. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79096. * @param generateHarmonics defines if you want to automatically generate (true by default)
  79097. * @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)
  79098. * @param reserved Internal use only
  79099. * @returns a new HDRCubeTextureAssetTask object
  79100. */
  79101. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  79102. /**
  79103. *
  79104. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  79105. * @param taskName defines the name of the new task
  79106. * @param url defines the url of the file to load
  79107. * @param size defines the size you want for the cubemap (can be null)
  79108. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79109. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  79110. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  79111. * @returns a new EquiRectangularCubeTextureAssetTask object
  79112. */
  79113. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  79114. /**
  79115. * Remove a task from the assets manager.
  79116. * @param task the task to remove
  79117. */
  79118. removeTask(task: AbstractAssetTask): void;
  79119. private _decreaseWaitingTasksCount;
  79120. private _runTask;
  79121. /**
  79122. * Reset the AssetsManager and remove all tasks
  79123. * @return the current instance of the AssetsManager
  79124. */
  79125. reset(): AssetsManager;
  79126. /**
  79127. * Start the loading process
  79128. * @return the current instance of the AssetsManager
  79129. */
  79130. load(): AssetsManager;
  79131. /**
  79132. * Start the loading process as an async operation
  79133. * @return a promise returning the list of failed tasks
  79134. */
  79135. loadAsync(): Promise<void>;
  79136. }
  79137. }
  79138. declare module "babylonjs/Misc/deferred" {
  79139. /**
  79140. * Wrapper class for promise with external resolve and reject.
  79141. */
  79142. export class Deferred<T> {
  79143. /**
  79144. * The promise associated with this deferred object.
  79145. */
  79146. readonly promise: Promise<T>;
  79147. private _resolve;
  79148. private _reject;
  79149. /**
  79150. * The resolve method of the promise associated with this deferred object.
  79151. */
  79152. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  79153. /**
  79154. * The reject method of the promise associated with this deferred object.
  79155. */
  79156. get reject(): (reason?: any) => void;
  79157. /**
  79158. * Constructor for this deferred object.
  79159. */
  79160. constructor();
  79161. }
  79162. }
  79163. declare module "babylonjs/Misc/meshExploder" {
  79164. import { Mesh } from "babylonjs/Meshes/mesh";
  79165. /**
  79166. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  79167. */
  79168. export class MeshExploder {
  79169. private _centerMesh;
  79170. private _meshes;
  79171. private _meshesOrigins;
  79172. private _toCenterVectors;
  79173. private _scaledDirection;
  79174. private _newPosition;
  79175. private _centerPosition;
  79176. /**
  79177. * Explodes meshes from a center mesh.
  79178. * @param meshes The meshes to explode.
  79179. * @param centerMesh The mesh to be center of explosion.
  79180. */
  79181. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  79182. private _setCenterMesh;
  79183. /**
  79184. * Get class name
  79185. * @returns "MeshExploder"
  79186. */
  79187. getClassName(): string;
  79188. /**
  79189. * "Exploded meshes"
  79190. * @returns Array of meshes with the centerMesh at index 0.
  79191. */
  79192. getMeshes(): Array<Mesh>;
  79193. /**
  79194. * Explodes meshes giving a specific direction
  79195. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  79196. */
  79197. explode(direction?: number): void;
  79198. }
  79199. }
  79200. declare module "babylonjs/Misc/filesInput" {
  79201. import { Engine } from "babylonjs/Engines/engine";
  79202. import { Scene } from "babylonjs/scene";
  79203. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  79204. import { Nullable } from "babylonjs/types";
  79205. /**
  79206. * Class used to help managing file picking and drag'n'drop
  79207. */
  79208. export class FilesInput {
  79209. /**
  79210. * List of files ready to be loaded
  79211. */
  79212. static get FilesToLoad(): {
  79213. [key: string]: File;
  79214. };
  79215. /**
  79216. * Callback called when a file is processed
  79217. */
  79218. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  79219. private _engine;
  79220. private _currentScene;
  79221. private _sceneLoadedCallback;
  79222. private _progressCallback;
  79223. private _additionalRenderLoopLogicCallback;
  79224. private _textureLoadingCallback;
  79225. private _startingProcessingFilesCallback;
  79226. private _onReloadCallback;
  79227. private _errorCallback;
  79228. private _elementToMonitor;
  79229. private _sceneFileToLoad;
  79230. private _filesToLoad;
  79231. /**
  79232. * Creates a new FilesInput
  79233. * @param engine defines the rendering engine
  79234. * @param scene defines the hosting scene
  79235. * @param sceneLoadedCallback callback called when scene is loaded
  79236. * @param progressCallback callback called to track progress
  79237. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  79238. * @param textureLoadingCallback callback called when a texture is loading
  79239. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  79240. * @param onReloadCallback callback called when a reload is requested
  79241. * @param errorCallback callback call if an error occurs
  79242. */
  79243. 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>);
  79244. private _dragEnterHandler;
  79245. private _dragOverHandler;
  79246. private _dropHandler;
  79247. /**
  79248. * Calls this function to listen to drag'n'drop events on a specific DOM element
  79249. * @param elementToMonitor defines the DOM element to track
  79250. */
  79251. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  79252. /** Gets the current list of files to load */
  79253. get filesToLoad(): File[];
  79254. /**
  79255. * Release all associated resources
  79256. */
  79257. dispose(): void;
  79258. private renderFunction;
  79259. private drag;
  79260. private drop;
  79261. private _traverseFolder;
  79262. private _processFiles;
  79263. /**
  79264. * Load files from a drop event
  79265. * @param event defines the drop event to use as source
  79266. */
  79267. loadFiles(event: any): void;
  79268. private _processReload;
  79269. /**
  79270. * Reload the current scene from the loaded files
  79271. */
  79272. reload(): void;
  79273. }
  79274. }
  79275. declare module "babylonjs/Misc/HighDynamicRange/index" {
  79276. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  79277. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  79278. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  79279. }
  79280. declare module "babylonjs/Misc/sceneOptimizer" {
  79281. import { Scene, IDisposable } from "babylonjs/scene";
  79282. import { Observable } from "babylonjs/Misc/observable";
  79283. /**
  79284. * Defines the root class used to create scene optimization to use with SceneOptimizer
  79285. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79286. */
  79287. export class SceneOptimization {
  79288. /**
  79289. * Defines the priority of this optimization (0 by default which means first in the list)
  79290. */
  79291. priority: number;
  79292. /**
  79293. * Gets a string describing the action executed by the current optimization
  79294. * @returns description string
  79295. */
  79296. getDescription(): string;
  79297. /**
  79298. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79299. * @param scene defines the current scene where to apply this optimization
  79300. * @param optimizer defines the current optimizer
  79301. * @returns true if everything that can be done was applied
  79302. */
  79303. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79304. /**
  79305. * Creates the SceneOptimization object
  79306. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79307. * @param desc defines the description associated with the optimization
  79308. */
  79309. constructor(
  79310. /**
  79311. * Defines the priority of this optimization (0 by default which means first in the list)
  79312. */
  79313. priority?: number);
  79314. }
  79315. /**
  79316. * Defines an optimization used to reduce the size of render target textures
  79317. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79318. */
  79319. export class TextureOptimization extends SceneOptimization {
  79320. /**
  79321. * Defines the priority of this optimization (0 by default which means first in the list)
  79322. */
  79323. priority: number;
  79324. /**
  79325. * 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
  79326. */
  79327. maximumSize: number;
  79328. /**
  79329. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79330. */
  79331. step: number;
  79332. /**
  79333. * Gets a string describing the action executed by the current optimization
  79334. * @returns description string
  79335. */
  79336. getDescription(): string;
  79337. /**
  79338. * Creates the TextureOptimization object
  79339. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79340. * @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
  79341. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79342. */
  79343. constructor(
  79344. /**
  79345. * Defines the priority of this optimization (0 by default which means first in the list)
  79346. */
  79347. priority?: number,
  79348. /**
  79349. * 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
  79350. */
  79351. maximumSize?: number,
  79352. /**
  79353. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79354. */
  79355. step?: number);
  79356. /**
  79357. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79358. * @param scene defines the current scene where to apply this optimization
  79359. * @param optimizer defines the current optimizer
  79360. * @returns true if everything that can be done was applied
  79361. */
  79362. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79363. }
  79364. /**
  79365. * Defines an optimization used to increase or decrease the rendering resolution
  79366. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79367. */
  79368. export class HardwareScalingOptimization extends SceneOptimization {
  79369. /**
  79370. * Defines the priority of this optimization (0 by default which means first in the list)
  79371. */
  79372. priority: number;
  79373. /**
  79374. * Defines the maximum scale to use (2 by default)
  79375. */
  79376. maximumScale: number;
  79377. /**
  79378. * Defines the step to use between two passes (0.5 by default)
  79379. */
  79380. step: number;
  79381. private _currentScale;
  79382. private _directionOffset;
  79383. /**
  79384. * Gets a string describing the action executed by the current optimization
  79385. * @return description string
  79386. */
  79387. getDescription(): string;
  79388. /**
  79389. * Creates the HardwareScalingOptimization object
  79390. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79391. * @param maximumScale defines the maximum scale to use (2 by default)
  79392. * @param step defines the step to use between two passes (0.5 by default)
  79393. */
  79394. constructor(
  79395. /**
  79396. * Defines the priority of this optimization (0 by default which means first in the list)
  79397. */
  79398. priority?: number,
  79399. /**
  79400. * Defines the maximum scale to use (2 by default)
  79401. */
  79402. maximumScale?: number,
  79403. /**
  79404. * Defines the step to use between two passes (0.5 by default)
  79405. */
  79406. step?: number);
  79407. /**
  79408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79409. * @param scene defines the current scene where to apply this optimization
  79410. * @param optimizer defines the current optimizer
  79411. * @returns true if everything that can be done was applied
  79412. */
  79413. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79414. }
  79415. /**
  79416. * Defines an optimization used to remove shadows
  79417. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79418. */
  79419. export class ShadowsOptimization extends SceneOptimization {
  79420. /**
  79421. * Gets a string describing the action executed by the current optimization
  79422. * @return description string
  79423. */
  79424. getDescription(): string;
  79425. /**
  79426. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79427. * @param scene defines the current scene where to apply this optimization
  79428. * @param optimizer defines the current optimizer
  79429. * @returns true if everything that can be done was applied
  79430. */
  79431. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79432. }
  79433. /**
  79434. * Defines an optimization used to turn post-processes off
  79435. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79436. */
  79437. export class PostProcessesOptimization extends SceneOptimization {
  79438. /**
  79439. * Gets a string describing the action executed by the current optimization
  79440. * @return description string
  79441. */
  79442. getDescription(): string;
  79443. /**
  79444. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79445. * @param scene defines the current scene where to apply this optimization
  79446. * @param optimizer defines the current optimizer
  79447. * @returns true if everything that can be done was applied
  79448. */
  79449. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79450. }
  79451. /**
  79452. * Defines an optimization used to turn lens flares off
  79453. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79454. */
  79455. export class LensFlaresOptimization extends SceneOptimization {
  79456. /**
  79457. * Gets a string describing the action executed by the current optimization
  79458. * @return description string
  79459. */
  79460. getDescription(): string;
  79461. /**
  79462. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79463. * @param scene defines the current scene where to apply this optimization
  79464. * @param optimizer defines the current optimizer
  79465. * @returns true if everything that can be done was applied
  79466. */
  79467. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79468. }
  79469. /**
  79470. * Defines an optimization based on user defined callback.
  79471. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79472. */
  79473. export class CustomOptimization extends SceneOptimization {
  79474. /**
  79475. * Callback called to apply the custom optimization.
  79476. */
  79477. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79478. /**
  79479. * Callback called to get custom description
  79480. */
  79481. onGetDescription: () => string;
  79482. /**
  79483. * Gets a string describing the action executed by the current optimization
  79484. * @returns description string
  79485. */
  79486. getDescription(): string;
  79487. /**
  79488. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79489. * @param scene defines the current scene where to apply this optimization
  79490. * @param optimizer defines the current optimizer
  79491. * @returns true if everything that can be done was applied
  79492. */
  79493. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79494. }
  79495. /**
  79496. * Defines an optimization used to turn particles off
  79497. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79498. */
  79499. export class ParticlesOptimization extends SceneOptimization {
  79500. /**
  79501. * Gets a string describing the action executed by the current optimization
  79502. * @return description string
  79503. */
  79504. getDescription(): string;
  79505. /**
  79506. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79507. * @param scene defines the current scene where to apply this optimization
  79508. * @param optimizer defines the current optimizer
  79509. * @returns true if everything that can be done was applied
  79510. */
  79511. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79512. }
  79513. /**
  79514. * Defines an optimization used to turn render targets off
  79515. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79516. */
  79517. export class RenderTargetsOptimization extends SceneOptimization {
  79518. /**
  79519. * Gets a string describing the action executed by the current optimization
  79520. * @return description string
  79521. */
  79522. getDescription(): string;
  79523. /**
  79524. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79525. * @param scene defines the current scene where to apply this optimization
  79526. * @param optimizer defines the current optimizer
  79527. * @returns true if everything that can be done was applied
  79528. */
  79529. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79530. }
  79531. /**
  79532. * Defines an optimization used to merge meshes with compatible materials
  79533. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79534. */
  79535. export class MergeMeshesOptimization extends SceneOptimization {
  79536. private static _UpdateSelectionTree;
  79537. /**
  79538. * Gets or sets a boolean which defines if optimization octree has to be updated
  79539. */
  79540. static get UpdateSelectionTree(): boolean;
  79541. /**
  79542. * Gets or sets a boolean which defines if optimization octree has to be updated
  79543. */
  79544. static set UpdateSelectionTree(value: boolean);
  79545. /**
  79546. * Gets a string describing the action executed by the current optimization
  79547. * @return description string
  79548. */
  79549. getDescription(): string;
  79550. private _canBeMerged;
  79551. /**
  79552. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79553. * @param scene defines the current scene where to apply this optimization
  79554. * @param optimizer defines the current optimizer
  79555. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79556. * @returns true if everything that can be done was applied
  79557. */
  79558. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79559. }
  79560. /**
  79561. * Defines a list of options used by SceneOptimizer
  79562. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79563. */
  79564. export class SceneOptimizerOptions {
  79565. /**
  79566. * Defines the target frame rate to reach (60 by default)
  79567. */
  79568. targetFrameRate: number;
  79569. /**
  79570. * Defines the interval between two checkes (2000ms by default)
  79571. */
  79572. trackerDuration: number;
  79573. /**
  79574. * Gets the list of optimizations to apply
  79575. */
  79576. optimizations: SceneOptimization[];
  79577. /**
  79578. * Creates a new list of options used by SceneOptimizer
  79579. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79580. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  79581. */
  79582. constructor(
  79583. /**
  79584. * Defines the target frame rate to reach (60 by default)
  79585. */
  79586. targetFrameRate?: number,
  79587. /**
  79588. * Defines the interval between two checkes (2000ms by default)
  79589. */
  79590. trackerDuration?: number);
  79591. /**
  79592. * Add a new optimization
  79593. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79594. * @returns the current SceneOptimizerOptions
  79595. */
  79596. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79597. /**
  79598. * Add a new custom optimization
  79599. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79600. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79601. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79602. * @returns the current SceneOptimizerOptions
  79603. */
  79604. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79605. /**
  79606. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79607. * @param targetFrameRate defines the target frame rate (60 by default)
  79608. * @returns a SceneOptimizerOptions object
  79609. */
  79610. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79611. /**
  79612. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79613. * @param targetFrameRate defines the target frame rate (60 by default)
  79614. * @returns a SceneOptimizerOptions object
  79615. */
  79616. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79617. /**
  79618. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79619. * @param targetFrameRate defines the target frame rate (60 by default)
  79620. * @returns a SceneOptimizerOptions object
  79621. */
  79622. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79623. }
  79624. /**
  79625. * Class used to run optimizations in order to reach a target frame rate
  79626. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79627. */
  79628. export class SceneOptimizer implements IDisposable {
  79629. private _isRunning;
  79630. private _options;
  79631. private _scene;
  79632. private _currentPriorityLevel;
  79633. private _targetFrameRate;
  79634. private _trackerDuration;
  79635. private _currentFrameRate;
  79636. private _sceneDisposeObserver;
  79637. private _improvementMode;
  79638. /**
  79639. * Defines an observable called when the optimizer reaches the target frame rate
  79640. */
  79641. onSuccessObservable: Observable<SceneOptimizer>;
  79642. /**
  79643. * Defines an observable called when the optimizer enables an optimization
  79644. */
  79645. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79646. /**
  79647. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79648. */
  79649. onFailureObservable: Observable<SceneOptimizer>;
  79650. /**
  79651. * Gets a boolean indicating if the optimizer is in improvement mode
  79652. */
  79653. get isInImprovementMode(): boolean;
  79654. /**
  79655. * Gets the current priority level (0 at start)
  79656. */
  79657. get currentPriorityLevel(): number;
  79658. /**
  79659. * Gets the current frame rate checked by the SceneOptimizer
  79660. */
  79661. get currentFrameRate(): number;
  79662. /**
  79663. * Gets or sets the current target frame rate (60 by default)
  79664. */
  79665. get targetFrameRate(): number;
  79666. /**
  79667. * Gets or sets the current target frame rate (60 by default)
  79668. */
  79669. set targetFrameRate(value: number);
  79670. /**
  79671. * Gets or sets the current interval between two checks (every 2000ms by default)
  79672. */
  79673. get trackerDuration(): number;
  79674. /**
  79675. * Gets or sets the current interval between two checks (every 2000ms by default)
  79676. */
  79677. set trackerDuration(value: number);
  79678. /**
  79679. * Gets the list of active optimizations
  79680. */
  79681. get optimizations(): SceneOptimization[];
  79682. /**
  79683. * Creates a new SceneOptimizer
  79684. * @param scene defines the scene to work on
  79685. * @param options defines the options to use with the SceneOptimizer
  79686. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79687. * @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)
  79688. */
  79689. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79690. /**
  79691. * Stops the current optimizer
  79692. */
  79693. stop(): void;
  79694. /**
  79695. * Reset the optimizer to initial step (current priority level = 0)
  79696. */
  79697. reset(): void;
  79698. /**
  79699. * Start the optimizer. By default it will try to reach a specific framerate
  79700. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  79701. */
  79702. start(): void;
  79703. private _checkCurrentState;
  79704. /**
  79705. * Release all resources
  79706. */
  79707. dispose(): void;
  79708. /**
  79709. * Helper function to create a SceneOptimizer with one single line of code
  79710. * @param scene defines the scene to work on
  79711. * @param options defines the options to use with the SceneOptimizer
  79712. * @param onSuccess defines a callback to call on success
  79713. * @param onFailure defines a callback to call on failure
  79714. * @returns the new SceneOptimizer object
  79715. */
  79716. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79717. }
  79718. }
  79719. declare module "babylonjs/Misc/sceneSerializer" {
  79720. import { Scene } from "babylonjs/scene";
  79721. /**
  79722. * Class used to serialize a scene into a string
  79723. */
  79724. export class SceneSerializer {
  79725. /**
  79726. * Clear cache used by a previous serialization
  79727. */
  79728. static ClearCache(): void;
  79729. /**
  79730. * Serialize a scene into a JSON compatible object
  79731. * @param scene defines the scene to serialize
  79732. * @returns a JSON compatible object
  79733. */
  79734. static Serialize(scene: Scene): any;
  79735. /**
  79736. * Serialize a mesh into a JSON compatible object
  79737. * @param toSerialize defines the mesh to serialize
  79738. * @param withParents defines if parents must be serialized as well
  79739. * @param withChildren defines if children must be serialized as well
  79740. * @returns a JSON compatible object
  79741. */
  79742. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79743. }
  79744. }
  79745. declare module "babylonjs/Misc/textureTools" {
  79746. import { Texture } from "babylonjs/Materials/Textures/texture";
  79747. /**
  79748. * Class used to host texture specific utilities
  79749. */
  79750. export class TextureTools {
  79751. /**
  79752. * Uses the GPU to create a copy texture rescaled at a given size
  79753. * @param texture Texture to copy from
  79754. * @param width defines the desired width
  79755. * @param height defines the desired height
  79756. * @param useBilinearMode defines if bilinear mode has to be used
  79757. * @return the generated texture
  79758. */
  79759. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  79760. }
  79761. }
  79762. declare module "babylonjs/Misc/videoRecorder" {
  79763. import { Nullable } from "babylonjs/types";
  79764. import { Engine } from "babylonjs/Engines/engine";
  79765. /**
  79766. * This represents the different options available for the video capture.
  79767. */
  79768. export interface VideoRecorderOptions {
  79769. /** Defines the mime type of the video. */
  79770. mimeType: string;
  79771. /** Defines the FPS the video should be recorded at. */
  79772. fps: number;
  79773. /** Defines the chunk size for the recording data. */
  79774. recordChunckSize: number;
  79775. /** The audio tracks to attach to the recording. */
  79776. audioTracks?: MediaStreamTrack[];
  79777. }
  79778. /**
  79779. * This can help with recording videos from BabylonJS.
  79780. * This is based on the available WebRTC functionalities of the browser.
  79781. *
  79782. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79783. */
  79784. export class VideoRecorder {
  79785. private static readonly _defaultOptions;
  79786. /**
  79787. * Returns whether or not the VideoRecorder is available in your browser.
  79788. * @param engine Defines the Babylon Engine.
  79789. * @returns true if supported otherwise false.
  79790. */
  79791. static IsSupported(engine: Engine): boolean;
  79792. private readonly _options;
  79793. private _canvas;
  79794. private _mediaRecorder;
  79795. private _recordedChunks;
  79796. private _fileName;
  79797. private _resolve;
  79798. private _reject;
  79799. /**
  79800. * True when a recording is already in progress.
  79801. */
  79802. get isRecording(): boolean;
  79803. /**
  79804. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79805. * @param engine Defines the BabylonJS Engine you wish to record.
  79806. * @param options Defines options that can be used to customize the capture.
  79807. */
  79808. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79809. /**
  79810. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79811. */
  79812. stopRecording(): void;
  79813. /**
  79814. * Starts recording the canvas for a max duration specified in parameters.
  79815. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79816. * If null no automatic download will start and you can rely on the promise to get the data back.
  79817. * @param maxDuration Defines the maximum recording time in seconds.
  79818. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79819. * @return A promise callback at the end of the recording with the video data in Blob.
  79820. */
  79821. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79822. /**
  79823. * Releases internal resources used during the recording.
  79824. */
  79825. dispose(): void;
  79826. private _handleDataAvailable;
  79827. private _handleError;
  79828. private _handleStop;
  79829. }
  79830. }
  79831. declare module "babylonjs/Misc/screenshotTools" {
  79832. import { Camera } from "babylonjs/Cameras/camera";
  79833. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79834. import { Engine } from "babylonjs/Engines/engine";
  79835. /**
  79836. * Class containing a set of static utilities functions for screenshots
  79837. */
  79838. export class ScreenshotTools {
  79839. /**
  79840. * Captures a screenshot of the current rendering
  79841. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79842. * @param engine defines the rendering engine
  79843. * @param camera defines the source camera
  79844. * @param size This parameter can be set to a single number or to an object with the
  79845. * following (optional) properties: precision, width, height. If a single number is passed,
  79846. * it will be used for both width and height. If an object is passed, the screenshot size
  79847. * will be derived from the parameters. The precision property is a multiplier allowing
  79848. * rendering at a higher or lower resolution
  79849. * @param successCallback defines the callback receives a single parameter which contains the
  79850. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79851. * src parameter of an <img> to display it
  79852. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79853. * Check your browser for supported MIME types
  79854. */
  79855. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79856. /**
  79857. * Captures a screenshot of the current rendering
  79858. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79859. * @param engine defines the rendering engine
  79860. * @param camera defines the source camera
  79861. * @param size This parameter can be set to a single number or to an object with the
  79862. * following (optional) properties: precision, width, height. If a single number is passed,
  79863. * it will be used for both width and height. If an object is passed, the screenshot size
  79864. * will be derived from the parameters. The precision property is a multiplier allowing
  79865. * rendering at a higher or lower resolution
  79866. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79867. * Check your browser for supported MIME types
  79868. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79869. * to the src parameter of an <img> to display it
  79870. */
  79871. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79872. /**
  79873. * Generates an image screenshot from the specified camera.
  79874. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79875. * @param engine The engine to use for rendering
  79876. * @param camera The camera to use for rendering
  79877. * @param size This parameter can be set to a single number or to an object with the
  79878. * following (optional) properties: precision, width, height. If a single number is passed,
  79879. * it will be used for both width and height. If an object is passed, the screenshot size
  79880. * will be derived from the parameters. The precision property is a multiplier allowing
  79881. * rendering at a higher or lower resolution
  79882. * @param successCallback The callback receives a single parameter which contains the
  79883. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79884. * src parameter of an <img> to display it
  79885. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79886. * Check your browser for supported MIME types
  79887. * @param samples Texture samples (default: 1)
  79888. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79889. * @param fileName A name for for the downloaded file.
  79890. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79891. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79892. */
  79893. 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;
  79894. /**
  79895. * Generates an image screenshot from the specified camera.
  79896. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79897. * @param engine The engine to use for rendering
  79898. * @param camera The camera to use for rendering
  79899. * @param size This parameter can be set to a single number or to an object with the
  79900. * following (optional) properties: precision, width, height. If a single number is passed,
  79901. * it will be used for both width and height. If an object is passed, the screenshot size
  79902. * will be derived from the parameters. The precision property is a multiplier allowing
  79903. * rendering at a higher or lower resolution
  79904. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79905. * Check your browser for supported MIME types
  79906. * @param samples Texture samples (default: 1)
  79907. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79908. * @param fileName A name for for the downloaded file.
  79909. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79910. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79911. * to the src parameter of an <img> to display it
  79912. */
  79913. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79914. /**
  79915. * Gets height and width for screenshot size
  79916. * @private
  79917. */
  79918. private static _getScreenshotSize;
  79919. }
  79920. }
  79921. declare module "babylonjs/Misc/dataReader" {
  79922. /**
  79923. * Interface for a data buffer
  79924. */
  79925. export interface IDataBuffer {
  79926. /**
  79927. * Reads bytes from the data buffer.
  79928. * @param byteOffset The byte offset to read
  79929. * @param byteLength The byte length to read
  79930. * @returns A promise that resolves when the bytes are read
  79931. */
  79932. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79933. /**
  79934. * The byte length of the buffer.
  79935. */
  79936. readonly byteLength: number;
  79937. }
  79938. /**
  79939. * Utility class for reading from a data buffer
  79940. */
  79941. export class DataReader {
  79942. /**
  79943. * The data buffer associated with this data reader.
  79944. */
  79945. readonly buffer: IDataBuffer;
  79946. /**
  79947. * The current byte offset from the beginning of the data buffer.
  79948. */
  79949. byteOffset: number;
  79950. private _dataView;
  79951. private _dataByteOffset;
  79952. /**
  79953. * Constructor
  79954. * @param buffer The buffer to read
  79955. */
  79956. constructor(buffer: IDataBuffer);
  79957. /**
  79958. * Loads the given byte length.
  79959. * @param byteLength The byte length to load
  79960. * @returns A promise that resolves when the load is complete
  79961. */
  79962. loadAsync(byteLength: number): Promise<void>;
  79963. /**
  79964. * Read a unsigned 32-bit integer from the currently loaded data range.
  79965. * @returns The 32-bit integer read
  79966. */
  79967. readUint32(): number;
  79968. /**
  79969. * Read a byte array from the currently loaded data range.
  79970. * @param byteLength The byte length to read
  79971. * @returns The byte array read
  79972. */
  79973. readUint8Array(byteLength: number): Uint8Array;
  79974. /**
  79975. * Read a string from the currently loaded data range.
  79976. * @param byteLength The byte length to read
  79977. * @returns The string read
  79978. */
  79979. readString(byteLength: number): string;
  79980. /**
  79981. * Skips the given byte length the currently loaded data range.
  79982. * @param byteLength The byte length to skip
  79983. */
  79984. skipBytes(byteLength: number): void;
  79985. }
  79986. }
  79987. declare module "babylonjs/Misc/dataStorage" {
  79988. /**
  79989. * Class for storing data to local storage if available or in-memory storage otherwise
  79990. */
  79991. export class DataStorage {
  79992. private static _Storage;
  79993. private static _GetStorage;
  79994. /**
  79995. * Reads a string from the data storage
  79996. * @param key The key to read
  79997. * @param defaultValue The value if the key doesn't exist
  79998. * @returns The string value
  79999. */
  80000. static ReadString(key: string, defaultValue: string): string;
  80001. /**
  80002. * Writes a string to the data storage
  80003. * @param key The key to write
  80004. * @param value The value to write
  80005. */
  80006. static WriteString(key: string, value: string): void;
  80007. /**
  80008. * Reads a boolean from the data storage
  80009. * @param key The key to read
  80010. * @param defaultValue The value if the key doesn't exist
  80011. * @returns The boolean value
  80012. */
  80013. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  80014. /**
  80015. * Writes a boolean to the data storage
  80016. * @param key The key to write
  80017. * @param value The value to write
  80018. */
  80019. static WriteBoolean(key: string, value: boolean): void;
  80020. /**
  80021. * Reads a number from the data storage
  80022. * @param key The key to read
  80023. * @param defaultValue The value if the key doesn't exist
  80024. * @returns The number value
  80025. */
  80026. static ReadNumber(key: string, defaultValue: number): number;
  80027. /**
  80028. * Writes a number to the data storage
  80029. * @param key The key to write
  80030. * @param value The value to write
  80031. */
  80032. static WriteNumber(key: string, value: number): void;
  80033. }
  80034. }
  80035. declare module "babylonjs/Misc/sceneRecorder" {
  80036. import { Scene } from "babylonjs/scene";
  80037. /**
  80038. * Class used to record delta files between 2 scene states
  80039. */
  80040. export class SceneRecorder {
  80041. private _trackedScene;
  80042. private _savedJSON;
  80043. /**
  80044. * Track a given scene. This means the current scene state will be considered the original state
  80045. * @param scene defines the scene to track
  80046. */
  80047. track(scene: Scene): void;
  80048. /**
  80049. * Get the delta between current state and original state
  80050. * @returns a string containing the delta
  80051. */
  80052. getDelta(): any;
  80053. private _compareArray;
  80054. private _compareObjects;
  80055. private _compareCollections;
  80056. private static GetShadowGeneratorById;
  80057. /**
  80058. * Apply a given delta to a given scene
  80059. * @param deltaJSON defines the JSON containing the delta
  80060. * @param scene defines the scene to apply the delta to
  80061. */
  80062. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  80063. private static _ApplyPropertiesToEntity;
  80064. private static _ApplyDeltaForEntity;
  80065. }
  80066. }
  80067. declare module "babylonjs/Misc/trajectoryClassifier" {
  80068. import { DeepImmutable, Nullable } from "babylonjs/types";
  80069. import { Vector3 } from "babylonjs/Maths/math.vector";
  80070. /**
  80071. * A 3D trajectory consisting of an order list of vectors describing a
  80072. * path of motion through 3D space.
  80073. */
  80074. export class Trajectory {
  80075. private _points;
  80076. private readonly _segmentLength;
  80077. /**
  80078. * Serialize to JSON.
  80079. * @returns serialized JSON string
  80080. */
  80081. serialize(): string;
  80082. /**
  80083. * Deserialize from JSON.
  80084. * @param json serialized JSON string
  80085. * @returns deserialized Trajectory
  80086. */
  80087. static Deserialize(json: string): Trajectory;
  80088. /**
  80089. * Create a new empty Trajectory.
  80090. * @param segmentLength radius of discretization for Trajectory points
  80091. */
  80092. constructor(segmentLength?: number);
  80093. /**
  80094. * Get the length of the Trajectory.
  80095. * @returns length of the Trajectory
  80096. */
  80097. getLength(): number;
  80098. /**
  80099. * Append a new point to the Trajectory.
  80100. * NOTE: This implementation has many allocations.
  80101. * @param point point to append to the Trajectory
  80102. */
  80103. add(point: DeepImmutable<Vector3>): void;
  80104. /**
  80105. * Create a new Trajectory with a segment length chosen to make it
  80106. * probable that the new Trajectory will have a specified number of
  80107. * segments. This operation is imprecise.
  80108. * @param targetResolution number of segments desired
  80109. * @returns new Trajectory with approximately the requested number of segments
  80110. */
  80111. resampleAtTargetResolution(targetResolution: number): Trajectory;
  80112. /**
  80113. * Convert Trajectory segments into tokenized representation. This
  80114. * representation is an array of numbers where each nth number is the
  80115. * index of the token which is most similar to the nth segment of the
  80116. * Trajectory.
  80117. * @param tokens list of vectors which serve as discrete tokens
  80118. * @returns list of indices of most similar token per segment
  80119. */
  80120. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  80121. private static _forwardDir;
  80122. private static _inverseFromVec;
  80123. private static _upDir;
  80124. private static _fromToVec;
  80125. private static _lookMatrix;
  80126. /**
  80127. * Transform the rotation (i.e., direction) of a segment to isolate
  80128. * the relative transformation represented by the segment. This operation
  80129. * may or may not succeed due to singularities in the equations that define
  80130. * motion relativity in this context.
  80131. * @param priorVec the origin of the prior segment
  80132. * @param fromVec the origin of the current segment
  80133. * @param toVec the destination of the current segment
  80134. * @param result reference to output variable
  80135. * @returns whether or not transformation was successful
  80136. */
  80137. private static _transformSegmentDirToRef;
  80138. private static _bestMatch;
  80139. private static _score;
  80140. private static _bestScore;
  80141. /**
  80142. * Determine which token vector is most similar to the
  80143. * segment vector.
  80144. * @param segment segment vector
  80145. * @param tokens token vector list
  80146. * @returns index of the most similar token to the segment
  80147. */
  80148. private static _tokenizeSegment;
  80149. }
  80150. /**
  80151. * Class representing a set of known, named trajectories to which Trajectories can be
  80152. * added and using which Trajectories can be recognized.
  80153. */
  80154. export class TrajectoryClassifier {
  80155. private _maximumAllowableMatchCost;
  80156. private _vector3Alphabet;
  80157. private _levenshteinAlphabet;
  80158. private _nameToDescribedTrajectory;
  80159. /**
  80160. * Serialize to JSON.
  80161. * @returns JSON serialization
  80162. */
  80163. serialize(): string;
  80164. /**
  80165. * Deserialize from JSON.
  80166. * @param json JSON serialization
  80167. * @returns deserialized TrajectorySet
  80168. */
  80169. static Deserialize(json: string): TrajectoryClassifier;
  80170. /**
  80171. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  80172. * VERY naive, need to be generating these things from known
  80173. * sets. Better version later, probably eliminating this one.
  80174. * @returns auto-generated TrajectorySet
  80175. */
  80176. static Generate(): TrajectoryClassifier;
  80177. private constructor();
  80178. /**
  80179. * Add a new Trajectory to the set with a given name.
  80180. * @param trajectory new Trajectory to be added
  80181. * @param classification name to which to add the Trajectory
  80182. */
  80183. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  80184. /**
  80185. * Remove a known named trajectory and all Trajectories associated with it.
  80186. * @param classification name to remove
  80187. * @returns whether anything was removed
  80188. */
  80189. deleteClassification(classification: string): boolean;
  80190. /**
  80191. * Attempt to recognize a Trajectory from among all the classifications
  80192. * already known to the classifier.
  80193. * @param trajectory Trajectory to be recognized
  80194. * @returns classification of Trajectory if recognized, null otherwise
  80195. */
  80196. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  80197. }
  80198. }
  80199. declare module "babylonjs/Misc/index" {
  80200. export * from "babylonjs/Misc/andOrNotEvaluator";
  80201. export * from "babylonjs/Misc/assetsManager";
  80202. export * from "babylonjs/Misc/basis";
  80203. export * from "babylonjs/Misc/dds";
  80204. export * from "babylonjs/Misc/decorators";
  80205. export * from "babylonjs/Misc/deferred";
  80206. export * from "babylonjs/Misc/environmentTextureTools";
  80207. export * from "babylonjs/Misc/meshExploder";
  80208. export * from "babylonjs/Misc/filesInput";
  80209. export * from "babylonjs/Misc/HighDynamicRange/index";
  80210. export * from "babylonjs/Misc/khronosTextureContainer";
  80211. export * from "babylonjs/Misc/observable";
  80212. export * from "babylonjs/Misc/performanceMonitor";
  80213. export * from "babylonjs/Misc/promise";
  80214. export * from "babylonjs/Misc/sceneOptimizer";
  80215. export * from "babylonjs/Misc/sceneSerializer";
  80216. export * from "babylonjs/Misc/smartArray";
  80217. export * from "babylonjs/Misc/stringDictionary";
  80218. export * from "babylonjs/Misc/tags";
  80219. export * from "babylonjs/Misc/textureTools";
  80220. export * from "babylonjs/Misc/tga";
  80221. export * from "babylonjs/Misc/tools";
  80222. export * from "babylonjs/Misc/videoRecorder";
  80223. export * from "babylonjs/Misc/virtualJoystick";
  80224. export * from "babylonjs/Misc/workerPool";
  80225. export * from "babylonjs/Misc/logger";
  80226. export * from "babylonjs/Misc/typeStore";
  80227. export * from "babylonjs/Misc/filesInputStore";
  80228. export * from "babylonjs/Misc/deepCopier";
  80229. export * from "babylonjs/Misc/pivotTools";
  80230. export * from "babylonjs/Misc/precisionDate";
  80231. export * from "babylonjs/Misc/screenshotTools";
  80232. export * from "babylonjs/Misc/typeStore";
  80233. export * from "babylonjs/Misc/webRequest";
  80234. export * from "babylonjs/Misc/iInspectable";
  80235. export * from "babylonjs/Misc/brdfTextureTools";
  80236. export * from "babylonjs/Misc/rgbdTextureTools";
  80237. export * from "babylonjs/Misc/gradients";
  80238. export * from "babylonjs/Misc/perfCounter";
  80239. export * from "babylonjs/Misc/fileRequest";
  80240. export * from "babylonjs/Misc/customAnimationFrameRequester";
  80241. export * from "babylonjs/Misc/retryStrategy";
  80242. export * from "babylonjs/Misc/interfaces/screenshotSize";
  80243. export * from "babylonjs/Misc/canvasGenerator";
  80244. export * from "babylonjs/Misc/fileTools";
  80245. export * from "babylonjs/Misc/stringTools";
  80246. export * from "babylonjs/Misc/dataReader";
  80247. export * from "babylonjs/Misc/minMaxReducer";
  80248. export * from "babylonjs/Misc/depthReducer";
  80249. export * from "babylonjs/Misc/dataStorage";
  80250. export * from "babylonjs/Misc/sceneRecorder";
  80251. export * from "babylonjs/Misc/khronosTextureContainer2";
  80252. export * from "babylonjs/Misc/trajectoryClassifier";
  80253. export * from "babylonjs/Misc/timer";
  80254. export * from "babylonjs/Misc/copyTools";
  80255. }
  80256. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  80257. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  80258. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80259. import { Observable } from "babylonjs/Misc/observable";
  80260. import { Matrix } from "babylonjs/Maths/math.vector";
  80261. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80262. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80263. /**
  80264. * An interface for all Hit test features
  80265. */
  80266. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  80267. /**
  80268. * Triggered when new babylon (transformed) hit test results are available
  80269. */
  80270. onHitTestResultObservable: Observable<T[]>;
  80271. }
  80272. /**
  80273. * Options used for hit testing
  80274. */
  80275. export interface IWebXRLegacyHitTestOptions {
  80276. /**
  80277. * Only test when user interacted with the scene. Default - hit test every frame
  80278. */
  80279. testOnPointerDownOnly?: boolean;
  80280. /**
  80281. * The node to use to transform the local results to world coordinates
  80282. */
  80283. worldParentNode?: TransformNode;
  80284. }
  80285. /**
  80286. * Interface defining the babylon result of raycasting/hit-test
  80287. */
  80288. export interface IWebXRLegacyHitResult {
  80289. /**
  80290. * Transformation matrix that can be applied to a node that will put it in the hit point location
  80291. */
  80292. transformationMatrix: Matrix;
  80293. /**
  80294. * The native hit test result
  80295. */
  80296. xrHitResult: XRHitResult | XRHitTestResult;
  80297. }
  80298. /**
  80299. * The currently-working hit-test module.
  80300. * Hit test (or Ray-casting) is used to interact with the real world.
  80301. * For further information read here - https://github.com/immersive-web/hit-test
  80302. */
  80303. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  80304. /**
  80305. * options to use when constructing this feature
  80306. */
  80307. readonly options: IWebXRLegacyHitTestOptions;
  80308. private _direction;
  80309. private _mat;
  80310. private _onSelectEnabled;
  80311. private _origin;
  80312. /**
  80313. * The module's name
  80314. */
  80315. static readonly Name: string;
  80316. /**
  80317. * The (Babylon) version of this module.
  80318. * This is an integer representing the implementation version.
  80319. * This number does not correspond to the WebXR specs version
  80320. */
  80321. static readonly Version: number;
  80322. /**
  80323. * Populated with the last native XR Hit Results
  80324. */
  80325. lastNativeXRHitResults: XRHitResult[];
  80326. /**
  80327. * Triggered when new babylon (transformed) hit test results are available
  80328. */
  80329. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  80330. /**
  80331. * Creates a new instance of the (legacy version) hit test feature
  80332. * @param _xrSessionManager an instance of WebXRSessionManager
  80333. * @param options options to use when constructing this feature
  80334. */
  80335. constructor(_xrSessionManager: WebXRSessionManager,
  80336. /**
  80337. * options to use when constructing this feature
  80338. */
  80339. options?: IWebXRLegacyHitTestOptions);
  80340. /**
  80341. * execute a hit test with an XR Ray
  80342. *
  80343. * @param xrSession a native xrSession that will execute this hit test
  80344. * @param xrRay the ray (position and direction) to use for ray-casting
  80345. * @param referenceSpace native XR reference space to use for the hit-test
  80346. * @param filter filter function that will filter the results
  80347. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80348. */
  80349. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  80350. /**
  80351. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  80352. * @param event the (select) event to use to select with
  80353. * @param referenceSpace the reference space to use for this hit test
  80354. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80355. */
  80356. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  80357. /**
  80358. * attach this feature
  80359. * Will usually be called by the features manager
  80360. *
  80361. * @returns true if successful.
  80362. */
  80363. attach(): boolean;
  80364. /**
  80365. * detach this feature.
  80366. * Will usually be called by the features manager
  80367. *
  80368. * @returns true if successful.
  80369. */
  80370. detach(): boolean;
  80371. /**
  80372. * Dispose this feature and all of the resources attached
  80373. */
  80374. dispose(): void;
  80375. protected _onXRFrame(frame: XRFrame): void;
  80376. private _onHitTestResults;
  80377. private _onSelect;
  80378. }
  80379. }
  80380. declare module "babylonjs/XR/features/WebXRHitTest" {
  80381. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80382. import { Observable } from "babylonjs/Misc/observable";
  80383. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80384. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80385. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  80386. /**
  80387. * Options used for hit testing (version 2)
  80388. */
  80389. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  80390. /**
  80391. * Do not create a permanent hit test. Will usually be used when only
  80392. * transient inputs are needed.
  80393. */
  80394. disablePermanentHitTest?: boolean;
  80395. /**
  80396. * Enable transient (for example touch-based) hit test inspections
  80397. */
  80398. enableTransientHitTest?: boolean;
  80399. /**
  80400. * Offset ray for the permanent hit test
  80401. */
  80402. offsetRay?: Vector3;
  80403. /**
  80404. * Offset ray for the transient hit test
  80405. */
  80406. transientOffsetRay?: Vector3;
  80407. /**
  80408. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  80409. */
  80410. useReferenceSpace?: boolean;
  80411. /**
  80412. * Override the default entity type(s) of the hit-test result
  80413. */
  80414. entityTypes?: XRHitTestTrackableType[];
  80415. }
  80416. /**
  80417. * Interface defining the babylon result of hit-test
  80418. */
  80419. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  80420. /**
  80421. * The input source that generated this hit test (if transient)
  80422. */
  80423. inputSource?: XRInputSource;
  80424. /**
  80425. * Is this a transient hit test
  80426. */
  80427. isTransient?: boolean;
  80428. /**
  80429. * Position of the hit test result
  80430. */
  80431. position: Vector3;
  80432. /**
  80433. * Rotation of the hit test result
  80434. */
  80435. rotationQuaternion: Quaternion;
  80436. /**
  80437. * The native hit test result
  80438. */
  80439. xrHitResult: XRHitTestResult;
  80440. }
  80441. /**
  80442. * The currently-working hit-test module.
  80443. * Hit test (or Ray-casting) is used to interact with the real world.
  80444. * For further information read here - https://github.com/immersive-web/hit-test
  80445. *
  80446. * Tested on chrome (mobile) 80.
  80447. */
  80448. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  80449. /**
  80450. * options to use when constructing this feature
  80451. */
  80452. readonly options: IWebXRHitTestOptions;
  80453. private _tmpMat;
  80454. private _tmpPos;
  80455. private _tmpQuat;
  80456. private _transientXrHitTestSource;
  80457. private _xrHitTestSource;
  80458. private initHitTestSource;
  80459. /**
  80460. * The module's name
  80461. */
  80462. static readonly Name: string;
  80463. /**
  80464. * The (Babylon) version of this module.
  80465. * This is an integer representing the implementation version.
  80466. * This number does not correspond to the WebXR specs version
  80467. */
  80468. static readonly Version: number;
  80469. /**
  80470. * When set to true, each hit test will have its own position/rotation objects
  80471. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  80472. * the developers will clone them or copy them as they see fit.
  80473. */
  80474. autoCloneTransformation: boolean;
  80475. /**
  80476. * Triggered when new babylon (transformed) hit test results are available
  80477. * Note - this will be called when results come back from the device. It can be an empty array!!
  80478. */
  80479. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  80480. /**
  80481. * Use this to temporarily pause hit test checks.
  80482. */
  80483. paused: boolean;
  80484. /**
  80485. * Creates a new instance of the hit test feature
  80486. * @param _xrSessionManager an instance of WebXRSessionManager
  80487. * @param options options to use when constructing this feature
  80488. */
  80489. constructor(_xrSessionManager: WebXRSessionManager,
  80490. /**
  80491. * options to use when constructing this feature
  80492. */
  80493. options?: IWebXRHitTestOptions);
  80494. /**
  80495. * attach this feature
  80496. * Will usually be called by the features manager
  80497. *
  80498. * @returns true if successful.
  80499. */
  80500. attach(): boolean;
  80501. /**
  80502. * detach this feature.
  80503. * Will usually be called by the features manager
  80504. *
  80505. * @returns true if successful.
  80506. */
  80507. detach(): boolean;
  80508. /**
  80509. * Dispose this feature and all of the resources attached
  80510. */
  80511. dispose(): void;
  80512. protected _onXRFrame(frame: XRFrame): void;
  80513. private _processWebXRHitTestResult;
  80514. }
  80515. }
  80516. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  80517. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80518. import { Observable } from "babylonjs/Misc/observable";
  80519. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80520. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80521. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80522. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  80523. /**
  80524. * Configuration options of the anchor system
  80525. */
  80526. export interface IWebXRAnchorSystemOptions {
  80527. /**
  80528. * a node that will be used to convert local to world coordinates
  80529. */
  80530. worldParentNode?: TransformNode;
  80531. /**
  80532. * If set to true a reference of the created anchors will be kept until the next session starts
  80533. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80534. */
  80535. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80536. }
  80537. /**
  80538. * A babylon container for an XR Anchor
  80539. */
  80540. export interface IWebXRAnchor {
  80541. /**
  80542. * A babylon-assigned ID for this anchor
  80543. */
  80544. id: number;
  80545. /**
  80546. * Transformation matrix to apply to an object attached to this anchor
  80547. */
  80548. transformationMatrix: Matrix;
  80549. /**
  80550. * The native anchor object
  80551. */
  80552. xrAnchor: XRAnchor;
  80553. /**
  80554. * if defined, this object will be constantly updated by the anchor's position and rotation
  80555. */
  80556. attachedNode?: TransformNode;
  80557. /**
  80558. * Remove this anchor from the scene
  80559. */
  80560. remove(): void;
  80561. }
  80562. /**
  80563. * An implementation of the anchor system for WebXR.
  80564. * For further information see https://github.com/immersive-web/anchors/
  80565. */
  80566. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80567. private _options;
  80568. private _lastFrameDetected;
  80569. private _trackedAnchors;
  80570. private _referenceSpaceForFrameAnchors;
  80571. private _futureAnchors;
  80572. /**
  80573. * The module's name
  80574. */
  80575. static readonly Name: string;
  80576. /**
  80577. * The (Babylon) version of this module.
  80578. * This is an integer representing the implementation version.
  80579. * This number does not correspond to the WebXR specs version
  80580. */
  80581. static readonly Version: number;
  80582. /**
  80583. * Observers registered here will be executed when a new anchor was added to the session
  80584. */
  80585. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80586. /**
  80587. * Observers registered here will be executed when an anchor was removed from the session
  80588. */
  80589. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80590. /**
  80591. * Observers registered here will be executed when an existing anchor updates
  80592. * This can execute N times every frame
  80593. */
  80594. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80595. /**
  80596. * Set the reference space to use for anchor creation, when not using a hit test.
  80597. * Will default to the session's reference space if not defined
  80598. */
  80599. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80600. /**
  80601. * constructs a new anchor system
  80602. * @param _xrSessionManager an instance of WebXRSessionManager
  80603. * @param _options configuration object for this feature
  80604. */
  80605. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80606. private _tmpVector;
  80607. private _tmpQuaternion;
  80608. private _populateTmpTransformation;
  80609. /**
  80610. * Create a new anchor point using a hit test result at a specific point in the scene
  80611. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80612. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80613. *
  80614. * @param hitTestResult The hit test result to use for this anchor creation
  80615. * @param position an optional position offset for this anchor
  80616. * @param rotationQuaternion an optional rotation offset for this anchor
  80617. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80618. */
  80619. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  80620. /**
  80621. * Add a new anchor at a specific position and rotation
  80622. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80623. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80624. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80625. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80626. *
  80627. * @param position the position in which to add an anchor
  80628. * @param rotationQuaternion an optional rotation for the anchor transformation
  80629. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80630. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80631. */
  80632. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  80633. /**
  80634. * Get the list of anchors currently being tracked by the system
  80635. */
  80636. get anchors(): IWebXRAnchor[];
  80637. /**
  80638. * detach this feature.
  80639. * Will usually be called by the features manager
  80640. *
  80641. * @returns true if successful.
  80642. */
  80643. detach(): boolean;
  80644. /**
  80645. * Dispose this feature and all of the resources attached
  80646. */
  80647. dispose(): void;
  80648. protected _onXRFrame(frame: XRFrame): void;
  80649. /**
  80650. * avoiding using Array.find for global support.
  80651. * @param xrAnchor the plane to find in the array
  80652. */
  80653. private _findIndexInAnchorArray;
  80654. private _updateAnchorWithXRFrame;
  80655. private _createAnchorAtTransformation;
  80656. }
  80657. }
  80658. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  80659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80660. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80661. import { Observable } from "babylonjs/Misc/observable";
  80662. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  80663. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80664. /**
  80665. * Options used in the plane detector module
  80666. */
  80667. export interface IWebXRPlaneDetectorOptions {
  80668. /**
  80669. * The node to use to transform the local results to world coordinates
  80670. */
  80671. worldParentNode?: TransformNode;
  80672. /**
  80673. * If set to true a reference of the created planes will be kept until the next session starts
  80674. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80675. */
  80676. doNotRemovePlanesOnSessionEnded?: boolean;
  80677. }
  80678. /**
  80679. * A babylon interface for a WebXR plane.
  80680. * A Plane is actually a polygon, built from N points in space
  80681. *
  80682. * Supported in chrome 79, not supported in canary 81 ATM
  80683. */
  80684. export interface IWebXRPlane {
  80685. /**
  80686. * a babylon-assigned ID for this polygon
  80687. */
  80688. id: number;
  80689. /**
  80690. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80691. */
  80692. polygonDefinition: Array<Vector3>;
  80693. /**
  80694. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80695. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80696. */
  80697. transformationMatrix: Matrix;
  80698. /**
  80699. * the native xr-plane object
  80700. */
  80701. xrPlane: XRPlane;
  80702. }
  80703. /**
  80704. * The plane detector is used to detect planes in the real world when in AR
  80705. * For more information see https://github.com/immersive-web/real-world-geometry/
  80706. */
  80707. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80708. private _options;
  80709. private _detectedPlanes;
  80710. private _enabled;
  80711. private _lastFrameDetected;
  80712. /**
  80713. * The module's name
  80714. */
  80715. static readonly Name: string;
  80716. /**
  80717. * The (Babylon) version of this module.
  80718. * This is an integer representing the implementation version.
  80719. * This number does not correspond to the WebXR specs version
  80720. */
  80721. static readonly Version: number;
  80722. /**
  80723. * Observers registered here will be executed when a new plane was added to the session
  80724. */
  80725. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80726. /**
  80727. * Observers registered here will be executed when a plane is no longer detected in the session
  80728. */
  80729. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80730. /**
  80731. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80732. * This can execute N times every frame
  80733. */
  80734. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80735. /**
  80736. * construct a new Plane Detector
  80737. * @param _xrSessionManager an instance of xr Session manager
  80738. * @param _options configuration to use when constructing this feature
  80739. */
  80740. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80741. /**
  80742. * detach this feature.
  80743. * Will usually be called by the features manager
  80744. *
  80745. * @returns true if successful.
  80746. */
  80747. detach(): boolean;
  80748. /**
  80749. * Dispose this feature and all of the resources attached
  80750. */
  80751. dispose(): void;
  80752. /**
  80753. * Check if the needed objects are defined.
  80754. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80755. */
  80756. isCompatible(): boolean;
  80757. protected _onXRFrame(frame: XRFrame): void;
  80758. private _init;
  80759. private _updatePlaneWithXRPlane;
  80760. /**
  80761. * avoiding using Array.find for global support.
  80762. * @param xrPlane the plane to find in the array
  80763. */
  80764. private findIndexInPlaneArray;
  80765. }
  80766. }
  80767. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  80768. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80770. import { Observable } from "babylonjs/Misc/observable";
  80771. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80772. /**
  80773. * Options interface for the background remover plugin
  80774. */
  80775. export interface IWebXRBackgroundRemoverOptions {
  80776. /**
  80777. * Further background meshes to disable when entering AR
  80778. */
  80779. backgroundMeshes?: AbstractMesh[];
  80780. /**
  80781. * flags to configure the removal of the environment helper.
  80782. * If not set, the entire background will be removed. If set, flags should be set as well.
  80783. */
  80784. environmentHelperRemovalFlags?: {
  80785. /**
  80786. * Should the skybox be removed (default false)
  80787. */
  80788. skyBox?: boolean;
  80789. /**
  80790. * Should the ground be removed (default false)
  80791. */
  80792. ground?: boolean;
  80793. };
  80794. /**
  80795. * don't disable the environment helper
  80796. */
  80797. ignoreEnvironmentHelper?: boolean;
  80798. }
  80799. /**
  80800. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80801. */
  80802. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80803. /**
  80804. * read-only options to be used in this module
  80805. */
  80806. readonly options: IWebXRBackgroundRemoverOptions;
  80807. /**
  80808. * The module's name
  80809. */
  80810. static readonly Name: string;
  80811. /**
  80812. * The (Babylon) version of this module.
  80813. * This is an integer representing the implementation version.
  80814. * This number does not correspond to the WebXR specs version
  80815. */
  80816. static readonly Version: number;
  80817. /**
  80818. * registered observers will be triggered when the background state changes
  80819. */
  80820. onBackgroundStateChangedObservable: Observable<boolean>;
  80821. /**
  80822. * constructs a new background remover module
  80823. * @param _xrSessionManager the session manager for this module
  80824. * @param options read-only options to be used in this module
  80825. */
  80826. constructor(_xrSessionManager: WebXRSessionManager,
  80827. /**
  80828. * read-only options to be used in this module
  80829. */
  80830. options?: IWebXRBackgroundRemoverOptions);
  80831. /**
  80832. * attach this feature
  80833. * Will usually be called by the features manager
  80834. *
  80835. * @returns true if successful.
  80836. */
  80837. attach(): boolean;
  80838. /**
  80839. * detach this feature.
  80840. * Will usually be called by the features manager
  80841. *
  80842. * @returns true if successful.
  80843. */
  80844. detach(): boolean;
  80845. /**
  80846. * Dispose this feature and all of the resources attached
  80847. */
  80848. dispose(): void;
  80849. protected _onXRFrame(_xrFrame: XRFrame): void;
  80850. private _setBackgroundState;
  80851. }
  80852. }
  80853. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80854. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80855. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80856. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80857. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80858. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80859. import { Nullable } from "babylonjs/types";
  80860. /**
  80861. * Options for the controller physics feature
  80862. */
  80863. export class IWebXRControllerPhysicsOptions {
  80864. /**
  80865. * Should the headset get its own impostor
  80866. */
  80867. enableHeadsetImpostor?: boolean;
  80868. /**
  80869. * Optional parameters for the headset impostor
  80870. */
  80871. headsetImpostorParams?: {
  80872. /**
  80873. * The type of impostor to create. Default is sphere
  80874. */
  80875. impostorType: number;
  80876. /**
  80877. * the size of the impostor. Defaults to 10cm
  80878. */
  80879. impostorSize?: number | {
  80880. width: number;
  80881. height: number;
  80882. depth: number;
  80883. };
  80884. /**
  80885. * Friction definitions
  80886. */
  80887. friction?: number;
  80888. /**
  80889. * Restitution
  80890. */
  80891. restitution?: number;
  80892. };
  80893. /**
  80894. * The physics properties of the future impostors
  80895. */
  80896. physicsProperties?: {
  80897. /**
  80898. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80899. * Note that this requires a physics engine that supports mesh impostors!
  80900. */
  80901. useControllerMesh?: boolean;
  80902. /**
  80903. * The type of impostor to create. Default is sphere
  80904. */
  80905. impostorType?: number;
  80906. /**
  80907. * the size of the impostor. Defaults to 10cm
  80908. */
  80909. impostorSize?: number | {
  80910. width: number;
  80911. height: number;
  80912. depth: number;
  80913. };
  80914. /**
  80915. * Friction definitions
  80916. */
  80917. friction?: number;
  80918. /**
  80919. * Restitution
  80920. */
  80921. restitution?: number;
  80922. };
  80923. /**
  80924. * the xr input to use with this pointer selection
  80925. */
  80926. xrInput: WebXRInput;
  80927. }
  80928. /**
  80929. * Add physics impostor to your webxr controllers,
  80930. * including naive calculation of their linear and angular velocity
  80931. */
  80932. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80933. private readonly _options;
  80934. private _attachController;
  80935. private _controllers;
  80936. private _debugMode;
  80937. private _delta;
  80938. private _headsetImpostor?;
  80939. private _headsetMesh?;
  80940. private _lastTimestamp;
  80941. private _tmpQuaternion;
  80942. private _tmpVector;
  80943. /**
  80944. * The module's name
  80945. */
  80946. static readonly Name: string;
  80947. /**
  80948. * The (Babylon) version of this module.
  80949. * This is an integer representing the implementation version.
  80950. * This number does not correspond to the webxr specs version
  80951. */
  80952. static readonly Version: number;
  80953. /**
  80954. * Construct a new Controller Physics Feature
  80955. * @param _xrSessionManager the corresponding xr session manager
  80956. * @param _options options to create this feature with
  80957. */
  80958. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80959. /**
  80960. * @hidden
  80961. * enable debugging - will show console outputs and the impostor mesh
  80962. */
  80963. _enablePhysicsDebug(): void;
  80964. /**
  80965. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80966. * @param xrController the controller to add
  80967. */
  80968. addController(xrController: WebXRInputSource): void;
  80969. /**
  80970. * attach this feature
  80971. * Will usually be called by the features manager
  80972. *
  80973. * @returns true if successful.
  80974. */
  80975. attach(): boolean;
  80976. /**
  80977. * detach this feature.
  80978. * Will usually be called by the features manager
  80979. *
  80980. * @returns true if successful.
  80981. */
  80982. detach(): boolean;
  80983. /**
  80984. * Get the headset impostor, if enabled
  80985. * @returns the impostor
  80986. */
  80987. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80988. /**
  80989. * Get the physics impostor of a specific controller.
  80990. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80991. * @param controller the controller or the controller id of which to get the impostor
  80992. * @returns the impostor or null
  80993. */
  80994. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80995. /**
  80996. * Update the physics properties provided in the constructor
  80997. * @param newProperties the new properties object
  80998. */
  80999. setPhysicsProperties(newProperties: {
  81000. impostorType?: number;
  81001. impostorSize?: number | {
  81002. width: number;
  81003. height: number;
  81004. depth: number;
  81005. };
  81006. friction?: number;
  81007. restitution?: number;
  81008. }): void;
  81009. protected _onXRFrame(_xrFrame: any): void;
  81010. private _detachController;
  81011. }
  81012. }
  81013. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  81014. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  81015. import { Observable } from "babylonjs/Misc/observable";
  81016. import { Vector3 } from "babylonjs/Maths/math.vector";
  81017. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  81018. /**
  81019. * A babylon interface for a "WebXR" feature point.
  81020. * Represents the position and confidence value of a given feature point.
  81021. */
  81022. export interface IWebXRFeaturePoint {
  81023. /**
  81024. * Represents the position of the feature point in world space.
  81025. */
  81026. position: Vector3;
  81027. /**
  81028. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  81029. */
  81030. confidenceValue: number;
  81031. }
  81032. /**
  81033. * The feature point system is used to detect feature points from real world geometry.
  81034. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  81035. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  81036. */
  81037. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  81038. private _enabled;
  81039. private _featurePointCloud;
  81040. /**
  81041. * The module's name
  81042. */
  81043. static readonly Name: string;
  81044. /**
  81045. * The (Babylon) version of this module.
  81046. * This is an integer representing the implementation version.
  81047. * This number does not correspond to the WebXR specs version
  81048. */
  81049. static readonly Version: number;
  81050. /**
  81051. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  81052. * Will notify the observers about which feature points have been added.
  81053. */
  81054. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  81055. /**
  81056. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  81057. * Will notify the observers about which feature points have been updated.
  81058. */
  81059. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  81060. /**
  81061. * The current feature point cloud maintained across frames.
  81062. */
  81063. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  81064. /**
  81065. * construct the feature point system
  81066. * @param _xrSessionManager an instance of xr Session manager
  81067. */
  81068. constructor(_xrSessionManager: WebXRSessionManager);
  81069. /**
  81070. * Detach this feature.
  81071. * Will usually be called by the features manager
  81072. *
  81073. * @returns true if successful.
  81074. */
  81075. detach(): boolean;
  81076. /**
  81077. * Dispose this feature and all of the resources attached
  81078. */
  81079. dispose(): void;
  81080. /**
  81081. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  81082. */
  81083. protected _onXRFrame(frame: XRFrame): void;
  81084. /**
  81085. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  81086. */
  81087. private _init;
  81088. }
  81089. }
  81090. declare module "babylonjs/XR/features/WebXRHandTracking" {
  81091. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  81092. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  81093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81094. import { Mesh } from "babylonjs/Meshes/mesh";
  81095. import { WebXRInput } from "babylonjs/XR/webXRInput";
  81096. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  81097. import { Nullable } from "babylonjs/types";
  81098. import { IDisposable } from "babylonjs/scene";
  81099. import { Observable } from "babylonjs/Misc/observable";
  81100. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  81101. /**
  81102. * Configuration interface for the hand tracking feature
  81103. */
  81104. export interface IWebXRHandTrackingOptions {
  81105. /**
  81106. * The xrInput that will be used as source for new hands
  81107. */
  81108. xrInput: WebXRInput;
  81109. /**
  81110. * Configuration object for the joint meshes
  81111. */
  81112. jointMeshes?: {
  81113. /**
  81114. * Should the meshes created be invisible (defaults to false)
  81115. */
  81116. invisible?: boolean;
  81117. /**
  81118. * A source mesh to be used to create instances. Defaults to a sphere.
  81119. * This mesh will be the source for all other (25) meshes.
  81120. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  81121. */
  81122. sourceMesh?: Mesh;
  81123. /**
  81124. * This function will be called after a mesh was created for a specific joint.
  81125. * Using this function you can either manipulate the instance or return a new mesh.
  81126. * When returning a new mesh the instance created before will be disposed
  81127. */
  81128. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  81129. /**
  81130. * Should the source mesh stay visible. Defaults to false
  81131. */
  81132. keepOriginalVisible?: boolean;
  81133. /**
  81134. * Scale factor for all instances (defaults to 2)
  81135. */
  81136. scaleFactor?: number;
  81137. /**
  81138. * Should each instance have its own physics impostor
  81139. */
  81140. enablePhysics?: boolean;
  81141. /**
  81142. * If enabled, override default physics properties
  81143. */
  81144. physicsProps?: {
  81145. friction?: number;
  81146. restitution?: number;
  81147. impostorType?: number;
  81148. };
  81149. /**
  81150. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  81151. */
  81152. disableDefaultHandMesh?: boolean;
  81153. /**
  81154. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  81155. */
  81156. handMeshes?: {
  81157. right: AbstractMesh;
  81158. left: AbstractMesh;
  81159. };
  81160. /**
  81161. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  81162. */
  81163. rigMapping?: {
  81164. right: string[];
  81165. left: string[];
  81166. };
  81167. };
  81168. }
  81169. /**
  81170. * Parts of the hands divided to writs and finger names
  81171. */
  81172. export const enum HandPart {
  81173. /**
  81174. * HandPart - Wrist
  81175. */
  81176. WRIST = "wrist",
  81177. /**
  81178. * HandPart - The THumb
  81179. */
  81180. THUMB = "thumb",
  81181. /**
  81182. * HandPart - Index finger
  81183. */
  81184. INDEX = "index",
  81185. /**
  81186. * HandPart - Middle finger
  81187. */
  81188. MIDDLE = "middle",
  81189. /**
  81190. * HandPart - Ring finger
  81191. */
  81192. RING = "ring",
  81193. /**
  81194. * HandPart - Little finger
  81195. */
  81196. LITTLE = "little"
  81197. }
  81198. /**
  81199. * Representing a single hand (with its corresponding native XRHand object)
  81200. */
  81201. export class WebXRHand implements IDisposable {
  81202. /** the controller to which the hand correlates */
  81203. readonly xrController: WebXRInputSource;
  81204. /** the meshes to be used to track the hand joints */
  81205. readonly trackedMeshes: AbstractMesh[];
  81206. private _handMesh?;
  81207. private _rigMapping?;
  81208. private _scene;
  81209. private _defaultHandMesh;
  81210. private _transformNodeMapping;
  81211. /**
  81212. * Hand-parts definition (key is HandPart)
  81213. */
  81214. handPartsDefinition: {
  81215. [key: string]: number[];
  81216. };
  81217. /**
  81218. * Populate the HandPartsDefinition object.
  81219. * This is called as a side effect since certain browsers don't have XRHand defined.
  81220. */
  81221. private generateHandPartsDefinition;
  81222. /**
  81223. * Construct a new hand object
  81224. * @param xrController the controller to which the hand correlates
  81225. * @param trackedMeshes the meshes to be used to track the hand joints
  81226. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  81227. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  81228. * @param disableDefaultHandMesh should the default mesh creation be disabled
  81229. */
  81230. constructor(
  81231. /** the controller to which the hand correlates */
  81232. xrController: WebXRInputSource,
  81233. /** the meshes to be used to track the hand joints */
  81234. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  81235. /**
  81236. * Update this hand from the latest xr frame
  81237. * @param xrFrame xrFrame to update from
  81238. * @param referenceSpace The current viewer reference space
  81239. * @param scaleFactor optional scale factor for the meshes
  81240. */
  81241. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  81242. /**
  81243. * Get meshes of part of the hand
  81244. * @param part the part of hand to get
  81245. * @returns An array of meshes that correlate to the hand part requested
  81246. */
  81247. getHandPartMeshes(part: HandPart): AbstractMesh[];
  81248. /**
  81249. * Dispose this Hand object
  81250. */
  81251. dispose(): void;
  81252. private _generateDefaultHandMesh;
  81253. }
  81254. /**
  81255. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  81256. */
  81257. export class WebXRHandTracking extends WebXRAbstractFeature {
  81258. /**
  81259. * options to use when constructing this feature
  81260. */
  81261. readonly options: IWebXRHandTrackingOptions;
  81262. private static _idCounter;
  81263. /**
  81264. * The module's name
  81265. */
  81266. static readonly Name: string;
  81267. /**
  81268. * The (Babylon) version of this module.
  81269. * This is an integer representing the implementation version.
  81270. * This number does not correspond to the WebXR specs version
  81271. */
  81272. static readonly Version: number;
  81273. /**
  81274. * This observable will notify registered observers when a new hand object was added and initialized
  81275. */
  81276. onHandAddedObservable: Observable<WebXRHand>;
  81277. /**
  81278. * This observable will notify its observers right before the hand object is disposed
  81279. */
  81280. onHandRemovedObservable: Observable<WebXRHand>;
  81281. private _hands;
  81282. /**
  81283. * Creates a new instance of the hit test feature
  81284. * @param _xrSessionManager an instance of WebXRSessionManager
  81285. * @param options options to use when constructing this feature
  81286. */
  81287. constructor(_xrSessionManager: WebXRSessionManager,
  81288. /**
  81289. * options to use when constructing this feature
  81290. */
  81291. options: IWebXRHandTrackingOptions);
  81292. /**
  81293. * Check if the needed objects are defined.
  81294. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  81295. */
  81296. isCompatible(): boolean;
  81297. /**
  81298. * attach this feature
  81299. * Will usually be called by the features manager
  81300. *
  81301. * @returns true if successful.
  81302. */
  81303. attach(): boolean;
  81304. /**
  81305. * detach this feature.
  81306. * Will usually be called by the features manager
  81307. *
  81308. * @returns true if successful.
  81309. */
  81310. detach(): boolean;
  81311. /**
  81312. * Dispose this feature and all of the resources attached
  81313. */
  81314. dispose(): void;
  81315. /**
  81316. * Get the hand object according to the controller id
  81317. * @param controllerId the controller id to which we want to get the hand
  81318. * @returns null if not found or the WebXRHand object if found
  81319. */
  81320. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  81321. /**
  81322. * Get a hand object according to the requested handedness
  81323. * @param handedness the handedness to request
  81324. * @returns null if not found or the WebXRHand object if found
  81325. */
  81326. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  81327. protected _onXRFrame(_xrFrame: XRFrame): void;
  81328. private _attachHand;
  81329. private _detachHand;
  81330. }
  81331. }
  81332. declare module "babylonjs/XR/features/index" {
  81333. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  81334. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  81335. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  81336. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  81337. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  81338. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  81339. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  81340. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  81341. export * from "babylonjs/XR/features/WebXRHitTest";
  81342. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  81343. export * from "babylonjs/XR/features/WebXRHandTracking";
  81344. }
  81345. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  81346. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81348. import { Scene } from "babylonjs/scene";
  81349. /**
  81350. * The motion controller class for all microsoft mixed reality controllers
  81351. */
  81352. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  81353. protected readonly _mapping: {
  81354. defaultButton: {
  81355. valueNodeName: string;
  81356. unpressedNodeName: string;
  81357. pressedNodeName: string;
  81358. };
  81359. defaultAxis: {
  81360. valueNodeName: string;
  81361. minNodeName: string;
  81362. maxNodeName: string;
  81363. };
  81364. buttons: {
  81365. "xr-standard-trigger": {
  81366. rootNodeName: string;
  81367. componentProperty: string;
  81368. states: string[];
  81369. };
  81370. "xr-standard-squeeze": {
  81371. rootNodeName: string;
  81372. componentProperty: string;
  81373. states: string[];
  81374. };
  81375. "xr-standard-touchpad": {
  81376. rootNodeName: string;
  81377. labelAnchorNodeName: string;
  81378. touchPointNodeName: string;
  81379. };
  81380. "xr-standard-thumbstick": {
  81381. rootNodeName: string;
  81382. componentProperty: string;
  81383. states: string[];
  81384. };
  81385. };
  81386. axes: {
  81387. "xr-standard-touchpad": {
  81388. "x-axis": {
  81389. rootNodeName: string;
  81390. };
  81391. "y-axis": {
  81392. rootNodeName: string;
  81393. };
  81394. };
  81395. "xr-standard-thumbstick": {
  81396. "x-axis": {
  81397. rootNodeName: string;
  81398. };
  81399. "y-axis": {
  81400. rootNodeName: string;
  81401. };
  81402. };
  81403. };
  81404. };
  81405. /**
  81406. * The base url used to load the left and right controller models
  81407. */
  81408. static MODEL_BASE_URL: string;
  81409. /**
  81410. * The name of the left controller model file
  81411. */
  81412. static MODEL_LEFT_FILENAME: string;
  81413. /**
  81414. * The name of the right controller model file
  81415. */
  81416. static MODEL_RIGHT_FILENAME: string;
  81417. profileId: string;
  81418. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81419. protected _getFilenameAndPath(): {
  81420. filename: string;
  81421. path: string;
  81422. };
  81423. protected _getModelLoadingConstraints(): boolean;
  81424. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81425. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81426. protected _updateModel(): void;
  81427. }
  81428. }
  81429. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  81430. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81432. import { Scene } from "babylonjs/scene";
  81433. /**
  81434. * The motion controller class for oculus touch (quest, rift).
  81435. * This class supports legacy mapping as well the standard xr mapping
  81436. */
  81437. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  81438. private _forceLegacyControllers;
  81439. private _modelRootNode;
  81440. /**
  81441. * The base url used to load the left and right controller models
  81442. */
  81443. static MODEL_BASE_URL: string;
  81444. /**
  81445. * The name of the left controller model file
  81446. */
  81447. static MODEL_LEFT_FILENAME: string;
  81448. /**
  81449. * The name of the right controller model file
  81450. */
  81451. static MODEL_RIGHT_FILENAME: string;
  81452. /**
  81453. * Base Url for the Quest controller model.
  81454. */
  81455. static QUEST_MODEL_BASE_URL: string;
  81456. profileId: string;
  81457. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  81458. protected _getFilenameAndPath(): {
  81459. filename: string;
  81460. path: string;
  81461. };
  81462. protected _getModelLoadingConstraints(): boolean;
  81463. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81464. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81465. protected _updateModel(): void;
  81466. /**
  81467. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81468. * between the touch and touch 2.
  81469. */
  81470. private _isQuest;
  81471. }
  81472. }
  81473. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  81474. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81475. import { Scene } from "babylonjs/scene";
  81476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81477. /**
  81478. * The motion controller class for the standard HTC-Vive controllers
  81479. */
  81480. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81481. private _modelRootNode;
  81482. /**
  81483. * The base url used to load the left and right controller models
  81484. */
  81485. static MODEL_BASE_URL: string;
  81486. /**
  81487. * File name for the controller model.
  81488. */
  81489. static MODEL_FILENAME: string;
  81490. profileId: string;
  81491. /**
  81492. * Create a new Vive motion controller object
  81493. * @param scene the scene to use to create this controller
  81494. * @param gamepadObject the corresponding gamepad object
  81495. * @param handedness the handedness of the controller
  81496. */
  81497. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81498. protected _getFilenameAndPath(): {
  81499. filename: string;
  81500. path: string;
  81501. };
  81502. protected _getModelLoadingConstraints(): boolean;
  81503. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81504. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81505. protected _updateModel(): void;
  81506. }
  81507. }
  81508. declare module "babylonjs/XR/motionController/index" {
  81509. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81510. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  81511. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  81512. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  81513. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  81514. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  81515. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  81516. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  81517. }
  81518. declare module "babylonjs/XR/index" {
  81519. export * from "babylonjs/XR/webXRCamera";
  81520. export * from "babylonjs/XR/webXREnterExitUI";
  81521. export * from "babylonjs/XR/webXRExperienceHelper";
  81522. export * from "babylonjs/XR/webXRInput";
  81523. export * from "babylonjs/XR/webXRInputSource";
  81524. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  81525. export * from "babylonjs/XR/webXRTypes";
  81526. export * from "babylonjs/XR/webXRSessionManager";
  81527. export * from "babylonjs/XR/webXRDefaultExperience";
  81528. export * from "babylonjs/XR/webXRFeaturesManager";
  81529. export * from "babylonjs/XR/features/index";
  81530. export * from "babylonjs/XR/motionController/index";
  81531. }
  81532. declare module "babylonjs/index" {
  81533. export * from "babylonjs/abstractScene";
  81534. export * from "babylonjs/Actions/index";
  81535. export * from "babylonjs/Animations/index";
  81536. export * from "babylonjs/assetContainer";
  81537. export * from "babylonjs/Audio/index";
  81538. export * from "babylonjs/Behaviors/index";
  81539. export * from "babylonjs/Bones/index";
  81540. export * from "babylonjs/Cameras/index";
  81541. export * from "babylonjs/Collisions/index";
  81542. export * from "babylonjs/Culling/index";
  81543. export * from "babylonjs/Debug/index";
  81544. export * from "babylonjs/DeviceInput/index";
  81545. export * from "babylonjs/Engines/index";
  81546. export * from "babylonjs/Events/index";
  81547. export * from "babylonjs/Gamepads/index";
  81548. export * from "babylonjs/Gizmos/index";
  81549. export * from "babylonjs/Helpers/index";
  81550. export * from "babylonjs/Instrumentation/index";
  81551. export * from "babylonjs/Layers/index";
  81552. export * from "babylonjs/LensFlares/index";
  81553. export * from "babylonjs/Lights/index";
  81554. export * from "babylonjs/Loading/index";
  81555. export * from "babylonjs/Materials/index";
  81556. export * from "babylonjs/Maths/index";
  81557. export * from "babylonjs/Meshes/index";
  81558. export * from "babylonjs/Morph/index";
  81559. export * from "babylonjs/Navigation/index";
  81560. export * from "babylonjs/node";
  81561. export * from "babylonjs/Offline/index";
  81562. export * from "babylonjs/Particles/index";
  81563. export * from "babylonjs/Physics/index";
  81564. export * from "babylonjs/PostProcesses/index";
  81565. export * from "babylonjs/Probes/index";
  81566. export * from "babylonjs/Rendering/index";
  81567. export * from "babylonjs/scene";
  81568. export * from "babylonjs/sceneComponent";
  81569. export * from "babylonjs/Sprites/index";
  81570. export * from "babylonjs/States/index";
  81571. export * from "babylonjs/Misc/index";
  81572. export * from "babylonjs/XR/index";
  81573. export * from "babylonjs/types";
  81574. }
  81575. declare module "babylonjs/Animations/pathCursor" {
  81576. import { Vector3 } from "babylonjs/Maths/math.vector";
  81577. import { Path2 } from "babylonjs/Maths/math.path";
  81578. /**
  81579. * A cursor which tracks a point on a path
  81580. */
  81581. export class PathCursor {
  81582. private path;
  81583. /**
  81584. * Stores path cursor callbacks for when an onchange event is triggered
  81585. */
  81586. private _onchange;
  81587. /**
  81588. * The value of the path cursor
  81589. */
  81590. value: number;
  81591. /**
  81592. * The animation array of the path cursor
  81593. */
  81594. animations: Animation[];
  81595. /**
  81596. * Initializes the path cursor
  81597. * @param path The path to track
  81598. */
  81599. constructor(path: Path2);
  81600. /**
  81601. * Gets the cursor point on the path
  81602. * @returns A point on the path cursor at the cursor location
  81603. */
  81604. getPoint(): Vector3;
  81605. /**
  81606. * Moves the cursor ahead by the step amount
  81607. * @param step The amount to move the cursor forward
  81608. * @returns This path cursor
  81609. */
  81610. moveAhead(step?: number): PathCursor;
  81611. /**
  81612. * Moves the cursor behind by the step amount
  81613. * @param step The amount to move the cursor back
  81614. * @returns This path cursor
  81615. */
  81616. moveBack(step?: number): PathCursor;
  81617. /**
  81618. * Moves the cursor by the step amount
  81619. * If the step amount is greater than one, an exception is thrown
  81620. * @param step The amount to move the cursor
  81621. * @returns This path cursor
  81622. */
  81623. move(step: number): PathCursor;
  81624. /**
  81625. * Ensures that the value is limited between zero and one
  81626. * @returns This path cursor
  81627. */
  81628. private ensureLimits;
  81629. /**
  81630. * Runs onchange callbacks on change (used by the animation engine)
  81631. * @returns This path cursor
  81632. */
  81633. private raiseOnChange;
  81634. /**
  81635. * Executes a function on change
  81636. * @param f A path cursor onchange callback
  81637. * @returns This path cursor
  81638. */
  81639. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81640. }
  81641. }
  81642. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  81643. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  81644. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  81645. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  81646. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  81647. }
  81648. declare module "babylonjs/Engines/Processors/Expressions/index" {
  81649. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  81650. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  81651. }
  81652. declare module "babylonjs/Engines/Processors/index" {
  81653. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  81654. export * from "babylonjs/Engines/Processors/Expressions/index";
  81655. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  81656. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  81657. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  81658. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  81659. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  81660. export * from "babylonjs/Engines/Processors/shaderProcessor";
  81661. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  81662. }
  81663. declare module "babylonjs/Legacy/legacy" {
  81664. import * as Babylon from "babylonjs/index";
  81665. export * from "babylonjs/index";
  81666. }
  81667. declare module "babylonjs/Shaders/blur.fragment" {
  81668. /** @hidden */
  81669. export var blurPixelShader: {
  81670. name: string;
  81671. shader: string;
  81672. };
  81673. }
  81674. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  81675. /** @hidden */
  81676. export var pointCloudVertexDeclaration: {
  81677. name: string;
  81678. shader: string;
  81679. };
  81680. }
  81681. declare module "babylonjs" {
  81682. export * from "babylonjs/Legacy/legacy";
  81683. }
  81684. declare module BABYLON {
  81685. /** Alias type for value that can be null */
  81686. export type Nullable<T> = T | null;
  81687. /**
  81688. * Alias type for number that are floats
  81689. * @ignorenaming
  81690. */
  81691. export type float = number;
  81692. /**
  81693. * Alias type for number that are doubles.
  81694. * @ignorenaming
  81695. */
  81696. export type double = number;
  81697. /**
  81698. * Alias type for number that are integer
  81699. * @ignorenaming
  81700. */
  81701. export type int = number;
  81702. /** Alias type for number array or Float32Array */
  81703. export type FloatArray = number[] | Float32Array;
  81704. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  81705. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  81706. /**
  81707. * Alias for types that can be used by a Buffer or VertexBuffer.
  81708. */
  81709. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  81710. /**
  81711. * Alias type for primitive types
  81712. * @ignorenaming
  81713. */
  81714. type Primitive = undefined | null | boolean | string | number | Function;
  81715. /**
  81716. * Type modifier to make all the properties of an object Readonly
  81717. */
  81718. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  81719. /**
  81720. * Type modifier to make all the properties of an object Readonly recursively
  81721. */
  81722. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  81723. /**
  81724. * Type modifier to make object properties readonly.
  81725. */
  81726. export type DeepImmutableObject<T> = {
  81727. readonly [K in keyof T]: DeepImmutable<T[K]>;
  81728. };
  81729. /** @hidden */
  81730. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  81731. }
  81732. }
  81733. declare module BABYLON {
  81734. /**
  81735. * A class serves as a medium between the observable and its observers
  81736. */
  81737. export class EventState {
  81738. /**
  81739. * Create a new EventState
  81740. * @param mask defines the mask associated with this state
  81741. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81742. * @param target defines the original target of the state
  81743. * @param currentTarget defines the current target of the state
  81744. */
  81745. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  81746. /**
  81747. * Initialize the current event state
  81748. * @param mask defines the mask associated with this state
  81749. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81750. * @param target defines the original target of the state
  81751. * @param currentTarget defines the current target of the state
  81752. * @returns the current event state
  81753. */
  81754. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  81755. /**
  81756. * An Observer can set this property to true to prevent subsequent observers of being notified
  81757. */
  81758. skipNextObservers: boolean;
  81759. /**
  81760. * Get the mask value that were used to trigger the event corresponding to this EventState object
  81761. */
  81762. mask: number;
  81763. /**
  81764. * The object that originally notified the event
  81765. */
  81766. target?: any;
  81767. /**
  81768. * The current object in the bubbling phase
  81769. */
  81770. currentTarget?: any;
  81771. /**
  81772. * This will be populated with the return value of the last function that was executed.
  81773. * If it is the first function in the callback chain it will be the event data.
  81774. */
  81775. lastReturnValue?: any;
  81776. /**
  81777. * User defined information that will be sent to observers
  81778. */
  81779. userInfo?: any;
  81780. }
  81781. /**
  81782. * Represent an Observer registered to a given Observable object.
  81783. */
  81784. export class Observer<T> {
  81785. /**
  81786. * Defines the callback to call when the observer is notified
  81787. */
  81788. callback: (eventData: T, eventState: EventState) => void;
  81789. /**
  81790. * Defines the mask of the observer (used to filter notifications)
  81791. */
  81792. mask: number;
  81793. /**
  81794. * Defines the current scope used to restore the JS context
  81795. */
  81796. scope: any;
  81797. /** @hidden */
  81798. _willBeUnregistered: boolean;
  81799. /**
  81800. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  81801. */
  81802. unregisterOnNextCall: boolean;
  81803. /**
  81804. * Creates a new observer
  81805. * @param callback defines the callback to call when the observer is notified
  81806. * @param mask defines the mask of the observer (used to filter notifications)
  81807. * @param scope defines the current scope used to restore the JS context
  81808. */
  81809. constructor(
  81810. /**
  81811. * Defines the callback to call when the observer is notified
  81812. */
  81813. callback: (eventData: T, eventState: EventState) => void,
  81814. /**
  81815. * Defines the mask of the observer (used to filter notifications)
  81816. */
  81817. mask: number,
  81818. /**
  81819. * Defines the current scope used to restore the JS context
  81820. */
  81821. scope?: any);
  81822. }
  81823. /**
  81824. * Represent a list of observers registered to multiple Observables object.
  81825. */
  81826. export class MultiObserver<T> {
  81827. private _observers;
  81828. private _observables;
  81829. /**
  81830. * Release associated resources
  81831. */
  81832. dispose(): void;
  81833. /**
  81834. * Raise a callback when one of the observable will notify
  81835. * @param observables defines a list of observables to watch
  81836. * @param callback defines the callback to call on notification
  81837. * @param mask defines the mask used to filter notifications
  81838. * @param scope defines the current scope used to restore the JS context
  81839. * @returns the new MultiObserver
  81840. */
  81841. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  81842. }
  81843. /**
  81844. * The Observable class is a simple implementation of the Observable pattern.
  81845. *
  81846. * 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.
  81847. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81848. * 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).
  81849. * 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.
  81850. */
  81851. export class Observable<T> {
  81852. private _observers;
  81853. private _eventState;
  81854. private _onObserverAdded;
  81855. /**
  81856. * Gets the list of observers
  81857. */
  81858. get observers(): Array<Observer<T>>;
  81859. /**
  81860. * Creates a new observable
  81861. * @param onObserverAdded defines a callback to call when a new observer is added
  81862. */
  81863. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81864. /**
  81865. * Create a new Observer with the specified callback
  81866. * @param callback the callback that will be executed for that Observer
  81867. * @param mask the mask used to filter observers
  81868. * @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.
  81869. * @param scope optional scope for the callback to be called from
  81870. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81871. * @returns the new observer created for the callback
  81872. */
  81873. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81874. /**
  81875. * Create a new Observer with the specified callback and unregisters after the next notification
  81876. * @param callback the callback that will be executed for that Observer
  81877. * @returns the new observer created for the callback
  81878. */
  81879. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81880. /**
  81881. * Remove an Observer from the Observable object
  81882. * @param observer the instance of the Observer to remove
  81883. * @returns false if it doesn't belong to this Observable
  81884. */
  81885. remove(observer: Nullable<Observer<T>>): boolean;
  81886. /**
  81887. * Remove a callback from the Observable object
  81888. * @param callback the callback to remove
  81889. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81890. * @returns false if it doesn't belong to this Observable
  81891. */
  81892. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81893. private _deferUnregister;
  81894. private _remove;
  81895. /**
  81896. * Moves the observable to the top of the observer list making it get called first when notified
  81897. * @param observer the observer to move
  81898. */
  81899. makeObserverTopPriority(observer: Observer<T>): void;
  81900. /**
  81901. * Moves the observable to the bottom of the observer list making it get called last when notified
  81902. * @param observer the observer to move
  81903. */
  81904. makeObserverBottomPriority(observer: Observer<T>): void;
  81905. /**
  81906. * Notify all Observers by calling their respective callback with the given data
  81907. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81908. * @param eventData defines the data to send to all observers
  81909. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81910. * @param target defines the original target of the state
  81911. * @param currentTarget defines the current target of the state
  81912. * @param userInfo defines any user info to send to observers
  81913. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81914. */
  81915. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81916. /**
  81917. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81918. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81919. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81920. * and it is crucial that all callbacks will be executed.
  81921. * The order of the callbacks is kept, callbacks are not executed parallel.
  81922. *
  81923. * @param eventData The data to be sent to each callback
  81924. * @param mask is used to filter observers defaults to -1
  81925. * @param target defines the callback target (see EventState)
  81926. * @param currentTarget defines he current object in the bubbling phase
  81927. * @param userInfo defines any user info to send to observers
  81928. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81929. */
  81930. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81931. /**
  81932. * Notify a specific observer
  81933. * @param observer defines the observer to notify
  81934. * @param eventData defines the data to be sent to each callback
  81935. * @param mask is used to filter observers defaults to -1
  81936. */
  81937. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81938. /**
  81939. * Gets a boolean indicating if the observable has at least one observer
  81940. * @returns true is the Observable has at least one Observer registered
  81941. */
  81942. hasObservers(): boolean;
  81943. /**
  81944. * Clear the list of observers
  81945. */
  81946. clear(): void;
  81947. /**
  81948. * Clone the current observable
  81949. * @returns a new observable
  81950. */
  81951. clone(): Observable<T>;
  81952. /**
  81953. * Does this observable handles observer registered with a given mask
  81954. * @param mask defines the mask to be tested
  81955. * @return whether or not one observer registered with the given mask is handeled
  81956. **/
  81957. hasSpecificMask(mask?: number): boolean;
  81958. }
  81959. }
  81960. declare module BABYLON {
  81961. /**
  81962. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81963. * Babylon.js
  81964. */
  81965. export class DomManagement {
  81966. /**
  81967. * Checks if the window object exists
  81968. * @returns true if the window object exists
  81969. */
  81970. static IsWindowObjectExist(): boolean;
  81971. /**
  81972. * Checks if the navigator object exists
  81973. * @returns true if the navigator object exists
  81974. */
  81975. static IsNavigatorAvailable(): boolean;
  81976. /**
  81977. * Check if the document object exists
  81978. * @returns true if the document object exists
  81979. */
  81980. static IsDocumentAvailable(): boolean;
  81981. /**
  81982. * Extracts text content from a DOM element hierarchy
  81983. * @param element defines the root element
  81984. * @returns a string
  81985. */
  81986. static GetDOMTextContent(element: HTMLElement): string;
  81987. }
  81988. }
  81989. declare module BABYLON {
  81990. /**
  81991. * Logger used througouht the application to allow configuration of
  81992. * the log level required for the messages.
  81993. */
  81994. export class Logger {
  81995. /**
  81996. * No log
  81997. */
  81998. static readonly NoneLogLevel: number;
  81999. /**
  82000. * Only message logs
  82001. */
  82002. static readonly MessageLogLevel: number;
  82003. /**
  82004. * Only warning logs
  82005. */
  82006. static readonly WarningLogLevel: number;
  82007. /**
  82008. * Only error logs
  82009. */
  82010. static readonly ErrorLogLevel: number;
  82011. /**
  82012. * All logs
  82013. */
  82014. static readonly AllLogLevel: number;
  82015. private static _LogCache;
  82016. /**
  82017. * Gets a value indicating the number of loading errors
  82018. * @ignorenaming
  82019. */
  82020. static errorsCount: number;
  82021. /**
  82022. * Callback called when a new log is added
  82023. */
  82024. static OnNewCacheEntry: (entry: string) => void;
  82025. private static _AddLogEntry;
  82026. private static _FormatMessage;
  82027. private static _LogDisabled;
  82028. private static _LogEnabled;
  82029. private static _WarnDisabled;
  82030. private static _WarnEnabled;
  82031. private static _ErrorDisabled;
  82032. private static _ErrorEnabled;
  82033. /**
  82034. * Log a message to the console
  82035. */
  82036. static Log: (message: string) => void;
  82037. /**
  82038. * Write a warning message to the console
  82039. */
  82040. static Warn: (message: string) => void;
  82041. /**
  82042. * Write an error message to the console
  82043. */
  82044. static Error: (message: string) => void;
  82045. /**
  82046. * Gets current log cache (list of logs)
  82047. */
  82048. static get LogCache(): string;
  82049. /**
  82050. * Clears the log cache
  82051. */
  82052. static ClearLogCache(): void;
  82053. /**
  82054. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  82055. */
  82056. static set LogLevels(level: number);
  82057. }
  82058. }
  82059. declare module BABYLON {
  82060. /** @hidden */
  82061. export class _TypeStore {
  82062. /** @hidden */
  82063. static RegisteredTypes: {
  82064. [key: string]: Object;
  82065. };
  82066. /** @hidden */
  82067. static GetClass(fqdn: string): any;
  82068. }
  82069. }
  82070. declare module BABYLON {
  82071. /**
  82072. * Helper to manipulate strings
  82073. */
  82074. export class StringTools {
  82075. /**
  82076. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  82077. * @param str Source string
  82078. * @param suffix Suffix to search for in the source string
  82079. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  82080. */
  82081. static EndsWith(str: string, suffix: string): boolean;
  82082. /**
  82083. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  82084. * @param str Source string
  82085. * @param suffix Suffix to search for in the source string
  82086. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  82087. */
  82088. static StartsWith(str: string, suffix: string): boolean;
  82089. /**
  82090. * Decodes a buffer into a string
  82091. * @param buffer The buffer to decode
  82092. * @returns The decoded string
  82093. */
  82094. static Decode(buffer: Uint8Array | Uint16Array): string;
  82095. /**
  82096. * Encode a buffer to a base64 string
  82097. * @param buffer defines the buffer to encode
  82098. * @returns the encoded string
  82099. */
  82100. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  82101. /**
  82102. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  82103. * @param num the number to convert and pad
  82104. * @param length the expected length of the string
  82105. * @returns the padded string
  82106. */
  82107. static PadNumber(num: number, length: number): string;
  82108. }
  82109. }
  82110. declare module BABYLON {
  82111. /**
  82112. * Class containing a set of static utilities functions for deep copy.
  82113. */
  82114. export class DeepCopier {
  82115. /**
  82116. * Tries to copy an object by duplicating every property
  82117. * @param source defines the source object
  82118. * @param destination defines the target object
  82119. * @param doNotCopyList defines a list of properties to avoid
  82120. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  82121. */
  82122. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  82123. }
  82124. }
  82125. declare module BABYLON {
  82126. /**
  82127. * Class containing a set of static utilities functions for precision date
  82128. */
  82129. export class PrecisionDate {
  82130. /**
  82131. * Gets either window.performance.now() if supported or Date.now() else
  82132. */
  82133. static get Now(): number;
  82134. }
  82135. }
  82136. declare module BABYLON {
  82137. /** @hidden */
  82138. export class _DevTools {
  82139. static WarnImport(name: string): string;
  82140. }
  82141. }
  82142. declare module BABYLON {
  82143. /**
  82144. * Interface used to define the mechanism to get data from the network
  82145. */
  82146. export interface IWebRequest {
  82147. /**
  82148. * Returns client's response url
  82149. */
  82150. responseURL: string;
  82151. /**
  82152. * Returns client's status
  82153. */
  82154. status: number;
  82155. /**
  82156. * Returns client's status as a text
  82157. */
  82158. statusText: string;
  82159. }
  82160. }
  82161. declare module BABYLON {
  82162. /**
  82163. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  82164. */
  82165. export class WebRequest implements IWebRequest {
  82166. private readonly _xhr;
  82167. /**
  82168. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  82169. * i.e. when loading files, where the server/service expects an Authorization header
  82170. */
  82171. static CustomRequestHeaders: {
  82172. [key: string]: string;
  82173. };
  82174. /**
  82175. * Add callback functions in this array to update all the requests before they get sent to the network
  82176. */
  82177. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  82178. private _injectCustomRequestHeaders;
  82179. /**
  82180. * Gets or sets a function to be called when loading progress changes
  82181. */
  82182. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  82183. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  82184. /**
  82185. * Returns client's state
  82186. */
  82187. get readyState(): number;
  82188. /**
  82189. * Returns client's status
  82190. */
  82191. get status(): number;
  82192. /**
  82193. * Returns client's status as a text
  82194. */
  82195. get statusText(): string;
  82196. /**
  82197. * Returns client's response
  82198. */
  82199. get response(): any;
  82200. /**
  82201. * Returns client's response url
  82202. */
  82203. get responseURL(): string;
  82204. /**
  82205. * Returns client's response as text
  82206. */
  82207. get responseText(): string;
  82208. /**
  82209. * Gets or sets the expected response type
  82210. */
  82211. get responseType(): XMLHttpRequestResponseType;
  82212. set responseType(value: XMLHttpRequestResponseType);
  82213. /** @hidden */
  82214. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  82215. /** @hidden */
  82216. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  82217. /**
  82218. * Cancels any network activity
  82219. */
  82220. abort(): void;
  82221. /**
  82222. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  82223. * @param body defines an optional request body
  82224. */
  82225. send(body?: Document | BodyInit | null): void;
  82226. /**
  82227. * Sets the request method, request URL
  82228. * @param method defines the method to use (GET, POST, etc..)
  82229. * @param url defines the url to connect with
  82230. */
  82231. open(method: string, url: string): void;
  82232. /**
  82233. * Sets the value of a request header.
  82234. * @param name The name of the header whose value is to be set
  82235. * @param value The value to set as the body of the header
  82236. */
  82237. setRequestHeader(name: string, value: string): void;
  82238. /**
  82239. * Get the string containing the text of a particular header's value.
  82240. * @param name The name of the header
  82241. * @returns The string containing the text of the given header name
  82242. */
  82243. getResponseHeader(name: string): Nullable<string>;
  82244. }
  82245. }
  82246. declare module BABYLON {
  82247. /**
  82248. * File request interface
  82249. */
  82250. export interface IFileRequest {
  82251. /**
  82252. * Raised when the request is complete (success or error).
  82253. */
  82254. onCompleteObservable: Observable<IFileRequest>;
  82255. /**
  82256. * Aborts the request for a file.
  82257. */
  82258. abort: () => void;
  82259. }
  82260. }
  82261. declare module BABYLON {
  82262. /**
  82263. * Define options used to create a render target texture
  82264. */
  82265. export class RenderTargetCreationOptions {
  82266. /**
  82267. * Specifies is mipmaps must be generated
  82268. */
  82269. generateMipMaps?: boolean;
  82270. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  82271. generateDepthBuffer?: boolean;
  82272. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  82273. generateStencilBuffer?: boolean;
  82274. /** Defines texture type (int by default) */
  82275. type?: number;
  82276. /** Defines sampling mode (trilinear by default) */
  82277. samplingMode?: number;
  82278. /** Defines format (RGBA by default) */
  82279. format?: number;
  82280. }
  82281. }
  82282. declare module BABYLON {
  82283. /** Defines the cross module used constants to avoid circular dependncies */
  82284. export class Constants {
  82285. /** Defines that alpha blending is disabled */
  82286. static readonly ALPHA_DISABLE: number;
  82287. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  82288. static readonly ALPHA_ADD: number;
  82289. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82290. static readonly ALPHA_COMBINE: number;
  82291. /** Defines that alpha blending is DEST - SRC * DEST */
  82292. static readonly ALPHA_SUBTRACT: number;
  82293. /** Defines that alpha blending is SRC * DEST */
  82294. static readonly ALPHA_MULTIPLY: number;
  82295. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  82296. static readonly ALPHA_MAXIMIZED: number;
  82297. /** Defines that alpha blending is SRC + DEST */
  82298. static readonly ALPHA_ONEONE: number;
  82299. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  82300. static readonly ALPHA_PREMULTIPLIED: number;
  82301. /**
  82302. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  82303. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82304. */
  82305. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82306. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  82307. static readonly ALPHA_INTERPOLATE: number;
  82308. /**
  82309. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  82310. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82311. */
  82312. static readonly ALPHA_SCREENMODE: number;
  82313. /**
  82314. * Defines that alpha blending is SRC + DST
  82315. * Alpha will be set to SRC ALPHA + DST ALPHA
  82316. */
  82317. static readonly ALPHA_ONEONE_ONEONE: number;
  82318. /**
  82319. * Defines that alpha blending is SRC * DST ALPHA + DST
  82320. * Alpha will be set to 0
  82321. */
  82322. static readonly ALPHA_ALPHATOCOLOR: number;
  82323. /**
  82324. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82325. */
  82326. static readonly ALPHA_REVERSEONEMINUS: number;
  82327. /**
  82328. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  82329. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  82330. */
  82331. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  82332. /**
  82333. * Defines that alpha blending is SRC + DST
  82334. * Alpha will be set to SRC ALPHA
  82335. */
  82336. static readonly ALPHA_ONEONE_ONEZERO: number;
  82337. /**
  82338. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82339. * Alpha will be set to DST ALPHA
  82340. */
  82341. static readonly ALPHA_EXCLUSION: number;
  82342. /** Defines that alpha blending equation a SUM */
  82343. static readonly ALPHA_EQUATION_ADD: number;
  82344. /** Defines that alpha blending equation a SUBSTRACTION */
  82345. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  82346. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  82347. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  82348. /** Defines that alpha blending equation a MAX operation */
  82349. static readonly ALPHA_EQUATION_MAX: number;
  82350. /** Defines that alpha blending equation a MIN operation */
  82351. static readonly ALPHA_EQUATION_MIN: number;
  82352. /**
  82353. * Defines that alpha blending equation a DARKEN operation:
  82354. * It takes the min of the src and sums the alpha channels.
  82355. */
  82356. static readonly ALPHA_EQUATION_DARKEN: number;
  82357. /** Defines that the ressource is not delayed*/
  82358. static readonly DELAYLOADSTATE_NONE: number;
  82359. /** Defines that the ressource was successfully delay loaded */
  82360. static readonly DELAYLOADSTATE_LOADED: number;
  82361. /** Defines that the ressource is currently delay loading */
  82362. static readonly DELAYLOADSTATE_LOADING: number;
  82363. /** Defines that the ressource is delayed and has not started loading */
  82364. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82365. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82366. static readonly NEVER: number;
  82367. /** 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 */
  82368. static readonly ALWAYS: number;
  82369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82370. static readonly LESS: number;
  82371. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82372. static readonly EQUAL: number;
  82373. /** 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 */
  82374. static readonly LEQUAL: number;
  82375. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82376. static readonly GREATER: number;
  82377. /** 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 */
  82378. static readonly GEQUAL: number;
  82379. /** 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 */
  82380. static readonly NOTEQUAL: number;
  82381. /** Passed to stencilOperation to specify that stencil value must be kept */
  82382. static readonly KEEP: number;
  82383. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82384. static readonly REPLACE: number;
  82385. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82386. static readonly INCR: number;
  82387. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82388. static readonly DECR: number;
  82389. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82390. static readonly INVERT: number;
  82391. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82392. static readonly INCR_WRAP: number;
  82393. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82394. static readonly DECR_WRAP: number;
  82395. /** Texture is not repeating outside of 0..1 UVs */
  82396. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82397. /** Texture is repeating outside of 0..1 UVs */
  82398. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82399. /** Texture is repeating and mirrored */
  82400. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82401. /** ALPHA */
  82402. static readonly TEXTUREFORMAT_ALPHA: number;
  82403. /** LUMINANCE */
  82404. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82405. /** LUMINANCE_ALPHA */
  82406. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82407. /** RGB */
  82408. static readonly TEXTUREFORMAT_RGB: number;
  82409. /** RGBA */
  82410. static readonly TEXTUREFORMAT_RGBA: number;
  82411. /** RED */
  82412. static readonly TEXTUREFORMAT_RED: number;
  82413. /** RED (2nd reference) */
  82414. static readonly TEXTUREFORMAT_R: number;
  82415. /** RG */
  82416. static readonly TEXTUREFORMAT_RG: number;
  82417. /** RED_INTEGER */
  82418. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82419. /** RED_INTEGER (2nd reference) */
  82420. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82421. /** RG_INTEGER */
  82422. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82423. /** RGB_INTEGER */
  82424. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82425. /** RGBA_INTEGER */
  82426. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82427. /** UNSIGNED_BYTE */
  82428. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82429. /** UNSIGNED_BYTE (2nd reference) */
  82430. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82431. /** FLOAT */
  82432. static readonly TEXTURETYPE_FLOAT: number;
  82433. /** HALF_FLOAT */
  82434. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82435. /** BYTE */
  82436. static readonly TEXTURETYPE_BYTE: number;
  82437. /** SHORT */
  82438. static readonly TEXTURETYPE_SHORT: number;
  82439. /** UNSIGNED_SHORT */
  82440. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82441. /** INT */
  82442. static readonly TEXTURETYPE_INT: number;
  82443. /** UNSIGNED_INT */
  82444. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82445. /** UNSIGNED_SHORT_4_4_4_4 */
  82446. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82447. /** UNSIGNED_SHORT_5_5_5_1 */
  82448. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82449. /** UNSIGNED_SHORT_5_6_5 */
  82450. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82451. /** UNSIGNED_INT_2_10_10_10_REV */
  82452. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82453. /** UNSIGNED_INT_24_8 */
  82454. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82455. /** UNSIGNED_INT_10F_11F_11F_REV */
  82456. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82457. /** UNSIGNED_INT_5_9_9_9_REV */
  82458. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82459. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82460. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82461. /** nearest is mag = nearest and min = nearest and no mip */
  82462. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82463. /** mag = nearest and min = nearest and mip = none */
  82464. static readonly TEXTURE_NEAREST_NEAREST: number;
  82465. /** Bilinear is mag = linear and min = linear and no mip */
  82466. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82467. /** mag = linear and min = linear and mip = none */
  82468. static readonly TEXTURE_LINEAR_LINEAR: number;
  82469. /** Trilinear is mag = linear and min = linear and mip = linear */
  82470. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82471. /** Trilinear is mag = linear and min = linear and mip = linear */
  82472. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82473. /** mag = nearest and min = nearest and mip = nearest */
  82474. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82475. /** mag = nearest and min = linear and mip = nearest */
  82476. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82477. /** mag = nearest and min = linear and mip = linear */
  82478. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82479. /** mag = nearest and min = linear and mip = none */
  82480. static readonly TEXTURE_NEAREST_LINEAR: number;
  82481. /** nearest is mag = nearest and min = nearest and mip = linear */
  82482. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82483. /** mag = linear and min = nearest and mip = nearest */
  82484. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82485. /** mag = linear and min = nearest and mip = linear */
  82486. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82487. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82488. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82489. /** mag = linear and min = nearest and mip = none */
  82490. static readonly TEXTURE_LINEAR_NEAREST: number;
  82491. /** Explicit coordinates mode */
  82492. static readonly TEXTURE_EXPLICIT_MODE: number;
  82493. /** Spherical coordinates mode */
  82494. static readonly TEXTURE_SPHERICAL_MODE: number;
  82495. /** Planar coordinates mode */
  82496. static readonly TEXTURE_PLANAR_MODE: number;
  82497. /** Cubic coordinates mode */
  82498. static readonly TEXTURE_CUBIC_MODE: number;
  82499. /** Projection coordinates mode */
  82500. static readonly TEXTURE_PROJECTION_MODE: number;
  82501. /** Skybox coordinates mode */
  82502. static readonly TEXTURE_SKYBOX_MODE: number;
  82503. /** Inverse Cubic coordinates mode */
  82504. static readonly TEXTURE_INVCUBIC_MODE: number;
  82505. /** Equirectangular coordinates mode */
  82506. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82507. /** Equirectangular Fixed coordinates mode */
  82508. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82509. /** Equirectangular Fixed Mirrored coordinates mode */
  82510. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82511. /** Offline (baking) quality for texture filtering */
  82512. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  82513. /** High quality for texture filtering */
  82514. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  82515. /** Medium quality for texture filtering */
  82516. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  82517. /** Low quality for texture filtering */
  82518. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  82519. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82520. static readonly SCALEMODE_FLOOR: number;
  82521. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82522. static readonly SCALEMODE_NEAREST: number;
  82523. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82524. static readonly SCALEMODE_CEILING: number;
  82525. /**
  82526. * The dirty texture flag value
  82527. */
  82528. static readonly MATERIAL_TextureDirtyFlag: number;
  82529. /**
  82530. * The dirty light flag value
  82531. */
  82532. static readonly MATERIAL_LightDirtyFlag: number;
  82533. /**
  82534. * The dirty fresnel flag value
  82535. */
  82536. static readonly MATERIAL_FresnelDirtyFlag: number;
  82537. /**
  82538. * The dirty attribute flag value
  82539. */
  82540. static readonly MATERIAL_AttributesDirtyFlag: number;
  82541. /**
  82542. * The dirty misc flag value
  82543. */
  82544. static readonly MATERIAL_MiscDirtyFlag: number;
  82545. /**
  82546. * The dirty prepass flag value
  82547. */
  82548. static readonly MATERIAL_PrePassDirtyFlag: number;
  82549. /**
  82550. * The all dirty flag value
  82551. */
  82552. static readonly MATERIAL_AllDirtyFlag: number;
  82553. /**
  82554. * Returns the triangle fill mode
  82555. */
  82556. static readonly MATERIAL_TriangleFillMode: number;
  82557. /**
  82558. * Returns the wireframe mode
  82559. */
  82560. static readonly MATERIAL_WireFrameFillMode: number;
  82561. /**
  82562. * Returns the point fill mode
  82563. */
  82564. static readonly MATERIAL_PointFillMode: number;
  82565. /**
  82566. * Returns the point list draw mode
  82567. */
  82568. static readonly MATERIAL_PointListDrawMode: number;
  82569. /**
  82570. * Returns the line list draw mode
  82571. */
  82572. static readonly MATERIAL_LineListDrawMode: number;
  82573. /**
  82574. * Returns the line loop draw mode
  82575. */
  82576. static readonly MATERIAL_LineLoopDrawMode: number;
  82577. /**
  82578. * Returns the line strip draw mode
  82579. */
  82580. static readonly MATERIAL_LineStripDrawMode: number;
  82581. /**
  82582. * Returns the triangle strip draw mode
  82583. */
  82584. static readonly MATERIAL_TriangleStripDrawMode: number;
  82585. /**
  82586. * Returns the triangle fan draw mode
  82587. */
  82588. static readonly MATERIAL_TriangleFanDrawMode: number;
  82589. /**
  82590. * Stores the clock-wise side orientation
  82591. */
  82592. static readonly MATERIAL_ClockWiseSideOrientation: number;
  82593. /**
  82594. * Stores the counter clock-wise side orientation
  82595. */
  82596. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  82597. /**
  82598. * Nothing
  82599. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82600. */
  82601. static readonly ACTION_NothingTrigger: number;
  82602. /**
  82603. * On pick
  82604. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82605. */
  82606. static readonly ACTION_OnPickTrigger: number;
  82607. /**
  82608. * On left pick
  82609. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82610. */
  82611. static readonly ACTION_OnLeftPickTrigger: number;
  82612. /**
  82613. * On right pick
  82614. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82615. */
  82616. static readonly ACTION_OnRightPickTrigger: number;
  82617. /**
  82618. * On center pick
  82619. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82620. */
  82621. static readonly ACTION_OnCenterPickTrigger: number;
  82622. /**
  82623. * On pick down
  82624. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82625. */
  82626. static readonly ACTION_OnPickDownTrigger: number;
  82627. /**
  82628. * On double pick
  82629. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82630. */
  82631. static readonly ACTION_OnDoublePickTrigger: number;
  82632. /**
  82633. * On pick up
  82634. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82635. */
  82636. static readonly ACTION_OnPickUpTrigger: number;
  82637. /**
  82638. * On pick out.
  82639. * This trigger will only be raised if you also declared a OnPickDown
  82640. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82641. */
  82642. static readonly ACTION_OnPickOutTrigger: number;
  82643. /**
  82644. * On long press
  82645. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82646. */
  82647. static readonly ACTION_OnLongPressTrigger: number;
  82648. /**
  82649. * On pointer over
  82650. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82651. */
  82652. static readonly ACTION_OnPointerOverTrigger: number;
  82653. /**
  82654. * On pointer out
  82655. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82656. */
  82657. static readonly ACTION_OnPointerOutTrigger: number;
  82658. /**
  82659. * On every frame
  82660. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82661. */
  82662. static readonly ACTION_OnEveryFrameTrigger: number;
  82663. /**
  82664. * On intersection enter
  82665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82666. */
  82667. static readonly ACTION_OnIntersectionEnterTrigger: number;
  82668. /**
  82669. * On intersection exit
  82670. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82671. */
  82672. static readonly ACTION_OnIntersectionExitTrigger: number;
  82673. /**
  82674. * On key down
  82675. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82676. */
  82677. static readonly ACTION_OnKeyDownTrigger: number;
  82678. /**
  82679. * On key up
  82680. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82681. */
  82682. static readonly ACTION_OnKeyUpTrigger: number;
  82683. /**
  82684. * Billboard mode will only apply to Y axis
  82685. */
  82686. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  82687. /**
  82688. * Billboard mode will apply to all axes
  82689. */
  82690. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  82691. /**
  82692. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82693. */
  82694. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  82695. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82696. * Test order :
  82697. * Is the bounding sphere outside the frustum ?
  82698. * If not, are the bounding box vertices outside the frustum ?
  82699. * It not, then the cullable object is in the frustum.
  82700. */
  82701. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  82702. /** Culling strategy : Bounding Sphere Only.
  82703. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82704. * It's also less accurate than the standard because some not visible objects can still be selected.
  82705. * Test : is the bounding sphere outside the frustum ?
  82706. * If not, then the cullable object is in the frustum.
  82707. */
  82708. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82709. /** Culling strategy : Optimistic Inclusion.
  82710. * This in an inclusion test first, then the standard exclusion test.
  82711. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82712. * 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.
  82713. * Anyway, it's as accurate as the standard strategy.
  82714. * Test :
  82715. * Is the cullable object bounding sphere center in the frustum ?
  82716. * If not, apply the default culling strategy.
  82717. */
  82718. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82719. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82720. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82721. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82722. * 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.
  82723. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82724. * Test :
  82725. * Is the cullable object bounding sphere center in the frustum ?
  82726. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82727. */
  82728. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82729. /**
  82730. * No logging while loading
  82731. */
  82732. static readonly SCENELOADER_NO_LOGGING: number;
  82733. /**
  82734. * Minimal logging while loading
  82735. */
  82736. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  82737. /**
  82738. * Summary logging while loading
  82739. */
  82740. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  82741. /**
  82742. * Detailled logging while loading
  82743. */
  82744. static readonly SCENELOADER_DETAILED_LOGGING: number;
  82745. /**
  82746. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  82747. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  82748. */
  82749. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  82750. /**
  82751. * Constant used to retrieve the position texture index in the textures array in the prepass
  82752. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  82753. */
  82754. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  82755. /**
  82756. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  82757. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  82758. */
  82759. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  82760. /**
  82761. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  82762. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  82763. */
  82764. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  82765. /**
  82766. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  82767. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  82768. */
  82769. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  82770. /**
  82771. * Constant used to retrieve depth + normal index in the textures array in the prepass
  82772. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  82773. */
  82774. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  82775. /**
  82776. * Constant used to retrieve albedo index in the textures array in the prepass
  82777. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  82778. */
  82779. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  82780. }
  82781. }
  82782. declare module BABYLON {
  82783. /**
  82784. * This represents the required contract to create a new type of texture loader.
  82785. */
  82786. export interface IInternalTextureLoader {
  82787. /**
  82788. * Defines wether the loader supports cascade loading the different faces.
  82789. */
  82790. supportCascades: boolean;
  82791. /**
  82792. * This returns if the loader support the current file information.
  82793. * @param extension defines the file extension of the file being loaded
  82794. * @param mimeType defines the optional mime type of the file being loaded
  82795. * @returns true if the loader can load the specified file
  82796. */
  82797. canLoad(extension: string, mimeType?: string): boolean;
  82798. /**
  82799. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  82800. * @param data contains the texture data
  82801. * @param texture defines the BabylonJS internal texture
  82802. * @param createPolynomials will be true if polynomials have been requested
  82803. * @param onLoad defines the callback to trigger once the texture is ready
  82804. * @param onError defines the callback to trigger in case of error
  82805. * @param options options to be passed to the loader
  82806. */
  82807. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  82808. /**
  82809. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  82810. * @param data contains the texture data
  82811. * @param texture defines the BabylonJS internal texture
  82812. * @param callback defines the method to call once ready to upload
  82813. * @param options options to be passed to the loader
  82814. */
  82815. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  82816. }
  82817. }
  82818. declare module BABYLON {
  82819. /**
  82820. * Class used to store and describe the pipeline context associated with an effect
  82821. */
  82822. export interface IPipelineContext {
  82823. /**
  82824. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  82825. */
  82826. isAsync: boolean;
  82827. /**
  82828. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  82829. */
  82830. isReady: boolean;
  82831. /** @hidden */
  82832. _getVertexShaderCode(): string | null;
  82833. /** @hidden */
  82834. _getFragmentShaderCode(): string | null;
  82835. /** @hidden */
  82836. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  82837. }
  82838. }
  82839. declare module BABYLON {
  82840. /**
  82841. * Class used to store gfx data (like WebGLBuffer)
  82842. */
  82843. export class DataBuffer {
  82844. /**
  82845. * Gets or sets the number of objects referencing this buffer
  82846. */
  82847. references: number;
  82848. /** Gets or sets the size of the underlying buffer */
  82849. capacity: number;
  82850. /**
  82851. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82852. */
  82853. is32Bits: boolean;
  82854. /**
  82855. * Gets the underlying buffer
  82856. */
  82857. get underlyingResource(): any;
  82858. }
  82859. }
  82860. declare module BABYLON {
  82861. /** @hidden */
  82862. export interface IShaderProcessor {
  82863. attributeProcessor?: (attribute: string) => string;
  82864. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82865. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82866. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82867. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82868. lineProcessor?: (line: string, isFragment: boolean) => string;
  82869. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82870. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82871. }
  82872. }
  82873. declare module BABYLON {
  82874. /** @hidden */
  82875. export interface ProcessingOptions {
  82876. defines: string[];
  82877. indexParameters: any;
  82878. isFragment: boolean;
  82879. shouldUseHighPrecisionShader: boolean;
  82880. supportsUniformBuffers: boolean;
  82881. shadersRepository: string;
  82882. includesShadersStore: {
  82883. [key: string]: string;
  82884. };
  82885. processor?: IShaderProcessor;
  82886. version: string;
  82887. platformName: string;
  82888. lookForClosingBracketForUniformBuffer?: boolean;
  82889. }
  82890. }
  82891. declare module BABYLON {
  82892. /** @hidden */
  82893. export class ShaderCodeNode {
  82894. line: string;
  82895. children: ShaderCodeNode[];
  82896. additionalDefineKey?: string;
  82897. additionalDefineValue?: string;
  82898. isValid(preprocessors: {
  82899. [key: string]: string;
  82900. }): boolean;
  82901. process(preprocessors: {
  82902. [key: string]: string;
  82903. }, options: ProcessingOptions): string;
  82904. }
  82905. }
  82906. declare module BABYLON {
  82907. /** @hidden */
  82908. export class ShaderCodeCursor {
  82909. private _lines;
  82910. lineIndex: number;
  82911. get currentLine(): string;
  82912. get canRead(): boolean;
  82913. set lines(value: string[]);
  82914. }
  82915. }
  82916. declare module BABYLON {
  82917. /** @hidden */
  82918. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82919. process(preprocessors: {
  82920. [key: string]: string;
  82921. }, options: ProcessingOptions): string;
  82922. }
  82923. }
  82924. declare module BABYLON {
  82925. /** @hidden */
  82926. export class ShaderDefineExpression {
  82927. isTrue(preprocessors: {
  82928. [key: string]: string;
  82929. }): boolean;
  82930. private static _OperatorPriority;
  82931. private static _Stack;
  82932. static postfixToInfix(postfix: string[]): string;
  82933. static infixToPostfix(infix: string): string[];
  82934. }
  82935. }
  82936. declare module BABYLON {
  82937. /** @hidden */
  82938. export class ShaderCodeTestNode extends ShaderCodeNode {
  82939. testExpression: ShaderDefineExpression;
  82940. isValid(preprocessors: {
  82941. [key: string]: string;
  82942. }): boolean;
  82943. }
  82944. }
  82945. declare module BABYLON {
  82946. /** @hidden */
  82947. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82948. define: string;
  82949. not: boolean;
  82950. constructor(define: string, not?: boolean);
  82951. isTrue(preprocessors: {
  82952. [key: string]: string;
  82953. }): boolean;
  82954. }
  82955. }
  82956. declare module BABYLON {
  82957. /** @hidden */
  82958. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82959. leftOperand: ShaderDefineExpression;
  82960. rightOperand: ShaderDefineExpression;
  82961. isTrue(preprocessors: {
  82962. [key: string]: string;
  82963. }): boolean;
  82964. }
  82965. }
  82966. declare module BABYLON {
  82967. /** @hidden */
  82968. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82969. leftOperand: ShaderDefineExpression;
  82970. rightOperand: ShaderDefineExpression;
  82971. isTrue(preprocessors: {
  82972. [key: string]: string;
  82973. }): boolean;
  82974. }
  82975. }
  82976. declare module BABYLON {
  82977. /** @hidden */
  82978. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82979. define: string;
  82980. operand: string;
  82981. testValue: string;
  82982. constructor(define: string, operand: string, testValue: string);
  82983. isTrue(preprocessors: {
  82984. [key: string]: string;
  82985. }): boolean;
  82986. }
  82987. }
  82988. declare module BABYLON {
  82989. /**
  82990. * Class used to enable access to offline support
  82991. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82992. */
  82993. export interface IOfflineProvider {
  82994. /**
  82995. * Gets a boolean indicating if scene must be saved in the database
  82996. */
  82997. enableSceneOffline: boolean;
  82998. /**
  82999. * Gets a boolean indicating if textures must be saved in the database
  83000. */
  83001. enableTexturesOffline: boolean;
  83002. /**
  83003. * Open the offline support and make it available
  83004. * @param successCallback defines the callback to call on success
  83005. * @param errorCallback defines the callback to call on error
  83006. */
  83007. open(successCallback: () => void, errorCallback: () => void): void;
  83008. /**
  83009. * Loads an image from the offline support
  83010. * @param url defines the url to load from
  83011. * @param image defines the target DOM image
  83012. */
  83013. loadImage(url: string, image: HTMLImageElement): void;
  83014. /**
  83015. * Loads a file from offline support
  83016. * @param url defines the URL to load from
  83017. * @param sceneLoaded defines a callback to call on success
  83018. * @param progressCallBack defines a callback to call when progress changed
  83019. * @param errorCallback defines a callback to call on error
  83020. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  83021. */
  83022. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  83023. }
  83024. }
  83025. declare module BABYLON {
  83026. /**
  83027. * Class used to help managing file picking and drag'n'drop
  83028. * File Storage
  83029. */
  83030. export class FilesInputStore {
  83031. /**
  83032. * List of files ready to be loaded
  83033. */
  83034. static FilesToLoad: {
  83035. [key: string]: File;
  83036. };
  83037. }
  83038. }
  83039. declare module BABYLON {
  83040. /**
  83041. * Class used to define a retry strategy when error happens while loading assets
  83042. */
  83043. export class RetryStrategy {
  83044. /**
  83045. * Function used to defines an exponential back off strategy
  83046. * @param maxRetries defines the maximum number of retries (3 by default)
  83047. * @param baseInterval defines the interval between retries
  83048. * @returns the strategy function to use
  83049. */
  83050. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  83051. }
  83052. }
  83053. declare module BABYLON {
  83054. /**
  83055. * @ignore
  83056. * Application error to support additional information when loading a file
  83057. */
  83058. export abstract class BaseError extends Error {
  83059. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  83060. }
  83061. }
  83062. declare module BABYLON {
  83063. /** @ignore */
  83064. export class LoadFileError extends BaseError {
  83065. request?: WebRequest;
  83066. file?: File;
  83067. /**
  83068. * Creates a new LoadFileError
  83069. * @param message defines the message of the error
  83070. * @param request defines the optional web request
  83071. * @param file defines the optional file
  83072. */
  83073. constructor(message: string, object?: WebRequest | File);
  83074. }
  83075. /** @ignore */
  83076. export class RequestFileError extends BaseError {
  83077. request: WebRequest;
  83078. /**
  83079. * Creates a new LoadFileError
  83080. * @param message defines the message of the error
  83081. * @param request defines the optional web request
  83082. */
  83083. constructor(message: string, request: WebRequest);
  83084. }
  83085. /** @ignore */
  83086. export class ReadFileError extends BaseError {
  83087. file: File;
  83088. /**
  83089. * Creates a new ReadFileError
  83090. * @param message defines the message of the error
  83091. * @param file defines the optional file
  83092. */
  83093. constructor(message: string, file: File);
  83094. }
  83095. /**
  83096. * @hidden
  83097. */
  83098. export class FileTools {
  83099. /**
  83100. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  83101. */
  83102. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  83103. /**
  83104. * Gets or sets the base URL to use to load assets
  83105. */
  83106. static BaseUrl: string;
  83107. /**
  83108. * Default behaviour for cors in the application.
  83109. * It can be a string if the expected behavior is identical in the entire app.
  83110. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  83111. */
  83112. static CorsBehavior: string | ((url: string | string[]) => string);
  83113. /**
  83114. * Gets or sets a function used to pre-process url before using them to load assets
  83115. */
  83116. static PreprocessUrl: (url: string) => string;
  83117. /**
  83118. * Removes unwanted characters from an url
  83119. * @param url defines the url to clean
  83120. * @returns the cleaned url
  83121. */
  83122. private static _CleanUrl;
  83123. /**
  83124. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  83125. * @param url define the url we are trying
  83126. * @param element define the dom element where to configure the cors policy
  83127. */
  83128. static SetCorsBehavior(url: string | string[], element: {
  83129. crossOrigin: string | null;
  83130. }): void;
  83131. /**
  83132. * Loads an image as an HTMLImageElement.
  83133. * @param input url string, ArrayBuffer, or Blob to load
  83134. * @param onLoad callback called when the image successfully loads
  83135. * @param onError callback called when the image fails to load
  83136. * @param offlineProvider offline provider for caching
  83137. * @param mimeType optional mime type
  83138. * @returns the HTMLImageElement of the loaded image
  83139. */
  83140. 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>;
  83141. /**
  83142. * Reads a file from a File object
  83143. * @param file defines the file to load
  83144. * @param onSuccess defines the callback to call when data is loaded
  83145. * @param onProgress defines the callback to call during loading process
  83146. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  83147. * @param onError defines the callback to call when an error occurs
  83148. * @returns a file request object
  83149. */
  83150. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  83151. /**
  83152. * Loads a file from a url
  83153. * @param url url to load
  83154. * @param onSuccess callback called when the file successfully loads
  83155. * @param onProgress callback called while file is loading (if the server supports this mode)
  83156. * @param offlineProvider defines the offline provider for caching
  83157. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83158. * @param onError callback called when the file fails to load
  83159. * @returns a file request object
  83160. */
  83161. 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;
  83162. /**
  83163. * Loads a file
  83164. * @param url url to load
  83165. * @param onSuccess callback called when the file successfully loads
  83166. * @param onProgress callback called while file is loading (if the server supports this mode)
  83167. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83168. * @param onError callback called when the file fails to load
  83169. * @param onOpened callback called when the web request is opened
  83170. * @returns a file request object
  83171. */
  83172. 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;
  83173. /**
  83174. * Checks if the loaded document was accessed via `file:`-Protocol.
  83175. * @returns boolean
  83176. */
  83177. static IsFileURL(): boolean;
  83178. }
  83179. }
  83180. declare module BABYLON {
  83181. /** @hidden */
  83182. export class ShaderProcessor {
  83183. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  83184. private static _ProcessPrecision;
  83185. private static _ExtractOperation;
  83186. private static _BuildSubExpression;
  83187. private static _BuildExpression;
  83188. private static _MoveCursorWithinIf;
  83189. private static _MoveCursor;
  83190. private static _EvaluatePreProcessors;
  83191. private static _PreparePreProcessors;
  83192. private static _ProcessShaderConversion;
  83193. private static _ProcessIncludes;
  83194. /**
  83195. * Loads a file from a url
  83196. * @param url url to load
  83197. * @param onSuccess callback called when the file successfully loads
  83198. * @param onProgress callback called while file is loading (if the server supports this mode)
  83199. * @param offlineProvider defines the offline provider for caching
  83200. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83201. * @param onError callback called when the file fails to load
  83202. * @returns a file request object
  83203. * @hidden
  83204. */
  83205. 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;
  83206. }
  83207. }
  83208. declare module BABYLON {
  83209. /**
  83210. * @hidden
  83211. */
  83212. export interface IColor4Like {
  83213. r: float;
  83214. g: float;
  83215. b: float;
  83216. a: float;
  83217. }
  83218. /**
  83219. * @hidden
  83220. */
  83221. export interface IColor3Like {
  83222. r: float;
  83223. g: float;
  83224. b: float;
  83225. }
  83226. /**
  83227. * @hidden
  83228. */
  83229. export interface IVector4Like {
  83230. x: float;
  83231. y: float;
  83232. z: float;
  83233. w: float;
  83234. }
  83235. /**
  83236. * @hidden
  83237. */
  83238. export interface IVector3Like {
  83239. x: float;
  83240. y: float;
  83241. z: float;
  83242. }
  83243. /**
  83244. * @hidden
  83245. */
  83246. export interface IVector2Like {
  83247. x: float;
  83248. y: float;
  83249. }
  83250. /**
  83251. * @hidden
  83252. */
  83253. export interface IMatrixLike {
  83254. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83255. updateFlag: int;
  83256. }
  83257. /**
  83258. * @hidden
  83259. */
  83260. export interface IViewportLike {
  83261. x: float;
  83262. y: float;
  83263. width: float;
  83264. height: float;
  83265. }
  83266. /**
  83267. * @hidden
  83268. */
  83269. export interface IPlaneLike {
  83270. normal: IVector3Like;
  83271. d: float;
  83272. normalize(): void;
  83273. }
  83274. }
  83275. declare module BABYLON {
  83276. /**
  83277. * Interface used to define common properties for effect fallbacks
  83278. */
  83279. export interface IEffectFallbacks {
  83280. /**
  83281. * Removes the defines that should be removed when falling back.
  83282. * @param currentDefines defines the current define statements for the shader.
  83283. * @param effect defines the current effect we try to compile
  83284. * @returns The resulting defines with defines of the current rank removed.
  83285. */
  83286. reduce(currentDefines: string, effect: Effect): string;
  83287. /**
  83288. * Removes the fallback from the bound mesh.
  83289. */
  83290. unBindMesh(): void;
  83291. /**
  83292. * Checks to see if more fallbacks are still availible.
  83293. */
  83294. hasMoreFallbacks: boolean;
  83295. }
  83296. }
  83297. declare module BABYLON {
  83298. /**
  83299. * Interface for the size containing width and height
  83300. */
  83301. export interface ISize {
  83302. /**
  83303. * Width
  83304. */
  83305. width: number;
  83306. /**
  83307. * Heighht
  83308. */
  83309. height: number;
  83310. }
  83311. /**
  83312. * Size containing widht and height
  83313. */
  83314. export class Size implements ISize {
  83315. /**
  83316. * Width
  83317. */
  83318. width: number;
  83319. /**
  83320. * Height
  83321. */
  83322. height: number;
  83323. /**
  83324. * Creates a Size object from the given width and height (floats).
  83325. * @param width width of the new size
  83326. * @param height height of the new size
  83327. */
  83328. constructor(width: number, height: number);
  83329. /**
  83330. * Returns a string with the Size width and height
  83331. * @returns a string with the Size width and height
  83332. */
  83333. toString(): string;
  83334. /**
  83335. * "Size"
  83336. * @returns the string "Size"
  83337. */
  83338. getClassName(): string;
  83339. /**
  83340. * Returns the Size hash code.
  83341. * @returns a hash code for a unique width and height
  83342. */
  83343. getHashCode(): number;
  83344. /**
  83345. * Updates the current size from the given one.
  83346. * @param src the given size
  83347. */
  83348. copyFrom(src: Size): void;
  83349. /**
  83350. * Updates in place the current Size from the given floats.
  83351. * @param width width of the new size
  83352. * @param height height of the new size
  83353. * @returns the updated Size.
  83354. */
  83355. copyFromFloats(width: number, height: number): Size;
  83356. /**
  83357. * Updates in place the current Size from the given floats.
  83358. * @param width width to set
  83359. * @param height height to set
  83360. * @returns the updated Size.
  83361. */
  83362. set(width: number, height: number): Size;
  83363. /**
  83364. * Multiplies the width and height by numbers
  83365. * @param w factor to multiple the width by
  83366. * @param h factor to multiple the height by
  83367. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83368. */
  83369. multiplyByFloats(w: number, h: number): Size;
  83370. /**
  83371. * Clones the size
  83372. * @returns a new Size copied from the given one.
  83373. */
  83374. clone(): Size;
  83375. /**
  83376. * True if the current Size and the given one width and height are strictly equal.
  83377. * @param other the other size to compare against
  83378. * @returns True if the current Size and the given one width and height are strictly equal.
  83379. */
  83380. equals(other: Size): boolean;
  83381. /**
  83382. * The surface of the Size : width * height (float).
  83383. */
  83384. get surface(): number;
  83385. /**
  83386. * Create a new size of zero
  83387. * @returns a new Size set to (0.0, 0.0)
  83388. */
  83389. static Zero(): Size;
  83390. /**
  83391. * Sums the width and height of two sizes
  83392. * @param otherSize size to add to this size
  83393. * @returns a new Size set as the addition result of the current Size and the given one.
  83394. */
  83395. add(otherSize: Size): Size;
  83396. /**
  83397. * Subtracts the width and height of two
  83398. * @param otherSize size to subtract to this size
  83399. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83400. */
  83401. subtract(otherSize: Size): Size;
  83402. /**
  83403. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83404. * @param start starting size to lerp between
  83405. * @param end end size to lerp between
  83406. * @param amount amount to lerp between the start and end values
  83407. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83408. */
  83409. static Lerp(start: Size, end: Size, amount: number): Size;
  83410. }
  83411. }
  83412. declare module BABYLON {
  83413. /**
  83414. * Base class of all the textures in babylon.
  83415. * It groups all the common properties required to work with Thin Engine.
  83416. */
  83417. export class ThinTexture {
  83418. protected _wrapU: number;
  83419. /**
  83420. * | Value | Type | Description |
  83421. * | ----- | ------------------ | ----------- |
  83422. * | 0 | CLAMP_ADDRESSMODE | |
  83423. * | 1 | WRAP_ADDRESSMODE | |
  83424. * | 2 | MIRROR_ADDRESSMODE | |
  83425. */
  83426. get wrapU(): number;
  83427. set wrapU(value: number);
  83428. protected _wrapV: number;
  83429. /**
  83430. * | Value | Type | Description |
  83431. * | ----- | ------------------ | ----------- |
  83432. * | 0 | CLAMP_ADDRESSMODE | |
  83433. * | 1 | WRAP_ADDRESSMODE | |
  83434. * | 2 | MIRROR_ADDRESSMODE | |
  83435. */
  83436. get wrapV(): number;
  83437. set wrapV(value: number);
  83438. /**
  83439. * | Value | Type | Description |
  83440. * | ----- | ------------------ | ----------- |
  83441. * | 0 | CLAMP_ADDRESSMODE | |
  83442. * | 1 | WRAP_ADDRESSMODE | |
  83443. * | 2 | MIRROR_ADDRESSMODE | |
  83444. */
  83445. wrapR: number;
  83446. /**
  83447. * With compliant hardware and browser (supporting anisotropic filtering)
  83448. * this defines the level of anisotropic filtering in the texture.
  83449. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83450. */
  83451. anisotropicFilteringLevel: number;
  83452. /**
  83453. * Define the current state of the loading sequence when in delayed load mode.
  83454. */
  83455. delayLoadState: number;
  83456. /**
  83457. * How a texture is mapped.
  83458. * Unused in thin texture mode.
  83459. */
  83460. get coordinatesMode(): number;
  83461. /**
  83462. * Define if the texture is a cube texture or if false a 2d texture.
  83463. */
  83464. get isCube(): boolean;
  83465. set isCube(value: boolean);
  83466. /**
  83467. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83468. */
  83469. get is3D(): boolean;
  83470. set is3D(value: boolean);
  83471. /**
  83472. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  83473. */
  83474. get is2DArray(): boolean;
  83475. set is2DArray(value: boolean);
  83476. /**
  83477. * Get the class name of the texture.
  83478. * @returns "ThinTexture"
  83479. */
  83480. getClassName(): string;
  83481. /** @hidden */
  83482. _texture: Nullable<InternalTexture>;
  83483. protected _engine: Nullable<ThinEngine>;
  83484. private _cachedSize;
  83485. private _cachedBaseSize;
  83486. /**
  83487. * Instantiates a new ThinTexture.
  83488. * Base class of all the textures in babylon.
  83489. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  83490. * @param internalTexture Define the internalTexture to wrap
  83491. */
  83492. constructor(internalTexture: Nullable<InternalTexture>);
  83493. /**
  83494. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83495. * @returns true if fully ready
  83496. */
  83497. isReady(): boolean;
  83498. /**
  83499. * Triggers the load sequence in delayed load mode.
  83500. */
  83501. delayLoad(): void;
  83502. /**
  83503. * Get the underlying lower level texture from Babylon.
  83504. * @returns the insternal texture
  83505. */
  83506. getInternalTexture(): Nullable<InternalTexture>;
  83507. /**
  83508. * Get the size of the texture.
  83509. * @returns the texture size.
  83510. */
  83511. getSize(): ISize;
  83512. /**
  83513. * Get the base size of the texture.
  83514. * It can be different from the size if the texture has been resized for POT for instance
  83515. * @returns the base size
  83516. */
  83517. getBaseSize(): ISize;
  83518. /**
  83519. * Update the sampling mode of the texture.
  83520. * Default is Trilinear mode.
  83521. *
  83522. * | Value | Type | Description |
  83523. * | ----- | ------------------ | ----------- |
  83524. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83525. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83526. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83527. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83528. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83529. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83530. * | 7 | NEAREST_LINEAR | |
  83531. * | 8 | NEAREST_NEAREST | |
  83532. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83533. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83534. * | 11 | LINEAR_LINEAR | |
  83535. * | 12 | LINEAR_NEAREST | |
  83536. *
  83537. * > _mag_: magnification filter (close to the viewer)
  83538. * > _min_: minification filter (far from the viewer)
  83539. * > _mip_: filter used between mip map levels
  83540. *@param samplingMode Define the new sampling mode of the texture
  83541. */
  83542. updateSamplingMode(samplingMode: number): void;
  83543. /**
  83544. * Release and destroy the underlying lower level texture aka internalTexture.
  83545. */
  83546. releaseInternalTexture(): void;
  83547. /**
  83548. * Dispose the texture and release its associated resources.
  83549. */
  83550. dispose(): void;
  83551. }
  83552. }
  83553. declare module BABYLON {
  83554. /**
  83555. * Defines an array and its length.
  83556. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83557. */
  83558. export interface ISmartArrayLike<T> {
  83559. /**
  83560. * The data of the array.
  83561. */
  83562. data: Array<T>;
  83563. /**
  83564. * The active length of the array.
  83565. */
  83566. length: number;
  83567. }
  83568. /**
  83569. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83570. */
  83571. export class SmartArray<T> implements ISmartArrayLike<T> {
  83572. /**
  83573. * The full set of data from the array.
  83574. */
  83575. data: Array<T>;
  83576. /**
  83577. * The active length of the array.
  83578. */
  83579. length: number;
  83580. protected _id: number;
  83581. /**
  83582. * Instantiates a Smart Array.
  83583. * @param capacity defines the default capacity of the array.
  83584. */
  83585. constructor(capacity: number);
  83586. /**
  83587. * Pushes a value at the end of the active data.
  83588. * @param value defines the object to push in the array.
  83589. */
  83590. push(value: T): void;
  83591. /**
  83592. * Iterates over the active data and apply the lambda to them.
  83593. * @param func defines the action to apply on each value.
  83594. */
  83595. forEach(func: (content: T) => void): void;
  83596. /**
  83597. * Sorts the full sets of data.
  83598. * @param compareFn defines the comparison function to apply.
  83599. */
  83600. sort(compareFn: (a: T, b: T) => number): void;
  83601. /**
  83602. * Resets the active data to an empty array.
  83603. */
  83604. reset(): void;
  83605. /**
  83606. * Releases all the data from the array as well as the array.
  83607. */
  83608. dispose(): void;
  83609. /**
  83610. * Concats the active data with a given array.
  83611. * @param array defines the data to concatenate with.
  83612. */
  83613. concat(array: any): void;
  83614. /**
  83615. * Returns the position of a value in the active data.
  83616. * @param value defines the value to find the index for
  83617. * @returns the index if found in the active data otherwise -1
  83618. */
  83619. indexOf(value: T): number;
  83620. /**
  83621. * Returns whether an element is part of the active data.
  83622. * @param value defines the value to look for
  83623. * @returns true if found in the active data otherwise false
  83624. */
  83625. contains(value: T): boolean;
  83626. private static _GlobalId;
  83627. }
  83628. /**
  83629. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83630. * The data in this array can only be present once
  83631. */
  83632. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83633. private _duplicateId;
  83634. /**
  83635. * Pushes a value at the end of the active data.
  83636. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83637. * @param value defines the object to push in the array.
  83638. */
  83639. push(value: T): void;
  83640. /**
  83641. * Pushes a value at the end of the active data.
  83642. * If the data is already present, it won t be added again
  83643. * @param value defines the object to push in the array.
  83644. * @returns true if added false if it was already present
  83645. */
  83646. pushNoDuplicate(value: T): boolean;
  83647. /**
  83648. * Resets the active data to an empty array.
  83649. */
  83650. reset(): void;
  83651. /**
  83652. * Concats the active data with a given array.
  83653. * This ensures no dupplicate will be present in the result.
  83654. * @param array defines the data to concatenate with.
  83655. */
  83656. concatWithNoDuplicate(array: any): void;
  83657. }
  83658. }
  83659. declare module BABYLON {
  83660. /**
  83661. * Class used to evalaute queries containing `and` and `or` operators
  83662. */
  83663. export class AndOrNotEvaluator {
  83664. /**
  83665. * Evaluate a query
  83666. * @param query defines the query to evaluate
  83667. * @param evaluateCallback defines the callback used to filter result
  83668. * @returns true if the query matches
  83669. */
  83670. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  83671. private static _HandleParenthesisContent;
  83672. private static _SimplifyNegation;
  83673. }
  83674. }
  83675. declare module BABYLON {
  83676. /**
  83677. * Class used to store custom tags
  83678. */
  83679. export class Tags {
  83680. /**
  83681. * Adds support for tags on the given object
  83682. * @param obj defines the object to use
  83683. */
  83684. static EnableFor(obj: any): void;
  83685. /**
  83686. * Removes tags support
  83687. * @param obj defines the object to use
  83688. */
  83689. static DisableFor(obj: any): void;
  83690. /**
  83691. * Gets a boolean indicating if the given object has tags
  83692. * @param obj defines the object to use
  83693. * @returns a boolean
  83694. */
  83695. static HasTags(obj: any): boolean;
  83696. /**
  83697. * Gets the tags available on a given object
  83698. * @param obj defines the object to use
  83699. * @param asString defines if the tags must be returned as a string instead of an array of strings
  83700. * @returns the tags
  83701. */
  83702. static GetTags(obj: any, asString?: boolean): any;
  83703. /**
  83704. * Adds tags to an object
  83705. * @param obj defines the object to use
  83706. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  83707. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  83708. */
  83709. static AddTagsTo(obj: any, tagsString: string): void;
  83710. /**
  83711. * @hidden
  83712. */
  83713. static _AddTagTo(obj: any, tag: string): void;
  83714. /**
  83715. * Removes specific tags from a specific object
  83716. * @param obj defines the object to use
  83717. * @param tagsString defines the tags to remove
  83718. */
  83719. static RemoveTagsFrom(obj: any, tagsString: string): void;
  83720. /**
  83721. * @hidden
  83722. */
  83723. static _RemoveTagFrom(obj: any, tag: string): void;
  83724. /**
  83725. * Defines if tags hosted on an object match a given query
  83726. * @param obj defines the object to use
  83727. * @param tagsQuery defines the tag query
  83728. * @returns a boolean
  83729. */
  83730. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  83731. }
  83732. }
  83733. declare module BABYLON {
  83734. /**
  83735. * Scalar computation library
  83736. */
  83737. export class Scalar {
  83738. /**
  83739. * Two pi constants convenient for computation.
  83740. */
  83741. static TwoPi: number;
  83742. /**
  83743. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83744. * @param a number
  83745. * @param b number
  83746. * @param epsilon (default = 1.401298E-45)
  83747. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83748. */
  83749. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  83750. /**
  83751. * Returns a string : the upper case translation of the number i to hexadecimal.
  83752. * @param i number
  83753. * @returns the upper case translation of the number i to hexadecimal.
  83754. */
  83755. static ToHex(i: number): string;
  83756. /**
  83757. * Returns -1 if value is negative and +1 is value is positive.
  83758. * @param value the value
  83759. * @returns the value itself if it's equal to zero.
  83760. */
  83761. static Sign(value: number): number;
  83762. /**
  83763. * Returns the value itself if it's between min and max.
  83764. * Returns min if the value is lower than min.
  83765. * Returns max if the value is greater than max.
  83766. * @param value the value to clmap
  83767. * @param min the min value to clamp to (default: 0)
  83768. * @param max the max value to clamp to (default: 1)
  83769. * @returns the clamped value
  83770. */
  83771. static Clamp(value: number, min?: number, max?: number): number;
  83772. /**
  83773. * the log2 of value.
  83774. * @param value the value to compute log2 of
  83775. * @returns the log2 of value.
  83776. */
  83777. static Log2(value: number): number;
  83778. /**
  83779. * Loops the value, so that it is never larger than length and never smaller than 0.
  83780. *
  83781. * This is similar to the modulo operator but it works with floating point numbers.
  83782. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  83783. * With t = 5 and length = 2.5, the result would be 0.0.
  83784. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  83785. * @param value the value
  83786. * @param length the length
  83787. * @returns the looped value
  83788. */
  83789. static Repeat(value: number, length: number): number;
  83790. /**
  83791. * Normalize the value between 0.0 and 1.0 using min and max values
  83792. * @param value value to normalize
  83793. * @param min max to normalize between
  83794. * @param max min to normalize between
  83795. * @returns the normalized value
  83796. */
  83797. static Normalize(value: number, min: number, max: number): number;
  83798. /**
  83799. * Denormalize the value from 0.0 and 1.0 using min and max values
  83800. * @param normalized value to denormalize
  83801. * @param min max to denormalize between
  83802. * @param max min to denormalize between
  83803. * @returns the denormalized value
  83804. */
  83805. static Denormalize(normalized: number, min: number, max: number): number;
  83806. /**
  83807. * Calculates the shortest difference between two given angles given in degrees.
  83808. * @param current current angle in degrees
  83809. * @param target target angle in degrees
  83810. * @returns the delta
  83811. */
  83812. static DeltaAngle(current: number, target: number): number;
  83813. /**
  83814. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  83815. * @param tx value
  83816. * @param length length
  83817. * @returns The returned value will move back and forth between 0 and length
  83818. */
  83819. static PingPong(tx: number, length: number): number;
  83820. /**
  83821. * Interpolates between min and max with smoothing at the limits.
  83822. *
  83823. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  83824. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  83825. * @param from from
  83826. * @param to to
  83827. * @param tx value
  83828. * @returns the smooth stepped value
  83829. */
  83830. static SmoothStep(from: number, to: number, tx: number): number;
  83831. /**
  83832. * Moves a value current towards target.
  83833. *
  83834. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  83835. * Negative values of maxDelta pushes the value away from target.
  83836. * @param current current value
  83837. * @param target target value
  83838. * @param maxDelta max distance to move
  83839. * @returns resulting value
  83840. */
  83841. static MoveTowards(current: number, target: number, maxDelta: number): number;
  83842. /**
  83843. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83844. *
  83845. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  83846. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  83847. * @param current current value
  83848. * @param target target value
  83849. * @param maxDelta max distance to move
  83850. * @returns resulting angle
  83851. */
  83852. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  83853. /**
  83854. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  83855. * @param start start value
  83856. * @param end target value
  83857. * @param amount amount to lerp between
  83858. * @returns the lerped value
  83859. */
  83860. static Lerp(start: number, end: number, amount: number): number;
  83861. /**
  83862. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83863. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  83864. * @param start start value
  83865. * @param end target value
  83866. * @param amount amount to lerp between
  83867. * @returns the lerped value
  83868. */
  83869. static LerpAngle(start: number, end: number, amount: number): number;
  83870. /**
  83871. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  83872. * @param a start value
  83873. * @param b target value
  83874. * @param value value between a and b
  83875. * @returns the inverseLerp value
  83876. */
  83877. static InverseLerp(a: number, b: number, value: number): number;
  83878. /**
  83879. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  83880. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  83881. * @param value1 spline value
  83882. * @param tangent1 spline value
  83883. * @param value2 spline value
  83884. * @param tangent2 spline value
  83885. * @param amount input value
  83886. * @returns hermite result
  83887. */
  83888. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  83889. /**
  83890. * Returns a random float number between and min and max values
  83891. * @param min min value of random
  83892. * @param max max value of random
  83893. * @returns random value
  83894. */
  83895. static RandomRange(min: number, max: number): number;
  83896. /**
  83897. * This function returns percentage of a number in a given range.
  83898. *
  83899. * RangeToPercent(40,20,60) will return 0.5 (50%)
  83900. * RangeToPercent(34,0,100) will return 0.34 (34%)
  83901. * @param number to convert to percentage
  83902. * @param min min range
  83903. * @param max max range
  83904. * @returns the percentage
  83905. */
  83906. static RangeToPercent(number: number, min: number, max: number): number;
  83907. /**
  83908. * This function returns number that corresponds to the percentage in a given range.
  83909. *
  83910. * PercentToRange(0.34,0,100) will return 34.
  83911. * @param percent to convert to number
  83912. * @param min min range
  83913. * @param max max range
  83914. * @returns the number
  83915. */
  83916. static PercentToRange(percent: number, min: number, max: number): number;
  83917. /**
  83918. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  83919. * @param angle The angle to normalize in radian.
  83920. * @return The converted angle.
  83921. */
  83922. static NormalizeRadians(angle: number): number;
  83923. }
  83924. }
  83925. declare module BABYLON {
  83926. /**
  83927. * Constant used to convert a value to gamma space
  83928. * @ignorenaming
  83929. */
  83930. export const ToGammaSpace: number;
  83931. /**
  83932. * Constant used to convert a value to linear space
  83933. * @ignorenaming
  83934. */
  83935. export const ToLinearSpace = 2.2;
  83936. /**
  83937. * Constant used to define the minimal number value in Babylon.js
  83938. * @ignorenaming
  83939. */
  83940. let Epsilon: number;
  83941. }
  83942. declare module BABYLON {
  83943. /**
  83944. * Class used to represent a viewport on screen
  83945. */
  83946. export class Viewport {
  83947. /** viewport left coordinate */
  83948. x: number;
  83949. /** viewport top coordinate */
  83950. y: number;
  83951. /**viewport width */
  83952. width: number;
  83953. /** viewport height */
  83954. height: number;
  83955. /**
  83956. * Creates a Viewport object located at (x, y) and sized (width, height)
  83957. * @param x defines viewport left coordinate
  83958. * @param y defines viewport top coordinate
  83959. * @param width defines the viewport width
  83960. * @param height defines the viewport height
  83961. */
  83962. constructor(
  83963. /** viewport left coordinate */
  83964. x: number,
  83965. /** viewport top coordinate */
  83966. y: number,
  83967. /**viewport width */
  83968. width: number,
  83969. /** viewport height */
  83970. height: number);
  83971. /**
  83972. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  83973. * @param renderWidth defines the rendering width
  83974. * @param renderHeight defines the rendering height
  83975. * @returns a new Viewport
  83976. */
  83977. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  83978. /**
  83979. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  83980. * @param renderWidth defines the rendering width
  83981. * @param renderHeight defines the rendering height
  83982. * @param ref defines the target viewport
  83983. * @returns the current viewport
  83984. */
  83985. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  83986. /**
  83987. * Returns a new Viewport copied from the current one
  83988. * @returns a new Viewport
  83989. */
  83990. clone(): Viewport;
  83991. }
  83992. }
  83993. declare module BABYLON {
  83994. /**
  83995. * Class containing a set of static utilities functions for arrays.
  83996. */
  83997. export class ArrayTools {
  83998. /**
  83999. * Returns an array of the given size filled with element built from the given constructor and the paramters
  84000. * @param size the number of element to construct and put in the array
  84001. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  84002. * @returns a new array filled with new objects
  84003. */
  84004. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  84005. }
  84006. }
  84007. declare module BABYLON {
  84008. /**
  84009. * Represents a plane by the equation ax + by + cz + d = 0
  84010. */
  84011. export class Plane {
  84012. private static _TmpMatrix;
  84013. /**
  84014. * Normal of the plane (a,b,c)
  84015. */
  84016. normal: Vector3;
  84017. /**
  84018. * d component of the plane
  84019. */
  84020. d: number;
  84021. /**
  84022. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  84023. * @param a a component of the plane
  84024. * @param b b component of the plane
  84025. * @param c c component of the plane
  84026. * @param d d component of the plane
  84027. */
  84028. constructor(a: number, b: number, c: number, d: number);
  84029. /**
  84030. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  84031. */
  84032. asArray(): number[];
  84033. /**
  84034. * @returns a new plane copied from the current Plane.
  84035. */
  84036. clone(): Plane;
  84037. /**
  84038. * @returns the string "Plane".
  84039. */
  84040. getClassName(): string;
  84041. /**
  84042. * @returns the Plane hash code.
  84043. */
  84044. getHashCode(): number;
  84045. /**
  84046. * Normalize the current Plane in place.
  84047. * @returns the updated Plane.
  84048. */
  84049. normalize(): Plane;
  84050. /**
  84051. * Applies a transformation the plane and returns the result
  84052. * @param transformation the transformation matrix to be applied to the plane
  84053. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  84054. */
  84055. transform(transformation: DeepImmutable<Matrix>): Plane;
  84056. /**
  84057. * Compute the dot product between the point and the plane normal
  84058. * @param point point to calculate the dot product with
  84059. * @returns the dot product (float) of the point coordinates and the plane normal.
  84060. */
  84061. dotCoordinate(point: DeepImmutable<Vector3>): number;
  84062. /**
  84063. * Updates the current Plane from the plane defined by the three given points.
  84064. * @param point1 one of the points used to contruct the plane
  84065. * @param point2 one of the points used to contruct the plane
  84066. * @param point3 one of the points used to contruct the plane
  84067. * @returns the updated Plane.
  84068. */
  84069. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  84070. /**
  84071. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  84072. * Note that for this function to work as expected you should make sure that:
  84073. * - direction and the plane normal are normalized
  84074. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  84075. * @param direction the direction to check if the plane is facing
  84076. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  84077. * @returns True if the plane is facing the given direction
  84078. */
  84079. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  84080. /**
  84081. * Calculates the distance to a point
  84082. * @param point point to calculate distance to
  84083. * @returns the signed distance (float) from the given point to the Plane.
  84084. */
  84085. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  84086. /**
  84087. * Creates a plane from an array
  84088. * @param array the array to create a plane from
  84089. * @returns a new Plane from the given array.
  84090. */
  84091. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  84092. /**
  84093. * Creates a plane from three points
  84094. * @param point1 point used to create the plane
  84095. * @param point2 point used to create the plane
  84096. * @param point3 point used to create the plane
  84097. * @returns a new Plane defined by the three given points.
  84098. */
  84099. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  84100. /**
  84101. * Creates a plane from an origin point and a normal
  84102. * @param origin origin of the plane to be constructed
  84103. * @param normal normal of the plane to be constructed
  84104. * @returns a new Plane the normal vector to this plane at the given origin point.
  84105. * Note : the vector "normal" is updated because normalized.
  84106. */
  84107. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  84108. /**
  84109. * Calculates the distance from a plane and a point
  84110. * @param origin origin of the plane to be constructed
  84111. * @param normal normal of the plane to be constructed
  84112. * @param point point to calculate distance to
  84113. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  84114. */
  84115. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  84116. }
  84117. }
  84118. declare module BABYLON {
  84119. /** @hidden */
  84120. export class PerformanceConfigurator {
  84121. /** @hidden */
  84122. static MatrixUse64Bits: boolean;
  84123. /** @hidden */
  84124. static MatrixTrackPrecisionChange: boolean;
  84125. /** @hidden */
  84126. static MatrixCurrentType: any;
  84127. /** @hidden */
  84128. static MatrixTrackedMatrices: Array<any> | null;
  84129. /** @hidden */
  84130. static SetMatrixPrecision(use64bits: boolean): void;
  84131. }
  84132. }
  84133. declare module BABYLON {
  84134. /**
  84135. * Class representing a vector containing 2 coordinates
  84136. */
  84137. export class Vector2 {
  84138. /** defines the first coordinate */
  84139. x: number;
  84140. /** defines the second coordinate */
  84141. y: number;
  84142. /**
  84143. * Creates a new Vector2 from the given x and y coordinates
  84144. * @param x defines the first coordinate
  84145. * @param y defines the second coordinate
  84146. */
  84147. constructor(
  84148. /** defines the first coordinate */
  84149. x?: number,
  84150. /** defines the second coordinate */
  84151. y?: number);
  84152. /**
  84153. * Gets a string with the Vector2 coordinates
  84154. * @returns a string with the Vector2 coordinates
  84155. */
  84156. toString(): string;
  84157. /**
  84158. * Gets class name
  84159. * @returns the string "Vector2"
  84160. */
  84161. getClassName(): string;
  84162. /**
  84163. * Gets current vector hash code
  84164. * @returns the Vector2 hash code as a number
  84165. */
  84166. getHashCode(): number;
  84167. /**
  84168. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  84169. * @param array defines the source array
  84170. * @param index defines the offset in source array
  84171. * @returns the current Vector2
  84172. */
  84173. toArray(array: FloatArray, index?: number): Vector2;
  84174. /**
  84175. * Update the current vector from an array
  84176. * @param array defines the destination array
  84177. * @param index defines the offset in the destination array
  84178. * @returns the current Vector3
  84179. */
  84180. fromArray(array: FloatArray, index?: number): Vector2;
  84181. /**
  84182. * Copy the current vector to an array
  84183. * @returns a new array with 2 elements: the Vector2 coordinates.
  84184. */
  84185. asArray(): number[];
  84186. /**
  84187. * Sets the Vector2 coordinates with the given Vector2 coordinates
  84188. * @param source defines the source Vector2
  84189. * @returns the current updated Vector2
  84190. */
  84191. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  84192. /**
  84193. * Sets the Vector2 coordinates with the given floats
  84194. * @param x defines the first coordinate
  84195. * @param y defines the second coordinate
  84196. * @returns the current updated Vector2
  84197. */
  84198. copyFromFloats(x: number, y: number): Vector2;
  84199. /**
  84200. * Sets the Vector2 coordinates with the given floats
  84201. * @param x defines the first coordinate
  84202. * @param y defines the second coordinate
  84203. * @returns the current updated Vector2
  84204. */
  84205. set(x: number, y: number): Vector2;
  84206. /**
  84207. * Add another vector with the current one
  84208. * @param otherVector defines the other vector
  84209. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  84210. */
  84211. add(otherVector: DeepImmutable<Vector2>): Vector2;
  84212. /**
  84213. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  84214. * @param otherVector defines the other vector
  84215. * @param result defines the target vector
  84216. * @returns the unmodified current Vector2
  84217. */
  84218. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84219. /**
  84220. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  84221. * @param otherVector defines the other vector
  84222. * @returns the current updated Vector2
  84223. */
  84224. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84225. /**
  84226. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  84227. * @param otherVector defines the other vector
  84228. * @returns a new Vector2
  84229. */
  84230. addVector3(otherVector: Vector3): Vector2;
  84231. /**
  84232. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  84233. * @param otherVector defines the other vector
  84234. * @returns a new Vector2
  84235. */
  84236. subtract(otherVector: Vector2): Vector2;
  84237. /**
  84238. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  84239. * @param otherVector defines the other vector
  84240. * @param result defines the target vector
  84241. * @returns the unmodified current Vector2
  84242. */
  84243. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84244. /**
  84245. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  84246. * @param otherVector defines the other vector
  84247. * @returns the current updated Vector2
  84248. */
  84249. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84250. /**
  84251. * Multiplies in place the current Vector2 coordinates by the given ones
  84252. * @param otherVector defines the other vector
  84253. * @returns the current updated Vector2
  84254. */
  84255. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84256. /**
  84257. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  84258. * @param otherVector defines the other vector
  84259. * @returns a new Vector2
  84260. */
  84261. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  84262. /**
  84263. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  84264. * @param otherVector defines the other vector
  84265. * @param result defines the target vector
  84266. * @returns the unmodified current Vector2
  84267. */
  84268. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84269. /**
  84270. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  84271. * @param x defines the first coordinate
  84272. * @param y defines the second coordinate
  84273. * @returns a new Vector2
  84274. */
  84275. multiplyByFloats(x: number, y: number): Vector2;
  84276. /**
  84277. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  84278. * @param otherVector defines the other vector
  84279. * @returns a new Vector2
  84280. */
  84281. divide(otherVector: Vector2): Vector2;
  84282. /**
  84283. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  84284. * @param otherVector defines the other vector
  84285. * @param result defines the target vector
  84286. * @returns the unmodified current Vector2
  84287. */
  84288. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84289. /**
  84290. * Divides the current Vector2 coordinates by the given ones
  84291. * @param otherVector defines the other vector
  84292. * @returns the current updated Vector2
  84293. */
  84294. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84295. /**
  84296. * Gets a new Vector2 with current Vector2 negated coordinates
  84297. * @returns a new Vector2
  84298. */
  84299. negate(): Vector2;
  84300. /**
  84301. * Negate this vector in place
  84302. * @returns this
  84303. */
  84304. negateInPlace(): Vector2;
  84305. /**
  84306. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  84307. * @param result defines the Vector3 object where to store the result
  84308. * @returns the current Vector2
  84309. */
  84310. negateToRef(result: Vector2): Vector2;
  84311. /**
  84312. * Multiply the Vector2 coordinates by scale
  84313. * @param scale defines the scaling factor
  84314. * @returns the current updated Vector2
  84315. */
  84316. scaleInPlace(scale: number): Vector2;
  84317. /**
  84318. * Returns a new Vector2 scaled by "scale" from the current Vector2
  84319. * @param scale defines the scaling factor
  84320. * @returns a new Vector2
  84321. */
  84322. scale(scale: number): Vector2;
  84323. /**
  84324. * Scale the current Vector2 values by a factor to a given Vector2
  84325. * @param scale defines the scale factor
  84326. * @param result defines the Vector2 object where to store the result
  84327. * @returns the unmodified current Vector2
  84328. */
  84329. scaleToRef(scale: number, result: Vector2): Vector2;
  84330. /**
  84331. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  84332. * @param scale defines the scale factor
  84333. * @param result defines the Vector2 object where to store the result
  84334. * @returns the unmodified current Vector2
  84335. */
  84336. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  84337. /**
  84338. * Gets a boolean if two vectors are equals
  84339. * @param otherVector defines the other vector
  84340. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  84341. */
  84342. equals(otherVector: DeepImmutable<Vector2>): boolean;
  84343. /**
  84344. * Gets a boolean if two vectors are equals (using an epsilon value)
  84345. * @param otherVector defines the other vector
  84346. * @param epsilon defines the minimal distance to consider equality
  84347. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  84348. */
  84349. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  84350. /**
  84351. * Gets a new Vector2 from current Vector2 floored values
  84352. * @returns a new Vector2
  84353. */
  84354. floor(): Vector2;
  84355. /**
  84356. * Gets a new Vector2 from current Vector2 floored values
  84357. * @returns a new Vector2
  84358. */
  84359. fract(): Vector2;
  84360. /**
  84361. * Gets the length of the vector
  84362. * @returns the vector length (float)
  84363. */
  84364. length(): number;
  84365. /**
  84366. * Gets the vector squared length
  84367. * @returns the vector squared length (float)
  84368. */
  84369. lengthSquared(): number;
  84370. /**
  84371. * Normalize the vector
  84372. * @returns the current updated Vector2
  84373. */
  84374. normalize(): Vector2;
  84375. /**
  84376. * Gets a new Vector2 copied from the Vector2
  84377. * @returns a new Vector2
  84378. */
  84379. clone(): Vector2;
  84380. /**
  84381. * Gets a new Vector2(0, 0)
  84382. * @returns a new Vector2
  84383. */
  84384. static Zero(): Vector2;
  84385. /**
  84386. * Gets a new Vector2(1, 1)
  84387. * @returns a new Vector2
  84388. */
  84389. static One(): Vector2;
  84390. /**
  84391. * Gets a new Vector2 set from the given index element of the given array
  84392. * @param array defines the data source
  84393. * @param offset defines the offset in the data source
  84394. * @returns a new Vector2
  84395. */
  84396. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  84397. /**
  84398. * Sets "result" from the given index element of the given array
  84399. * @param array defines the data source
  84400. * @param offset defines the offset in the data source
  84401. * @param result defines the target vector
  84402. */
  84403. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  84404. /**
  84405. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  84406. * @param value1 defines 1st point of control
  84407. * @param value2 defines 2nd point of control
  84408. * @param value3 defines 3rd point of control
  84409. * @param value4 defines 4th point of control
  84410. * @param amount defines the interpolation factor
  84411. * @returns a new Vector2
  84412. */
  84413. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  84414. /**
  84415. * 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".
  84416. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  84417. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  84418. * @param value defines the value to clamp
  84419. * @param min defines the lower limit
  84420. * @param max defines the upper limit
  84421. * @returns a new Vector2
  84422. */
  84423. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  84424. /**
  84425. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  84426. * @param value1 defines the 1st control point
  84427. * @param tangent1 defines the outgoing tangent
  84428. * @param value2 defines the 2nd control point
  84429. * @param tangent2 defines the incoming tangent
  84430. * @param amount defines the interpolation factor
  84431. * @returns a new Vector2
  84432. */
  84433. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  84434. /**
  84435. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  84436. * @param start defines the start vector
  84437. * @param end defines the end vector
  84438. * @param amount defines the interpolation factor
  84439. * @returns a new Vector2
  84440. */
  84441. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  84442. /**
  84443. * Gets the dot product of the vector "left" and the vector "right"
  84444. * @param left defines first vector
  84445. * @param right defines second vector
  84446. * @returns the dot product (float)
  84447. */
  84448. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  84449. /**
  84450. * Returns a new Vector2 equal to the normalized given vector
  84451. * @param vector defines the vector to normalize
  84452. * @returns a new Vector2
  84453. */
  84454. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  84455. /**
  84456. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  84457. * @param left defines 1st vector
  84458. * @param right defines 2nd vector
  84459. * @returns a new Vector2
  84460. */
  84461. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84462. /**
  84463. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  84464. * @param left defines 1st vector
  84465. * @param right defines 2nd vector
  84466. * @returns a new Vector2
  84467. */
  84468. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84469. /**
  84470. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  84471. * @param vector defines the vector to transform
  84472. * @param transformation defines the matrix to apply
  84473. * @returns a new Vector2
  84474. */
  84475. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  84476. /**
  84477. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  84478. * @param vector defines the vector to transform
  84479. * @param transformation defines the matrix to apply
  84480. * @param result defines the target vector
  84481. */
  84482. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  84483. /**
  84484. * Determines if a given vector is included in a triangle
  84485. * @param p defines the vector to test
  84486. * @param p0 defines 1st triangle point
  84487. * @param p1 defines 2nd triangle point
  84488. * @param p2 defines 3rd triangle point
  84489. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  84490. */
  84491. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  84492. /**
  84493. * Gets the distance between the vectors "value1" and "value2"
  84494. * @param value1 defines first vector
  84495. * @param value2 defines second vector
  84496. * @returns the distance between vectors
  84497. */
  84498. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84499. /**
  84500. * Returns the squared distance between the vectors "value1" and "value2"
  84501. * @param value1 defines first vector
  84502. * @param value2 defines second vector
  84503. * @returns the squared distance between vectors
  84504. */
  84505. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84506. /**
  84507. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  84508. * @param value1 defines first vector
  84509. * @param value2 defines second vector
  84510. * @returns a new Vector2
  84511. */
  84512. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  84513. /**
  84514. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  84515. * @param value1 defines first vector
  84516. * @param value2 defines second vector
  84517. * @param ref defines third vector
  84518. * @returns ref
  84519. */
  84520. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  84521. /**
  84522. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  84523. * @param p defines the middle point
  84524. * @param segA defines one point of the segment
  84525. * @param segB defines the other point of the segment
  84526. * @returns the shortest distance
  84527. */
  84528. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  84529. }
  84530. /**
  84531. * Class used to store (x,y,z) vector representation
  84532. * A Vector3 is the main object used in 3D geometry
  84533. * It can represent etiher the coordinates of a point the space, either a direction
  84534. * Reminder: js uses a left handed forward facing system
  84535. */
  84536. export class Vector3 {
  84537. private static _UpReadOnly;
  84538. private static _ZeroReadOnly;
  84539. /** @hidden */
  84540. _x: number;
  84541. /** @hidden */
  84542. _y: number;
  84543. /** @hidden */
  84544. _z: number;
  84545. /** @hidden */
  84546. _isDirty: boolean;
  84547. /** Gets or sets the x coordinate */
  84548. get x(): number;
  84549. set x(value: number);
  84550. /** Gets or sets the y coordinate */
  84551. get y(): number;
  84552. set y(value: number);
  84553. /** Gets or sets the z coordinate */
  84554. get z(): number;
  84555. set z(value: number);
  84556. /**
  84557. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  84558. * @param x defines the first coordinates (on X axis)
  84559. * @param y defines the second coordinates (on Y axis)
  84560. * @param z defines the third coordinates (on Z axis)
  84561. */
  84562. constructor(x?: number, y?: number, z?: number);
  84563. /**
  84564. * Creates a string representation of the Vector3
  84565. * @returns a string with the Vector3 coordinates.
  84566. */
  84567. toString(): string;
  84568. /**
  84569. * Gets the class name
  84570. * @returns the string "Vector3"
  84571. */
  84572. getClassName(): string;
  84573. /**
  84574. * Creates the Vector3 hash code
  84575. * @returns a number which tends to be unique between Vector3 instances
  84576. */
  84577. getHashCode(): number;
  84578. /**
  84579. * Creates an array containing three elements : the coordinates of the Vector3
  84580. * @returns a new array of numbers
  84581. */
  84582. asArray(): number[];
  84583. /**
  84584. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  84585. * @param array defines the destination array
  84586. * @param index defines the offset in the destination array
  84587. * @returns the current Vector3
  84588. */
  84589. toArray(array: FloatArray, index?: number): Vector3;
  84590. /**
  84591. * Update the current vector from an array
  84592. * @param array defines the destination array
  84593. * @param index defines the offset in the destination array
  84594. * @returns the current Vector3
  84595. */
  84596. fromArray(array: FloatArray, index?: number): Vector3;
  84597. /**
  84598. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  84599. * @returns a new Quaternion object, computed from the Vector3 coordinates
  84600. */
  84601. toQuaternion(): Quaternion;
  84602. /**
  84603. * Adds the given vector to the current Vector3
  84604. * @param otherVector defines the second operand
  84605. * @returns the current updated Vector3
  84606. */
  84607. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84608. /**
  84609. * Adds the given coordinates to the current Vector3
  84610. * @param x defines the x coordinate of the operand
  84611. * @param y defines the y coordinate of the operand
  84612. * @param z defines the z coordinate of the operand
  84613. * @returns the current updated Vector3
  84614. */
  84615. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84616. /**
  84617. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  84618. * @param otherVector defines the second operand
  84619. * @returns the resulting Vector3
  84620. */
  84621. add(otherVector: DeepImmutable<Vector3>): Vector3;
  84622. /**
  84623. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  84624. * @param otherVector defines the second operand
  84625. * @param result defines the Vector3 object where to store the result
  84626. * @returns the current Vector3
  84627. */
  84628. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84629. /**
  84630. * Subtract the given vector from the current Vector3
  84631. * @param otherVector defines the second operand
  84632. * @returns the current updated Vector3
  84633. */
  84634. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84635. /**
  84636. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  84637. * @param otherVector defines the second operand
  84638. * @returns the resulting Vector3
  84639. */
  84640. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  84641. /**
  84642. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  84643. * @param otherVector defines the second operand
  84644. * @param result defines the Vector3 object where to store the result
  84645. * @returns the current Vector3
  84646. */
  84647. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84648. /**
  84649. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  84650. * @param x defines the x coordinate of the operand
  84651. * @param y defines the y coordinate of the operand
  84652. * @param z defines the z coordinate of the operand
  84653. * @returns the resulting Vector3
  84654. */
  84655. subtractFromFloats(x: number, y: number, z: number): Vector3;
  84656. /**
  84657. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  84658. * @param x defines the x coordinate of the operand
  84659. * @param y defines the y coordinate of the operand
  84660. * @param z defines the z coordinate of the operand
  84661. * @param result defines the Vector3 object where to store the result
  84662. * @returns the current Vector3
  84663. */
  84664. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  84665. /**
  84666. * Gets a new Vector3 set with the current Vector3 negated coordinates
  84667. * @returns a new Vector3
  84668. */
  84669. negate(): Vector3;
  84670. /**
  84671. * Negate this vector in place
  84672. * @returns this
  84673. */
  84674. negateInPlace(): Vector3;
  84675. /**
  84676. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  84677. * @param result defines the Vector3 object where to store the result
  84678. * @returns the current Vector3
  84679. */
  84680. negateToRef(result: Vector3): Vector3;
  84681. /**
  84682. * Multiplies the Vector3 coordinates by the float "scale"
  84683. * @param scale defines the multiplier factor
  84684. * @returns the current updated Vector3
  84685. */
  84686. scaleInPlace(scale: number): Vector3;
  84687. /**
  84688. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  84689. * @param scale defines the multiplier factor
  84690. * @returns a new Vector3
  84691. */
  84692. scale(scale: number): Vector3;
  84693. /**
  84694. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  84695. * @param scale defines the multiplier factor
  84696. * @param result defines the Vector3 object where to store the result
  84697. * @returns the current Vector3
  84698. */
  84699. scaleToRef(scale: number, result: Vector3): Vector3;
  84700. /**
  84701. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  84702. * @param scale defines the scale factor
  84703. * @param result defines the Vector3 object where to store the result
  84704. * @returns the unmodified current Vector3
  84705. */
  84706. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  84707. /**
  84708. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84709. * @param origin defines the origin of the projection ray
  84710. * @param plane defines the plane to project to
  84711. * @returns the projected vector3
  84712. */
  84713. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  84714. /**
  84715. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84716. * @param origin defines the origin of the projection ray
  84717. * @param plane defines the plane to project to
  84718. * @param result defines the Vector3 where to store the result
  84719. */
  84720. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  84721. /**
  84722. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  84723. * @param otherVector defines the second operand
  84724. * @returns true if both vectors are equals
  84725. */
  84726. equals(otherVector: DeepImmutable<Vector3>): boolean;
  84727. /**
  84728. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  84729. * @param otherVector defines the second operand
  84730. * @param epsilon defines the minimal distance to define values as equals
  84731. * @returns true if both vectors are distant less than epsilon
  84732. */
  84733. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  84734. /**
  84735. * Returns true if the current Vector3 coordinates equals the given floats
  84736. * @param x defines the x coordinate of the operand
  84737. * @param y defines the y coordinate of the operand
  84738. * @param z defines the z coordinate of the operand
  84739. * @returns true if both vectors are equals
  84740. */
  84741. equalsToFloats(x: number, y: number, z: number): boolean;
  84742. /**
  84743. * Multiplies the current Vector3 coordinates by the given ones
  84744. * @param otherVector defines the second operand
  84745. * @returns the current updated Vector3
  84746. */
  84747. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84748. /**
  84749. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  84750. * @param otherVector defines the second operand
  84751. * @returns the new Vector3
  84752. */
  84753. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  84754. /**
  84755. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  84756. * @param otherVector defines the second operand
  84757. * @param result defines the Vector3 object where to store the result
  84758. * @returns the current Vector3
  84759. */
  84760. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84761. /**
  84762. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  84763. * @param x defines the x coordinate of the operand
  84764. * @param y defines the y coordinate of the operand
  84765. * @param z defines the z coordinate of the operand
  84766. * @returns the new Vector3
  84767. */
  84768. multiplyByFloats(x: number, y: number, z: number): Vector3;
  84769. /**
  84770. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  84771. * @param otherVector defines the second operand
  84772. * @returns the new Vector3
  84773. */
  84774. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  84775. /**
  84776. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  84777. * @param otherVector defines the second operand
  84778. * @param result defines the Vector3 object where to store the result
  84779. * @returns the current Vector3
  84780. */
  84781. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84782. /**
  84783. * Divides the current Vector3 coordinates by the given ones.
  84784. * @param otherVector defines the second operand
  84785. * @returns the current updated Vector3
  84786. */
  84787. divideInPlace(otherVector: Vector3): Vector3;
  84788. /**
  84789. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  84790. * @param other defines the second operand
  84791. * @returns the current updated Vector3
  84792. */
  84793. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84794. /**
  84795. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  84796. * @param other defines the second operand
  84797. * @returns the current updated Vector3
  84798. */
  84799. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84800. /**
  84801. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  84802. * @param x defines the x coordinate of the operand
  84803. * @param y defines the y coordinate of the operand
  84804. * @param z defines the z coordinate of the operand
  84805. * @returns the current updated Vector3
  84806. */
  84807. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84808. /**
  84809. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  84810. * @param x defines the x coordinate of the operand
  84811. * @param y defines the y coordinate of the operand
  84812. * @param z defines the z coordinate of the operand
  84813. * @returns the current updated Vector3
  84814. */
  84815. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84816. /**
  84817. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  84818. * Check if is non uniform within a certain amount of decimal places to account for this
  84819. * @param epsilon the amount the values can differ
  84820. * @returns if the the vector is non uniform to a certain number of decimal places
  84821. */
  84822. isNonUniformWithinEpsilon(epsilon: number): boolean;
  84823. /**
  84824. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  84825. */
  84826. get isNonUniform(): boolean;
  84827. /**
  84828. * Gets a new Vector3 from current Vector3 floored values
  84829. * @returns a new Vector3
  84830. */
  84831. floor(): Vector3;
  84832. /**
  84833. * Gets a new Vector3 from current Vector3 floored values
  84834. * @returns a new Vector3
  84835. */
  84836. fract(): Vector3;
  84837. /**
  84838. * Gets the length of the Vector3
  84839. * @returns the length of the Vector3
  84840. */
  84841. length(): number;
  84842. /**
  84843. * Gets the squared length of the Vector3
  84844. * @returns squared length of the Vector3
  84845. */
  84846. lengthSquared(): number;
  84847. /**
  84848. * Normalize the current Vector3.
  84849. * Please note that this is an in place operation.
  84850. * @returns the current updated Vector3
  84851. */
  84852. normalize(): Vector3;
  84853. /**
  84854. * Reorders the x y z properties of the vector in place
  84855. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  84856. * @returns the current updated vector
  84857. */
  84858. reorderInPlace(order: string): this;
  84859. /**
  84860. * Rotates the vector around 0,0,0 by a quaternion
  84861. * @param quaternion the rotation quaternion
  84862. * @param result vector to store the result
  84863. * @returns the resulting vector
  84864. */
  84865. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  84866. /**
  84867. * Rotates a vector around a given point
  84868. * @param quaternion the rotation quaternion
  84869. * @param point the point to rotate around
  84870. * @param result vector to store the result
  84871. * @returns the resulting vector
  84872. */
  84873. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  84874. /**
  84875. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  84876. * The cross product is then orthogonal to both current and "other"
  84877. * @param other defines the right operand
  84878. * @returns the cross product
  84879. */
  84880. cross(other: Vector3): Vector3;
  84881. /**
  84882. * Normalize the current Vector3 with the given input length.
  84883. * Please note that this is an in place operation.
  84884. * @param len the length of the vector
  84885. * @returns the current updated Vector3
  84886. */
  84887. normalizeFromLength(len: number): Vector3;
  84888. /**
  84889. * Normalize the current Vector3 to a new vector
  84890. * @returns the new Vector3
  84891. */
  84892. normalizeToNew(): Vector3;
  84893. /**
  84894. * Normalize the current Vector3 to the reference
  84895. * @param reference define the Vector3 to update
  84896. * @returns the updated Vector3
  84897. */
  84898. normalizeToRef(reference: Vector3): Vector3;
  84899. /**
  84900. * Creates a new Vector3 copied from the current Vector3
  84901. * @returns the new Vector3
  84902. */
  84903. clone(): Vector3;
  84904. /**
  84905. * Copies the given vector coordinates to the current Vector3 ones
  84906. * @param source defines the source Vector3
  84907. * @returns the current updated Vector3
  84908. */
  84909. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  84910. /**
  84911. * Copies the given floats to the current Vector3 coordinates
  84912. * @param x defines the x coordinate of the operand
  84913. * @param y defines the y coordinate of the operand
  84914. * @param z defines the z coordinate of the operand
  84915. * @returns the current updated Vector3
  84916. */
  84917. copyFromFloats(x: number, y: number, z: number): Vector3;
  84918. /**
  84919. * Copies the given floats to the current Vector3 coordinates
  84920. * @param x defines the x coordinate of the operand
  84921. * @param y defines the y coordinate of the operand
  84922. * @param z defines the z coordinate of the operand
  84923. * @returns the current updated Vector3
  84924. */
  84925. set(x: number, y: number, z: number): Vector3;
  84926. /**
  84927. * Copies the given float to the current Vector3 coordinates
  84928. * @param v defines the x, y and z coordinates of the operand
  84929. * @returns the current updated Vector3
  84930. */
  84931. setAll(v: number): Vector3;
  84932. /**
  84933. * Get the clip factor between two vectors
  84934. * @param vector0 defines the first operand
  84935. * @param vector1 defines the second operand
  84936. * @param axis defines the axis to use
  84937. * @param size defines the size along the axis
  84938. * @returns the clip factor
  84939. */
  84940. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  84941. /**
  84942. * Get angle between two vectors
  84943. * @param vector0 angle between vector0 and vector1
  84944. * @param vector1 angle between vector0 and vector1
  84945. * @param normal direction of the normal
  84946. * @return the angle between vector0 and vector1
  84947. */
  84948. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  84949. /**
  84950. * Returns a new Vector3 set from the index "offset" of the given array
  84951. * @param array defines the source array
  84952. * @param offset defines the offset in the source array
  84953. * @returns the new Vector3
  84954. */
  84955. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  84956. /**
  84957. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84958. * @param array defines the source array
  84959. * @param offset defines the offset in the source array
  84960. * @returns the new Vector3
  84961. * @deprecated Please use FromArray instead.
  84962. */
  84963. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  84964. /**
  84965. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84966. * @param array defines the source array
  84967. * @param offset defines the offset in the source array
  84968. * @param result defines the Vector3 where to store the result
  84969. */
  84970. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  84971. /**
  84972. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84973. * @param array defines the source array
  84974. * @param offset defines the offset in the source array
  84975. * @param result defines the Vector3 where to store the result
  84976. * @deprecated Please use FromArrayToRef instead.
  84977. */
  84978. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  84979. /**
  84980. * Sets the given vector "result" with the given floats.
  84981. * @param x defines the x coordinate of the source
  84982. * @param y defines the y coordinate of the source
  84983. * @param z defines the z coordinate of the source
  84984. * @param result defines the Vector3 where to store the result
  84985. */
  84986. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  84987. /**
  84988. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84989. * @returns a new empty Vector3
  84990. */
  84991. static Zero(): Vector3;
  84992. /**
  84993. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84994. * @returns a new unit Vector3
  84995. */
  84996. static One(): Vector3;
  84997. /**
  84998. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84999. * @returns a new up Vector3
  85000. */
  85001. static Up(): Vector3;
  85002. /**
  85003. * Gets a up Vector3 that must not be updated
  85004. */
  85005. static get UpReadOnly(): DeepImmutable<Vector3>;
  85006. /**
  85007. * Gets a zero Vector3 that must not be updated
  85008. */
  85009. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  85010. /**
  85011. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  85012. * @returns a new down Vector3
  85013. */
  85014. static Down(): Vector3;
  85015. /**
  85016. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  85017. * @param rightHandedSystem is the scene right-handed (negative z)
  85018. * @returns a new forward Vector3
  85019. */
  85020. static Forward(rightHandedSystem?: boolean): Vector3;
  85021. /**
  85022. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  85023. * @param rightHandedSystem is the scene right-handed (negative-z)
  85024. * @returns a new forward Vector3
  85025. */
  85026. static Backward(rightHandedSystem?: boolean): Vector3;
  85027. /**
  85028. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  85029. * @returns a new right Vector3
  85030. */
  85031. static Right(): Vector3;
  85032. /**
  85033. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  85034. * @returns a new left Vector3
  85035. */
  85036. static Left(): Vector3;
  85037. /**
  85038. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  85039. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  85040. * @param vector defines the Vector3 to transform
  85041. * @param transformation defines the transformation matrix
  85042. * @returns the transformed Vector3
  85043. */
  85044. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  85045. /**
  85046. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  85047. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  85048. * @param vector defines the Vector3 to transform
  85049. * @param transformation defines the transformation matrix
  85050. * @param result defines the Vector3 where to store the result
  85051. */
  85052. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  85053. /**
  85054. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  85055. * This method computes tranformed coordinates only, not transformed direction vectors
  85056. * @param x define the x coordinate of the source vector
  85057. * @param y define the y coordinate of the source vector
  85058. * @param z define the z coordinate of the source vector
  85059. * @param transformation defines the transformation matrix
  85060. * @param result defines the Vector3 where to store the result
  85061. */
  85062. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  85063. /**
  85064. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  85065. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  85066. * @param vector defines the Vector3 to transform
  85067. * @param transformation defines the transformation matrix
  85068. * @returns the new Vector3
  85069. */
  85070. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  85071. /**
  85072. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  85073. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  85074. * @param vector defines the Vector3 to transform
  85075. * @param transformation defines the transformation matrix
  85076. * @param result defines the Vector3 where to store the result
  85077. */
  85078. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  85079. /**
  85080. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  85081. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  85082. * @param x define the x coordinate of the source vector
  85083. * @param y define the y coordinate of the source vector
  85084. * @param z define the z coordinate of the source vector
  85085. * @param transformation defines the transformation matrix
  85086. * @param result defines the Vector3 where to store the result
  85087. */
  85088. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  85089. /**
  85090. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  85091. * @param value1 defines the first control point
  85092. * @param value2 defines the second control point
  85093. * @param value3 defines the third control point
  85094. * @param value4 defines the fourth control point
  85095. * @param amount defines the amount on the spline to use
  85096. * @returns the new Vector3
  85097. */
  85098. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  85099. /**
  85100. * 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"
  85101. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  85102. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  85103. * @param value defines the current value
  85104. * @param min defines the lower range value
  85105. * @param max defines the upper range value
  85106. * @returns the new Vector3
  85107. */
  85108. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  85109. /**
  85110. * 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"
  85111. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  85112. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  85113. * @param value defines the current value
  85114. * @param min defines the lower range value
  85115. * @param max defines the upper range value
  85116. * @param result defines the Vector3 where to store the result
  85117. */
  85118. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  85119. /**
  85120. * Checks if a given vector is inside a specific range
  85121. * @param v defines the vector to test
  85122. * @param min defines the minimum range
  85123. * @param max defines the maximum range
  85124. */
  85125. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  85126. /**
  85127. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  85128. * @param value1 defines the first control point
  85129. * @param tangent1 defines the first tangent vector
  85130. * @param value2 defines the second control point
  85131. * @param tangent2 defines the second tangent vector
  85132. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  85133. * @returns the new Vector3
  85134. */
  85135. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  85136. /**
  85137. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  85138. * @param start defines the start value
  85139. * @param end defines the end value
  85140. * @param amount max defines amount between both (between 0 and 1)
  85141. * @returns the new Vector3
  85142. */
  85143. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  85144. /**
  85145. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  85146. * @param start defines the start value
  85147. * @param end defines the end value
  85148. * @param amount max defines amount between both (between 0 and 1)
  85149. * @param result defines the Vector3 where to store the result
  85150. */
  85151. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  85152. /**
  85153. * Returns the dot product (float) between the vectors "left" and "right"
  85154. * @param left defines the left operand
  85155. * @param right defines the right operand
  85156. * @returns the dot product
  85157. */
  85158. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  85159. /**
  85160. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  85161. * The cross product is then orthogonal to both "left" and "right"
  85162. * @param left defines the left operand
  85163. * @param right defines the right operand
  85164. * @returns the cross product
  85165. */
  85166. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85167. /**
  85168. * Sets the given vector "result" with the cross product of "left" and "right"
  85169. * The cross product is then orthogonal to both "left" and "right"
  85170. * @param left defines the left operand
  85171. * @param right defines the right operand
  85172. * @param result defines the Vector3 where to store the result
  85173. */
  85174. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  85175. /**
  85176. * Returns a new Vector3 as the normalization of the given vector
  85177. * @param vector defines the Vector3 to normalize
  85178. * @returns the new Vector3
  85179. */
  85180. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  85181. /**
  85182. * Sets the given vector "result" with the normalization of the given first vector
  85183. * @param vector defines the Vector3 to normalize
  85184. * @param result defines the Vector3 where to store the result
  85185. */
  85186. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  85187. /**
  85188. * Project a Vector3 onto screen space
  85189. * @param vector defines the Vector3 to project
  85190. * @param world defines the world matrix to use
  85191. * @param transform defines the transform (view x projection) matrix to use
  85192. * @param viewport defines the screen viewport to use
  85193. * @returns the new Vector3
  85194. */
  85195. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  85196. /**
  85197. * Project a Vector3 onto screen space to reference
  85198. * @param vector defines the Vector3 to project
  85199. * @param world defines the world matrix to use
  85200. * @param transform defines the transform (view x projection) matrix to use
  85201. * @param viewport defines the screen viewport to use
  85202. * @param result the vector in which the screen space will be stored
  85203. * @returns the new Vector3
  85204. */
  85205. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  85206. /** @hidden */
  85207. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  85208. /**
  85209. * Unproject from screen space to object space
  85210. * @param source defines the screen space Vector3 to use
  85211. * @param viewportWidth defines the current width of the viewport
  85212. * @param viewportHeight defines the current height of the viewport
  85213. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85214. * @param transform defines the transform (view x projection) matrix to use
  85215. * @returns the new Vector3
  85216. */
  85217. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  85218. /**
  85219. * Unproject from screen space to object space
  85220. * @param source defines the screen space Vector3 to use
  85221. * @param viewportWidth defines the current width of the viewport
  85222. * @param viewportHeight defines the current height of the viewport
  85223. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85224. * @param view defines the view matrix to use
  85225. * @param projection defines the projection matrix to use
  85226. * @returns the new Vector3
  85227. */
  85228. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  85229. /**
  85230. * Unproject from screen space to object space
  85231. * @param source defines the screen space Vector3 to use
  85232. * @param viewportWidth defines the current width of the viewport
  85233. * @param viewportHeight defines the current height of the viewport
  85234. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85235. * @param view defines the view matrix to use
  85236. * @param projection defines the projection matrix to use
  85237. * @param result defines the Vector3 where to store the result
  85238. */
  85239. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  85240. /**
  85241. * Unproject from screen space to object space
  85242. * @param sourceX defines the screen space x coordinate to use
  85243. * @param sourceY defines the screen space y coordinate to use
  85244. * @param sourceZ defines the screen space z coordinate to use
  85245. * @param viewportWidth defines the current width of the viewport
  85246. * @param viewportHeight defines the current height of the viewport
  85247. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85248. * @param view defines the view matrix to use
  85249. * @param projection defines the projection matrix to use
  85250. * @param result defines the Vector3 where to store the result
  85251. */
  85252. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  85253. /**
  85254. * Gets the minimal coordinate values between two Vector3
  85255. * @param left defines the first operand
  85256. * @param right defines the second operand
  85257. * @returns the new Vector3
  85258. */
  85259. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85260. /**
  85261. * Gets the maximal coordinate values between two Vector3
  85262. * @param left defines the first operand
  85263. * @param right defines the second operand
  85264. * @returns the new Vector3
  85265. */
  85266. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85267. /**
  85268. * Returns the distance between the vectors "value1" and "value2"
  85269. * @param value1 defines the first operand
  85270. * @param value2 defines the second operand
  85271. * @returns the distance
  85272. */
  85273. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85274. /**
  85275. * Returns the squared distance between the vectors "value1" and "value2"
  85276. * @param value1 defines the first operand
  85277. * @param value2 defines the second operand
  85278. * @returns the squared distance
  85279. */
  85280. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85281. /**
  85282. * Returns a new Vector3 located at the center between "value1" and "value2"
  85283. * @param value1 defines the first operand
  85284. * @param value2 defines the second operand
  85285. * @returns the new Vector3
  85286. */
  85287. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  85288. /**
  85289. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  85290. * @param value1 defines first vector
  85291. * @param value2 defines second vector
  85292. * @param ref defines third vector
  85293. * @returns ref
  85294. */
  85295. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  85296. /**
  85297. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  85298. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  85299. * to something in order to rotate it from its local system to the given target system
  85300. * Note: axis1, axis2 and axis3 are normalized during this operation
  85301. * @param axis1 defines the first axis
  85302. * @param axis2 defines the second axis
  85303. * @param axis3 defines the third axis
  85304. * @returns a new Vector3
  85305. */
  85306. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  85307. /**
  85308. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  85309. * @param axis1 defines the first axis
  85310. * @param axis2 defines the second axis
  85311. * @param axis3 defines the third axis
  85312. * @param ref defines the Vector3 where to store the result
  85313. */
  85314. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  85315. }
  85316. /**
  85317. * Vector4 class created for EulerAngle class conversion to Quaternion
  85318. */
  85319. export class Vector4 {
  85320. /** x value of the vector */
  85321. x: number;
  85322. /** y value of the vector */
  85323. y: number;
  85324. /** z value of the vector */
  85325. z: number;
  85326. /** w value of the vector */
  85327. w: number;
  85328. /**
  85329. * Creates a Vector4 object from the given floats.
  85330. * @param x x value of the vector
  85331. * @param y y value of the vector
  85332. * @param z z value of the vector
  85333. * @param w w value of the vector
  85334. */
  85335. constructor(
  85336. /** x value of the vector */
  85337. x: number,
  85338. /** y value of the vector */
  85339. y: number,
  85340. /** z value of the vector */
  85341. z: number,
  85342. /** w value of the vector */
  85343. w: number);
  85344. /**
  85345. * Returns the string with the Vector4 coordinates.
  85346. * @returns a string containing all the vector values
  85347. */
  85348. toString(): string;
  85349. /**
  85350. * Returns the string "Vector4".
  85351. * @returns "Vector4"
  85352. */
  85353. getClassName(): string;
  85354. /**
  85355. * Returns the Vector4 hash code.
  85356. * @returns a unique hash code
  85357. */
  85358. getHashCode(): number;
  85359. /**
  85360. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  85361. * @returns the resulting array
  85362. */
  85363. asArray(): number[];
  85364. /**
  85365. * Populates the given array from the given index with the Vector4 coordinates.
  85366. * @param array array to populate
  85367. * @param index index of the array to start at (default: 0)
  85368. * @returns the Vector4.
  85369. */
  85370. toArray(array: FloatArray, index?: number): Vector4;
  85371. /**
  85372. * Update the current vector from an array
  85373. * @param array defines the destination array
  85374. * @param index defines the offset in the destination array
  85375. * @returns the current Vector3
  85376. */
  85377. fromArray(array: FloatArray, index?: number): Vector4;
  85378. /**
  85379. * Adds the given vector to the current Vector4.
  85380. * @param otherVector the vector to add
  85381. * @returns the updated Vector4.
  85382. */
  85383. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85384. /**
  85385. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  85386. * @param otherVector the vector to add
  85387. * @returns the resulting vector
  85388. */
  85389. add(otherVector: DeepImmutable<Vector4>): Vector4;
  85390. /**
  85391. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  85392. * @param otherVector the vector to add
  85393. * @param result the vector to store the result
  85394. * @returns the current Vector4.
  85395. */
  85396. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85397. /**
  85398. * Subtract in place the given vector from the current Vector4.
  85399. * @param otherVector the vector to subtract
  85400. * @returns the updated Vector4.
  85401. */
  85402. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85403. /**
  85404. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  85405. * @param otherVector the vector to add
  85406. * @returns the new vector with the result
  85407. */
  85408. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  85409. /**
  85410. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  85411. * @param otherVector the vector to subtract
  85412. * @param result the vector to store the result
  85413. * @returns the current Vector4.
  85414. */
  85415. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85416. /**
  85417. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85418. */
  85419. /**
  85420. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85421. * @param x value to subtract
  85422. * @param y value to subtract
  85423. * @param z value to subtract
  85424. * @param w value to subtract
  85425. * @returns new vector containing the result
  85426. */
  85427. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85428. /**
  85429. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85430. * @param x value to subtract
  85431. * @param y value to subtract
  85432. * @param z value to subtract
  85433. * @param w value to subtract
  85434. * @param result the vector to store the result in
  85435. * @returns the current Vector4.
  85436. */
  85437. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  85438. /**
  85439. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  85440. * @returns a new vector with the negated values
  85441. */
  85442. negate(): Vector4;
  85443. /**
  85444. * Negate this vector in place
  85445. * @returns this
  85446. */
  85447. negateInPlace(): Vector4;
  85448. /**
  85449. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  85450. * @param result defines the Vector3 object where to store the result
  85451. * @returns the current Vector4
  85452. */
  85453. negateToRef(result: Vector4): Vector4;
  85454. /**
  85455. * Multiplies the current Vector4 coordinates by scale (float).
  85456. * @param scale the number to scale with
  85457. * @returns the updated Vector4.
  85458. */
  85459. scaleInPlace(scale: number): Vector4;
  85460. /**
  85461. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  85462. * @param scale the number to scale with
  85463. * @returns a new vector with the result
  85464. */
  85465. scale(scale: number): Vector4;
  85466. /**
  85467. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  85468. * @param scale the number to scale with
  85469. * @param result a vector to store the result in
  85470. * @returns the current Vector4.
  85471. */
  85472. scaleToRef(scale: number, result: Vector4): Vector4;
  85473. /**
  85474. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  85475. * @param scale defines the scale factor
  85476. * @param result defines the Vector4 object where to store the result
  85477. * @returns the unmodified current Vector4
  85478. */
  85479. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  85480. /**
  85481. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  85482. * @param otherVector the vector to compare against
  85483. * @returns true if they are equal
  85484. */
  85485. equals(otherVector: DeepImmutable<Vector4>): boolean;
  85486. /**
  85487. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  85488. * @param otherVector vector to compare against
  85489. * @param epsilon (Default: very small number)
  85490. * @returns true if they are equal
  85491. */
  85492. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  85493. /**
  85494. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  85495. * @param x x value to compare against
  85496. * @param y y value to compare against
  85497. * @param z z value to compare against
  85498. * @param w w value to compare against
  85499. * @returns true if equal
  85500. */
  85501. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  85502. /**
  85503. * Multiplies in place the current Vector4 by the given one.
  85504. * @param otherVector vector to multiple with
  85505. * @returns the updated Vector4.
  85506. */
  85507. multiplyInPlace(otherVector: Vector4): Vector4;
  85508. /**
  85509. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  85510. * @param otherVector vector to multiple with
  85511. * @returns resulting new vector
  85512. */
  85513. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  85514. /**
  85515. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  85516. * @param otherVector vector to multiple with
  85517. * @param result vector to store the result
  85518. * @returns the current Vector4.
  85519. */
  85520. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85521. /**
  85522. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  85523. * @param x x value multiply with
  85524. * @param y y value multiply with
  85525. * @param z z value multiply with
  85526. * @param w w value multiply with
  85527. * @returns resulting new vector
  85528. */
  85529. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  85530. /**
  85531. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  85532. * @param otherVector vector to devide with
  85533. * @returns resulting new vector
  85534. */
  85535. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  85536. /**
  85537. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  85538. * @param otherVector vector to devide with
  85539. * @param result vector to store the result
  85540. * @returns the current Vector4.
  85541. */
  85542. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85543. /**
  85544. * Divides the current Vector3 coordinates by the given ones.
  85545. * @param otherVector vector to devide with
  85546. * @returns the updated Vector3.
  85547. */
  85548. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85549. /**
  85550. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  85551. * @param other defines the second operand
  85552. * @returns the current updated Vector4
  85553. */
  85554. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85555. /**
  85556. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  85557. * @param other defines the second operand
  85558. * @returns the current updated Vector4
  85559. */
  85560. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85561. /**
  85562. * Gets a new Vector4 from current Vector4 floored values
  85563. * @returns a new Vector4
  85564. */
  85565. floor(): Vector4;
  85566. /**
  85567. * Gets a new Vector4 from current Vector3 floored values
  85568. * @returns a new Vector4
  85569. */
  85570. fract(): Vector4;
  85571. /**
  85572. * Returns the Vector4 length (float).
  85573. * @returns the length
  85574. */
  85575. length(): number;
  85576. /**
  85577. * Returns the Vector4 squared length (float).
  85578. * @returns the length squared
  85579. */
  85580. lengthSquared(): number;
  85581. /**
  85582. * Normalizes in place the Vector4.
  85583. * @returns the updated Vector4.
  85584. */
  85585. normalize(): Vector4;
  85586. /**
  85587. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  85588. * @returns this converted to a new vector3
  85589. */
  85590. toVector3(): Vector3;
  85591. /**
  85592. * Returns a new Vector4 copied from the current one.
  85593. * @returns the new cloned vector
  85594. */
  85595. clone(): Vector4;
  85596. /**
  85597. * Updates the current Vector4 with the given one coordinates.
  85598. * @param source the source vector to copy from
  85599. * @returns the updated Vector4.
  85600. */
  85601. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  85602. /**
  85603. * Updates the current Vector4 coordinates with the given floats.
  85604. * @param x float to copy from
  85605. * @param y float to copy from
  85606. * @param z float to copy from
  85607. * @param w float to copy from
  85608. * @returns the updated Vector4.
  85609. */
  85610. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85611. /**
  85612. * Updates the current Vector4 coordinates with the given floats.
  85613. * @param x float to set from
  85614. * @param y float to set from
  85615. * @param z float to set from
  85616. * @param w float to set from
  85617. * @returns the updated Vector4.
  85618. */
  85619. set(x: number, y: number, z: number, w: number): Vector4;
  85620. /**
  85621. * Copies the given float to the current Vector3 coordinates
  85622. * @param v defines the x, y, z and w coordinates of the operand
  85623. * @returns the current updated Vector3
  85624. */
  85625. setAll(v: number): Vector4;
  85626. /**
  85627. * Returns a new Vector4 set from the starting index of the given array.
  85628. * @param array the array to pull values from
  85629. * @param offset the offset into the array to start at
  85630. * @returns the new vector
  85631. */
  85632. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  85633. /**
  85634. * Updates the given vector "result" from the starting index of the given array.
  85635. * @param array the array to pull values from
  85636. * @param offset the offset into the array to start at
  85637. * @param result the vector to store the result in
  85638. */
  85639. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  85640. /**
  85641. * Updates the given vector "result" from the starting index of the given Float32Array.
  85642. * @param array the array to pull values from
  85643. * @param offset the offset into the array to start at
  85644. * @param result the vector to store the result in
  85645. */
  85646. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  85647. /**
  85648. * Updates the given vector "result" coordinates from the given floats.
  85649. * @param x float to set from
  85650. * @param y float to set from
  85651. * @param z float to set from
  85652. * @param w float to set from
  85653. * @param result the vector to the floats in
  85654. */
  85655. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  85656. /**
  85657. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  85658. * @returns the new vector
  85659. */
  85660. static Zero(): Vector4;
  85661. /**
  85662. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  85663. * @returns the new vector
  85664. */
  85665. static One(): Vector4;
  85666. /**
  85667. * Returns a new normalized Vector4 from the given one.
  85668. * @param vector the vector to normalize
  85669. * @returns the vector
  85670. */
  85671. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  85672. /**
  85673. * Updates the given vector "result" from the normalization of the given one.
  85674. * @param vector the vector to normalize
  85675. * @param result the vector to store the result in
  85676. */
  85677. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  85678. /**
  85679. * Returns a vector with the minimum values from the left and right vectors
  85680. * @param left left vector to minimize
  85681. * @param right right vector to minimize
  85682. * @returns a new vector with the minimum of the left and right vector values
  85683. */
  85684. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85685. /**
  85686. * Returns a vector with the maximum values from the left and right vectors
  85687. * @param left left vector to maximize
  85688. * @param right right vector to maximize
  85689. * @returns a new vector with the maximum of the left and right vector values
  85690. */
  85691. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85692. /**
  85693. * Returns the distance (float) between the vectors "value1" and "value2".
  85694. * @param value1 value to calulate the distance between
  85695. * @param value2 value to calulate the distance between
  85696. * @return the distance between the two vectors
  85697. */
  85698. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85699. /**
  85700. * Returns the squared distance (float) between the vectors "value1" and "value2".
  85701. * @param value1 value to calulate the distance between
  85702. * @param value2 value to calulate the distance between
  85703. * @return the distance between the two vectors squared
  85704. */
  85705. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85706. /**
  85707. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  85708. * @param value1 value to calulate the center between
  85709. * @param value2 value to calulate the center between
  85710. * @return the center between the two vectors
  85711. */
  85712. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  85713. /**
  85714. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  85715. * @param value1 defines first vector
  85716. * @param value2 defines second vector
  85717. * @param ref defines third vector
  85718. * @returns ref
  85719. */
  85720. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  85721. /**
  85722. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  85723. * This methods computes transformed normalized direction vectors only.
  85724. * @param vector the vector to transform
  85725. * @param transformation the transformation matrix to apply
  85726. * @returns the new vector
  85727. */
  85728. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  85729. /**
  85730. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  85731. * This methods computes transformed normalized direction vectors only.
  85732. * @param vector the vector to transform
  85733. * @param transformation the transformation matrix to apply
  85734. * @param result the vector to store the result in
  85735. */
  85736. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85737. /**
  85738. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  85739. * This methods computes transformed normalized direction vectors only.
  85740. * @param x value to transform
  85741. * @param y value to transform
  85742. * @param z value to transform
  85743. * @param w value to transform
  85744. * @param transformation the transformation matrix to apply
  85745. * @param result the vector to store the results in
  85746. */
  85747. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85748. /**
  85749. * Creates a new Vector4 from a Vector3
  85750. * @param source defines the source data
  85751. * @param w defines the 4th component (default is 0)
  85752. * @returns a new Vector4
  85753. */
  85754. static FromVector3(source: Vector3, w?: number): Vector4;
  85755. }
  85756. /**
  85757. * Class used to store quaternion data
  85758. * @see https://en.wikipedia.org/wiki/Quaternion
  85759. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  85760. */
  85761. export class Quaternion {
  85762. /** @hidden */
  85763. _x: number;
  85764. /** @hidden */
  85765. _y: number;
  85766. /** @hidden */
  85767. _z: number;
  85768. /** @hidden */
  85769. _w: number;
  85770. /** @hidden */
  85771. _isDirty: boolean;
  85772. /** Gets or sets the x coordinate */
  85773. get x(): number;
  85774. set x(value: number);
  85775. /** Gets or sets the y coordinate */
  85776. get y(): number;
  85777. set y(value: number);
  85778. /** Gets or sets the z coordinate */
  85779. get z(): number;
  85780. set z(value: number);
  85781. /** Gets or sets the w coordinate */
  85782. get w(): number;
  85783. set w(value: number);
  85784. /**
  85785. * Creates a new Quaternion from the given floats
  85786. * @param x defines the first component (0 by default)
  85787. * @param y defines the second component (0 by default)
  85788. * @param z defines the third component (0 by default)
  85789. * @param w defines the fourth component (1.0 by default)
  85790. */
  85791. constructor(x?: number, y?: number, z?: number, w?: number);
  85792. /**
  85793. * Gets a string representation for the current quaternion
  85794. * @returns a string with the Quaternion coordinates
  85795. */
  85796. toString(): string;
  85797. /**
  85798. * Gets the class name of the quaternion
  85799. * @returns the string "Quaternion"
  85800. */
  85801. getClassName(): string;
  85802. /**
  85803. * Gets a hash code for this quaternion
  85804. * @returns the quaternion hash code
  85805. */
  85806. getHashCode(): number;
  85807. /**
  85808. * Copy the quaternion to an array
  85809. * @returns a new array populated with 4 elements from the quaternion coordinates
  85810. */
  85811. asArray(): number[];
  85812. /**
  85813. * Check if two quaternions are equals
  85814. * @param otherQuaternion defines the second operand
  85815. * @return true if the current quaternion and the given one coordinates are strictly equals
  85816. */
  85817. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  85818. /**
  85819. * Gets a boolean if two quaternions are equals (using an epsilon value)
  85820. * @param otherQuaternion defines the other quaternion
  85821. * @param epsilon defines the minimal distance to consider equality
  85822. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  85823. */
  85824. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  85825. /**
  85826. * Clone the current quaternion
  85827. * @returns a new quaternion copied from the current one
  85828. */
  85829. clone(): Quaternion;
  85830. /**
  85831. * Copy a quaternion to the current one
  85832. * @param other defines the other quaternion
  85833. * @returns the updated current quaternion
  85834. */
  85835. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  85836. /**
  85837. * Updates the current quaternion with the given float coordinates
  85838. * @param x defines the x coordinate
  85839. * @param y defines the y coordinate
  85840. * @param z defines the z coordinate
  85841. * @param w defines the w coordinate
  85842. * @returns the updated current quaternion
  85843. */
  85844. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  85845. /**
  85846. * Updates the current quaternion from the given float coordinates
  85847. * @param x defines the x coordinate
  85848. * @param y defines the y coordinate
  85849. * @param z defines the z coordinate
  85850. * @param w defines the w coordinate
  85851. * @returns the updated current quaternion
  85852. */
  85853. set(x: number, y: number, z: number, w: number): Quaternion;
  85854. /**
  85855. * Adds two quaternions
  85856. * @param other defines the second operand
  85857. * @returns a new quaternion as the addition result of the given one and the current quaternion
  85858. */
  85859. add(other: DeepImmutable<Quaternion>): Quaternion;
  85860. /**
  85861. * Add a quaternion to the current one
  85862. * @param other defines the quaternion to add
  85863. * @returns the current quaternion
  85864. */
  85865. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  85866. /**
  85867. * Subtract two quaternions
  85868. * @param other defines the second operand
  85869. * @returns a new quaternion as the subtraction result of the given one from the current one
  85870. */
  85871. subtract(other: Quaternion): Quaternion;
  85872. /**
  85873. * Multiplies the current quaternion by a scale factor
  85874. * @param value defines the scale factor
  85875. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  85876. */
  85877. scale(value: number): Quaternion;
  85878. /**
  85879. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  85880. * @param scale defines the scale factor
  85881. * @param result defines the Quaternion object where to store the result
  85882. * @returns the unmodified current quaternion
  85883. */
  85884. scaleToRef(scale: number, result: Quaternion): Quaternion;
  85885. /**
  85886. * Multiplies in place the current quaternion by a scale factor
  85887. * @param value defines the scale factor
  85888. * @returns the current modified quaternion
  85889. */
  85890. scaleInPlace(value: number): Quaternion;
  85891. /**
  85892. * Scale the current quaternion values by a factor and add the result to a given quaternion
  85893. * @param scale defines the scale factor
  85894. * @param result defines the Quaternion object where to store the result
  85895. * @returns the unmodified current quaternion
  85896. */
  85897. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  85898. /**
  85899. * Multiplies two quaternions
  85900. * @param q1 defines the second operand
  85901. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  85902. */
  85903. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  85904. /**
  85905. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  85906. * @param q1 defines the second operand
  85907. * @param result defines the target quaternion
  85908. * @returns the current quaternion
  85909. */
  85910. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  85911. /**
  85912. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  85913. * @param q1 defines the second operand
  85914. * @returns the currentupdated quaternion
  85915. */
  85916. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  85917. /**
  85918. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  85919. * @param ref defines the target quaternion
  85920. * @returns the current quaternion
  85921. */
  85922. conjugateToRef(ref: Quaternion): Quaternion;
  85923. /**
  85924. * Conjugates in place (1-q) the current quaternion
  85925. * @returns the current updated quaternion
  85926. */
  85927. conjugateInPlace(): Quaternion;
  85928. /**
  85929. * Conjugates in place (1-q) the current quaternion
  85930. * @returns a new quaternion
  85931. */
  85932. conjugate(): Quaternion;
  85933. /**
  85934. * Gets length of current quaternion
  85935. * @returns the quaternion length (float)
  85936. */
  85937. length(): number;
  85938. /**
  85939. * Normalize in place the current quaternion
  85940. * @returns the current updated quaternion
  85941. */
  85942. normalize(): Quaternion;
  85943. /**
  85944. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85945. * @param order is a reserved parameter and is ignored for now
  85946. * @returns a new Vector3 containing the Euler angles
  85947. */
  85948. toEulerAngles(order?: string): Vector3;
  85949. /**
  85950. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85951. * @param result defines the vector which will be filled with the Euler angles
  85952. * @returns the current unchanged quaternion
  85953. */
  85954. toEulerAnglesToRef(result: Vector3): Quaternion;
  85955. /**
  85956. * Updates the given rotation matrix with the current quaternion values
  85957. * @param result defines the target matrix
  85958. * @returns the current unchanged quaternion
  85959. */
  85960. toRotationMatrix(result: Matrix): Quaternion;
  85961. /**
  85962. * Updates the current quaternion from the given rotation matrix values
  85963. * @param matrix defines the source matrix
  85964. * @returns the current updated quaternion
  85965. */
  85966. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85967. /**
  85968. * Creates a new quaternion from a rotation matrix
  85969. * @param matrix defines the source matrix
  85970. * @returns a new quaternion created from the given rotation matrix values
  85971. */
  85972. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85973. /**
  85974. * Updates the given quaternion with the given rotation matrix values
  85975. * @param matrix defines the source matrix
  85976. * @param result defines the target quaternion
  85977. */
  85978. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  85979. /**
  85980. * Returns the dot product (float) between the quaternions "left" and "right"
  85981. * @param left defines the left operand
  85982. * @param right defines the right operand
  85983. * @returns the dot product
  85984. */
  85985. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  85986. /**
  85987. * Checks if the two quaternions are close to each other
  85988. * @param quat0 defines the first quaternion to check
  85989. * @param quat1 defines the second quaternion to check
  85990. * @returns true if the two quaternions are close to each other
  85991. */
  85992. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  85993. /**
  85994. * Creates an empty quaternion
  85995. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85996. */
  85997. static Zero(): Quaternion;
  85998. /**
  85999. * Inverse a given quaternion
  86000. * @param q defines the source quaternion
  86001. * @returns a new quaternion as the inverted current quaternion
  86002. */
  86003. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  86004. /**
  86005. * Inverse a given quaternion
  86006. * @param q defines the source quaternion
  86007. * @param result the quaternion the result will be stored in
  86008. * @returns the result quaternion
  86009. */
  86010. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  86011. /**
  86012. * Creates an identity quaternion
  86013. * @returns the identity quaternion
  86014. */
  86015. static Identity(): Quaternion;
  86016. /**
  86017. * Gets a boolean indicating if the given quaternion is identity
  86018. * @param quaternion defines the quaternion to check
  86019. * @returns true if the quaternion is identity
  86020. */
  86021. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  86022. /**
  86023. * Creates a quaternion from a rotation around an axis
  86024. * @param axis defines the axis to use
  86025. * @param angle defines the angle to use
  86026. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  86027. */
  86028. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  86029. /**
  86030. * Creates a rotation around an axis and stores it into the given quaternion
  86031. * @param axis defines the axis to use
  86032. * @param angle defines the angle to use
  86033. * @param result defines the target quaternion
  86034. * @returns the target quaternion
  86035. */
  86036. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  86037. /**
  86038. * Creates a new quaternion from data stored into an array
  86039. * @param array defines the data source
  86040. * @param offset defines the offset in the source array where the data starts
  86041. * @returns a new quaternion
  86042. */
  86043. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  86044. /**
  86045. * Updates the given quaternion "result" from the starting index of the given array.
  86046. * @param array the array to pull values from
  86047. * @param offset the offset into the array to start at
  86048. * @param result the quaternion to store the result in
  86049. */
  86050. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  86051. /**
  86052. * Create a quaternion from Euler rotation angles
  86053. * @param x Pitch
  86054. * @param y Yaw
  86055. * @param z Roll
  86056. * @returns the new Quaternion
  86057. */
  86058. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  86059. /**
  86060. * Updates a quaternion from Euler rotation angles
  86061. * @param x Pitch
  86062. * @param y Yaw
  86063. * @param z Roll
  86064. * @param result the quaternion to store the result
  86065. * @returns the updated quaternion
  86066. */
  86067. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  86068. /**
  86069. * Create a quaternion from Euler rotation vector
  86070. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  86071. * @returns the new Quaternion
  86072. */
  86073. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  86074. /**
  86075. * Updates a quaternion from Euler rotation vector
  86076. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  86077. * @param result the quaternion to store the result
  86078. * @returns the updated quaternion
  86079. */
  86080. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  86081. /**
  86082. * Creates a new quaternion from the given Euler float angles (y, x, z)
  86083. * @param yaw defines the rotation around Y axis
  86084. * @param pitch defines the rotation around X axis
  86085. * @param roll defines the rotation around Z axis
  86086. * @returns the new quaternion
  86087. */
  86088. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  86089. /**
  86090. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  86091. * @param yaw defines the rotation around Y axis
  86092. * @param pitch defines the rotation around X axis
  86093. * @param roll defines the rotation around Z axis
  86094. * @param result defines the target quaternion
  86095. */
  86096. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  86097. /**
  86098. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  86099. * @param alpha defines the rotation around first axis
  86100. * @param beta defines the rotation around second axis
  86101. * @param gamma defines the rotation around third axis
  86102. * @returns the new quaternion
  86103. */
  86104. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  86105. /**
  86106. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  86107. * @param alpha defines the rotation around first axis
  86108. * @param beta defines the rotation around second axis
  86109. * @param gamma defines the rotation around third axis
  86110. * @param result defines the target quaternion
  86111. */
  86112. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  86113. /**
  86114. * 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)
  86115. * @param axis1 defines the first axis
  86116. * @param axis2 defines the second axis
  86117. * @param axis3 defines the third axis
  86118. * @returns the new quaternion
  86119. */
  86120. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  86121. /**
  86122. * 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
  86123. * @param axis1 defines the first axis
  86124. * @param axis2 defines the second axis
  86125. * @param axis3 defines the third axis
  86126. * @param ref defines the target quaternion
  86127. */
  86128. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  86129. /**
  86130. * Interpolates between two quaternions
  86131. * @param left defines first quaternion
  86132. * @param right defines second quaternion
  86133. * @param amount defines the gradient to use
  86134. * @returns the new interpolated quaternion
  86135. */
  86136. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  86137. /**
  86138. * Interpolates between two quaternions and stores it into a target quaternion
  86139. * @param left defines first quaternion
  86140. * @param right defines second quaternion
  86141. * @param amount defines the gradient to use
  86142. * @param result defines the target quaternion
  86143. */
  86144. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  86145. /**
  86146. * Interpolate between two quaternions using Hermite interpolation
  86147. * @param value1 defines first quaternion
  86148. * @param tangent1 defines the incoming tangent
  86149. * @param value2 defines second quaternion
  86150. * @param tangent2 defines the outgoing tangent
  86151. * @param amount defines the target quaternion
  86152. * @returns the new interpolated quaternion
  86153. */
  86154. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  86155. }
  86156. /**
  86157. * Class used to store matrix data (4x4)
  86158. */
  86159. export class Matrix {
  86160. /**
  86161. * Gets the precision of matrix computations
  86162. */
  86163. static get Use64Bits(): boolean;
  86164. private static _updateFlagSeed;
  86165. private static _identityReadOnly;
  86166. private _isIdentity;
  86167. private _isIdentityDirty;
  86168. private _isIdentity3x2;
  86169. private _isIdentity3x2Dirty;
  86170. /**
  86171. * Gets the update flag of the matrix which is an unique number for the matrix.
  86172. * It will be incremented every time the matrix data change.
  86173. * You can use it to speed the comparison between two versions of the same matrix.
  86174. */
  86175. updateFlag: number;
  86176. private readonly _m;
  86177. /**
  86178. * Gets the internal data of the matrix
  86179. */
  86180. get m(): DeepImmutable<Float32Array | Array<number>>;
  86181. /** @hidden */
  86182. _markAsUpdated(): void;
  86183. /** @hidden */
  86184. private _updateIdentityStatus;
  86185. /**
  86186. * Creates an empty matrix (filled with zeros)
  86187. */
  86188. constructor();
  86189. /**
  86190. * Check if the current matrix is identity
  86191. * @returns true is the matrix is the identity matrix
  86192. */
  86193. isIdentity(): boolean;
  86194. /**
  86195. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  86196. * @returns true is the matrix is the identity matrix
  86197. */
  86198. isIdentityAs3x2(): boolean;
  86199. /**
  86200. * Gets the determinant of the matrix
  86201. * @returns the matrix determinant
  86202. */
  86203. determinant(): number;
  86204. /**
  86205. * Returns the matrix as a Float32Array or Array<number>
  86206. * @returns the matrix underlying array
  86207. */
  86208. toArray(): DeepImmutable<Float32Array | Array<number>>;
  86209. /**
  86210. * Returns the matrix as a Float32Array or Array<number>
  86211. * @returns the matrix underlying array.
  86212. */
  86213. asArray(): DeepImmutable<Float32Array | Array<number>>;
  86214. /**
  86215. * Inverts the current matrix in place
  86216. * @returns the current inverted matrix
  86217. */
  86218. invert(): Matrix;
  86219. /**
  86220. * Sets all the matrix elements to zero
  86221. * @returns the current matrix
  86222. */
  86223. reset(): Matrix;
  86224. /**
  86225. * Adds the current matrix with a second one
  86226. * @param other defines the matrix to add
  86227. * @returns a new matrix as the addition of the current matrix and the given one
  86228. */
  86229. add(other: DeepImmutable<Matrix>): Matrix;
  86230. /**
  86231. * Sets the given matrix "result" to the addition of the current matrix and the given one
  86232. * @param other defines the matrix to add
  86233. * @param result defines the target matrix
  86234. * @returns the current matrix
  86235. */
  86236. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  86237. /**
  86238. * Adds in place the given matrix to the current matrix
  86239. * @param other defines the second operand
  86240. * @returns the current updated matrix
  86241. */
  86242. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  86243. /**
  86244. * Sets the given matrix to the current inverted Matrix
  86245. * @param other defines the target matrix
  86246. * @returns the unmodified current matrix
  86247. */
  86248. invertToRef(other: Matrix): Matrix;
  86249. /**
  86250. * add a value at the specified position in the current Matrix
  86251. * @param index the index of the value within the matrix. between 0 and 15.
  86252. * @param value the value to be added
  86253. * @returns the current updated matrix
  86254. */
  86255. addAtIndex(index: number, value: number): Matrix;
  86256. /**
  86257. * mutiply the specified position in the current Matrix by a value
  86258. * @param index the index of the value within the matrix. between 0 and 15.
  86259. * @param value the value to be added
  86260. * @returns the current updated matrix
  86261. */
  86262. multiplyAtIndex(index: number, value: number): Matrix;
  86263. /**
  86264. * Inserts the translation vector (using 3 floats) in the current matrix
  86265. * @param x defines the 1st component of the translation
  86266. * @param y defines the 2nd component of the translation
  86267. * @param z defines the 3rd component of the translation
  86268. * @returns the current updated matrix
  86269. */
  86270. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  86271. /**
  86272. * Adds the translation vector (using 3 floats) in the current matrix
  86273. * @param x defines the 1st component of the translation
  86274. * @param y defines the 2nd component of the translation
  86275. * @param z defines the 3rd component of the translation
  86276. * @returns the current updated matrix
  86277. */
  86278. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  86279. /**
  86280. * Inserts the translation vector in the current matrix
  86281. * @param vector3 defines the translation to insert
  86282. * @returns the current updated matrix
  86283. */
  86284. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  86285. /**
  86286. * Gets the translation value of the current matrix
  86287. * @returns a new Vector3 as the extracted translation from the matrix
  86288. */
  86289. getTranslation(): Vector3;
  86290. /**
  86291. * Fill a Vector3 with the extracted translation from the matrix
  86292. * @param result defines the Vector3 where to store the translation
  86293. * @returns the current matrix
  86294. */
  86295. getTranslationToRef(result: Vector3): Matrix;
  86296. /**
  86297. * Remove rotation and scaling part from the matrix
  86298. * @returns the updated matrix
  86299. */
  86300. removeRotationAndScaling(): Matrix;
  86301. /**
  86302. * Multiply two matrices
  86303. * @param other defines the second operand
  86304. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  86305. */
  86306. multiply(other: DeepImmutable<Matrix>): Matrix;
  86307. /**
  86308. * Copy the current matrix from the given one
  86309. * @param other defines the source matrix
  86310. * @returns the current updated matrix
  86311. */
  86312. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  86313. /**
  86314. * Populates the given array from the starting index with the current matrix values
  86315. * @param array defines the target array
  86316. * @param offset defines the offset in the target array where to start storing values
  86317. * @returns the current matrix
  86318. */
  86319. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  86320. /**
  86321. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  86322. * @param other defines the second operand
  86323. * @param result defines the matrix where to store the multiplication
  86324. * @returns the current matrix
  86325. */
  86326. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  86327. /**
  86328. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  86329. * @param other defines the second operand
  86330. * @param result defines the array where to store the multiplication
  86331. * @param offset defines the offset in the target array where to start storing values
  86332. * @returns the current matrix
  86333. */
  86334. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  86335. /**
  86336. * Check equality between this matrix and a second one
  86337. * @param value defines the second matrix to compare
  86338. * @returns true is the current matrix and the given one values are strictly equal
  86339. */
  86340. equals(value: DeepImmutable<Matrix>): boolean;
  86341. /**
  86342. * Clone the current matrix
  86343. * @returns a new matrix from the current matrix
  86344. */
  86345. clone(): Matrix;
  86346. /**
  86347. * Returns the name of the current matrix class
  86348. * @returns the string "Matrix"
  86349. */
  86350. getClassName(): string;
  86351. /**
  86352. * Gets the hash code of the current matrix
  86353. * @returns the hash code
  86354. */
  86355. getHashCode(): number;
  86356. /**
  86357. * Decomposes the current Matrix into a translation, rotation and scaling components
  86358. * @param scale defines the scale vector3 given as a reference to update
  86359. * @param rotation defines the rotation quaternion given as a reference to update
  86360. * @param translation defines the translation vector3 given as a reference to update
  86361. * @returns true if operation was successful
  86362. */
  86363. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  86364. /**
  86365. * Gets specific row of the matrix
  86366. * @param index defines the number of the row to get
  86367. * @returns the index-th row of the current matrix as a new Vector4
  86368. */
  86369. getRow(index: number): Nullable<Vector4>;
  86370. /**
  86371. * Sets the index-th row of the current matrix to the vector4 values
  86372. * @param index defines the number of the row to set
  86373. * @param row defines the target vector4
  86374. * @returns the updated current matrix
  86375. */
  86376. setRow(index: number, row: Vector4): Matrix;
  86377. /**
  86378. * Compute the transpose of the matrix
  86379. * @returns the new transposed matrix
  86380. */
  86381. transpose(): Matrix;
  86382. /**
  86383. * Compute the transpose of the matrix and store it in a given matrix
  86384. * @param result defines the target matrix
  86385. * @returns the current matrix
  86386. */
  86387. transposeToRef(result: Matrix): Matrix;
  86388. /**
  86389. * Sets the index-th row of the current matrix with the given 4 x float values
  86390. * @param index defines the row index
  86391. * @param x defines the x component to set
  86392. * @param y defines the y component to set
  86393. * @param z defines the z component to set
  86394. * @param w defines the w component to set
  86395. * @returns the updated current matrix
  86396. */
  86397. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  86398. /**
  86399. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  86400. * @param scale defines the scale factor
  86401. * @returns a new matrix
  86402. */
  86403. scale(scale: number): Matrix;
  86404. /**
  86405. * Scale the current matrix values by a factor to a given result matrix
  86406. * @param scale defines the scale factor
  86407. * @param result defines the matrix to store the result
  86408. * @returns the current matrix
  86409. */
  86410. scaleToRef(scale: number, result: Matrix): Matrix;
  86411. /**
  86412. * Scale the current matrix values by a factor and add the result to a given matrix
  86413. * @param scale defines the scale factor
  86414. * @param result defines the Matrix to store the result
  86415. * @returns the current matrix
  86416. */
  86417. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  86418. /**
  86419. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  86420. * @param ref matrix to store the result
  86421. */
  86422. toNormalMatrix(ref: Matrix): void;
  86423. /**
  86424. * Gets only rotation part of the current matrix
  86425. * @returns a new matrix sets to the extracted rotation matrix from the current one
  86426. */
  86427. getRotationMatrix(): Matrix;
  86428. /**
  86429. * Extracts the rotation matrix from the current one and sets it as the given "result"
  86430. * @param result defines the target matrix to store data to
  86431. * @returns the current matrix
  86432. */
  86433. getRotationMatrixToRef(result: Matrix): Matrix;
  86434. /**
  86435. * Toggles model matrix from being right handed to left handed in place and vice versa
  86436. */
  86437. toggleModelMatrixHandInPlace(): void;
  86438. /**
  86439. * Toggles projection matrix from being right handed to left handed in place and vice versa
  86440. */
  86441. toggleProjectionMatrixHandInPlace(): void;
  86442. /**
  86443. * Creates a matrix from an array
  86444. * @param array defines the source array
  86445. * @param offset defines an offset in the source array
  86446. * @returns a new Matrix set from the starting index of the given array
  86447. */
  86448. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  86449. /**
  86450. * Copy the content of an array into a given matrix
  86451. * @param array defines the source array
  86452. * @param offset defines an offset in the source array
  86453. * @param result defines the target matrix
  86454. */
  86455. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  86456. /**
  86457. * Stores an array into a matrix after having multiplied each component by a given factor
  86458. * @param array defines the source array
  86459. * @param offset defines the offset in the source array
  86460. * @param scale defines the scaling factor
  86461. * @param result defines the target matrix
  86462. */
  86463. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  86464. /**
  86465. * Gets an identity matrix that must not be updated
  86466. */
  86467. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  86468. /**
  86469. * Stores a list of values (16) inside a given matrix
  86470. * @param initialM11 defines 1st value of 1st row
  86471. * @param initialM12 defines 2nd value of 1st row
  86472. * @param initialM13 defines 3rd value of 1st row
  86473. * @param initialM14 defines 4th value of 1st row
  86474. * @param initialM21 defines 1st value of 2nd row
  86475. * @param initialM22 defines 2nd value of 2nd row
  86476. * @param initialM23 defines 3rd value of 2nd row
  86477. * @param initialM24 defines 4th value of 2nd row
  86478. * @param initialM31 defines 1st value of 3rd row
  86479. * @param initialM32 defines 2nd value of 3rd row
  86480. * @param initialM33 defines 3rd value of 3rd row
  86481. * @param initialM34 defines 4th value of 3rd row
  86482. * @param initialM41 defines 1st value of 4th row
  86483. * @param initialM42 defines 2nd value of 4th row
  86484. * @param initialM43 defines 3rd value of 4th row
  86485. * @param initialM44 defines 4th value of 4th row
  86486. * @param result defines the target matrix
  86487. */
  86488. 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;
  86489. /**
  86490. * Creates new matrix from a list of values (16)
  86491. * @param initialM11 defines 1st value of 1st row
  86492. * @param initialM12 defines 2nd value of 1st row
  86493. * @param initialM13 defines 3rd value of 1st row
  86494. * @param initialM14 defines 4th value of 1st row
  86495. * @param initialM21 defines 1st value of 2nd row
  86496. * @param initialM22 defines 2nd value of 2nd row
  86497. * @param initialM23 defines 3rd value of 2nd row
  86498. * @param initialM24 defines 4th value of 2nd row
  86499. * @param initialM31 defines 1st value of 3rd row
  86500. * @param initialM32 defines 2nd value of 3rd row
  86501. * @param initialM33 defines 3rd value of 3rd row
  86502. * @param initialM34 defines 4th value of 3rd row
  86503. * @param initialM41 defines 1st value of 4th row
  86504. * @param initialM42 defines 2nd value of 4th row
  86505. * @param initialM43 defines 3rd value of 4th row
  86506. * @param initialM44 defines 4th value of 4th row
  86507. * @returns the new matrix
  86508. */
  86509. 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;
  86510. /**
  86511. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86512. * @param scale defines the scale vector3
  86513. * @param rotation defines the rotation quaternion
  86514. * @param translation defines the translation vector3
  86515. * @returns a new matrix
  86516. */
  86517. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  86518. /**
  86519. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86520. * @param scale defines the scale vector3
  86521. * @param rotation defines the rotation quaternion
  86522. * @param translation defines the translation vector3
  86523. * @param result defines the target matrix
  86524. */
  86525. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  86526. /**
  86527. * Creates a new identity matrix
  86528. * @returns a new identity matrix
  86529. */
  86530. static Identity(): Matrix;
  86531. /**
  86532. * Creates a new identity matrix and stores the result in a given matrix
  86533. * @param result defines the target matrix
  86534. */
  86535. static IdentityToRef(result: Matrix): void;
  86536. /**
  86537. * Creates a new zero matrix
  86538. * @returns a new zero matrix
  86539. */
  86540. static Zero(): Matrix;
  86541. /**
  86542. * Creates a new rotation matrix for "angle" radians around the X axis
  86543. * @param angle defines the angle (in radians) to use
  86544. * @return the new matrix
  86545. */
  86546. static RotationX(angle: number): Matrix;
  86547. /**
  86548. * Creates a new matrix as the invert of a given matrix
  86549. * @param source defines the source matrix
  86550. * @returns the new matrix
  86551. */
  86552. static Invert(source: DeepImmutable<Matrix>): Matrix;
  86553. /**
  86554. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  86555. * @param angle defines the angle (in radians) to use
  86556. * @param result defines the target matrix
  86557. */
  86558. static RotationXToRef(angle: number, result: Matrix): void;
  86559. /**
  86560. * Creates a new rotation matrix for "angle" radians around the Y axis
  86561. * @param angle defines the angle (in radians) to use
  86562. * @return the new matrix
  86563. */
  86564. static RotationY(angle: number): Matrix;
  86565. /**
  86566. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  86567. * @param angle defines the angle (in radians) to use
  86568. * @param result defines the target matrix
  86569. */
  86570. static RotationYToRef(angle: number, result: Matrix): void;
  86571. /**
  86572. * Creates a new rotation matrix for "angle" radians around the Z axis
  86573. * @param angle defines the angle (in radians) to use
  86574. * @return the new matrix
  86575. */
  86576. static RotationZ(angle: number): Matrix;
  86577. /**
  86578. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  86579. * @param angle defines the angle (in radians) to use
  86580. * @param result defines the target matrix
  86581. */
  86582. static RotationZToRef(angle: number, result: Matrix): void;
  86583. /**
  86584. * Creates a new rotation matrix for "angle" radians around the given axis
  86585. * @param axis defines the axis to use
  86586. * @param angle defines the angle (in radians) to use
  86587. * @return the new matrix
  86588. */
  86589. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  86590. /**
  86591. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  86592. * @param axis defines the axis to use
  86593. * @param angle defines the angle (in radians) to use
  86594. * @param result defines the target matrix
  86595. */
  86596. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  86597. /**
  86598. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  86599. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  86600. * @param from defines the vector to align
  86601. * @param to defines the vector to align to
  86602. * @param result defines the target matrix
  86603. */
  86604. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  86605. /**
  86606. * Creates a rotation matrix
  86607. * @param yaw defines the yaw angle in radians (Y axis)
  86608. * @param pitch defines the pitch angle in radians (X axis)
  86609. * @param roll defines the roll angle in radians (Z axis)
  86610. * @returns the new rotation matrix
  86611. */
  86612. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  86613. /**
  86614. * Creates a rotation matrix and stores it in a given matrix
  86615. * @param yaw defines the yaw angle in radians (Y axis)
  86616. * @param pitch defines the pitch angle in radians (X axis)
  86617. * @param roll defines the roll angle in radians (Z axis)
  86618. * @param result defines the target matrix
  86619. */
  86620. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  86621. /**
  86622. * Creates a scaling matrix
  86623. * @param x defines the scale factor on X axis
  86624. * @param y defines the scale factor on Y axis
  86625. * @param z defines the scale factor on Z axis
  86626. * @returns the new matrix
  86627. */
  86628. static Scaling(x: number, y: number, z: number): Matrix;
  86629. /**
  86630. * Creates a scaling matrix and stores it in a given matrix
  86631. * @param x defines the scale factor on X axis
  86632. * @param y defines the scale factor on Y axis
  86633. * @param z defines the scale factor on Z axis
  86634. * @param result defines the target matrix
  86635. */
  86636. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  86637. /**
  86638. * Creates a translation matrix
  86639. * @param x defines the translation on X axis
  86640. * @param y defines the translation on Y axis
  86641. * @param z defines the translationon Z axis
  86642. * @returns the new matrix
  86643. */
  86644. static Translation(x: number, y: number, z: number): Matrix;
  86645. /**
  86646. * Creates a translation matrix and stores it in a given matrix
  86647. * @param x defines the translation on X axis
  86648. * @param y defines the translation on Y axis
  86649. * @param z defines the translationon Z axis
  86650. * @param result defines the target matrix
  86651. */
  86652. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  86653. /**
  86654. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86655. * @param startValue defines the start value
  86656. * @param endValue defines the end value
  86657. * @param gradient defines the gradient factor
  86658. * @returns the new matrix
  86659. */
  86660. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86661. /**
  86662. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86663. * @param startValue defines the start value
  86664. * @param endValue defines the end value
  86665. * @param gradient defines the gradient factor
  86666. * @param result defines the Matrix object where to store data
  86667. */
  86668. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86669. /**
  86670. * Builds a new matrix whose values are computed by:
  86671. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86672. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86673. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86674. * @param startValue defines the first matrix
  86675. * @param endValue defines the second matrix
  86676. * @param gradient defines the gradient between the two matrices
  86677. * @returns the new matrix
  86678. */
  86679. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86680. /**
  86681. * Update a matrix to values which are computed by:
  86682. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86683. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86684. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86685. * @param startValue defines the first matrix
  86686. * @param endValue defines the second matrix
  86687. * @param gradient defines the gradient between the two matrices
  86688. * @param result defines the target matrix
  86689. */
  86690. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86691. /**
  86692. * 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"
  86693. * This function works in left handed mode
  86694. * @param eye defines the final position of the entity
  86695. * @param target defines where the entity should look at
  86696. * @param up defines the up vector for the entity
  86697. * @returns the new matrix
  86698. */
  86699. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86700. /**
  86701. * 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".
  86702. * This function works in left handed mode
  86703. * @param eye defines the final position of the entity
  86704. * @param target defines where the entity should look at
  86705. * @param up defines the up vector for the entity
  86706. * @param result defines the target matrix
  86707. */
  86708. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86709. /**
  86710. * 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"
  86711. * This function works in right handed mode
  86712. * @param eye defines the final position of the entity
  86713. * @param target defines where the entity should look at
  86714. * @param up defines the up vector for the entity
  86715. * @returns the new matrix
  86716. */
  86717. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86718. /**
  86719. * 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".
  86720. * This function works in right handed mode
  86721. * @param eye defines the final position of the entity
  86722. * @param target defines where the entity should look at
  86723. * @param up defines the up vector for the entity
  86724. * @param result defines the target matrix
  86725. */
  86726. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86727. /**
  86728. * Create a left-handed orthographic projection matrix
  86729. * @param width defines the viewport width
  86730. * @param height defines the viewport height
  86731. * @param znear defines the near clip plane
  86732. * @param zfar defines the far clip plane
  86733. * @returns a new matrix as a left-handed orthographic projection matrix
  86734. */
  86735. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86736. /**
  86737. * Store a left-handed orthographic projection to a given matrix
  86738. * @param width defines the viewport width
  86739. * @param height defines the viewport height
  86740. * @param znear defines the near clip plane
  86741. * @param zfar defines the far clip plane
  86742. * @param result defines the target matrix
  86743. */
  86744. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  86745. /**
  86746. * Create a left-handed orthographic projection matrix
  86747. * @param left defines the viewport left coordinate
  86748. * @param right defines the viewport right coordinate
  86749. * @param bottom defines the viewport bottom coordinate
  86750. * @param top defines the viewport top coordinate
  86751. * @param znear defines the near clip plane
  86752. * @param zfar defines the far clip plane
  86753. * @returns a new matrix as a left-handed orthographic projection matrix
  86754. */
  86755. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86756. /**
  86757. * Stores a left-handed orthographic projection into a given matrix
  86758. * @param left defines the viewport left coordinate
  86759. * @param right defines the viewport right coordinate
  86760. * @param bottom defines the viewport bottom coordinate
  86761. * @param top defines the viewport top coordinate
  86762. * @param znear defines the near clip plane
  86763. * @param zfar defines the far clip plane
  86764. * @param result defines the target matrix
  86765. */
  86766. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86767. /**
  86768. * Creates a right-handed orthographic projection matrix
  86769. * @param left defines the viewport left coordinate
  86770. * @param right defines the viewport right coordinate
  86771. * @param bottom defines the viewport bottom coordinate
  86772. * @param top defines the viewport top coordinate
  86773. * @param znear defines the near clip plane
  86774. * @param zfar defines the far clip plane
  86775. * @returns a new matrix as a right-handed orthographic projection matrix
  86776. */
  86777. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86778. /**
  86779. * Stores a right-handed orthographic projection into a given matrix
  86780. * @param left defines the viewport left coordinate
  86781. * @param right defines the viewport right coordinate
  86782. * @param bottom defines the viewport bottom coordinate
  86783. * @param top defines the viewport top coordinate
  86784. * @param znear defines the near clip plane
  86785. * @param zfar defines the far clip plane
  86786. * @param result defines the target matrix
  86787. */
  86788. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86789. /**
  86790. * Creates a left-handed perspective projection matrix
  86791. * @param width defines the viewport width
  86792. * @param height defines the viewport height
  86793. * @param znear defines the near clip plane
  86794. * @param zfar defines the far clip plane
  86795. * @returns a new matrix as a left-handed perspective projection matrix
  86796. */
  86797. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86798. /**
  86799. * Creates a left-handed perspective projection matrix
  86800. * @param fov defines the horizontal field of view
  86801. * @param aspect defines the aspect ratio
  86802. * @param znear defines the near clip plane
  86803. * @param zfar defines the far clip plane
  86804. * @returns a new matrix as a left-handed perspective projection matrix
  86805. */
  86806. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86807. /**
  86808. * Stores a left-handed perspective projection into a given matrix
  86809. * @param fov defines the horizontal field of view
  86810. * @param aspect defines the aspect ratio
  86811. * @param znear defines the near clip plane
  86812. * @param zfar defines the far clip plane
  86813. * @param result defines the target matrix
  86814. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86815. */
  86816. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86817. /**
  86818. * Stores a left-handed perspective projection into a given matrix with depth reversed
  86819. * @param fov defines the horizontal field of view
  86820. * @param aspect defines the aspect ratio
  86821. * @param znear defines the near clip plane
  86822. * @param zfar not used as infinity is used as far clip
  86823. * @param result defines the target matrix
  86824. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86825. */
  86826. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86827. /**
  86828. * Creates a right-handed perspective projection matrix
  86829. * @param fov defines the horizontal field of view
  86830. * @param aspect defines the aspect ratio
  86831. * @param znear defines the near clip plane
  86832. * @param zfar defines the far clip plane
  86833. * @returns a new matrix as a right-handed perspective projection matrix
  86834. */
  86835. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86836. /**
  86837. * Stores a right-handed perspective projection into a given matrix
  86838. * @param fov defines the horizontal field of view
  86839. * @param aspect defines the aspect ratio
  86840. * @param znear defines the near clip plane
  86841. * @param zfar defines the far clip plane
  86842. * @param result defines the target matrix
  86843. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86844. */
  86845. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86846. /**
  86847. * Stores a right-handed perspective projection into a given matrix
  86848. * @param fov defines the horizontal field of view
  86849. * @param aspect defines the aspect ratio
  86850. * @param znear defines the near clip plane
  86851. * @param zfar not used as infinity is used as far clip
  86852. * @param result defines the target matrix
  86853. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86854. */
  86855. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86856. /**
  86857. * Stores a perspective projection for WebVR info a given matrix
  86858. * @param fov defines the field of view
  86859. * @param znear defines the near clip plane
  86860. * @param zfar defines the far clip plane
  86861. * @param result defines the target matrix
  86862. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  86863. */
  86864. static PerspectiveFovWebVRToRef(fov: {
  86865. upDegrees: number;
  86866. downDegrees: number;
  86867. leftDegrees: number;
  86868. rightDegrees: number;
  86869. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  86870. /**
  86871. * Computes a complete transformation matrix
  86872. * @param viewport defines the viewport to use
  86873. * @param world defines the world matrix
  86874. * @param view defines the view matrix
  86875. * @param projection defines the projection matrix
  86876. * @param zmin defines the near clip plane
  86877. * @param zmax defines the far clip plane
  86878. * @returns the transformation matrix
  86879. */
  86880. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  86881. /**
  86882. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  86883. * @param matrix defines the matrix to use
  86884. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  86885. */
  86886. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86887. /**
  86888. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  86889. * @param matrix defines the matrix to use
  86890. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  86891. */
  86892. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86893. /**
  86894. * Compute the transpose of a given matrix
  86895. * @param matrix defines the matrix to transpose
  86896. * @returns the new matrix
  86897. */
  86898. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  86899. /**
  86900. * Compute the transpose of a matrix and store it in a target matrix
  86901. * @param matrix defines the matrix to transpose
  86902. * @param result defines the target matrix
  86903. */
  86904. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  86905. /**
  86906. * Computes a reflection matrix from a plane
  86907. * @param plane defines the reflection plane
  86908. * @returns a new matrix
  86909. */
  86910. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  86911. /**
  86912. * Computes a reflection matrix from a plane
  86913. * @param plane defines the reflection plane
  86914. * @param result defines the target matrix
  86915. */
  86916. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  86917. /**
  86918. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  86919. * @param xaxis defines the value of the 1st axis
  86920. * @param yaxis defines the value of the 2nd axis
  86921. * @param zaxis defines the value of the 3rd axis
  86922. * @param result defines the target matrix
  86923. */
  86924. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  86925. /**
  86926. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  86927. * @param quat defines the quaternion to use
  86928. * @param result defines the target matrix
  86929. */
  86930. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  86931. }
  86932. /**
  86933. * @hidden
  86934. */
  86935. export class TmpVectors {
  86936. static Vector2: Vector2[];
  86937. static Vector3: Vector3[];
  86938. static Vector4: Vector4[];
  86939. static Quaternion: Quaternion[];
  86940. static Matrix: Matrix[];
  86941. }
  86942. }
  86943. declare module BABYLON {
  86944. /**
  86945. * Defines potential orientation for back face culling
  86946. */
  86947. export enum Orientation {
  86948. /**
  86949. * Clockwise
  86950. */
  86951. CW = 0,
  86952. /** Counter clockwise */
  86953. CCW = 1
  86954. }
  86955. /** Class used to represent a Bezier curve */
  86956. export class BezierCurve {
  86957. /**
  86958. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  86959. * @param t defines the time
  86960. * @param x1 defines the left coordinate on X axis
  86961. * @param y1 defines the left coordinate on Y axis
  86962. * @param x2 defines the right coordinate on X axis
  86963. * @param y2 defines the right coordinate on Y axis
  86964. * @returns the interpolated value
  86965. */
  86966. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  86967. }
  86968. /**
  86969. * Defines angle representation
  86970. */
  86971. export class Angle {
  86972. private _radians;
  86973. /**
  86974. * Creates an Angle object of "radians" radians (float).
  86975. * @param radians the angle in radians
  86976. */
  86977. constructor(radians: number);
  86978. /**
  86979. * Get value in degrees
  86980. * @returns the Angle value in degrees (float)
  86981. */
  86982. degrees(): number;
  86983. /**
  86984. * Get value in radians
  86985. * @returns the Angle value in radians (float)
  86986. */
  86987. radians(): number;
  86988. /**
  86989. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  86990. * @param a defines first point as the origin
  86991. * @param b defines point
  86992. * @returns a new Angle
  86993. */
  86994. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  86995. /**
  86996. * Gets a new Angle object from the given float in radians
  86997. * @param radians defines the angle value in radians
  86998. * @returns a new Angle
  86999. */
  87000. static FromRadians(radians: number): Angle;
  87001. /**
  87002. * Gets a new Angle object from the given float in degrees
  87003. * @param degrees defines the angle value in degrees
  87004. * @returns a new Angle
  87005. */
  87006. static FromDegrees(degrees: number): Angle;
  87007. }
  87008. /**
  87009. * This represents an arc in a 2d space.
  87010. */
  87011. export class Arc2 {
  87012. /** Defines the start point of the arc */
  87013. startPoint: Vector2;
  87014. /** Defines the mid point of the arc */
  87015. midPoint: Vector2;
  87016. /** Defines the end point of the arc */
  87017. endPoint: Vector2;
  87018. /**
  87019. * Defines the center point of the arc.
  87020. */
  87021. centerPoint: Vector2;
  87022. /**
  87023. * Defines the radius of the arc.
  87024. */
  87025. radius: number;
  87026. /**
  87027. * Defines the angle of the arc (from mid point to end point).
  87028. */
  87029. angle: Angle;
  87030. /**
  87031. * Defines the start angle of the arc (from start point to middle point).
  87032. */
  87033. startAngle: Angle;
  87034. /**
  87035. * Defines the orientation of the arc (clock wise/counter clock wise).
  87036. */
  87037. orientation: Orientation;
  87038. /**
  87039. * Creates an Arc object from the three given points : start, middle and end.
  87040. * @param startPoint Defines the start point of the arc
  87041. * @param midPoint Defines the midlle point of the arc
  87042. * @param endPoint Defines the end point of the arc
  87043. */
  87044. constructor(
  87045. /** Defines the start point of the arc */
  87046. startPoint: Vector2,
  87047. /** Defines the mid point of the arc */
  87048. midPoint: Vector2,
  87049. /** Defines the end point of the arc */
  87050. endPoint: Vector2);
  87051. }
  87052. /**
  87053. * Represents a 2D path made up of multiple 2D points
  87054. */
  87055. export class Path2 {
  87056. private _points;
  87057. private _length;
  87058. /**
  87059. * If the path start and end point are the same
  87060. */
  87061. closed: boolean;
  87062. /**
  87063. * Creates a Path2 object from the starting 2D coordinates x and y.
  87064. * @param x the starting points x value
  87065. * @param y the starting points y value
  87066. */
  87067. constructor(x: number, y: number);
  87068. /**
  87069. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  87070. * @param x the added points x value
  87071. * @param y the added points y value
  87072. * @returns the updated Path2.
  87073. */
  87074. addLineTo(x: number, y: number): Path2;
  87075. /**
  87076. * 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.
  87077. * @param midX middle point x value
  87078. * @param midY middle point y value
  87079. * @param endX end point x value
  87080. * @param endY end point y value
  87081. * @param numberOfSegments (default: 36)
  87082. * @returns the updated Path2.
  87083. */
  87084. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  87085. /**
  87086. * Closes the Path2.
  87087. * @returns the Path2.
  87088. */
  87089. close(): Path2;
  87090. /**
  87091. * Gets the sum of the distance between each sequential point in the path
  87092. * @returns the Path2 total length (float).
  87093. */
  87094. length(): number;
  87095. /**
  87096. * Gets the points which construct the path
  87097. * @returns the Path2 internal array of points.
  87098. */
  87099. getPoints(): Vector2[];
  87100. /**
  87101. * Retreives the point at the distance aways from the starting point
  87102. * @param normalizedLengthPosition the length along the path to retreive the point from
  87103. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  87104. */
  87105. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  87106. /**
  87107. * Creates a new path starting from an x and y position
  87108. * @param x starting x value
  87109. * @param y starting y value
  87110. * @returns a new Path2 starting at the coordinates (x, y).
  87111. */
  87112. static StartingAt(x: number, y: number): Path2;
  87113. }
  87114. /**
  87115. * Represents a 3D path made up of multiple 3D points
  87116. */
  87117. export class Path3D {
  87118. /**
  87119. * an array of Vector3, the curve axis of the Path3D
  87120. */
  87121. path: Vector3[];
  87122. private _curve;
  87123. private _distances;
  87124. private _tangents;
  87125. private _normals;
  87126. private _binormals;
  87127. private _raw;
  87128. private _alignTangentsWithPath;
  87129. private readonly _pointAtData;
  87130. /**
  87131. * new Path3D(path, normal, raw)
  87132. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  87133. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  87134. * @param path an array of Vector3, the curve axis of the Path3D
  87135. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  87136. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  87137. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  87138. */
  87139. constructor(
  87140. /**
  87141. * an array of Vector3, the curve axis of the Path3D
  87142. */
  87143. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  87144. /**
  87145. * Returns the Path3D array of successive Vector3 designing its curve.
  87146. * @returns the Path3D array of successive Vector3 designing its curve.
  87147. */
  87148. getCurve(): Vector3[];
  87149. /**
  87150. * Returns the Path3D array of successive Vector3 designing its curve.
  87151. * @returns the Path3D array of successive Vector3 designing its curve.
  87152. */
  87153. getPoints(): Vector3[];
  87154. /**
  87155. * @returns the computed length (float) of the path.
  87156. */
  87157. length(): number;
  87158. /**
  87159. * Returns an array populated with tangent vectors on each Path3D curve point.
  87160. * @returns an array populated with tangent vectors on each Path3D curve point.
  87161. */
  87162. getTangents(): Vector3[];
  87163. /**
  87164. * Returns an array populated with normal vectors on each Path3D curve point.
  87165. * @returns an array populated with normal vectors on each Path3D curve point.
  87166. */
  87167. getNormals(): Vector3[];
  87168. /**
  87169. * Returns an array populated with binormal vectors on each Path3D curve point.
  87170. * @returns an array populated with binormal vectors on each Path3D curve point.
  87171. */
  87172. getBinormals(): Vector3[];
  87173. /**
  87174. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  87175. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  87176. */
  87177. getDistances(): number[];
  87178. /**
  87179. * Returns an interpolated point along this path
  87180. * @param position the position of the point along this path, from 0.0 to 1.0
  87181. * @returns a new Vector3 as the point
  87182. */
  87183. getPointAt(position: number): Vector3;
  87184. /**
  87185. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  87186. * @param position the position of the point along this path, from 0.0 to 1.0
  87187. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  87188. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  87189. */
  87190. getTangentAt(position: number, interpolated?: boolean): Vector3;
  87191. /**
  87192. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  87193. * @param position the position of the point along this path, from 0.0 to 1.0
  87194. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  87195. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  87196. */
  87197. getNormalAt(position: number, interpolated?: boolean): Vector3;
  87198. /**
  87199. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  87200. * @param position the position of the point along this path, from 0.0 to 1.0
  87201. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  87202. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  87203. */
  87204. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  87205. /**
  87206. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  87207. * @param position the position of the point along this path, from 0.0 to 1.0
  87208. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  87209. */
  87210. getDistanceAt(position: number): number;
  87211. /**
  87212. * Returns the array index of the previous point of an interpolated point along this path
  87213. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  87214. * @returns the array index
  87215. */
  87216. getPreviousPointIndexAt(position: number): number;
  87217. /**
  87218. * 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)
  87219. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  87220. * @returns the sub position
  87221. */
  87222. getSubPositionAt(position: number): number;
  87223. /**
  87224. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  87225. * @param target the vector of which to get the closest position to
  87226. * @returns the position of the closest virtual point on this path to the target vector
  87227. */
  87228. getClosestPositionTo(target: Vector3): number;
  87229. /**
  87230. * Returns a sub path (slice) of this path
  87231. * @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
  87232. * @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
  87233. * @returns a sub path (slice) of this path
  87234. */
  87235. slice(start?: number, end?: number): Path3D;
  87236. /**
  87237. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  87238. * @param path path which all values are copied into the curves points
  87239. * @param firstNormal which should be projected onto the curve
  87240. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  87241. * @returns the same object updated.
  87242. */
  87243. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  87244. private _compute;
  87245. private _getFirstNonNullVector;
  87246. private _getLastNonNullVector;
  87247. private _normalVector;
  87248. /**
  87249. * Updates the point at data for an interpolated point along this curve
  87250. * @param position the position of the point along this curve, from 0.0 to 1.0
  87251. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  87252. * @returns the (updated) point at data
  87253. */
  87254. private _updatePointAtData;
  87255. /**
  87256. * Updates the point at data from the specified parameters
  87257. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  87258. * @param point the interpolated point
  87259. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  87260. */
  87261. private _setPointAtData;
  87262. /**
  87263. * Updates the point at interpolation matrix for the tangents, normals and binormals
  87264. */
  87265. private _updateInterpolationMatrix;
  87266. }
  87267. /**
  87268. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87269. * A Curve3 is designed from a series of successive Vector3.
  87270. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  87271. */
  87272. export class Curve3 {
  87273. private _points;
  87274. private _length;
  87275. /**
  87276. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  87277. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  87278. * @param v1 (Vector3) the control point
  87279. * @param v2 (Vector3) the end point of the Quadratic Bezier
  87280. * @param nbPoints (integer) the wanted number of points in the curve
  87281. * @returns the created Curve3
  87282. */
  87283. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87284. /**
  87285. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  87286. * @param v0 (Vector3) the origin point of the Cubic Bezier
  87287. * @param v1 (Vector3) the first control point
  87288. * @param v2 (Vector3) the second control point
  87289. * @param v3 (Vector3) the end point of the Cubic Bezier
  87290. * @param nbPoints (integer) the wanted number of points in the curve
  87291. * @returns the created Curve3
  87292. */
  87293. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87294. /**
  87295. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  87296. * @param p1 (Vector3) the origin point of the Hermite Spline
  87297. * @param t1 (Vector3) the tangent vector at the origin point
  87298. * @param p2 (Vector3) the end point of the Hermite Spline
  87299. * @param t2 (Vector3) the tangent vector at the end point
  87300. * @param nbPoints (integer) the wanted number of points in the curve
  87301. * @returns the created Curve3
  87302. */
  87303. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87304. /**
  87305. * Returns a Curve3 object along a CatmullRom Spline curve :
  87306. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  87307. * @param nbPoints (integer) the wanted number of points between each curve control points
  87308. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  87309. * @returns the created Curve3
  87310. */
  87311. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  87312. /**
  87313. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87314. * A Curve3 is designed from a series of successive Vector3.
  87315. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  87316. * @param points points which make up the curve
  87317. */
  87318. constructor(points: Vector3[]);
  87319. /**
  87320. * @returns the Curve3 stored array of successive Vector3
  87321. */
  87322. getPoints(): Vector3[];
  87323. /**
  87324. * @returns the computed length (float) of the curve.
  87325. */
  87326. length(): number;
  87327. /**
  87328. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  87329. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  87330. * curveA and curveB keep unchanged.
  87331. * @param curve the curve to continue from this curve
  87332. * @returns the newly constructed curve
  87333. */
  87334. continue(curve: DeepImmutable<Curve3>): Curve3;
  87335. private _computeLength;
  87336. }
  87337. }
  87338. declare module BABYLON {
  87339. /**
  87340. * This represents the main contract an easing function should follow.
  87341. * Easing functions are used throughout the animation system.
  87342. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87343. */
  87344. export interface IEasingFunction {
  87345. /**
  87346. * Given an input gradient between 0 and 1, this returns the corrseponding value
  87347. * of the easing function.
  87348. * The link below provides some of the most common examples of easing functions.
  87349. * @see https://easings.net/
  87350. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87351. * @returns the corresponding value on the curve defined by the easing function
  87352. */
  87353. ease(gradient: number): number;
  87354. }
  87355. /**
  87356. * Base class used for every default easing function.
  87357. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87358. */
  87359. export class EasingFunction implements IEasingFunction {
  87360. /**
  87361. * Interpolation follows the mathematical formula associated with the easing function.
  87362. */
  87363. static readonly EASINGMODE_EASEIN: number;
  87364. /**
  87365. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  87366. */
  87367. static readonly EASINGMODE_EASEOUT: number;
  87368. /**
  87369. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  87370. */
  87371. static readonly EASINGMODE_EASEINOUT: number;
  87372. private _easingMode;
  87373. /**
  87374. * Sets the easing mode of the current function.
  87375. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  87376. */
  87377. setEasingMode(easingMode: number): void;
  87378. /**
  87379. * Gets the current easing mode.
  87380. * @returns the easing mode
  87381. */
  87382. getEasingMode(): number;
  87383. /**
  87384. * @hidden
  87385. */
  87386. easeInCore(gradient: number): number;
  87387. /**
  87388. * Given an input gradient between 0 and 1, this returns the corresponding value
  87389. * of the easing function.
  87390. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87391. * @returns the corresponding value on the curve defined by the easing function
  87392. */
  87393. ease(gradient: number): number;
  87394. }
  87395. /**
  87396. * Easing function with a circle shape (see link below).
  87397. * @see https://easings.net/#easeInCirc
  87398. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87399. */
  87400. export class CircleEase extends EasingFunction implements IEasingFunction {
  87401. /** @hidden */
  87402. easeInCore(gradient: number): number;
  87403. }
  87404. /**
  87405. * Easing function with a ease back shape (see link below).
  87406. * @see https://easings.net/#easeInBack
  87407. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87408. */
  87409. export class BackEase extends EasingFunction implements IEasingFunction {
  87410. /** Defines the amplitude of the function */
  87411. amplitude: number;
  87412. /**
  87413. * Instantiates a back ease easing
  87414. * @see https://easings.net/#easeInBack
  87415. * @param amplitude Defines the amplitude of the function
  87416. */
  87417. constructor(
  87418. /** Defines the amplitude of the function */
  87419. amplitude?: number);
  87420. /** @hidden */
  87421. easeInCore(gradient: number): number;
  87422. }
  87423. /**
  87424. * Easing function with a bouncing shape (see link below).
  87425. * @see https://easings.net/#easeInBounce
  87426. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87427. */
  87428. export class BounceEase extends EasingFunction implements IEasingFunction {
  87429. /** Defines the number of bounces */
  87430. bounces: number;
  87431. /** Defines the amplitude of the bounce */
  87432. bounciness: number;
  87433. /**
  87434. * Instantiates a bounce easing
  87435. * @see https://easings.net/#easeInBounce
  87436. * @param bounces Defines the number of bounces
  87437. * @param bounciness Defines the amplitude of the bounce
  87438. */
  87439. constructor(
  87440. /** Defines the number of bounces */
  87441. bounces?: number,
  87442. /** Defines the amplitude of the bounce */
  87443. bounciness?: number);
  87444. /** @hidden */
  87445. easeInCore(gradient: number): number;
  87446. }
  87447. /**
  87448. * Easing function with a power of 3 shape (see link below).
  87449. * @see https://easings.net/#easeInCubic
  87450. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87451. */
  87452. export class CubicEase extends EasingFunction implements IEasingFunction {
  87453. /** @hidden */
  87454. easeInCore(gradient: number): number;
  87455. }
  87456. /**
  87457. * Easing function with an elastic shape (see link below).
  87458. * @see https://easings.net/#easeInElastic
  87459. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87460. */
  87461. export class ElasticEase extends EasingFunction implements IEasingFunction {
  87462. /** Defines the number of oscillations*/
  87463. oscillations: number;
  87464. /** Defines the amplitude of the oscillations*/
  87465. springiness: number;
  87466. /**
  87467. * Instantiates an elastic easing function
  87468. * @see https://easings.net/#easeInElastic
  87469. * @param oscillations Defines the number of oscillations
  87470. * @param springiness Defines the amplitude of the oscillations
  87471. */
  87472. constructor(
  87473. /** Defines the number of oscillations*/
  87474. oscillations?: number,
  87475. /** Defines the amplitude of the oscillations*/
  87476. springiness?: number);
  87477. /** @hidden */
  87478. easeInCore(gradient: number): number;
  87479. }
  87480. /**
  87481. * Easing function with an exponential shape (see link below).
  87482. * @see https://easings.net/#easeInExpo
  87483. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87484. */
  87485. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  87486. /** Defines the exponent of the function */
  87487. exponent: number;
  87488. /**
  87489. * Instantiates an exponential easing function
  87490. * @see https://easings.net/#easeInExpo
  87491. * @param exponent Defines the exponent of the function
  87492. */
  87493. constructor(
  87494. /** Defines the exponent of the function */
  87495. exponent?: number);
  87496. /** @hidden */
  87497. easeInCore(gradient: number): number;
  87498. }
  87499. /**
  87500. * Easing function with a power shape (see link below).
  87501. * @see https://easings.net/#easeInQuad
  87502. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87503. */
  87504. export class PowerEase extends EasingFunction implements IEasingFunction {
  87505. /** Defines the power of the function */
  87506. power: number;
  87507. /**
  87508. * Instantiates an power base easing function
  87509. * @see https://easings.net/#easeInQuad
  87510. * @param power Defines the power of the function
  87511. */
  87512. constructor(
  87513. /** Defines the power of the function */
  87514. power?: number);
  87515. /** @hidden */
  87516. easeInCore(gradient: number): number;
  87517. }
  87518. /**
  87519. * Easing function with a power of 2 shape (see link below).
  87520. * @see https://easings.net/#easeInQuad
  87521. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87522. */
  87523. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  87524. /** @hidden */
  87525. easeInCore(gradient: number): number;
  87526. }
  87527. /**
  87528. * Easing function with a power of 4 shape (see link below).
  87529. * @see https://easings.net/#easeInQuart
  87530. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87531. */
  87532. export class QuarticEase extends EasingFunction implements IEasingFunction {
  87533. /** @hidden */
  87534. easeInCore(gradient: number): number;
  87535. }
  87536. /**
  87537. * Easing function with a power of 5 shape (see link below).
  87538. * @see https://easings.net/#easeInQuint
  87539. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87540. */
  87541. export class QuinticEase extends EasingFunction implements IEasingFunction {
  87542. /** @hidden */
  87543. easeInCore(gradient: number): number;
  87544. }
  87545. /**
  87546. * Easing function with a sin shape (see link below).
  87547. * @see https://easings.net/#easeInSine
  87548. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87549. */
  87550. export class SineEase extends EasingFunction implements IEasingFunction {
  87551. /** @hidden */
  87552. easeInCore(gradient: number): number;
  87553. }
  87554. /**
  87555. * Easing function with a bezier shape (see link below).
  87556. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87557. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87558. */
  87559. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  87560. /** Defines the x component of the start tangent in the bezier curve */
  87561. x1: number;
  87562. /** Defines the y component of the start tangent in the bezier curve */
  87563. y1: number;
  87564. /** Defines the x component of the end tangent in the bezier curve */
  87565. x2: number;
  87566. /** Defines the y component of the end tangent in the bezier curve */
  87567. y2: number;
  87568. /**
  87569. * Instantiates a bezier function
  87570. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87571. * @param x1 Defines the x component of the start tangent in the bezier curve
  87572. * @param y1 Defines the y component of the start tangent in the bezier curve
  87573. * @param x2 Defines the x component of the end tangent in the bezier curve
  87574. * @param y2 Defines the y component of the end tangent in the bezier curve
  87575. */
  87576. constructor(
  87577. /** Defines the x component of the start tangent in the bezier curve */
  87578. x1?: number,
  87579. /** Defines the y component of the start tangent in the bezier curve */
  87580. y1?: number,
  87581. /** Defines the x component of the end tangent in the bezier curve */
  87582. x2?: number,
  87583. /** Defines the y component of the end tangent in the bezier curve */
  87584. y2?: number);
  87585. /** @hidden */
  87586. easeInCore(gradient: number): number;
  87587. }
  87588. }
  87589. declare module BABYLON {
  87590. /**
  87591. * Class used to hold a RBG color
  87592. */
  87593. export class Color3 {
  87594. /**
  87595. * Defines the red component (between 0 and 1, default is 0)
  87596. */
  87597. r: number;
  87598. /**
  87599. * Defines the green component (between 0 and 1, default is 0)
  87600. */
  87601. g: number;
  87602. /**
  87603. * Defines the blue component (between 0 and 1, default is 0)
  87604. */
  87605. b: number;
  87606. /**
  87607. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  87608. * @param r defines the red component (between 0 and 1, default is 0)
  87609. * @param g defines the green component (between 0 and 1, default is 0)
  87610. * @param b defines the blue component (between 0 and 1, default is 0)
  87611. */
  87612. constructor(
  87613. /**
  87614. * Defines the red component (between 0 and 1, default is 0)
  87615. */
  87616. r?: number,
  87617. /**
  87618. * Defines the green component (between 0 and 1, default is 0)
  87619. */
  87620. g?: number,
  87621. /**
  87622. * Defines the blue component (between 0 and 1, default is 0)
  87623. */
  87624. b?: number);
  87625. /**
  87626. * Creates a string with the Color3 current values
  87627. * @returns the string representation of the Color3 object
  87628. */
  87629. toString(): string;
  87630. /**
  87631. * Returns the string "Color3"
  87632. * @returns "Color3"
  87633. */
  87634. getClassName(): string;
  87635. /**
  87636. * Compute the Color3 hash code
  87637. * @returns an unique number that can be used to hash Color3 objects
  87638. */
  87639. getHashCode(): number;
  87640. /**
  87641. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  87642. * @param array defines the array where to store the r,g,b components
  87643. * @param index defines an optional index in the target array to define where to start storing values
  87644. * @returns the current Color3 object
  87645. */
  87646. toArray(array: FloatArray, index?: number): Color3;
  87647. /**
  87648. * Update the current color with values stored in an array from the starting index of the given array
  87649. * @param array defines the source array
  87650. * @param offset defines an offset in the source array
  87651. * @returns the current Color3 object
  87652. */
  87653. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87654. /**
  87655. * Returns a new Color4 object from the current Color3 and the given alpha
  87656. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  87657. * @returns a new Color4 object
  87658. */
  87659. toColor4(alpha?: number): Color4;
  87660. /**
  87661. * Returns a new array populated with 3 numeric elements : red, green and blue values
  87662. * @returns the new array
  87663. */
  87664. asArray(): number[];
  87665. /**
  87666. * Returns the luminance value
  87667. * @returns a float value
  87668. */
  87669. toLuminance(): number;
  87670. /**
  87671. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  87672. * @param otherColor defines the second operand
  87673. * @returns the new Color3 object
  87674. */
  87675. multiply(otherColor: DeepImmutable<Color3>): Color3;
  87676. /**
  87677. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  87678. * @param otherColor defines the second operand
  87679. * @param result defines the Color3 object where to store the result
  87680. * @returns the current Color3
  87681. */
  87682. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87683. /**
  87684. * Determines equality between Color3 objects
  87685. * @param otherColor defines the second operand
  87686. * @returns true if the rgb values are equal to the given ones
  87687. */
  87688. equals(otherColor: DeepImmutable<Color3>): boolean;
  87689. /**
  87690. * Determines equality between the current Color3 object and a set of r,b,g values
  87691. * @param r defines the red component to check
  87692. * @param g defines the green component to check
  87693. * @param b defines the blue component to check
  87694. * @returns true if the rgb values are equal to the given ones
  87695. */
  87696. equalsFloats(r: number, g: number, b: number): boolean;
  87697. /**
  87698. * Multiplies in place each rgb value by scale
  87699. * @param scale defines the scaling factor
  87700. * @returns the updated Color3
  87701. */
  87702. scale(scale: number): Color3;
  87703. /**
  87704. * Multiplies the rgb values by scale and stores the result into "result"
  87705. * @param scale defines the scaling factor
  87706. * @param result defines the Color3 object where to store the result
  87707. * @returns the unmodified current Color3
  87708. */
  87709. scaleToRef(scale: number, result: Color3): Color3;
  87710. /**
  87711. * Scale the current Color3 values by a factor and add the result to a given Color3
  87712. * @param scale defines the scale factor
  87713. * @param result defines color to store the result into
  87714. * @returns the unmodified current Color3
  87715. */
  87716. scaleAndAddToRef(scale: number, result: Color3): Color3;
  87717. /**
  87718. * Clamps the rgb values by the min and max values and stores the result into "result"
  87719. * @param min defines minimum clamping value (default is 0)
  87720. * @param max defines maximum clamping value (default is 1)
  87721. * @param result defines color to store the result into
  87722. * @returns the original Color3
  87723. */
  87724. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  87725. /**
  87726. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  87727. * @param otherColor defines the second operand
  87728. * @returns the new Color3
  87729. */
  87730. add(otherColor: DeepImmutable<Color3>): Color3;
  87731. /**
  87732. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  87733. * @param otherColor defines the second operand
  87734. * @param result defines Color3 object to store the result into
  87735. * @returns the unmodified current Color3
  87736. */
  87737. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87738. /**
  87739. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  87740. * @param otherColor defines the second operand
  87741. * @returns the new Color3
  87742. */
  87743. subtract(otherColor: DeepImmutable<Color3>): Color3;
  87744. /**
  87745. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  87746. * @param otherColor defines the second operand
  87747. * @param result defines Color3 object to store the result into
  87748. * @returns the unmodified current Color3
  87749. */
  87750. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87751. /**
  87752. * Copy the current object
  87753. * @returns a new Color3 copied the current one
  87754. */
  87755. clone(): Color3;
  87756. /**
  87757. * Copies the rgb values from the source in the current Color3
  87758. * @param source defines the source Color3 object
  87759. * @returns the updated Color3 object
  87760. */
  87761. copyFrom(source: DeepImmutable<Color3>): Color3;
  87762. /**
  87763. * Updates the Color3 rgb values from the given floats
  87764. * @param r defines the red component to read from
  87765. * @param g defines the green component to read from
  87766. * @param b defines the blue component to read from
  87767. * @returns the current Color3 object
  87768. */
  87769. copyFromFloats(r: number, g: number, b: number): Color3;
  87770. /**
  87771. * Updates the Color3 rgb values from the given floats
  87772. * @param r defines the red component to read from
  87773. * @param g defines the green component to read from
  87774. * @param b defines the blue component to read from
  87775. * @returns the current Color3 object
  87776. */
  87777. set(r: number, g: number, b: number): Color3;
  87778. /**
  87779. * Compute the Color3 hexadecimal code as a string
  87780. * @returns a string containing the hexadecimal representation of the Color3 object
  87781. */
  87782. toHexString(): string;
  87783. /**
  87784. * Computes a new Color3 converted from the current one to linear space
  87785. * @returns a new Color3 object
  87786. */
  87787. toLinearSpace(): Color3;
  87788. /**
  87789. * Converts current color in rgb space to HSV values
  87790. * @returns a new color3 representing the HSV values
  87791. */
  87792. toHSV(): Color3;
  87793. /**
  87794. * Converts current color in rgb space to HSV values
  87795. * @param result defines the Color3 where to store the HSV values
  87796. */
  87797. toHSVToRef(result: Color3): void;
  87798. /**
  87799. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  87800. * @param convertedColor defines the Color3 object where to store the linear space version
  87801. * @returns the unmodified Color3
  87802. */
  87803. toLinearSpaceToRef(convertedColor: Color3): Color3;
  87804. /**
  87805. * Computes a new Color3 converted from the current one to gamma space
  87806. * @returns a new Color3 object
  87807. */
  87808. toGammaSpace(): Color3;
  87809. /**
  87810. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  87811. * @param convertedColor defines the Color3 object where to store the gamma space version
  87812. * @returns the unmodified Color3
  87813. */
  87814. toGammaSpaceToRef(convertedColor: Color3): Color3;
  87815. private static _BlackReadOnly;
  87816. /**
  87817. * Convert Hue, saturation and value to a Color3 (RGB)
  87818. * @param hue defines the hue
  87819. * @param saturation defines the saturation
  87820. * @param value defines the value
  87821. * @param result defines the Color3 where to store the RGB values
  87822. */
  87823. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  87824. /**
  87825. * Creates a new Color3 from the string containing valid hexadecimal values
  87826. * @param hex defines a string containing valid hexadecimal values
  87827. * @returns a new Color3 object
  87828. */
  87829. static FromHexString(hex: string): Color3;
  87830. /**
  87831. * Creates a new Color3 from the starting index of the given array
  87832. * @param array defines the source array
  87833. * @param offset defines an offset in the source array
  87834. * @returns a new Color3 object
  87835. */
  87836. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87837. /**
  87838. * Creates a new Color3 from the starting index element of the given array
  87839. * @param array defines the source array to read from
  87840. * @param offset defines the offset in the source array
  87841. * @param result defines the target Color3 object
  87842. */
  87843. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  87844. /**
  87845. * Creates a new Color3 from integer values (< 256)
  87846. * @param r defines the red component to read from (value between 0 and 255)
  87847. * @param g defines the green component to read from (value between 0 and 255)
  87848. * @param b defines the blue component to read from (value between 0 and 255)
  87849. * @returns a new Color3 object
  87850. */
  87851. static FromInts(r: number, g: number, b: number): Color3;
  87852. /**
  87853. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87854. * @param start defines the start Color3 value
  87855. * @param end defines the end Color3 value
  87856. * @param amount defines the gradient value between start and end
  87857. * @returns a new Color3 object
  87858. */
  87859. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  87860. /**
  87861. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87862. * @param left defines the start value
  87863. * @param right defines the end value
  87864. * @param amount defines the gradient factor
  87865. * @param result defines the Color3 object where to store the result
  87866. */
  87867. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  87868. /**
  87869. * Returns a Color3 value containing a red color
  87870. * @returns a new Color3 object
  87871. */
  87872. static Red(): Color3;
  87873. /**
  87874. * Returns a Color3 value containing a green color
  87875. * @returns a new Color3 object
  87876. */
  87877. static Green(): Color3;
  87878. /**
  87879. * Returns a Color3 value containing a blue color
  87880. * @returns a new Color3 object
  87881. */
  87882. static Blue(): Color3;
  87883. /**
  87884. * Returns a Color3 value containing a black color
  87885. * @returns a new Color3 object
  87886. */
  87887. static Black(): Color3;
  87888. /**
  87889. * Gets a Color3 value containing a black color that must not be updated
  87890. */
  87891. static get BlackReadOnly(): DeepImmutable<Color3>;
  87892. /**
  87893. * Returns a Color3 value containing a white color
  87894. * @returns a new Color3 object
  87895. */
  87896. static White(): Color3;
  87897. /**
  87898. * Returns a Color3 value containing a purple color
  87899. * @returns a new Color3 object
  87900. */
  87901. static Purple(): Color3;
  87902. /**
  87903. * Returns a Color3 value containing a magenta color
  87904. * @returns a new Color3 object
  87905. */
  87906. static Magenta(): Color3;
  87907. /**
  87908. * Returns a Color3 value containing a yellow color
  87909. * @returns a new Color3 object
  87910. */
  87911. static Yellow(): Color3;
  87912. /**
  87913. * Returns a Color3 value containing a gray color
  87914. * @returns a new Color3 object
  87915. */
  87916. static Gray(): Color3;
  87917. /**
  87918. * Returns a Color3 value containing a teal color
  87919. * @returns a new Color3 object
  87920. */
  87921. static Teal(): Color3;
  87922. /**
  87923. * Returns a Color3 value containing a random color
  87924. * @returns a new Color3 object
  87925. */
  87926. static Random(): Color3;
  87927. }
  87928. /**
  87929. * Class used to hold a RBGA color
  87930. */
  87931. export class Color4 {
  87932. /**
  87933. * Defines the red component (between 0 and 1, default is 0)
  87934. */
  87935. r: number;
  87936. /**
  87937. * Defines the green component (between 0 and 1, default is 0)
  87938. */
  87939. g: number;
  87940. /**
  87941. * Defines the blue component (between 0 and 1, default is 0)
  87942. */
  87943. b: number;
  87944. /**
  87945. * Defines the alpha component (between 0 and 1, default is 1)
  87946. */
  87947. a: number;
  87948. /**
  87949. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  87950. * @param r defines the red component (between 0 and 1, default is 0)
  87951. * @param g defines the green component (between 0 and 1, default is 0)
  87952. * @param b defines the blue component (between 0 and 1, default is 0)
  87953. * @param a defines the alpha component (between 0 and 1, default is 1)
  87954. */
  87955. constructor(
  87956. /**
  87957. * Defines the red component (between 0 and 1, default is 0)
  87958. */
  87959. r?: number,
  87960. /**
  87961. * Defines the green component (between 0 and 1, default is 0)
  87962. */
  87963. g?: number,
  87964. /**
  87965. * Defines the blue component (between 0 and 1, default is 0)
  87966. */
  87967. b?: number,
  87968. /**
  87969. * Defines the alpha component (between 0 and 1, default is 1)
  87970. */
  87971. a?: number);
  87972. /**
  87973. * Adds in place the given Color4 values to the current Color4 object
  87974. * @param right defines the second operand
  87975. * @returns the current updated Color4 object
  87976. */
  87977. addInPlace(right: DeepImmutable<Color4>): Color4;
  87978. /**
  87979. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  87980. * @returns the new array
  87981. */
  87982. asArray(): number[];
  87983. /**
  87984. * Stores from the starting index in the given array the Color4 successive values
  87985. * @param array defines the array where to store the r,g,b components
  87986. * @param index defines an optional index in the target array to define where to start storing values
  87987. * @returns the current Color4 object
  87988. */
  87989. toArray(array: number[], index?: number): Color4;
  87990. /**
  87991. * Update the current color with values stored in an array from the starting index of the given array
  87992. * @param array defines the source array
  87993. * @param offset defines an offset in the source array
  87994. * @returns the current Color4 object
  87995. */
  87996. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87997. /**
  87998. * Determines equality between Color4 objects
  87999. * @param otherColor defines the second operand
  88000. * @returns true if the rgba values are equal to the given ones
  88001. */
  88002. equals(otherColor: DeepImmutable<Color4>): boolean;
  88003. /**
  88004. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  88005. * @param right defines the second operand
  88006. * @returns a new Color4 object
  88007. */
  88008. add(right: DeepImmutable<Color4>): Color4;
  88009. /**
  88010. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  88011. * @param right defines the second operand
  88012. * @returns a new Color4 object
  88013. */
  88014. subtract(right: DeepImmutable<Color4>): Color4;
  88015. /**
  88016. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  88017. * @param right defines the second operand
  88018. * @param result defines the Color4 object where to store the result
  88019. * @returns the current Color4 object
  88020. */
  88021. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  88022. /**
  88023. * Creates a new Color4 with the current Color4 values multiplied by scale
  88024. * @param scale defines the scaling factor to apply
  88025. * @returns a new Color4 object
  88026. */
  88027. scale(scale: number): Color4;
  88028. /**
  88029. * Multiplies the current Color4 values by scale and stores the result in "result"
  88030. * @param scale defines the scaling factor to apply
  88031. * @param result defines the Color4 object where to store the result
  88032. * @returns the current unmodified Color4
  88033. */
  88034. scaleToRef(scale: number, result: Color4): Color4;
  88035. /**
  88036. * Scale the current Color4 values by a factor and add the result to a given Color4
  88037. * @param scale defines the scale factor
  88038. * @param result defines the Color4 object where to store the result
  88039. * @returns the unmodified current Color4
  88040. */
  88041. scaleAndAddToRef(scale: number, result: Color4): Color4;
  88042. /**
  88043. * Clamps the rgb values by the min and max values and stores the result into "result"
  88044. * @param min defines minimum clamping value (default is 0)
  88045. * @param max defines maximum clamping value (default is 1)
  88046. * @param result defines color to store the result into.
  88047. * @returns the cuurent Color4
  88048. */
  88049. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  88050. /**
  88051. * Multipy an Color4 value by another and return a new Color4 object
  88052. * @param color defines the Color4 value to multiply by
  88053. * @returns a new Color4 object
  88054. */
  88055. multiply(color: Color4): Color4;
  88056. /**
  88057. * Multipy a Color4 value by another and push the result in a reference value
  88058. * @param color defines the Color4 value to multiply by
  88059. * @param result defines the Color4 to fill the result in
  88060. * @returns the result Color4
  88061. */
  88062. multiplyToRef(color: Color4, result: Color4): Color4;
  88063. /**
  88064. * Creates a string with the Color4 current values
  88065. * @returns the string representation of the Color4 object
  88066. */
  88067. toString(): string;
  88068. /**
  88069. * Returns the string "Color4"
  88070. * @returns "Color4"
  88071. */
  88072. getClassName(): string;
  88073. /**
  88074. * Compute the Color4 hash code
  88075. * @returns an unique number that can be used to hash Color4 objects
  88076. */
  88077. getHashCode(): number;
  88078. /**
  88079. * Creates a new Color4 copied from the current one
  88080. * @returns a new Color4 object
  88081. */
  88082. clone(): Color4;
  88083. /**
  88084. * Copies the given Color4 values into the current one
  88085. * @param source defines the source Color4 object
  88086. * @returns the current updated Color4 object
  88087. */
  88088. copyFrom(source: Color4): Color4;
  88089. /**
  88090. * Copies the given float values into the current one
  88091. * @param r defines the red component to read from
  88092. * @param g defines the green component to read from
  88093. * @param b defines the blue component to read from
  88094. * @param a defines the alpha component to read from
  88095. * @returns the current updated Color4 object
  88096. */
  88097. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  88098. /**
  88099. * Copies the given float values into the current one
  88100. * @param r defines the red component to read from
  88101. * @param g defines the green component to read from
  88102. * @param b defines the blue component to read from
  88103. * @param a defines the alpha component to read from
  88104. * @returns the current updated Color4 object
  88105. */
  88106. set(r: number, g: number, b: number, a: number): Color4;
  88107. /**
  88108. * Compute the Color4 hexadecimal code as a string
  88109. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  88110. * @returns a string containing the hexadecimal representation of the Color4 object
  88111. */
  88112. toHexString(returnAsColor3?: boolean): string;
  88113. /**
  88114. * Computes a new Color4 converted from the current one to linear space
  88115. * @returns a new Color4 object
  88116. */
  88117. toLinearSpace(): Color4;
  88118. /**
  88119. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  88120. * @param convertedColor defines the Color4 object where to store the linear space version
  88121. * @returns the unmodified Color4
  88122. */
  88123. toLinearSpaceToRef(convertedColor: Color4): Color4;
  88124. /**
  88125. * Computes a new Color4 converted from the current one to gamma space
  88126. * @returns a new Color4 object
  88127. */
  88128. toGammaSpace(): Color4;
  88129. /**
  88130. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  88131. * @param convertedColor defines the Color4 object where to store the gamma space version
  88132. * @returns the unmodified Color4
  88133. */
  88134. toGammaSpaceToRef(convertedColor: Color4): Color4;
  88135. /**
  88136. * Creates a new Color4 from the string containing valid hexadecimal values
  88137. * @param hex defines a string containing valid hexadecimal values
  88138. * @returns a new Color4 object
  88139. */
  88140. static FromHexString(hex: string): Color4;
  88141. /**
  88142. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  88143. * @param left defines the start value
  88144. * @param right defines the end value
  88145. * @param amount defines the gradient factor
  88146. * @returns a new Color4 object
  88147. */
  88148. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  88149. /**
  88150. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  88151. * @param left defines the start value
  88152. * @param right defines the end value
  88153. * @param amount defines the gradient factor
  88154. * @param result defines the Color4 object where to store data
  88155. */
  88156. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  88157. /**
  88158. * Creates a new Color4 from a Color3 and an alpha value
  88159. * @param color3 defines the source Color3 to read from
  88160. * @param alpha defines the alpha component (1.0 by default)
  88161. * @returns a new Color4 object
  88162. */
  88163. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  88164. /**
  88165. * Creates a new Color4 from the starting index element of the given array
  88166. * @param array defines the source array to read from
  88167. * @param offset defines the offset in the source array
  88168. * @returns a new Color4 object
  88169. */
  88170. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  88171. /**
  88172. * Creates a new Color4 from the starting index element of the given array
  88173. * @param array defines the source array to read from
  88174. * @param offset defines the offset in the source array
  88175. * @param result defines the target Color4 object
  88176. */
  88177. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  88178. /**
  88179. * Creates a new Color3 from integer values (< 256)
  88180. * @param r defines the red component to read from (value between 0 and 255)
  88181. * @param g defines the green component to read from (value between 0 and 255)
  88182. * @param b defines the blue component to read from (value between 0 and 255)
  88183. * @param a defines the alpha component to read from (value between 0 and 255)
  88184. * @returns a new Color3 object
  88185. */
  88186. static FromInts(r: number, g: number, b: number, a: number): Color4;
  88187. /**
  88188. * Check the content of a given array and convert it to an array containing RGBA data
  88189. * If the original array was already containing count * 4 values then it is returned directly
  88190. * @param colors defines the array to check
  88191. * @param count defines the number of RGBA data to expect
  88192. * @returns an array containing count * 4 values (RGBA)
  88193. */
  88194. static CheckColors4(colors: number[], count: number): number[];
  88195. }
  88196. /**
  88197. * @hidden
  88198. */
  88199. export class TmpColors {
  88200. static Color3: Color3[];
  88201. static Color4: Color4[];
  88202. }
  88203. }
  88204. declare module BABYLON {
  88205. /**
  88206. * Defines an interface which represents an animation key frame
  88207. */
  88208. export interface IAnimationKey {
  88209. /**
  88210. * Frame of the key frame
  88211. */
  88212. frame: number;
  88213. /**
  88214. * Value at the specifies key frame
  88215. */
  88216. value: any;
  88217. /**
  88218. * The input tangent for the cubic hermite spline
  88219. */
  88220. inTangent?: any;
  88221. /**
  88222. * The output tangent for the cubic hermite spline
  88223. */
  88224. outTangent?: any;
  88225. /**
  88226. * The animation interpolation type
  88227. */
  88228. interpolation?: AnimationKeyInterpolation;
  88229. }
  88230. /**
  88231. * Enum for the animation key frame interpolation type
  88232. */
  88233. export enum AnimationKeyInterpolation {
  88234. /**
  88235. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  88236. */
  88237. STEP = 1
  88238. }
  88239. }
  88240. declare module BABYLON {
  88241. /**
  88242. * Represents the range of an animation
  88243. */
  88244. export class AnimationRange {
  88245. /**The name of the animation range**/
  88246. name: string;
  88247. /**The starting frame of the animation */
  88248. from: number;
  88249. /**The ending frame of the animation*/
  88250. to: number;
  88251. /**
  88252. * Initializes the range of an animation
  88253. * @param name The name of the animation range
  88254. * @param from The starting frame of the animation
  88255. * @param to The ending frame of the animation
  88256. */
  88257. constructor(
  88258. /**The name of the animation range**/
  88259. name: string,
  88260. /**The starting frame of the animation */
  88261. from: number,
  88262. /**The ending frame of the animation*/
  88263. to: number);
  88264. /**
  88265. * Makes a copy of the animation range
  88266. * @returns A copy of the animation range
  88267. */
  88268. clone(): AnimationRange;
  88269. }
  88270. }
  88271. declare module BABYLON {
  88272. /**
  88273. * Composed of a frame, and an action function
  88274. */
  88275. export class AnimationEvent {
  88276. /** The frame for which the event is triggered **/
  88277. frame: number;
  88278. /** The event to perform when triggered **/
  88279. action: (currentFrame: number) => void;
  88280. /** Specifies if the event should be triggered only once**/
  88281. onlyOnce?: boolean | undefined;
  88282. /**
  88283. * Specifies if the animation event is done
  88284. */
  88285. isDone: boolean;
  88286. /**
  88287. * Initializes the animation event
  88288. * @param frame The frame for which the event is triggered
  88289. * @param action The event to perform when triggered
  88290. * @param onlyOnce Specifies if the event should be triggered only once
  88291. */
  88292. constructor(
  88293. /** The frame for which the event is triggered **/
  88294. frame: number,
  88295. /** The event to perform when triggered **/
  88296. action: (currentFrame: number) => void,
  88297. /** Specifies if the event should be triggered only once**/
  88298. onlyOnce?: boolean | undefined);
  88299. /** @hidden */
  88300. _clone(): AnimationEvent;
  88301. }
  88302. }
  88303. declare module BABYLON {
  88304. /**
  88305. * Interface used to define a behavior
  88306. */
  88307. export interface Behavior<T> {
  88308. /** gets or sets behavior's name */
  88309. name: string;
  88310. /**
  88311. * Function called when the behavior needs to be initialized (after attaching it to a target)
  88312. */
  88313. init(): void;
  88314. /**
  88315. * Called when the behavior is attached to a target
  88316. * @param target defines the target where the behavior is attached to
  88317. */
  88318. attach(target: T): void;
  88319. /**
  88320. * Called when the behavior is detached from its target
  88321. */
  88322. detach(): void;
  88323. }
  88324. /**
  88325. * Interface implemented by classes supporting behaviors
  88326. */
  88327. export interface IBehaviorAware<T> {
  88328. /**
  88329. * Attach a behavior
  88330. * @param behavior defines the behavior to attach
  88331. * @returns the current host
  88332. */
  88333. addBehavior(behavior: Behavior<T>): T;
  88334. /**
  88335. * Remove a behavior from the current object
  88336. * @param behavior defines the behavior to detach
  88337. * @returns the current host
  88338. */
  88339. removeBehavior(behavior: Behavior<T>): T;
  88340. /**
  88341. * Gets a behavior using its name to search
  88342. * @param name defines the name to search
  88343. * @returns the behavior or null if not found
  88344. */
  88345. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  88346. }
  88347. }
  88348. declare module BABYLON {
  88349. /**
  88350. * Class used to store data that will be store in GPU memory
  88351. */
  88352. export class Buffer {
  88353. private _engine;
  88354. private _buffer;
  88355. /** @hidden */
  88356. _data: Nullable<DataArray>;
  88357. private _updatable;
  88358. private _instanced;
  88359. private _divisor;
  88360. private _isAlreadyOwned;
  88361. /**
  88362. * Gets the byte stride.
  88363. */
  88364. readonly byteStride: number;
  88365. /**
  88366. * Constructor
  88367. * @param engine the engine
  88368. * @param data the data to use for this buffer
  88369. * @param updatable whether the data is updatable
  88370. * @param stride the stride (optional)
  88371. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88372. * @param instanced whether the buffer is instanced (optional)
  88373. * @param useBytes set to true if the stride in in bytes (optional)
  88374. * @param divisor sets an optional divisor for instances (1 by default)
  88375. */
  88376. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  88377. /**
  88378. * Create a new VertexBuffer based on the current buffer
  88379. * @param kind defines the vertex buffer kind (position, normal, etc.)
  88380. * @param offset defines offset in the buffer (0 by default)
  88381. * @param size defines the size in floats of attributes (position is 3 for instance)
  88382. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  88383. * @param instanced defines if the vertex buffer contains indexed data
  88384. * @param useBytes defines if the offset and stride are in bytes *
  88385. * @param divisor sets an optional divisor for instances (1 by default)
  88386. * @returns the new vertex buffer
  88387. */
  88388. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  88389. /**
  88390. * Gets a boolean indicating if the Buffer is updatable?
  88391. * @returns true if the buffer is updatable
  88392. */
  88393. isUpdatable(): boolean;
  88394. /**
  88395. * Gets current buffer's data
  88396. * @returns a DataArray or null
  88397. */
  88398. getData(): Nullable<DataArray>;
  88399. /**
  88400. * Gets underlying native buffer
  88401. * @returns underlying native buffer
  88402. */
  88403. getBuffer(): Nullable<DataBuffer>;
  88404. /**
  88405. * Gets the stride in float32 units (i.e. byte stride / 4).
  88406. * May not be an integer if the byte stride is not divisible by 4.
  88407. * @returns the stride in float32 units
  88408. * @deprecated Please use byteStride instead.
  88409. */
  88410. getStrideSize(): number;
  88411. /**
  88412. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88413. * @param data defines the data to store
  88414. */
  88415. create(data?: Nullable<DataArray>): void;
  88416. /** @hidden */
  88417. _rebuild(): void;
  88418. /**
  88419. * Update current buffer data
  88420. * @param data defines the data to store
  88421. */
  88422. update(data: DataArray): void;
  88423. /**
  88424. * Updates the data directly.
  88425. * @param data the new data
  88426. * @param offset the new offset
  88427. * @param vertexCount the vertex count (optional)
  88428. * @param useBytes set to true if the offset is in bytes
  88429. */
  88430. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  88431. /** @hidden */
  88432. _increaseReferences(): void;
  88433. /**
  88434. * Release all resources
  88435. */
  88436. dispose(): void;
  88437. }
  88438. /**
  88439. * Specialized buffer used to store vertex data
  88440. */
  88441. export class VertexBuffer {
  88442. /** @hidden */
  88443. _buffer: Buffer;
  88444. private _kind;
  88445. private _size;
  88446. private _ownsBuffer;
  88447. private _instanced;
  88448. private _instanceDivisor;
  88449. /**
  88450. * The byte type.
  88451. */
  88452. static readonly BYTE: number;
  88453. /**
  88454. * The unsigned byte type.
  88455. */
  88456. static readonly UNSIGNED_BYTE: number;
  88457. /**
  88458. * The short type.
  88459. */
  88460. static readonly SHORT: number;
  88461. /**
  88462. * The unsigned short type.
  88463. */
  88464. static readonly UNSIGNED_SHORT: number;
  88465. /**
  88466. * The integer type.
  88467. */
  88468. static readonly INT: number;
  88469. /**
  88470. * The unsigned integer type.
  88471. */
  88472. static readonly UNSIGNED_INT: number;
  88473. /**
  88474. * The float type.
  88475. */
  88476. static readonly FLOAT: number;
  88477. /**
  88478. * Gets or sets the instance divisor when in instanced mode
  88479. */
  88480. get instanceDivisor(): number;
  88481. set instanceDivisor(value: number);
  88482. /**
  88483. * Gets the byte stride.
  88484. */
  88485. readonly byteStride: number;
  88486. /**
  88487. * Gets the byte offset.
  88488. */
  88489. readonly byteOffset: number;
  88490. /**
  88491. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  88492. */
  88493. readonly normalized: boolean;
  88494. /**
  88495. * Gets the data type of each component in the array.
  88496. */
  88497. readonly type: number;
  88498. /**
  88499. * Constructor
  88500. * @param engine the engine
  88501. * @param data the data to use for this vertex buffer
  88502. * @param kind the vertex buffer kind
  88503. * @param updatable whether the data is updatable
  88504. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88505. * @param stride the stride (optional)
  88506. * @param instanced whether the buffer is instanced (optional)
  88507. * @param offset the offset of the data (optional)
  88508. * @param size the number of components (optional)
  88509. * @param type the type of the component (optional)
  88510. * @param normalized whether the data contains normalized data (optional)
  88511. * @param useBytes set to true if stride and offset are in bytes (optional)
  88512. * @param divisor defines the instance divisor to use (1 by default)
  88513. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  88514. */
  88515. 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, takeBufferOwnership?: boolean);
  88516. /** @hidden */
  88517. _rebuild(): void;
  88518. /**
  88519. * Returns the kind of the VertexBuffer (string)
  88520. * @returns a string
  88521. */
  88522. getKind(): string;
  88523. /**
  88524. * Gets a boolean indicating if the VertexBuffer is updatable?
  88525. * @returns true if the buffer is updatable
  88526. */
  88527. isUpdatable(): boolean;
  88528. /**
  88529. * Gets current buffer's data
  88530. * @returns a DataArray or null
  88531. */
  88532. getData(): Nullable<DataArray>;
  88533. /**
  88534. * Gets underlying native buffer
  88535. * @returns underlying native buffer
  88536. */
  88537. getBuffer(): Nullable<DataBuffer>;
  88538. /**
  88539. * Gets the stride in float32 units (i.e. byte stride / 4).
  88540. * May not be an integer if the byte stride is not divisible by 4.
  88541. * @returns the stride in float32 units
  88542. * @deprecated Please use byteStride instead.
  88543. */
  88544. getStrideSize(): number;
  88545. /**
  88546. * Returns the offset as a multiple of the type byte length.
  88547. * @returns the offset in bytes
  88548. * @deprecated Please use byteOffset instead.
  88549. */
  88550. getOffset(): number;
  88551. /**
  88552. * Returns the number of components per vertex attribute (integer)
  88553. * @returns the size in float
  88554. */
  88555. getSize(): number;
  88556. /**
  88557. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  88558. * @returns true if this buffer is instanced
  88559. */
  88560. getIsInstanced(): boolean;
  88561. /**
  88562. * Returns the instancing divisor, zero for non-instanced (integer).
  88563. * @returns a number
  88564. */
  88565. getInstanceDivisor(): number;
  88566. /**
  88567. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88568. * @param data defines the data to store
  88569. */
  88570. create(data?: DataArray): void;
  88571. /**
  88572. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  88573. * This function will create a new buffer if the current one is not updatable
  88574. * @param data defines the data to store
  88575. */
  88576. update(data: DataArray): void;
  88577. /**
  88578. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  88579. * Returns the directly updated WebGLBuffer.
  88580. * @param data the new data
  88581. * @param offset the new offset
  88582. * @param useBytes set to true if the offset is in bytes
  88583. */
  88584. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  88585. /**
  88586. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  88587. */
  88588. dispose(): void;
  88589. /**
  88590. * Enumerates each value of this vertex buffer as numbers.
  88591. * @param count the number of values to enumerate
  88592. * @param callback the callback function called for each value
  88593. */
  88594. forEach(count: number, callback: (value: number, index: number) => void): void;
  88595. /**
  88596. * Positions
  88597. */
  88598. static readonly PositionKind: string;
  88599. /**
  88600. * Normals
  88601. */
  88602. static readonly NormalKind: string;
  88603. /**
  88604. * Tangents
  88605. */
  88606. static readonly TangentKind: string;
  88607. /**
  88608. * Texture coordinates
  88609. */
  88610. static readonly UVKind: string;
  88611. /**
  88612. * Texture coordinates 2
  88613. */
  88614. static readonly UV2Kind: string;
  88615. /**
  88616. * Texture coordinates 3
  88617. */
  88618. static readonly UV3Kind: string;
  88619. /**
  88620. * Texture coordinates 4
  88621. */
  88622. static readonly UV4Kind: string;
  88623. /**
  88624. * Texture coordinates 5
  88625. */
  88626. static readonly UV5Kind: string;
  88627. /**
  88628. * Texture coordinates 6
  88629. */
  88630. static readonly UV6Kind: string;
  88631. /**
  88632. * Colors
  88633. */
  88634. static readonly ColorKind: string;
  88635. /**
  88636. * Matrix indices (for bones)
  88637. */
  88638. static readonly MatricesIndicesKind: string;
  88639. /**
  88640. * Matrix weights (for bones)
  88641. */
  88642. static readonly MatricesWeightsKind: string;
  88643. /**
  88644. * Additional matrix indices (for bones)
  88645. */
  88646. static readonly MatricesIndicesExtraKind: string;
  88647. /**
  88648. * Additional matrix weights (for bones)
  88649. */
  88650. static readonly MatricesWeightsExtraKind: string;
  88651. /**
  88652. * Deduces the stride given a kind.
  88653. * @param kind The kind string to deduce
  88654. * @returns The deduced stride
  88655. */
  88656. static DeduceStride(kind: string): number;
  88657. /**
  88658. * Gets the byte length of the given type.
  88659. * @param type the type
  88660. * @returns the number of bytes
  88661. */
  88662. static GetTypeByteLength(type: number): number;
  88663. /**
  88664. * Enumerates each value of the given parameters as numbers.
  88665. * @param data the data to enumerate
  88666. * @param byteOffset the byte offset of the data
  88667. * @param byteStride the byte stride of the data
  88668. * @param componentCount the number of components per element
  88669. * @param componentType the type of the component
  88670. * @param count the number of values to enumerate
  88671. * @param normalized whether the data is normalized
  88672. * @param callback the callback function called for each value
  88673. */
  88674. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  88675. private static _GetFloatValue;
  88676. }
  88677. }
  88678. declare module BABYLON {
  88679. /**
  88680. * @hidden
  88681. */
  88682. export class IntersectionInfo {
  88683. bu: Nullable<number>;
  88684. bv: Nullable<number>;
  88685. distance: number;
  88686. faceId: number;
  88687. subMeshId: number;
  88688. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  88689. }
  88690. }
  88691. declare module BABYLON {
  88692. /**
  88693. * Class used to store bounding sphere information
  88694. */
  88695. export class BoundingSphere {
  88696. /**
  88697. * Gets the center of the bounding sphere in local space
  88698. */
  88699. readonly center: Vector3;
  88700. /**
  88701. * Radius of the bounding sphere in local space
  88702. */
  88703. radius: number;
  88704. /**
  88705. * Gets the center of the bounding sphere in world space
  88706. */
  88707. readonly centerWorld: Vector3;
  88708. /**
  88709. * Radius of the bounding sphere in world space
  88710. */
  88711. radiusWorld: number;
  88712. /**
  88713. * Gets the minimum vector in local space
  88714. */
  88715. readonly minimum: Vector3;
  88716. /**
  88717. * Gets the maximum vector in local space
  88718. */
  88719. readonly maximum: Vector3;
  88720. private _worldMatrix;
  88721. private static readonly TmpVector3;
  88722. /**
  88723. * Creates a new bounding sphere
  88724. * @param min defines the minimum vector (in local space)
  88725. * @param max defines the maximum vector (in local space)
  88726. * @param worldMatrix defines the new world matrix
  88727. */
  88728. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88729. /**
  88730. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  88731. * @param min defines the new minimum vector (in local space)
  88732. * @param max defines the new maximum vector (in local space)
  88733. * @param worldMatrix defines the new world matrix
  88734. */
  88735. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88736. /**
  88737. * Scale the current bounding sphere by applying a scale factor
  88738. * @param factor defines the scale factor to apply
  88739. * @returns the current bounding box
  88740. */
  88741. scale(factor: number): BoundingSphere;
  88742. /**
  88743. * Gets the world matrix of the bounding box
  88744. * @returns a matrix
  88745. */
  88746. getWorldMatrix(): DeepImmutable<Matrix>;
  88747. /** @hidden */
  88748. _update(worldMatrix: DeepImmutable<Matrix>): void;
  88749. /**
  88750. * Tests if the bounding sphere is intersecting the frustum planes
  88751. * @param frustumPlanes defines the frustum planes to test
  88752. * @returns true if there is an intersection
  88753. */
  88754. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88755. /**
  88756. * Tests if the bounding sphere center is in between the frustum planes.
  88757. * Used for optimistic fast inclusion.
  88758. * @param frustumPlanes defines the frustum planes to test
  88759. * @returns true if the sphere center is in between the frustum planes
  88760. */
  88761. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88762. /**
  88763. * Tests if a point is inside the bounding sphere
  88764. * @param point defines the point to test
  88765. * @returns true if the point is inside the bounding sphere
  88766. */
  88767. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88768. /**
  88769. * Checks if two sphere intersct
  88770. * @param sphere0 sphere 0
  88771. * @param sphere1 sphere 1
  88772. * @returns true if the speres intersect
  88773. */
  88774. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  88775. }
  88776. }
  88777. declare module BABYLON {
  88778. /**
  88779. * Class used to store bounding box information
  88780. */
  88781. export class BoundingBox implements ICullable {
  88782. /**
  88783. * Gets the 8 vectors representing the bounding box in local space
  88784. */
  88785. readonly vectors: Vector3[];
  88786. /**
  88787. * Gets the center of the bounding box in local space
  88788. */
  88789. readonly center: Vector3;
  88790. /**
  88791. * Gets the center of the bounding box in world space
  88792. */
  88793. readonly centerWorld: Vector3;
  88794. /**
  88795. * Gets the extend size in local space
  88796. */
  88797. readonly extendSize: Vector3;
  88798. /**
  88799. * Gets the extend size in world space
  88800. */
  88801. readonly extendSizeWorld: Vector3;
  88802. /**
  88803. * Gets the OBB (object bounding box) directions
  88804. */
  88805. readonly directions: Vector3[];
  88806. /**
  88807. * Gets the 8 vectors representing the bounding box in world space
  88808. */
  88809. readonly vectorsWorld: Vector3[];
  88810. /**
  88811. * Gets the minimum vector in world space
  88812. */
  88813. readonly minimumWorld: Vector3;
  88814. /**
  88815. * Gets the maximum vector in world space
  88816. */
  88817. readonly maximumWorld: Vector3;
  88818. /**
  88819. * Gets the minimum vector in local space
  88820. */
  88821. readonly minimum: Vector3;
  88822. /**
  88823. * Gets the maximum vector in local space
  88824. */
  88825. readonly maximum: Vector3;
  88826. private _worldMatrix;
  88827. private static readonly TmpVector3;
  88828. /**
  88829. * @hidden
  88830. */
  88831. _tag: number;
  88832. /**
  88833. * Creates a new bounding box
  88834. * @param min defines the minimum vector (in local space)
  88835. * @param max defines the maximum vector (in local space)
  88836. * @param worldMatrix defines the new world matrix
  88837. */
  88838. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88839. /**
  88840. * Recreates the entire bounding box from scratch as if we call the constructor in place
  88841. * @param min defines the new minimum vector (in local space)
  88842. * @param max defines the new maximum vector (in local space)
  88843. * @param worldMatrix defines the new world matrix
  88844. */
  88845. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88846. /**
  88847. * Scale the current bounding box by applying a scale factor
  88848. * @param factor defines the scale factor to apply
  88849. * @returns the current bounding box
  88850. */
  88851. scale(factor: number): BoundingBox;
  88852. /**
  88853. * Gets the world matrix of the bounding box
  88854. * @returns a matrix
  88855. */
  88856. getWorldMatrix(): DeepImmutable<Matrix>;
  88857. /** @hidden */
  88858. _update(world: DeepImmutable<Matrix>): void;
  88859. /**
  88860. * Tests if the bounding box is intersecting the frustum planes
  88861. * @param frustumPlanes defines the frustum planes to test
  88862. * @returns true if there is an intersection
  88863. */
  88864. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88865. /**
  88866. * Tests if the bounding box is entirely inside the frustum planes
  88867. * @param frustumPlanes defines the frustum planes to test
  88868. * @returns true if there is an inclusion
  88869. */
  88870. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88871. /**
  88872. * Tests if a point is inside the bounding box
  88873. * @param point defines the point to test
  88874. * @returns true if the point is inside the bounding box
  88875. */
  88876. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88877. /**
  88878. * Tests if the bounding box intersects with a bounding sphere
  88879. * @param sphere defines the sphere to test
  88880. * @returns true if there is an intersection
  88881. */
  88882. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  88883. /**
  88884. * Tests if the bounding box intersects with a box defined by a min and max vectors
  88885. * @param min defines the min vector to use
  88886. * @param max defines the max vector to use
  88887. * @returns true if there is an intersection
  88888. */
  88889. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  88890. /**
  88891. * Tests if two bounding boxes are intersections
  88892. * @param box0 defines the first box to test
  88893. * @param box1 defines the second box to test
  88894. * @returns true if there is an intersection
  88895. */
  88896. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  88897. /**
  88898. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  88899. * @param minPoint defines the minimum vector of the bounding box
  88900. * @param maxPoint defines the maximum vector of the bounding box
  88901. * @param sphereCenter defines the sphere center
  88902. * @param sphereRadius defines the sphere radius
  88903. * @returns true if there is an intersection
  88904. */
  88905. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  88906. /**
  88907. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  88908. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88909. * @param frustumPlanes defines the frustum planes to test
  88910. * @return true if there is an inclusion
  88911. */
  88912. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88913. /**
  88914. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  88915. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88916. * @param frustumPlanes defines the frustum planes to test
  88917. * @return true if there is an intersection
  88918. */
  88919. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88920. }
  88921. }
  88922. declare module BABYLON {
  88923. /** @hidden */
  88924. export class Collider {
  88925. /** Define if a collision was found */
  88926. collisionFound: boolean;
  88927. /**
  88928. * Define last intersection point in local space
  88929. */
  88930. intersectionPoint: Vector3;
  88931. /**
  88932. * Define last collided mesh
  88933. */
  88934. collidedMesh: Nullable<AbstractMesh>;
  88935. private _collisionPoint;
  88936. private _planeIntersectionPoint;
  88937. private _tempVector;
  88938. private _tempVector2;
  88939. private _tempVector3;
  88940. private _tempVector4;
  88941. private _edge;
  88942. private _baseToVertex;
  88943. private _destinationPoint;
  88944. private _slidePlaneNormal;
  88945. private _displacementVector;
  88946. /** @hidden */
  88947. _radius: Vector3;
  88948. /** @hidden */
  88949. _retry: number;
  88950. private _velocity;
  88951. private _basePoint;
  88952. private _epsilon;
  88953. /** @hidden */
  88954. _velocityWorldLength: number;
  88955. /** @hidden */
  88956. _basePointWorld: Vector3;
  88957. private _velocityWorld;
  88958. private _normalizedVelocity;
  88959. /** @hidden */
  88960. _initialVelocity: Vector3;
  88961. /** @hidden */
  88962. _initialPosition: Vector3;
  88963. private _nearestDistance;
  88964. private _collisionMask;
  88965. get collisionMask(): number;
  88966. set collisionMask(mask: number);
  88967. /**
  88968. * Gets the plane normal used to compute the sliding response (in local space)
  88969. */
  88970. get slidePlaneNormal(): Vector3;
  88971. /** @hidden */
  88972. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88973. /** @hidden */
  88974. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88975. /** @hidden */
  88976. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88977. /** @hidden */
  88978. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88979. /** @hidden */
  88980. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88981. /** @hidden */
  88982. _getResponse(pos: Vector3, vel: Vector3): void;
  88983. }
  88984. }
  88985. declare module BABYLON {
  88986. /**
  88987. * Interface for cullable objects
  88988. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88989. */
  88990. export interface ICullable {
  88991. /**
  88992. * Checks if the object or part of the object is in the frustum
  88993. * @param frustumPlanes Camera near/planes
  88994. * @returns true if the object is in frustum otherwise false
  88995. */
  88996. isInFrustum(frustumPlanes: Plane[]): boolean;
  88997. /**
  88998. * Checks if a cullable object (mesh...) is in the camera frustum
  88999. * Unlike isInFrustum this cheks the full bounding box
  89000. * @param frustumPlanes Camera near/planes
  89001. * @returns true if the object is in frustum otherwise false
  89002. */
  89003. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89004. }
  89005. /**
  89006. * Info for a bounding data of a mesh
  89007. */
  89008. export class BoundingInfo implements ICullable {
  89009. /**
  89010. * Bounding box for the mesh
  89011. */
  89012. readonly boundingBox: BoundingBox;
  89013. /**
  89014. * Bounding sphere for the mesh
  89015. */
  89016. readonly boundingSphere: BoundingSphere;
  89017. private _isLocked;
  89018. private static readonly TmpVector3;
  89019. /**
  89020. * Constructs bounding info
  89021. * @param minimum min vector of the bounding box/sphere
  89022. * @param maximum max vector of the bounding box/sphere
  89023. * @param worldMatrix defines the new world matrix
  89024. */
  89025. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  89026. /**
  89027. * Recreates the entire bounding info from scratch as if we call the constructor in place
  89028. * @param min defines the new minimum vector (in local space)
  89029. * @param max defines the new maximum vector (in local space)
  89030. * @param worldMatrix defines the new world matrix
  89031. */
  89032. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  89033. /**
  89034. * min vector of the bounding box/sphere
  89035. */
  89036. get minimum(): Vector3;
  89037. /**
  89038. * max vector of the bounding box/sphere
  89039. */
  89040. get maximum(): Vector3;
  89041. /**
  89042. * If the info is locked and won't be updated to avoid perf overhead
  89043. */
  89044. get isLocked(): boolean;
  89045. set isLocked(value: boolean);
  89046. /**
  89047. * Updates the bounding sphere and box
  89048. * @param world world matrix to be used to update
  89049. */
  89050. update(world: DeepImmutable<Matrix>): void;
  89051. /**
  89052. * Recreate the bounding info to be centered around a specific point given a specific extend.
  89053. * @param center New center of the bounding info
  89054. * @param extend New extend of the bounding info
  89055. * @returns the current bounding info
  89056. */
  89057. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  89058. /**
  89059. * Scale the current bounding info by applying a scale factor
  89060. * @param factor defines the scale factor to apply
  89061. * @returns the current bounding info
  89062. */
  89063. scale(factor: number): BoundingInfo;
  89064. /**
  89065. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  89066. * @param frustumPlanes defines the frustum to test
  89067. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  89068. * @returns true if the bounding info is in the frustum planes
  89069. */
  89070. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  89071. /**
  89072. * Gets the world distance between the min and max points of the bounding box
  89073. */
  89074. get diagonalLength(): number;
  89075. /**
  89076. * Checks if a cullable object (mesh...) is in the camera frustum
  89077. * Unlike isInFrustum this cheks the full bounding box
  89078. * @param frustumPlanes Camera near/planes
  89079. * @returns true if the object is in frustum otherwise false
  89080. */
  89081. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  89082. /** @hidden */
  89083. _checkCollision(collider: Collider): boolean;
  89084. /**
  89085. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  89086. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  89087. * @param point the point to check intersection with
  89088. * @returns if the point intersects
  89089. */
  89090. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  89091. /**
  89092. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  89093. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  89094. * @param boundingInfo the bounding info to check intersection with
  89095. * @param precise if the intersection should be done using OBB
  89096. * @returns if the bounding info intersects
  89097. */
  89098. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  89099. }
  89100. }
  89101. declare module BABYLON {
  89102. /**
  89103. * Extracts minimum and maximum values from a list of indexed positions
  89104. * @param positions defines the positions to use
  89105. * @param indices defines the indices to the positions
  89106. * @param indexStart defines the start index
  89107. * @param indexCount defines the end index
  89108. * @param bias defines bias value to add to the result
  89109. * @return minimum and maximum values
  89110. */
  89111. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89112. minimum: Vector3;
  89113. maximum: Vector3;
  89114. };
  89115. /**
  89116. * Extracts minimum and maximum values from a list of positions
  89117. * @param positions defines the positions to use
  89118. * @param start defines the start index in the positions array
  89119. * @param count defines the number of positions to handle
  89120. * @param bias defines bias value to add to the result
  89121. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89122. * @return minimum and maximum values
  89123. */
  89124. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89125. minimum: Vector3;
  89126. maximum: Vector3;
  89127. };
  89128. }
  89129. declare module BABYLON {
  89130. /**
  89131. * Class used to manipulate GUIDs
  89132. */
  89133. export class GUID {
  89134. /**
  89135. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89136. * Be aware Math.random() could cause collisions, but:
  89137. * "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"
  89138. * @returns a pseudo random id
  89139. */
  89140. static RandomId(): string;
  89141. }
  89142. }
  89143. declare module BABYLON {
  89144. /**
  89145. * Base class of all the textures in babylon.
  89146. * It groups all the common properties the materials, post process, lights... might need
  89147. * in order to make a correct use of the texture.
  89148. */
  89149. export class BaseTexture extends ThinTexture implements IAnimatable {
  89150. /**
  89151. * Default anisotropic filtering level for the application.
  89152. * It is set to 4 as a good tradeoff between perf and quality.
  89153. */
  89154. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  89155. /**
  89156. * Gets or sets the unique id of the texture
  89157. */
  89158. uniqueId: number;
  89159. /**
  89160. * Define the name of the texture.
  89161. */
  89162. name: string;
  89163. /**
  89164. * Gets or sets an object used to store user defined information.
  89165. */
  89166. metadata: any;
  89167. /**
  89168. * For internal use only. Please do not use.
  89169. */
  89170. reservedDataStore: any;
  89171. private _hasAlpha;
  89172. /**
  89173. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  89174. */
  89175. set hasAlpha(value: boolean);
  89176. get hasAlpha(): boolean;
  89177. /**
  89178. * Defines if the alpha value should be determined via the rgb values.
  89179. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  89180. */
  89181. getAlphaFromRGB: boolean;
  89182. /**
  89183. * Intensity or strength of the texture.
  89184. * It is commonly used by materials to fine tune the intensity of the texture
  89185. */
  89186. level: number;
  89187. /**
  89188. * Define the UV chanel to use starting from 0 and defaulting to 0.
  89189. * This is part of the texture as textures usually maps to one uv set.
  89190. */
  89191. coordinatesIndex: number;
  89192. protected _coordinatesMode: number;
  89193. /**
  89194. * How a texture is mapped.
  89195. *
  89196. * | Value | Type | Description |
  89197. * | ----- | ----------------------------------- | ----------- |
  89198. * | 0 | EXPLICIT_MODE | |
  89199. * | 1 | SPHERICAL_MODE | |
  89200. * | 2 | PLANAR_MODE | |
  89201. * | 3 | CUBIC_MODE | |
  89202. * | 4 | PROJECTION_MODE | |
  89203. * | 5 | SKYBOX_MODE | |
  89204. * | 6 | INVCUBIC_MODE | |
  89205. * | 7 | EQUIRECTANGULAR_MODE | |
  89206. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89207. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89208. */
  89209. set coordinatesMode(value: number);
  89210. get coordinatesMode(): number;
  89211. /**
  89212. * | Value | Type | Description |
  89213. * | ----- | ------------------ | ----------- |
  89214. * | 0 | CLAMP_ADDRESSMODE | |
  89215. * | 1 | WRAP_ADDRESSMODE | |
  89216. * | 2 | MIRROR_ADDRESSMODE | |
  89217. */
  89218. get wrapU(): number;
  89219. set wrapU(value: number);
  89220. /**
  89221. * | Value | Type | Description |
  89222. * | ----- | ------------------ | ----------- |
  89223. * | 0 | CLAMP_ADDRESSMODE | |
  89224. * | 1 | WRAP_ADDRESSMODE | |
  89225. * | 2 | MIRROR_ADDRESSMODE | |
  89226. */
  89227. get wrapV(): number;
  89228. set wrapV(value: number);
  89229. /**
  89230. * | Value | Type | Description |
  89231. * | ----- | ------------------ | ----------- |
  89232. * | 0 | CLAMP_ADDRESSMODE | |
  89233. * | 1 | WRAP_ADDRESSMODE | |
  89234. * | 2 | MIRROR_ADDRESSMODE | |
  89235. */
  89236. wrapR: number;
  89237. /**
  89238. * With compliant hardware and browser (supporting anisotropic filtering)
  89239. * this defines the level of anisotropic filtering in the texture.
  89240. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89241. */
  89242. anisotropicFilteringLevel: number;
  89243. private _isCube;
  89244. /**
  89245. * Define if the texture is a cube texture or if false a 2d texture.
  89246. */
  89247. get isCube(): boolean;
  89248. set isCube(value: boolean);
  89249. /**
  89250. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89251. */
  89252. get is3D(): boolean;
  89253. set is3D(value: boolean);
  89254. /**
  89255. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  89256. */
  89257. get is2DArray(): boolean;
  89258. set is2DArray(value: boolean);
  89259. private _gammaSpace;
  89260. /**
  89261. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89262. * HDR texture are usually stored in linear space.
  89263. * This only impacts the PBR and Background materials
  89264. */
  89265. get gammaSpace(): boolean;
  89266. set gammaSpace(gamma: boolean);
  89267. /**
  89268. * Gets or sets whether or not the texture contains RGBD data.
  89269. */
  89270. get isRGBD(): boolean;
  89271. set isRGBD(value: boolean);
  89272. /**
  89273. * Is Z inverted in the texture (useful in a cube texture).
  89274. */
  89275. invertZ: boolean;
  89276. /**
  89277. * Are mip maps generated for this texture or not.
  89278. */
  89279. get noMipmap(): boolean;
  89280. /**
  89281. * @hidden
  89282. */
  89283. lodLevelInAlpha: boolean;
  89284. /**
  89285. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89286. */
  89287. get lodGenerationOffset(): number;
  89288. set lodGenerationOffset(value: number);
  89289. /**
  89290. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89291. */
  89292. get lodGenerationScale(): number;
  89293. set lodGenerationScale(value: number);
  89294. /**
  89295. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89296. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89297. * average roughness values.
  89298. */
  89299. get linearSpecularLOD(): boolean;
  89300. set linearSpecularLOD(value: boolean);
  89301. /**
  89302. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89303. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89304. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89305. */
  89306. get irradianceTexture(): Nullable<BaseTexture>;
  89307. set irradianceTexture(value: Nullable<BaseTexture>);
  89308. /**
  89309. * Define if the texture is a render target.
  89310. */
  89311. isRenderTarget: boolean;
  89312. /**
  89313. * Define the unique id of the texture in the scene.
  89314. */
  89315. get uid(): string;
  89316. /** @hidden */
  89317. _prefiltered: boolean;
  89318. /**
  89319. * Return a string representation of the texture.
  89320. * @returns the texture as a string
  89321. */
  89322. toString(): string;
  89323. /**
  89324. * Get the class name of the texture.
  89325. * @returns "BaseTexture"
  89326. */
  89327. getClassName(): string;
  89328. /**
  89329. * Define the list of animation attached to the texture.
  89330. */
  89331. animations: Animation[];
  89332. /**
  89333. * An event triggered when the texture is disposed.
  89334. */
  89335. onDisposeObservable: Observable<BaseTexture>;
  89336. private _onDisposeObserver;
  89337. /**
  89338. * Callback triggered when the texture has been disposed.
  89339. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89340. */
  89341. set onDispose(callback: () => void);
  89342. protected _scene: Nullable<Scene>;
  89343. /** @hidden */
  89344. _texture: Nullable<InternalTexture>;
  89345. private _uid;
  89346. /**
  89347. * Define if the texture is preventinga material to render or not.
  89348. * If not and the texture is not ready, the engine will use a default black texture instead.
  89349. */
  89350. get isBlocking(): boolean;
  89351. /**
  89352. * Instantiates a new BaseTexture.
  89353. * Base class of all the textures in babylon.
  89354. * It groups all the common properties the materials, post process, lights... might need
  89355. * in order to make a correct use of the texture.
  89356. * @param sceneOrEngine Define the scene or engine the texture blongs to
  89357. */
  89358. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  89359. /**
  89360. * Get the scene the texture belongs to.
  89361. * @returns the scene or null if undefined
  89362. */
  89363. getScene(): Nullable<Scene>;
  89364. /** @hidden */
  89365. protected _getEngine(): Nullable<ThinEngine>;
  89366. /**
  89367. * Checks if the texture has the same transform matrix than another texture
  89368. * @param texture texture to check against
  89369. * @returns true if the transforms are the same, else false
  89370. */
  89371. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  89372. /**
  89373. * Get the texture transform matrix used to offset tile the texture for istance.
  89374. * @returns the transformation matrix
  89375. */
  89376. getTextureMatrix(): Matrix;
  89377. /**
  89378. * Get the texture reflection matrix used to rotate/transform the reflection.
  89379. * @returns the reflection matrix
  89380. */
  89381. getReflectionTextureMatrix(): Matrix;
  89382. /**
  89383. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89384. * @returns true if ready or not blocking
  89385. */
  89386. isReadyOrNotBlocking(): boolean;
  89387. /**
  89388. * Scales the texture if is `canRescale()`
  89389. * @param ratio the resize factor we want to use to rescale
  89390. */
  89391. scale(ratio: number): void;
  89392. /**
  89393. * Get if the texture can rescale.
  89394. */
  89395. get canRescale(): boolean;
  89396. /** @hidden */
  89397. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89398. /** @hidden */
  89399. _rebuild(): void;
  89400. /**
  89401. * Clones the texture.
  89402. * @returns the cloned texture
  89403. */
  89404. clone(): Nullable<BaseTexture>;
  89405. /**
  89406. * Get the texture underlying type (INT, FLOAT...)
  89407. */
  89408. get textureType(): number;
  89409. /**
  89410. * Get the texture underlying format (RGB, RGBA...)
  89411. */
  89412. get textureFormat(): number;
  89413. /**
  89414. * Indicates that textures need to be re-calculated for all materials
  89415. */
  89416. protected _markAllSubMeshesAsTexturesDirty(): void;
  89417. /**
  89418. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89419. * This will returns an RGBA array buffer containing either in values (0-255) or
  89420. * float values (0-1) depending of the underlying buffer type.
  89421. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89422. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89423. * @param buffer defines a user defined buffer to fill with data (can be null)
  89424. * @returns The Array buffer containing the pixels data.
  89425. */
  89426. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89427. /** @hidden */
  89428. get _lodTextureHigh(): Nullable<BaseTexture>;
  89429. /** @hidden */
  89430. get _lodTextureMid(): Nullable<BaseTexture>;
  89431. /** @hidden */
  89432. get _lodTextureLow(): Nullable<BaseTexture>;
  89433. /**
  89434. * Dispose the texture and release its associated resources.
  89435. */
  89436. dispose(): void;
  89437. /**
  89438. * Serialize the texture into a JSON representation that can be parsed later on.
  89439. * @returns the JSON representation of the texture
  89440. */
  89441. serialize(): any;
  89442. /**
  89443. * Helper function to be called back once a list of texture contains only ready textures.
  89444. * @param textures Define the list of textures to wait for
  89445. * @param callback Define the callback triggered once the entire list will be ready
  89446. */
  89447. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89448. private static _isScene;
  89449. }
  89450. }
  89451. declare module BABYLON {
  89452. /** @hidden */
  89453. export class WebGLDataBuffer extends DataBuffer {
  89454. private _buffer;
  89455. constructor(resource: WebGLBuffer);
  89456. get underlyingResource(): any;
  89457. }
  89458. }
  89459. declare module BABYLON {
  89460. /** @hidden */
  89461. export class WebGLPipelineContext implements IPipelineContext {
  89462. engine: ThinEngine;
  89463. program: Nullable<WebGLProgram>;
  89464. context?: WebGLRenderingContext;
  89465. vertexShader?: WebGLShader;
  89466. fragmentShader?: WebGLShader;
  89467. isParallelCompiled: boolean;
  89468. onCompiled?: () => void;
  89469. transformFeedback?: WebGLTransformFeedback | null;
  89470. vertexCompilationError: Nullable<string>;
  89471. fragmentCompilationError: Nullable<string>;
  89472. programLinkError: Nullable<string>;
  89473. programValidationError: Nullable<string>;
  89474. get isAsync(): boolean;
  89475. get isReady(): boolean;
  89476. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89477. _getVertexShaderCode(): string | null;
  89478. _getFragmentShaderCode(): string | null;
  89479. }
  89480. }
  89481. declare module BABYLON {
  89482. interface ThinEngine {
  89483. /**
  89484. * Create an uniform buffer
  89485. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89486. * @param elements defines the content of the uniform buffer
  89487. * @returns the webGL uniform buffer
  89488. */
  89489. createUniformBuffer(elements: FloatArray): DataBuffer;
  89490. /**
  89491. * Create a dynamic uniform buffer
  89492. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89493. * @param elements defines the content of the uniform buffer
  89494. * @returns the webGL uniform buffer
  89495. */
  89496. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  89497. /**
  89498. * Update an existing uniform buffer
  89499. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89500. * @param uniformBuffer defines the target uniform buffer
  89501. * @param elements defines the content to update
  89502. * @param offset defines the offset in the uniform buffer where update should start
  89503. * @param count defines the size of the data to update
  89504. */
  89505. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  89506. /**
  89507. * Bind an uniform buffer to the current webGL context
  89508. * @param buffer defines the buffer to bind
  89509. */
  89510. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  89511. /**
  89512. * Bind a buffer to the current webGL context at a given location
  89513. * @param buffer defines the buffer to bind
  89514. * @param location defines the index where to bind the buffer
  89515. */
  89516. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  89517. /**
  89518. * Bind a specific block at a given index in a specific shader program
  89519. * @param pipelineContext defines the pipeline context to use
  89520. * @param blockName defines the block name
  89521. * @param index defines the index where to bind the block
  89522. */
  89523. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  89524. }
  89525. }
  89526. declare module BABYLON {
  89527. /**
  89528. * Uniform buffer objects.
  89529. *
  89530. * Handles blocks of uniform on the GPU.
  89531. *
  89532. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89533. *
  89534. * For more information, please refer to :
  89535. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89536. */
  89537. export class UniformBuffer {
  89538. private _engine;
  89539. private _buffer;
  89540. private _data;
  89541. private _bufferData;
  89542. private _dynamic?;
  89543. private _uniformLocations;
  89544. private _uniformSizes;
  89545. private _uniformLocationPointer;
  89546. private _needSync;
  89547. private _noUBO;
  89548. private _currentEffect;
  89549. /** @hidden */
  89550. _alreadyBound: boolean;
  89551. private static _MAX_UNIFORM_SIZE;
  89552. private static _tempBuffer;
  89553. /**
  89554. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89555. * This is dynamic to allow compat with webgl 1 and 2.
  89556. * You will need to pass the name of the uniform as well as the value.
  89557. */
  89558. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89559. /**
  89560. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89561. * This is dynamic to allow compat with webgl 1 and 2.
  89562. * You will need to pass the name of the uniform as well as the value.
  89563. */
  89564. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89565. /**
  89566. * Lambda to Update a single float in a uniform buffer.
  89567. * This is dynamic to allow compat with webgl 1 and 2.
  89568. * You will need to pass the name of the uniform as well as the value.
  89569. */
  89570. updateFloat: (name: string, x: number) => void;
  89571. /**
  89572. * Lambda to Update a vec2 of float in a uniform buffer.
  89573. * This is dynamic to allow compat with webgl 1 and 2.
  89574. * You will need to pass the name of the uniform as well as the value.
  89575. */
  89576. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89577. /**
  89578. * Lambda to Update a vec3 of float in a uniform buffer.
  89579. * This is dynamic to allow compat with webgl 1 and 2.
  89580. * You will need to pass the name of the uniform as well as the value.
  89581. */
  89582. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89583. /**
  89584. * Lambda to Update a vec4 of float in a uniform buffer.
  89585. * This is dynamic to allow compat with webgl 1 and 2.
  89586. * You will need to pass the name of the uniform as well as the value.
  89587. */
  89588. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89589. /**
  89590. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89591. * This is dynamic to allow compat with webgl 1 and 2.
  89592. * You will need to pass the name of the uniform as well as the value.
  89593. */
  89594. updateMatrix: (name: string, mat: Matrix) => void;
  89595. /**
  89596. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89597. * This is dynamic to allow compat with webgl 1 and 2.
  89598. * You will need to pass the name of the uniform as well as the value.
  89599. */
  89600. updateVector3: (name: string, vector: Vector3) => void;
  89601. /**
  89602. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89603. * This is dynamic to allow compat with webgl 1 and 2.
  89604. * You will need to pass the name of the uniform as well as the value.
  89605. */
  89606. updateVector4: (name: string, vector: Vector4) => void;
  89607. /**
  89608. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89609. * This is dynamic to allow compat with webgl 1 and 2.
  89610. * You will need to pass the name of the uniform as well as the value.
  89611. */
  89612. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89613. /**
  89614. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89615. * This is dynamic to allow compat with webgl 1 and 2.
  89616. * You will need to pass the name of the uniform as well as the value.
  89617. */
  89618. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89619. /**
  89620. * Instantiates a new Uniform buffer objects.
  89621. *
  89622. * Handles blocks of uniform on the GPU.
  89623. *
  89624. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89625. *
  89626. * For more information, please refer to :
  89627. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89628. * @param engine Define the engine the buffer is associated with
  89629. * @param data Define the data contained in the buffer
  89630. * @param dynamic Define if the buffer is updatable
  89631. */
  89632. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89633. /**
  89634. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89635. * or just falling back on setUniformXXX calls.
  89636. */
  89637. get useUbo(): boolean;
  89638. /**
  89639. * Indicates if the WebGL underlying uniform buffer is in sync
  89640. * with the javascript cache data.
  89641. */
  89642. get isSync(): boolean;
  89643. /**
  89644. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89645. * Also, a dynamic UniformBuffer will disable cache verification and always
  89646. * update the underlying WebGL uniform buffer to the GPU.
  89647. * @returns if Dynamic, otherwise false
  89648. */
  89649. isDynamic(): boolean;
  89650. /**
  89651. * The data cache on JS side.
  89652. * @returns the underlying data as a float array
  89653. */
  89654. getData(): Float32Array;
  89655. /**
  89656. * The underlying WebGL Uniform buffer.
  89657. * @returns the webgl buffer
  89658. */
  89659. getBuffer(): Nullable<DataBuffer>;
  89660. /**
  89661. * std140 layout specifies how to align data within an UBO structure.
  89662. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89663. * for specs.
  89664. */
  89665. private _fillAlignment;
  89666. /**
  89667. * Adds an uniform in the buffer.
  89668. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89669. * for the layout to be correct !
  89670. * @param name Name of the uniform, as used in the uniform block in the shader.
  89671. * @param size Data size, or data directly.
  89672. */
  89673. addUniform(name: string, size: number | number[]): void;
  89674. /**
  89675. * Adds a Matrix 4x4 to the uniform buffer.
  89676. * @param name Name of the uniform, as used in the uniform block in the shader.
  89677. * @param mat A 4x4 matrix.
  89678. */
  89679. addMatrix(name: string, mat: Matrix): void;
  89680. /**
  89681. * Adds a vec2 to the uniform buffer.
  89682. * @param name Name of the uniform, as used in the uniform block in the shader.
  89683. * @param x Define the x component value of the vec2
  89684. * @param y Define the y component value of the vec2
  89685. */
  89686. addFloat2(name: string, x: number, y: number): void;
  89687. /**
  89688. * Adds a vec3 to the uniform buffer.
  89689. * @param name Name of the uniform, as used in the uniform block in the shader.
  89690. * @param x Define the x component value of the vec3
  89691. * @param y Define the y component value of the vec3
  89692. * @param z Define the z component value of the vec3
  89693. */
  89694. addFloat3(name: string, x: number, y: number, z: number): void;
  89695. /**
  89696. * Adds a vec3 to the uniform buffer.
  89697. * @param name Name of the uniform, as used in the uniform block in the shader.
  89698. * @param color Define the vec3 from a Color
  89699. */
  89700. addColor3(name: string, color: Color3): void;
  89701. /**
  89702. * Adds a vec4 to the uniform buffer.
  89703. * @param name Name of the uniform, as used in the uniform block in the shader.
  89704. * @param color Define the rgb components from a Color
  89705. * @param alpha Define the a component of the vec4
  89706. */
  89707. addColor4(name: string, color: Color3, alpha: number): void;
  89708. /**
  89709. * Adds a vec3 to the uniform buffer.
  89710. * @param name Name of the uniform, as used in the uniform block in the shader.
  89711. * @param vector Define the vec3 components from a Vector
  89712. */
  89713. addVector3(name: string, vector: Vector3): void;
  89714. /**
  89715. * Adds a Matrix 3x3 to the uniform buffer.
  89716. * @param name Name of the uniform, as used in the uniform block in the shader.
  89717. */
  89718. addMatrix3x3(name: string): void;
  89719. /**
  89720. * Adds a Matrix 2x2 to the uniform buffer.
  89721. * @param name Name of the uniform, as used in the uniform block in the shader.
  89722. */
  89723. addMatrix2x2(name: string): void;
  89724. /**
  89725. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89726. */
  89727. create(): void;
  89728. /** @hidden */
  89729. _rebuild(): void;
  89730. /**
  89731. * Updates the WebGL Uniform Buffer on the GPU.
  89732. * If the `dynamic` flag is set to true, no cache comparison is done.
  89733. * Otherwise, the buffer will be updated only if the cache differs.
  89734. */
  89735. update(): void;
  89736. /**
  89737. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89738. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89739. * @param data Define the flattened data
  89740. * @param size Define the size of the data.
  89741. */
  89742. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89743. private _valueCache;
  89744. private _cacheMatrix;
  89745. private _updateMatrix3x3ForUniform;
  89746. private _updateMatrix3x3ForEffect;
  89747. private _updateMatrix2x2ForEffect;
  89748. private _updateMatrix2x2ForUniform;
  89749. private _updateFloatForEffect;
  89750. private _updateFloatForUniform;
  89751. private _updateFloat2ForEffect;
  89752. private _updateFloat2ForUniform;
  89753. private _updateFloat3ForEffect;
  89754. private _updateFloat3ForUniform;
  89755. private _updateFloat4ForEffect;
  89756. private _updateFloat4ForUniform;
  89757. private _updateMatrixForEffect;
  89758. private _updateMatrixForUniform;
  89759. private _updateVector3ForEffect;
  89760. private _updateVector3ForUniform;
  89761. private _updateVector4ForEffect;
  89762. private _updateVector4ForUniform;
  89763. private _updateColor3ForEffect;
  89764. private _updateColor3ForUniform;
  89765. private _updateColor4ForEffect;
  89766. private _updateColor4ForUniform;
  89767. /**
  89768. * Sets a sampler uniform on the effect.
  89769. * @param name Define the name of the sampler.
  89770. * @param texture Define the texture to set in the sampler
  89771. */
  89772. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89773. /**
  89774. * Directly updates the value of the uniform in the cache AND on the GPU.
  89775. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89776. * @param data Define the flattened data
  89777. */
  89778. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89779. /**
  89780. * Binds this uniform buffer to an effect.
  89781. * @param effect Define the effect to bind the buffer to
  89782. * @param name Name of the uniform block in the shader.
  89783. */
  89784. bindToEffect(effect: Effect, name: string): void;
  89785. /**
  89786. * Disposes the uniform buffer.
  89787. */
  89788. dispose(): void;
  89789. }
  89790. }
  89791. declare module BABYLON {
  89792. /**
  89793. * Manages the defines for the Material
  89794. */
  89795. export class MaterialDefines {
  89796. /** @hidden */
  89797. protected _keys: string[];
  89798. private _isDirty;
  89799. /** @hidden */
  89800. _renderId: number;
  89801. /** @hidden */
  89802. _areLightsDirty: boolean;
  89803. /** @hidden */
  89804. _areLightsDisposed: boolean;
  89805. /** @hidden */
  89806. _areAttributesDirty: boolean;
  89807. /** @hidden */
  89808. _areTexturesDirty: boolean;
  89809. /** @hidden */
  89810. _areFresnelDirty: boolean;
  89811. /** @hidden */
  89812. _areMiscDirty: boolean;
  89813. /** @hidden */
  89814. _arePrePassDirty: boolean;
  89815. /** @hidden */
  89816. _areImageProcessingDirty: boolean;
  89817. /** @hidden */
  89818. _normals: boolean;
  89819. /** @hidden */
  89820. _uvs: boolean;
  89821. /** @hidden */
  89822. _needNormals: boolean;
  89823. /** @hidden */
  89824. _needUVs: boolean;
  89825. [id: string]: any;
  89826. /**
  89827. * Specifies if the material needs to be re-calculated
  89828. */
  89829. get isDirty(): boolean;
  89830. /**
  89831. * Marks the material to indicate that it has been re-calculated
  89832. */
  89833. markAsProcessed(): void;
  89834. /**
  89835. * Marks the material to indicate that it needs to be re-calculated
  89836. */
  89837. markAsUnprocessed(): void;
  89838. /**
  89839. * Marks the material to indicate all of its defines need to be re-calculated
  89840. */
  89841. markAllAsDirty(): void;
  89842. /**
  89843. * Marks the material to indicate that image processing needs to be re-calculated
  89844. */
  89845. markAsImageProcessingDirty(): void;
  89846. /**
  89847. * Marks the material to indicate the lights need to be re-calculated
  89848. * @param disposed Defines whether the light is dirty due to dispose or not
  89849. */
  89850. markAsLightDirty(disposed?: boolean): void;
  89851. /**
  89852. * Marks the attribute state as changed
  89853. */
  89854. markAsAttributesDirty(): void;
  89855. /**
  89856. * Marks the texture state as changed
  89857. */
  89858. markAsTexturesDirty(): void;
  89859. /**
  89860. * Marks the fresnel state as changed
  89861. */
  89862. markAsFresnelDirty(): void;
  89863. /**
  89864. * Marks the misc state as changed
  89865. */
  89866. markAsMiscDirty(): void;
  89867. /**
  89868. * Marks the prepass state as changed
  89869. */
  89870. markAsPrePassDirty(): void;
  89871. /**
  89872. * Rebuilds the material defines
  89873. */
  89874. rebuild(): void;
  89875. /**
  89876. * Specifies if two material defines are equal
  89877. * @param other - A material define instance to compare to
  89878. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  89879. */
  89880. isEqual(other: MaterialDefines): boolean;
  89881. /**
  89882. * Clones this instance's defines to another instance
  89883. * @param other - material defines to clone values to
  89884. */
  89885. cloneTo(other: MaterialDefines): void;
  89886. /**
  89887. * Resets the material define values
  89888. */
  89889. reset(): void;
  89890. /**
  89891. * Converts the material define values to a string
  89892. * @returns - String of material define information
  89893. */
  89894. toString(): string;
  89895. }
  89896. }
  89897. declare module BABYLON {
  89898. /**
  89899. * Enum that determines the text-wrapping mode to use.
  89900. */
  89901. export enum InspectableType {
  89902. /**
  89903. * Checkbox for booleans
  89904. */
  89905. Checkbox = 0,
  89906. /**
  89907. * Sliders for numbers
  89908. */
  89909. Slider = 1,
  89910. /**
  89911. * Vector3
  89912. */
  89913. Vector3 = 2,
  89914. /**
  89915. * Quaternions
  89916. */
  89917. Quaternion = 3,
  89918. /**
  89919. * Color3
  89920. */
  89921. Color3 = 4,
  89922. /**
  89923. * String
  89924. */
  89925. String = 5
  89926. }
  89927. /**
  89928. * Interface used to define custom inspectable properties.
  89929. * This interface is used by the inspector to display custom property grids
  89930. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89931. */
  89932. export interface IInspectable {
  89933. /**
  89934. * Gets the label to display
  89935. */
  89936. label: string;
  89937. /**
  89938. * Gets the name of the property to edit
  89939. */
  89940. propertyName: string;
  89941. /**
  89942. * Gets the type of the editor to use
  89943. */
  89944. type: InspectableType;
  89945. /**
  89946. * Gets the minimum value of the property when using in "slider" mode
  89947. */
  89948. min?: number;
  89949. /**
  89950. * Gets the maximum value of the property when using in "slider" mode
  89951. */
  89952. max?: number;
  89953. /**
  89954. * Gets the setp to use when using in "slider" mode
  89955. */
  89956. step?: number;
  89957. }
  89958. }
  89959. declare module BABYLON {
  89960. /**
  89961. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89962. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89963. * 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.
  89964. */
  89965. export abstract class Light extends Node {
  89966. /**
  89967. * Falloff Default: light is falling off following the material specification:
  89968. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89969. */
  89970. static readonly FALLOFF_DEFAULT: number;
  89971. /**
  89972. * Falloff Physical: light is falling off following the inverse squared distance law.
  89973. */
  89974. static readonly FALLOFF_PHYSICAL: number;
  89975. /**
  89976. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89977. * to enhance interoperability with other engines.
  89978. */
  89979. static readonly FALLOFF_GLTF: number;
  89980. /**
  89981. * Falloff Standard: light is falling off like in the standard material
  89982. * to enhance interoperability with other materials.
  89983. */
  89984. static readonly FALLOFF_STANDARD: number;
  89985. /**
  89986. * If every light affecting the material is in this lightmapMode,
  89987. * material.lightmapTexture adds or multiplies
  89988. * (depends on material.useLightmapAsShadowmap)
  89989. * after every other light calculations.
  89990. */
  89991. static readonly LIGHTMAP_DEFAULT: number;
  89992. /**
  89993. * material.lightmapTexture as only diffuse lighting from this light
  89994. * adds only specular lighting from this light
  89995. * adds dynamic shadows
  89996. */
  89997. static readonly LIGHTMAP_SPECULAR: number;
  89998. /**
  89999. * material.lightmapTexture as only lighting
  90000. * no light calculation from this light
  90001. * only adds dynamic shadows from this light
  90002. */
  90003. static readonly LIGHTMAP_SHADOWSONLY: number;
  90004. /**
  90005. * Each light type uses the default quantity according to its type:
  90006. * point/spot lights use luminous intensity
  90007. * directional lights use illuminance
  90008. */
  90009. static readonly INTENSITYMODE_AUTOMATIC: number;
  90010. /**
  90011. * lumen (lm)
  90012. */
  90013. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90014. /**
  90015. * candela (lm/sr)
  90016. */
  90017. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90018. /**
  90019. * lux (lm/m^2)
  90020. */
  90021. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90022. /**
  90023. * nit (cd/m^2)
  90024. */
  90025. static readonly INTENSITYMODE_LUMINANCE: number;
  90026. /**
  90027. * Light type const id of the point light.
  90028. */
  90029. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90030. /**
  90031. * Light type const id of the directional light.
  90032. */
  90033. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90034. /**
  90035. * Light type const id of the spot light.
  90036. */
  90037. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90038. /**
  90039. * Light type const id of the hemispheric light.
  90040. */
  90041. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90042. /**
  90043. * Diffuse gives the basic color to an object.
  90044. */
  90045. diffuse: Color3;
  90046. /**
  90047. * Specular produces a highlight color on an object.
  90048. * Note: This is note affecting PBR materials.
  90049. */
  90050. specular: Color3;
  90051. /**
  90052. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90053. * falling off base on range or angle.
  90054. * This can be set to any values in Light.FALLOFF_x.
  90055. *
  90056. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90057. * other types of materials.
  90058. */
  90059. falloffType: number;
  90060. /**
  90061. * Strength of the light.
  90062. * Note: By default it is define in the framework own unit.
  90063. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90064. */
  90065. intensity: number;
  90066. private _range;
  90067. protected _inverseSquaredRange: number;
  90068. /**
  90069. * Defines how far from the source the light is impacting in scene units.
  90070. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90071. */
  90072. get range(): number;
  90073. /**
  90074. * Defines how far from the source the light is impacting in scene units.
  90075. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90076. */
  90077. set range(value: number);
  90078. /**
  90079. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90080. * of light.
  90081. */
  90082. private _photometricScale;
  90083. private _intensityMode;
  90084. /**
  90085. * Gets the photometric scale used to interpret the intensity.
  90086. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90087. */
  90088. get intensityMode(): number;
  90089. /**
  90090. * Sets the photometric scale used to interpret the intensity.
  90091. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90092. */
  90093. set intensityMode(value: number);
  90094. private _radius;
  90095. /**
  90096. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90097. */
  90098. get radius(): number;
  90099. /**
  90100. * sets the light radius used by PBR Materials to simulate soft area lights.
  90101. */
  90102. set radius(value: number);
  90103. private _renderPriority;
  90104. /**
  90105. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90106. * exceeding the number allowed of the materials.
  90107. */
  90108. renderPriority: number;
  90109. private _shadowEnabled;
  90110. /**
  90111. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90112. * the current shadow generator.
  90113. */
  90114. get shadowEnabled(): boolean;
  90115. /**
  90116. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90117. * the current shadow generator.
  90118. */
  90119. set shadowEnabled(value: boolean);
  90120. private _includedOnlyMeshes;
  90121. /**
  90122. * Gets the only meshes impacted by this light.
  90123. */
  90124. get includedOnlyMeshes(): AbstractMesh[];
  90125. /**
  90126. * Sets the only meshes impacted by this light.
  90127. */
  90128. set includedOnlyMeshes(value: AbstractMesh[]);
  90129. private _excludedMeshes;
  90130. /**
  90131. * Gets the meshes not impacted by this light.
  90132. */
  90133. get excludedMeshes(): AbstractMesh[];
  90134. /**
  90135. * Sets the meshes not impacted by this light.
  90136. */
  90137. set excludedMeshes(value: AbstractMesh[]);
  90138. private _excludeWithLayerMask;
  90139. /**
  90140. * Gets the layer id use to find what meshes are not impacted by the light.
  90141. * Inactive if 0
  90142. */
  90143. get excludeWithLayerMask(): number;
  90144. /**
  90145. * Sets the layer id use to find what meshes are not impacted by the light.
  90146. * Inactive if 0
  90147. */
  90148. set excludeWithLayerMask(value: number);
  90149. private _includeOnlyWithLayerMask;
  90150. /**
  90151. * Gets the layer id use to find what meshes are impacted by the light.
  90152. * Inactive if 0
  90153. */
  90154. get includeOnlyWithLayerMask(): number;
  90155. /**
  90156. * Sets the layer id use to find what meshes are impacted by the light.
  90157. * Inactive if 0
  90158. */
  90159. set includeOnlyWithLayerMask(value: number);
  90160. private _lightmapMode;
  90161. /**
  90162. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90163. */
  90164. get lightmapMode(): number;
  90165. /**
  90166. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90167. */
  90168. set lightmapMode(value: number);
  90169. /**
  90170. * Shadow generator associted to the light.
  90171. * @hidden Internal use only.
  90172. */
  90173. _shadowGenerator: Nullable<IShadowGenerator>;
  90174. /**
  90175. * @hidden Internal use only.
  90176. */
  90177. _excludedMeshesIds: string[];
  90178. /**
  90179. * @hidden Internal use only.
  90180. */
  90181. _includedOnlyMeshesIds: string[];
  90182. /**
  90183. * The current light unifom buffer.
  90184. * @hidden Internal use only.
  90185. */
  90186. _uniformBuffer: UniformBuffer;
  90187. /** @hidden */
  90188. _renderId: number;
  90189. /**
  90190. * Creates a Light object in the scene.
  90191. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90192. * @param name The firendly name of the light
  90193. * @param scene The scene the light belongs too
  90194. */
  90195. constructor(name: string, scene: Scene);
  90196. protected abstract _buildUniformLayout(): void;
  90197. /**
  90198. * Sets the passed Effect "effect" with the Light information.
  90199. * @param effect The effect to update
  90200. * @param lightIndex The index of the light in the effect to update
  90201. * @returns The light
  90202. */
  90203. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90204. /**
  90205. * Sets the passed Effect "effect" with the Light textures.
  90206. * @param effect The effect to update
  90207. * @param lightIndex The index of the light in the effect to update
  90208. * @returns The light
  90209. */
  90210. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90211. /**
  90212. * Binds the lights information from the scene to the effect for the given mesh.
  90213. * @param lightIndex Light index
  90214. * @param scene The scene where the light belongs to
  90215. * @param effect The effect we are binding the data to
  90216. * @param useSpecular Defines if specular is supported
  90217. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90218. */
  90219. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90220. /**
  90221. * Sets the passed Effect "effect" with the Light information.
  90222. * @param effect The effect to update
  90223. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90224. * @returns The light
  90225. */
  90226. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90227. /**
  90228. * Returns the string "Light".
  90229. * @returns the class name
  90230. */
  90231. getClassName(): string;
  90232. /** @hidden */
  90233. readonly _isLight: boolean;
  90234. /**
  90235. * Converts the light information to a readable string for debug purpose.
  90236. * @param fullDetails Supports for multiple levels of logging within scene loading
  90237. * @returns the human readable light info
  90238. */
  90239. toString(fullDetails?: boolean): string;
  90240. /** @hidden */
  90241. protected _syncParentEnabledState(): void;
  90242. /**
  90243. * Set the enabled state of this node.
  90244. * @param value - the new enabled state
  90245. */
  90246. setEnabled(value: boolean): void;
  90247. /**
  90248. * Returns the Light associated shadow generator if any.
  90249. * @return the associated shadow generator.
  90250. */
  90251. getShadowGenerator(): Nullable<IShadowGenerator>;
  90252. /**
  90253. * Returns a Vector3, the absolute light position in the World.
  90254. * @returns the world space position of the light
  90255. */
  90256. getAbsolutePosition(): Vector3;
  90257. /**
  90258. * Specifies if the light will affect the passed mesh.
  90259. * @param mesh The mesh to test against the light
  90260. * @return true the mesh is affected otherwise, false.
  90261. */
  90262. canAffectMesh(mesh: AbstractMesh): boolean;
  90263. /**
  90264. * Sort function to order lights for rendering.
  90265. * @param a First Light object to compare to second.
  90266. * @param b Second Light object to compare first.
  90267. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90268. */
  90269. static CompareLightsPriority(a: Light, b: Light): number;
  90270. /**
  90271. * Releases resources associated with this node.
  90272. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90273. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90274. */
  90275. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90276. /**
  90277. * Returns the light type ID (integer).
  90278. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90279. */
  90280. getTypeID(): number;
  90281. /**
  90282. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90283. * @returns the scaled intensity in intensity mode unit
  90284. */
  90285. getScaledIntensity(): number;
  90286. /**
  90287. * Returns a new Light object, named "name", from the current one.
  90288. * @param name The name of the cloned light
  90289. * @param newParent The parent of this light, if it has one
  90290. * @returns the new created light
  90291. */
  90292. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  90293. /**
  90294. * Serializes the current light into a Serialization object.
  90295. * @returns the serialized object.
  90296. */
  90297. serialize(): any;
  90298. /**
  90299. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90300. * This new light is named "name" and added to the passed scene.
  90301. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90302. * @param name The friendly name of the light
  90303. * @param scene The scene the new light will belong to
  90304. * @returns the constructor function
  90305. */
  90306. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90307. /**
  90308. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90309. * @param parsedLight The JSON representation of the light
  90310. * @param scene The scene to create the parsed light in
  90311. * @returns the created light after parsing
  90312. */
  90313. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90314. private _hookArrayForExcluded;
  90315. private _hookArrayForIncludedOnly;
  90316. private _resyncMeshes;
  90317. /**
  90318. * Forces the meshes to update their light related information in their rendering used effects
  90319. * @hidden Internal Use Only
  90320. */
  90321. _markMeshesAsLightDirty(): void;
  90322. /**
  90323. * Recomputes the cached photometric scale if needed.
  90324. */
  90325. private _computePhotometricScale;
  90326. /**
  90327. * Returns the Photometric Scale according to the light type and intensity mode.
  90328. */
  90329. private _getPhotometricScale;
  90330. /**
  90331. * Reorder the light in the scene according to their defined priority.
  90332. * @hidden Internal Use Only
  90333. */
  90334. _reorderLightsInScene(): void;
  90335. /**
  90336. * Prepares the list of defines specific to the light type.
  90337. * @param defines the list of defines
  90338. * @param lightIndex defines the index of the light for the effect
  90339. */
  90340. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90341. }
  90342. }
  90343. declare module BABYLON {
  90344. /** Defines supported spaces */
  90345. export enum Space {
  90346. /** Local (object) space */
  90347. LOCAL = 0,
  90348. /** World space */
  90349. WORLD = 1,
  90350. /** Bone space */
  90351. BONE = 2
  90352. }
  90353. /** Defines the 3 main axes */
  90354. export class Axis {
  90355. /** X axis */
  90356. static X: Vector3;
  90357. /** Y axis */
  90358. static Y: Vector3;
  90359. /** Z axis */
  90360. static Z: Vector3;
  90361. }
  90362. /**
  90363. * Defines cartesian components.
  90364. */
  90365. export enum Coordinate {
  90366. /** X axis */
  90367. X = 0,
  90368. /** Y axis */
  90369. Y = 1,
  90370. /** Z axis */
  90371. Z = 2
  90372. }
  90373. }
  90374. declare module BABYLON {
  90375. /**
  90376. * Interface describing all the common properties and methods a shadow light needs to implement.
  90377. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  90378. * as well as binding the different shadow properties to the effects.
  90379. */
  90380. export interface IShadowLight extends Light {
  90381. /**
  90382. * The light id in the scene (used in scene.findLighById for instance)
  90383. */
  90384. id: string;
  90385. /**
  90386. * The position the shdow will be casted from.
  90387. */
  90388. position: Vector3;
  90389. /**
  90390. * In 2d mode (needCube being false), the direction used to cast the shadow.
  90391. */
  90392. direction: Vector3;
  90393. /**
  90394. * The transformed position. Position of the light in world space taking parenting in account.
  90395. */
  90396. transformedPosition: Vector3;
  90397. /**
  90398. * The transformed direction. Direction of the light in world space taking parenting in account.
  90399. */
  90400. transformedDirection: Vector3;
  90401. /**
  90402. * The friendly name of the light in the scene.
  90403. */
  90404. name: string;
  90405. /**
  90406. * Defines the shadow projection clipping minimum z value.
  90407. */
  90408. shadowMinZ: number;
  90409. /**
  90410. * Defines the shadow projection clipping maximum z value.
  90411. */
  90412. shadowMaxZ: number;
  90413. /**
  90414. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90415. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90416. */
  90417. computeTransformedInformation(): boolean;
  90418. /**
  90419. * Gets the scene the light belongs to.
  90420. * @returns The scene
  90421. */
  90422. getScene(): Scene;
  90423. /**
  90424. * Callback defining a custom Projection Matrix Builder.
  90425. * This can be used to override the default projection matrix computation.
  90426. */
  90427. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90428. /**
  90429. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90430. * @param matrix The materix to updated with the projection information
  90431. * @param viewMatrix The transform matrix of the light
  90432. * @param renderList The list of mesh to render in the map
  90433. * @returns The current light
  90434. */
  90435. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90436. /**
  90437. * Gets the current depth scale used in ESM.
  90438. * @returns The scale
  90439. */
  90440. getDepthScale(): number;
  90441. /**
  90442. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90443. * @returns true if a cube texture needs to be use
  90444. */
  90445. needCube(): boolean;
  90446. /**
  90447. * Detects if the projection matrix requires to be recomputed this frame.
  90448. * @returns true if it requires to be recomputed otherwise, false.
  90449. */
  90450. needProjectionMatrixCompute(): boolean;
  90451. /**
  90452. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90453. */
  90454. forceProjectionMatrixCompute(): void;
  90455. /**
  90456. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90457. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90458. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90459. */
  90460. getShadowDirection(faceIndex?: number): Vector3;
  90461. /**
  90462. * Gets the minZ used for shadow according to both the scene and the light.
  90463. * @param activeCamera The camera we are returning the min for
  90464. * @returns the depth min z
  90465. */
  90466. getDepthMinZ(activeCamera: Camera): number;
  90467. /**
  90468. * Gets the maxZ used for shadow according to both the scene and the light.
  90469. * @param activeCamera The camera we are returning the max for
  90470. * @returns the depth max z
  90471. */
  90472. getDepthMaxZ(activeCamera: Camera): number;
  90473. }
  90474. /**
  90475. * Base implementation IShadowLight
  90476. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  90477. */
  90478. export abstract class ShadowLight extends Light implements IShadowLight {
  90479. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  90480. protected _position: Vector3;
  90481. protected _setPosition(value: Vector3): void;
  90482. /**
  90483. * Sets the position the shadow will be casted from. Also use as the light position for both
  90484. * point and spot lights.
  90485. */
  90486. get position(): Vector3;
  90487. /**
  90488. * Sets the position the shadow will be casted from. Also use as the light position for both
  90489. * point and spot lights.
  90490. */
  90491. set position(value: Vector3);
  90492. protected _direction: Vector3;
  90493. protected _setDirection(value: Vector3): void;
  90494. /**
  90495. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  90496. * Also use as the light direction on spot and directional lights.
  90497. */
  90498. get direction(): Vector3;
  90499. /**
  90500. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  90501. * Also use as the light direction on spot and directional lights.
  90502. */
  90503. set direction(value: Vector3);
  90504. protected _shadowMinZ: number;
  90505. /**
  90506. * Gets the shadow projection clipping minimum z value.
  90507. */
  90508. get shadowMinZ(): number;
  90509. /**
  90510. * Sets the shadow projection clipping minimum z value.
  90511. */
  90512. set shadowMinZ(value: number);
  90513. protected _shadowMaxZ: number;
  90514. /**
  90515. * Sets the shadow projection clipping maximum z value.
  90516. */
  90517. get shadowMaxZ(): number;
  90518. /**
  90519. * Gets the shadow projection clipping maximum z value.
  90520. */
  90521. set shadowMaxZ(value: number);
  90522. /**
  90523. * Callback defining a custom Projection Matrix Builder.
  90524. * This can be used to override the default projection matrix computation.
  90525. */
  90526. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90527. /**
  90528. * The transformed position. Position of the light in world space taking parenting in account.
  90529. */
  90530. transformedPosition: Vector3;
  90531. /**
  90532. * The transformed direction. Direction of the light in world space taking parenting in account.
  90533. */
  90534. transformedDirection: Vector3;
  90535. private _needProjectionMatrixCompute;
  90536. /**
  90537. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90538. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90539. */
  90540. computeTransformedInformation(): boolean;
  90541. /**
  90542. * Return the depth scale used for the shadow map.
  90543. * @returns the depth scale.
  90544. */
  90545. getDepthScale(): number;
  90546. /**
  90547. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90548. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90549. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90550. */
  90551. getShadowDirection(faceIndex?: number): Vector3;
  90552. /**
  90553. * Returns the ShadowLight absolute position in the World.
  90554. * @returns the position vector in world space
  90555. */
  90556. getAbsolutePosition(): Vector3;
  90557. /**
  90558. * Sets the ShadowLight direction toward the passed target.
  90559. * @param target The point to target in local space
  90560. * @returns the updated ShadowLight direction
  90561. */
  90562. setDirectionToTarget(target: Vector3): Vector3;
  90563. /**
  90564. * Returns the light rotation in euler definition.
  90565. * @returns the x y z rotation in local space.
  90566. */
  90567. getRotation(): Vector3;
  90568. /**
  90569. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90570. * @returns true if a cube texture needs to be use
  90571. */
  90572. needCube(): boolean;
  90573. /**
  90574. * Detects if the projection matrix requires to be recomputed this frame.
  90575. * @returns true if it requires to be recomputed otherwise, false.
  90576. */
  90577. needProjectionMatrixCompute(): boolean;
  90578. /**
  90579. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90580. */
  90581. forceProjectionMatrixCompute(): void;
  90582. /** @hidden */
  90583. _initCache(): void;
  90584. /** @hidden */
  90585. _isSynchronized(): boolean;
  90586. /**
  90587. * Computes the world matrix of the node
  90588. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90589. * @returns the world matrix
  90590. */
  90591. computeWorldMatrix(force?: boolean): Matrix;
  90592. /**
  90593. * Gets the minZ used for shadow according to both the scene and the light.
  90594. * @param activeCamera The camera we are returning the min for
  90595. * @returns the depth min z
  90596. */
  90597. getDepthMinZ(activeCamera: Camera): number;
  90598. /**
  90599. * Gets the maxZ used for shadow according to both the scene and the light.
  90600. * @param activeCamera The camera we are returning the max for
  90601. * @returns the depth max z
  90602. */
  90603. getDepthMaxZ(activeCamera: Camera): number;
  90604. /**
  90605. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90606. * @param matrix The materix to updated with the projection information
  90607. * @param viewMatrix The transform matrix of the light
  90608. * @param renderList The list of mesh to render in the map
  90609. * @returns The current light
  90610. */
  90611. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90612. }
  90613. }
  90614. declare module BABYLON {
  90615. /**
  90616. * Configuration needed for prepass-capable materials
  90617. */
  90618. export class PrePassConfiguration {
  90619. /**
  90620. * Previous world matrices of meshes carrying this material
  90621. * Used for computing velocity
  90622. */
  90623. previousWorldMatrices: {
  90624. [index: number]: Matrix;
  90625. };
  90626. /**
  90627. * Previous view project matrix
  90628. * Used for computing velocity
  90629. */
  90630. previousViewProjection: Matrix;
  90631. /**
  90632. * Previous bones of meshes carrying this material
  90633. * Used for computing velocity
  90634. */
  90635. previousBones: {
  90636. [index: number]: Float32Array;
  90637. };
  90638. /**
  90639. * Add the required uniforms to the current list.
  90640. * @param uniforms defines the current uniform list.
  90641. */
  90642. static AddUniforms(uniforms: string[]): void;
  90643. /**
  90644. * Add the required samplers to the current list.
  90645. * @param samplers defines the current sampler list.
  90646. */
  90647. static AddSamplers(samplers: string[]): void;
  90648. /**
  90649. * Binds the material data.
  90650. * @param effect defines the effect to update
  90651. * @param scene defines the scene the material belongs to.
  90652. * @param mesh The mesh
  90653. * @param world World matrix of this mesh
  90654. * @param isFrozen Is the material frozen
  90655. */
  90656. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  90657. }
  90658. }
  90659. declare module BABYLON {
  90660. /**
  90661. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  90662. * This is the base of the follow, arc rotate cameras and Free camera
  90663. * @see https://doc.babylonjs.com/features/cameras
  90664. */
  90665. export class TargetCamera extends Camera {
  90666. private static _RigCamTransformMatrix;
  90667. private static _TargetTransformMatrix;
  90668. private static _TargetFocalPoint;
  90669. private _tmpUpVector;
  90670. private _tmpTargetVector;
  90671. /**
  90672. * Define the current direction the camera is moving to
  90673. */
  90674. cameraDirection: Vector3;
  90675. /**
  90676. * Define the current rotation the camera is rotating to
  90677. */
  90678. cameraRotation: Vector2;
  90679. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  90680. ignoreParentScaling: boolean;
  90681. /**
  90682. * When set, the up vector of the camera will be updated by the rotation of the camera
  90683. */
  90684. updateUpVectorFromRotation: boolean;
  90685. private _tmpQuaternion;
  90686. /**
  90687. * Define the current rotation of the camera
  90688. */
  90689. rotation: Vector3;
  90690. /**
  90691. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  90692. */
  90693. rotationQuaternion: Quaternion;
  90694. /**
  90695. * Define the current speed of the camera
  90696. */
  90697. speed: number;
  90698. /**
  90699. * Add constraint to the camera to prevent it to move freely in all directions and
  90700. * around all axis.
  90701. */
  90702. noRotationConstraint: boolean;
  90703. /**
  90704. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  90705. * panning
  90706. */
  90707. invertRotation: boolean;
  90708. /**
  90709. * Speed multiplier for inverse camera panning
  90710. */
  90711. inverseRotationSpeed: number;
  90712. /**
  90713. * Define the current target of the camera as an object or a position.
  90714. */
  90715. lockedTarget: any;
  90716. /** @hidden */
  90717. _currentTarget: Vector3;
  90718. /** @hidden */
  90719. _initialFocalDistance: number;
  90720. /** @hidden */
  90721. _viewMatrix: Matrix;
  90722. /** @hidden */
  90723. _camMatrix: Matrix;
  90724. /** @hidden */
  90725. _cameraTransformMatrix: Matrix;
  90726. /** @hidden */
  90727. _cameraRotationMatrix: Matrix;
  90728. /** @hidden */
  90729. _referencePoint: Vector3;
  90730. /** @hidden */
  90731. _transformedReferencePoint: Vector3;
  90732. /** @hidden */
  90733. _reset: () => void;
  90734. private _defaultUp;
  90735. /**
  90736. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  90737. * This is the base of the follow, arc rotate cameras and Free camera
  90738. * @see https://doc.babylonjs.com/features/cameras
  90739. * @param name Defines the name of the camera in the scene
  90740. * @param position Defines the start position of the camera in the scene
  90741. * @param scene Defines the scene the camera belongs to
  90742. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90743. */
  90744. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90745. /**
  90746. * Gets the position in front of the camera at a given distance.
  90747. * @param distance The distance from the camera we want the position to be
  90748. * @returns the position
  90749. */
  90750. getFrontPosition(distance: number): Vector3;
  90751. /** @hidden */
  90752. _getLockedTargetPosition(): Nullable<Vector3>;
  90753. private _storedPosition;
  90754. private _storedRotation;
  90755. private _storedRotationQuaternion;
  90756. /**
  90757. * Store current camera state of the camera (fov, position, rotation, etc..)
  90758. * @returns the camera
  90759. */
  90760. storeState(): Camera;
  90761. /**
  90762. * Restored camera state. You must call storeState() first
  90763. * @returns whether it was successful or not
  90764. * @hidden
  90765. */
  90766. _restoreStateValues(): boolean;
  90767. /** @hidden */
  90768. _initCache(): void;
  90769. /** @hidden */
  90770. _updateCache(ignoreParentClass?: boolean): void;
  90771. /** @hidden */
  90772. _isSynchronizedViewMatrix(): boolean;
  90773. /** @hidden */
  90774. _computeLocalCameraSpeed(): number;
  90775. /**
  90776. * Defines the target the camera should look at.
  90777. * @param target Defines the new target as a Vector or a mesh
  90778. */
  90779. setTarget(target: Vector3): void;
  90780. /**
  90781. * Defines the target point of the camera.
  90782. * The camera looks towards it form the radius distance.
  90783. */
  90784. get target(): Vector3;
  90785. set target(value: Vector3);
  90786. /**
  90787. * Return the current target position of the camera. This value is expressed in local space.
  90788. * @returns the target position
  90789. */
  90790. getTarget(): Vector3;
  90791. /** @hidden */
  90792. _decideIfNeedsToMove(): boolean;
  90793. /** @hidden */
  90794. _updatePosition(): void;
  90795. /** @hidden */
  90796. _checkInputs(): void;
  90797. protected _updateCameraRotationMatrix(): void;
  90798. /**
  90799. * 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)
  90800. * @returns the current camera
  90801. */
  90802. private _rotateUpVectorWithCameraRotationMatrix;
  90803. private _cachedRotationZ;
  90804. private _cachedQuaternionRotationZ;
  90805. /** @hidden */
  90806. _getViewMatrix(): Matrix;
  90807. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  90808. /**
  90809. * @hidden
  90810. */
  90811. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90812. /**
  90813. * @hidden
  90814. */
  90815. _updateRigCameras(): void;
  90816. private _getRigCamPositionAndTarget;
  90817. /**
  90818. * Gets the current object class name.
  90819. * @return the class name
  90820. */
  90821. getClassName(): string;
  90822. }
  90823. }
  90824. declare module BABYLON {
  90825. /**
  90826. * @ignore
  90827. * This is a list of all the different input types that are available in the application.
  90828. * Fo instance: ArcRotateCameraGamepadInput...
  90829. */
  90830. export var CameraInputTypes: {};
  90831. /**
  90832. * This is the contract to implement in order to create a new input class.
  90833. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  90834. */
  90835. export interface ICameraInput<TCamera extends Camera> {
  90836. /**
  90837. * Defines the camera the input is attached to.
  90838. */
  90839. camera: Nullable<TCamera>;
  90840. /**
  90841. * Gets the class name of the current intput.
  90842. * @returns the class name
  90843. */
  90844. getClassName(): string;
  90845. /**
  90846. * Get the friendly name associated with the input class.
  90847. * @returns the input friendly name
  90848. */
  90849. getSimpleName(): string;
  90850. /**
  90851. * Attach the input controls to a specific dom element to get the input from.
  90852. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90853. */
  90854. attachControl(noPreventDefault?: boolean): void;
  90855. /**
  90856. * Detach the current controls from the specified dom element.
  90857. */
  90858. detachControl(): void;
  90859. /**
  90860. * Update the current camera state depending on the inputs that have been used this frame.
  90861. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90862. */
  90863. checkInputs?: () => void;
  90864. }
  90865. /**
  90866. * Represents a map of input types to input instance or input index to input instance.
  90867. */
  90868. export interface CameraInputsMap<TCamera extends Camera> {
  90869. /**
  90870. * Accessor to the input by input type.
  90871. */
  90872. [name: string]: ICameraInput<TCamera>;
  90873. /**
  90874. * Accessor to the input by input index.
  90875. */
  90876. [idx: number]: ICameraInput<TCamera>;
  90877. }
  90878. /**
  90879. * This represents the input manager used within a camera.
  90880. * It helps dealing with all the different kind of input attached to a camera.
  90881. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90882. */
  90883. export class CameraInputsManager<TCamera extends Camera> {
  90884. /**
  90885. * Defines the list of inputs attahed to the camera.
  90886. */
  90887. attached: CameraInputsMap<TCamera>;
  90888. /**
  90889. * Defines the dom element the camera is collecting inputs from.
  90890. * This is null if the controls have not been attached.
  90891. */
  90892. attachedToElement: boolean;
  90893. /**
  90894. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90895. */
  90896. noPreventDefault: boolean;
  90897. /**
  90898. * Defined the camera the input manager belongs to.
  90899. */
  90900. camera: TCamera;
  90901. /**
  90902. * Update the current camera state depending on the inputs that have been used this frame.
  90903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90904. */
  90905. checkInputs: () => void;
  90906. /**
  90907. * Instantiate a new Camera Input Manager.
  90908. * @param camera Defines the camera the input manager blongs to
  90909. */
  90910. constructor(camera: TCamera);
  90911. /**
  90912. * Add an input method to a camera
  90913. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90914. * @param input camera input method
  90915. */
  90916. add(input: ICameraInput<TCamera>): void;
  90917. /**
  90918. * Remove a specific input method from a camera
  90919. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  90920. * @param inputToRemove camera input method
  90921. */
  90922. remove(inputToRemove: ICameraInput<TCamera>): void;
  90923. /**
  90924. * Remove a specific input type from a camera
  90925. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  90926. * @param inputType the type of the input to remove
  90927. */
  90928. removeByType(inputType: string): void;
  90929. private _addCheckInputs;
  90930. /**
  90931. * Attach the input controls to the currently attached dom element to listen the events from.
  90932. * @param input Defines the input to attach
  90933. */
  90934. attachInput(input: ICameraInput<TCamera>): void;
  90935. /**
  90936. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  90937. * @param element Defines the dom element to collect the events from
  90938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90939. */
  90940. attachElement(noPreventDefault?: boolean): void;
  90941. /**
  90942. * Detach the current manager inputs controls from a specific dom element.
  90943. * @param element Defines the dom element to collect the events from
  90944. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  90945. */
  90946. detachElement(disconnect?: boolean): void;
  90947. /**
  90948. * Rebuild the dynamic inputCheck function from the current list of
  90949. * defined inputs in the manager.
  90950. */
  90951. rebuildInputCheck(): void;
  90952. /**
  90953. * Remove all attached input methods from a camera
  90954. */
  90955. clear(): void;
  90956. /**
  90957. * Serialize the current input manager attached to a camera.
  90958. * This ensures than once parsed,
  90959. * the input associated to the camera will be identical to the current ones
  90960. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  90961. */
  90962. serialize(serializedCamera: any): void;
  90963. /**
  90964. * Parses an input manager serialized JSON to restore the previous list of inputs
  90965. * and states associated to a camera.
  90966. * @param parsedCamera Defines the JSON to parse
  90967. */
  90968. parse(parsedCamera: any): void;
  90969. }
  90970. }
  90971. declare module BABYLON {
  90972. /**
  90973. * Gather the list of keyboard event types as constants.
  90974. */
  90975. export class KeyboardEventTypes {
  90976. /**
  90977. * The keydown event is fired when a key becomes active (pressed).
  90978. */
  90979. static readonly KEYDOWN: number;
  90980. /**
  90981. * The keyup event is fired when a key has been released.
  90982. */
  90983. static readonly KEYUP: number;
  90984. }
  90985. /**
  90986. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90987. */
  90988. export class KeyboardInfo {
  90989. /**
  90990. * Defines the type of event (KeyboardEventTypes)
  90991. */
  90992. type: number;
  90993. /**
  90994. * Defines the related dom event
  90995. */
  90996. event: KeyboardEvent;
  90997. /**
  90998. * Instantiates a new keyboard info.
  90999. * This class is used to store keyboard related info for the onKeyboardObservable event.
  91000. * @param type Defines the type of event (KeyboardEventTypes)
  91001. * @param event Defines the related dom event
  91002. */
  91003. constructor(
  91004. /**
  91005. * Defines the type of event (KeyboardEventTypes)
  91006. */
  91007. type: number,
  91008. /**
  91009. * Defines the related dom event
  91010. */
  91011. event: KeyboardEvent);
  91012. }
  91013. /**
  91014. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  91015. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  91016. */
  91017. export class KeyboardInfoPre extends KeyboardInfo {
  91018. /**
  91019. * Defines the type of event (KeyboardEventTypes)
  91020. */
  91021. type: number;
  91022. /**
  91023. * Defines the related dom event
  91024. */
  91025. event: KeyboardEvent;
  91026. /**
  91027. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  91028. */
  91029. skipOnPointerObservable: boolean;
  91030. /**
  91031. * Instantiates a new keyboard pre info.
  91032. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  91033. * @param type Defines the type of event (KeyboardEventTypes)
  91034. * @param event Defines the related dom event
  91035. */
  91036. constructor(
  91037. /**
  91038. * Defines the type of event (KeyboardEventTypes)
  91039. */
  91040. type: number,
  91041. /**
  91042. * Defines the related dom event
  91043. */
  91044. event: KeyboardEvent);
  91045. }
  91046. }
  91047. declare module BABYLON {
  91048. /**
  91049. * Manage the keyboard inputs to control the movement of a free camera.
  91050. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  91051. */
  91052. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  91053. /**
  91054. * Defines the camera the input is attached to.
  91055. */
  91056. camera: FreeCamera;
  91057. /**
  91058. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91059. */
  91060. keysUp: number[];
  91061. /**
  91062. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  91063. */
  91064. keysUpward: number[];
  91065. /**
  91066. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91067. */
  91068. keysDown: number[];
  91069. /**
  91070. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  91071. */
  91072. keysDownward: number[];
  91073. /**
  91074. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91075. */
  91076. keysLeft: number[];
  91077. /**
  91078. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91079. */
  91080. keysRight: number[];
  91081. private _keys;
  91082. private _onCanvasBlurObserver;
  91083. private _onKeyboardObserver;
  91084. private _engine;
  91085. private _scene;
  91086. /**
  91087. * Attach the input controls to a specific dom element to get the input from.
  91088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91089. */
  91090. attachControl(noPreventDefault?: boolean): void;
  91091. /**
  91092. * Detach the current controls from the specified dom element.
  91093. */
  91094. detachControl(): void;
  91095. /**
  91096. * Update the current camera state depending on the inputs that have been used this frame.
  91097. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91098. */
  91099. checkInputs(): void;
  91100. /**
  91101. * Gets the class name of the current intput.
  91102. * @returns the class name
  91103. */
  91104. getClassName(): string;
  91105. /** @hidden */
  91106. _onLostFocus(): void;
  91107. /**
  91108. * Get the friendly name associated with the input class.
  91109. * @returns the input friendly name
  91110. */
  91111. getSimpleName(): string;
  91112. }
  91113. }
  91114. declare module BABYLON {
  91115. /**
  91116. * Interface used to define Action
  91117. */
  91118. export interface IAction {
  91119. /**
  91120. * Trigger for the action
  91121. */
  91122. trigger: number;
  91123. /** Options of the trigger */
  91124. triggerOptions: any;
  91125. /**
  91126. * Gets the trigger parameters
  91127. * @returns the trigger parameters
  91128. */
  91129. getTriggerParameter(): any;
  91130. /**
  91131. * Internal only - executes current action event
  91132. * @hidden
  91133. */
  91134. _executeCurrent(evt?: ActionEvent): void;
  91135. /**
  91136. * Serialize placeholder for child classes
  91137. * @param parent of child
  91138. * @returns the serialized object
  91139. */
  91140. serialize(parent: any): any;
  91141. /**
  91142. * Internal only
  91143. * @hidden
  91144. */
  91145. _prepare(): void;
  91146. /**
  91147. * Internal only - manager for action
  91148. * @hidden
  91149. */
  91150. _actionManager: Nullable<AbstractActionManager>;
  91151. /**
  91152. * Adds action to chain of actions, may be a DoNothingAction
  91153. * @param action defines the next action to execute
  91154. * @returns The action passed in
  91155. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91156. */
  91157. then(action: IAction): IAction;
  91158. }
  91159. /**
  91160. * The action to be carried out following a trigger
  91161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91162. */
  91163. export class Action implements IAction {
  91164. /** the trigger, with or without parameters, for the action */
  91165. triggerOptions: any;
  91166. /**
  91167. * Trigger for the action
  91168. */
  91169. trigger: number;
  91170. /**
  91171. * Internal only - manager for action
  91172. * @hidden
  91173. */
  91174. _actionManager: ActionManager;
  91175. private _nextActiveAction;
  91176. private _child;
  91177. private _condition?;
  91178. private _triggerParameter;
  91179. /**
  91180. * An event triggered prior to action being executed.
  91181. */
  91182. onBeforeExecuteObservable: Observable<Action>;
  91183. /**
  91184. * Creates a new Action
  91185. * @param triggerOptions the trigger, with or without parameters, for the action
  91186. * @param condition an optional determinant of action
  91187. */
  91188. constructor(
  91189. /** the trigger, with or without parameters, for the action */
  91190. triggerOptions: any, condition?: Condition);
  91191. /**
  91192. * Internal only
  91193. * @hidden
  91194. */
  91195. _prepare(): void;
  91196. /**
  91197. * Gets the trigger parameters
  91198. * @returns the trigger parameters
  91199. */
  91200. getTriggerParameter(): any;
  91201. /**
  91202. * Internal only - executes current action event
  91203. * @hidden
  91204. */
  91205. _executeCurrent(evt?: ActionEvent): void;
  91206. /**
  91207. * Execute placeholder for child classes
  91208. * @param evt optional action event
  91209. */
  91210. execute(evt?: ActionEvent): void;
  91211. /**
  91212. * Skips to next active action
  91213. */
  91214. skipToNextActiveAction(): void;
  91215. /**
  91216. * Adds action to chain of actions, may be a DoNothingAction
  91217. * @param action defines the next action to execute
  91218. * @returns The action passed in
  91219. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91220. */
  91221. then(action: Action): Action;
  91222. /**
  91223. * Internal only
  91224. * @hidden
  91225. */
  91226. _getProperty(propertyPath: string): string;
  91227. /**
  91228. * Internal only
  91229. * @hidden
  91230. */
  91231. _getEffectiveTarget(target: any, propertyPath: string): any;
  91232. /**
  91233. * Serialize placeholder for child classes
  91234. * @param parent of child
  91235. * @returns the serialized object
  91236. */
  91237. serialize(parent: any): any;
  91238. /**
  91239. * Internal only called by serialize
  91240. * @hidden
  91241. */
  91242. protected _serialize(serializedAction: any, parent?: any): any;
  91243. /**
  91244. * Internal only
  91245. * @hidden
  91246. */
  91247. static _SerializeValueAsString: (value: any) => string;
  91248. /**
  91249. * Internal only
  91250. * @hidden
  91251. */
  91252. static _GetTargetProperty: (target: Scene | Node) => {
  91253. name: string;
  91254. targetType: string;
  91255. value: string;
  91256. };
  91257. }
  91258. }
  91259. declare module BABYLON {
  91260. /**
  91261. * A Condition applied to an Action
  91262. */
  91263. export class Condition {
  91264. /**
  91265. * Internal only - manager for action
  91266. * @hidden
  91267. */
  91268. _actionManager: ActionManager;
  91269. /**
  91270. * Internal only
  91271. * @hidden
  91272. */
  91273. _evaluationId: number;
  91274. /**
  91275. * Internal only
  91276. * @hidden
  91277. */
  91278. _currentResult: boolean;
  91279. /**
  91280. * Creates a new Condition
  91281. * @param actionManager the manager of the action the condition is applied to
  91282. */
  91283. constructor(actionManager: ActionManager);
  91284. /**
  91285. * Check if the current condition is valid
  91286. * @returns a boolean
  91287. */
  91288. isValid(): boolean;
  91289. /**
  91290. * Internal only
  91291. * @hidden
  91292. */
  91293. _getProperty(propertyPath: string): string;
  91294. /**
  91295. * Internal only
  91296. * @hidden
  91297. */
  91298. _getEffectiveTarget(target: any, propertyPath: string): any;
  91299. /**
  91300. * Serialize placeholder for child classes
  91301. * @returns the serialized object
  91302. */
  91303. serialize(): any;
  91304. /**
  91305. * Internal only
  91306. * @hidden
  91307. */
  91308. protected _serialize(serializedCondition: any): any;
  91309. }
  91310. /**
  91311. * Defines specific conditional operators as extensions of Condition
  91312. */
  91313. export class ValueCondition extends Condition {
  91314. /** path to specify the property of the target the conditional operator uses */
  91315. propertyPath: string;
  91316. /** the value compared by the conditional operator against the current value of the property */
  91317. value: any;
  91318. /** the conditional operator, default ValueCondition.IsEqual */
  91319. operator: number;
  91320. /**
  91321. * Internal only
  91322. * @hidden
  91323. */
  91324. private static _IsEqual;
  91325. /**
  91326. * Internal only
  91327. * @hidden
  91328. */
  91329. private static _IsDifferent;
  91330. /**
  91331. * Internal only
  91332. * @hidden
  91333. */
  91334. private static _IsGreater;
  91335. /**
  91336. * Internal only
  91337. * @hidden
  91338. */
  91339. private static _IsLesser;
  91340. /**
  91341. * returns the number for IsEqual
  91342. */
  91343. static get IsEqual(): number;
  91344. /**
  91345. * Returns the number for IsDifferent
  91346. */
  91347. static get IsDifferent(): number;
  91348. /**
  91349. * Returns the number for IsGreater
  91350. */
  91351. static get IsGreater(): number;
  91352. /**
  91353. * Returns the number for IsLesser
  91354. */
  91355. static get IsLesser(): number;
  91356. /**
  91357. * Internal only The action manager for the condition
  91358. * @hidden
  91359. */
  91360. _actionManager: ActionManager;
  91361. /**
  91362. * Internal only
  91363. * @hidden
  91364. */
  91365. private _target;
  91366. /**
  91367. * Internal only
  91368. * @hidden
  91369. */
  91370. private _effectiveTarget;
  91371. /**
  91372. * Internal only
  91373. * @hidden
  91374. */
  91375. private _property;
  91376. /**
  91377. * Creates a new ValueCondition
  91378. * @param actionManager manager for the action the condition applies to
  91379. * @param target for the action
  91380. * @param propertyPath path to specify the property of the target the conditional operator uses
  91381. * @param value the value compared by the conditional operator against the current value of the property
  91382. * @param operator the conditional operator, default ValueCondition.IsEqual
  91383. */
  91384. constructor(actionManager: ActionManager, target: any,
  91385. /** path to specify the property of the target the conditional operator uses */
  91386. propertyPath: string,
  91387. /** the value compared by the conditional operator against the current value of the property */
  91388. value: any,
  91389. /** the conditional operator, default ValueCondition.IsEqual */
  91390. operator?: number);
  91391. /**
  91392. * Compares the given value with the property value for the specified conditional operator
  91393. * @returns the result of the comparison
  91394. */
  91395. isValid(): boolean;
  91396. /**
  91397. * Serialize the ValueCondition into a JSON compatible object
  91398. * @returns serialization object
  91399. */
  91400. serialize(): any;
  91401. /**
  91402. * Gets the name of the conditional operator for the ValueCondition
  91403. * @param operator the conditional operator
  91404. * @returns the name
  91405. */
  91406. static GetOperatorName(operator: number): string;
  91407. }
  91408. /**
  91409. * Defines a predicate condition as an extension of Condition
  91410. */
  91411. export class PredicateCondition extends Condition {
  91412. /** defines the predicate function used to validate the condition */
  91413. predicate: () => boolean;
  91414. /**
  91415. * Internal only - manager for action
  91416. * @hidden
  91417. */
  91418. _actionManager: ActionManager;
  91419. /**
  91420. * Creates a new PredicateCondition
  91421. * @param actionManager manager for the action the condition applies to
  91422. * @param predicate defines the predicate function used to validate the condition
  91423. */
  91424. constructor(actionManager: ActionManager,
  91425. /** defines the predicate function used to validate the condition */
  91426. predicate: () => boolean);
  91427. /**
  91428. * @returns the validity of the predicate condition
  91429. */
  91430. isValid(): boolean;
  91431. }
  91432. /**
  91433. * Defines a state condition as an extension of Condition
  91434. */
  91435. export class StateCondition extends Condition {
  91436. /** Value to compare with target state */
  91437. value: string;
  91438. /**
  91439. * Internal only - manager for action
  91440. * @hidden
  91441. */
  91442. _actionManager: ActionManager;
  91443. /**
  91444. * Internal only
  91445. * @hidden
  91446. */
  91447. private _target;
  91448. /**
  91449. * Creates a new StateCondition
  91450. * @param actionManager manager for the action the condition applies to
  91451. * @param target of the condition
  91452. * @param value to compare with target state
  91453. */
  91454. constructor(actionManager: ActionManager, target: any,
  91455. /** Value to compare with target state */
  91456. value: string);
  91457. /**
  91458. * Gets a boolean indicating if the current condition is met
  91459. * @returns the validity of the state
  91460. */
  91461. isValid(): boolean;
  91462. /**
  91463. * Serialize the StateCondition into a JSON compatible object
  91464. * @returns serialization object
  91465. */
  91466. serialize(): any;
  91467. }
  91468. }
  91469. declare module BABYLON {
  91470. /**
  91471. * This defines an action responsible to toggle a boolean once triggered.
  91472. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91473. */
  91474. export class SwitchBooleanAction extends Action {
  91475. /**
  91476. * The path to the boolean property in the target object
  91477. */
  91478. propertyPath: string;
  91479. private _target;
  91480. private _effectiveTarget;
  91481. private _property;
  91482. /**
  91483. * Instantiate the action
  91484. * @param triggerOptions defines the trigger options
  91485. * @param target defines the object containing the boolean
  91486. * @param propertyPath defines the path to the boolean property in the target object
  91487. * @param condition defines the trigger related conditions
  91488. */
  91489. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91490. /** @hidden */
  91491. _prepare(): void;
  91492. /**
  91493. * Execute the action toggle the boolean value.
  91494. */
  91495. execute(): void;
  91496. /**
  91497. * Serializes the actions and its related information.
  91498. * @param parent defines the object to serialize in
  91499. * @returns the serialized object
  91500. */
  91501. serialize(parent: any): any;
  91502. }
  91503. /**
  91504. * This defines an action responsible to set a the state field of the target
  91505. * to a desired value once triggered.
  91506. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91507. */
  91508. export class SetStateAction extends Action {
  91509. /**
  91510. * The value to store in the state field.
  91511. */
  91512. value: string;
  91513. private _target;
  91514. /**
  91515. * Instantiate the action
  91516. * @param triggerOptions defines the trigger options
  91517. * @param target defines the object containing the state property
  91518. * @param value defines the value to store in the state field
  91519. * @param condition defines the trigger related conditions
  91520. */
  91521. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91522. /**
  91523. * Execute the action and store the value on the target state property.
  91524. */
  91525. execute(): void;
  91526. /**
  91527. * Serializes the actions and its related information.
  91528. * @param parent defines the object to serialize in
  91529. * @returns the serialized object
  91530. */
  91531. serialize(parent: any): any;
  91532. }
  91533. /**
  91534. * This defines an action responsible to set a property of the target
  91535. * to a desired value once triggered.
  91536. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91537. */
  91538. export class SetValueAction extends Action {
  91539. /**
  91540. * The path of the property to set in the target.
  91541. */
  91542. propertyPath: string;
  91543. /**
  91544. * The value to set in the property
  91545. */
  91546. value: any;
  91547. private _target;
  91548. private _effectiveTarget;
  91549. private _property;
  91550. /**
  91551. * Instantiate the action
  91552. * @param triggerOptions defines the trigger options
  91553. * @param target defines the object containing the property
  91554. * @param propertyPath defines the path of the property to set in the target
  91555. * @param value defines the value to set in the property
  91556. * @param condition defines the trigger related conditions
  91557. */
  91558. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91559. /** @hidden */
  91560. _prepare(): void;
  91561. /**
  91562. * Execute the action and set the targetted property to the desired value.
  91563. */
  91564. execute(): void;
  91565. /**
  91566. * Serializes the actions and its related information.
  91567. * @param parent defines the object to serialize in
  91568. * @returns the serialized object
  91569. */
  91570. serialize(parent: any): any;
  91571. }
  91572. /**
  91573. * This defines an action responsible to increment the target value
  91574. * to a desired value once triggered.
  91575. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91576. */
  91577. export class IncrementValueAction extends Action {
  91578. /**
  91579. * The path of the property to increment in the target.
  91580. */
  91581. propertyPath: string;
  91582. /**
  91583. * The value we should increment the property by.
  91584. */
  91585. value: any;
  91586. private _target;
  91587. private _effectiveTarget;
  91588. private _property;
  91589. /**
  91590. * Instantiate the action
  91591. * @param triggerOptions defines the trigger options
  91592. * @param target defines the object containing the property
  91593. * @param propertyPath defines the path of the property to increment in the target
  91594. * @param value defines the value value we should increment the property by
  91595. * @param condition defines the trigger related conditions
  91596. */
  91597. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91598. /** @hidden */
  91599. _prepare(): void;
  91600. /**
  91601. * Execute the action and increment the target of the value amount.
  91602. */
  91603. execute(): void;
  91604. /**
  91605. * Serializes the actions and its related information.
  91606. * @param parent defines the object to serialize in
  91607. * @returns the serialized object
  91608. */
  91609. serialize(parent: any): any;
  91610. }
  91611. /**
  91612. * This defines an action responsible to start an animation once triggered.
  91613. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91614. */
  91615. export class PlayAnimationAction extends Action {
  91616. /**
  91617. * Where the animation should start (animation frame)
  91618. */
  91619. from: number;
  91620. /**
  91621. * Where the animation should stop (animation frame)
  91622. */
  91623. to: number;
  91624. /**
  91625. * Define if the animation should loop or stop after the first play.
  91626. */
  91627. loop?: boolean;
  91628. private _target;
  91629. /**
  91630. * Instantiate the action
  91631. * @param triggerOptions defines the trigger options
  91632. * @param target defines the target animation or animation name
  91633. * @param from defines from where the animation should start (animation frame)
  91634. * @param end defines where the animation should stop (animation frame)
  91635. * @param loop defines if the animation should loop or stop after the first play
  91636. * @param condition defines the trigger related conditions
  91637. */
  91638. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91639. /** @hidden */
  91640. _prepare(): void;
  91641. /**
  91642. * Execute the action and play the animation.
  91643. */
  91644. execute(): void;
  91645. /**
  91646. * Serializes the actions and its related information.
  91647. * @param parent defines the object to serialize in
  91648. * @returns the serialized object
  91649. */
  91650. serialize(parent: any): any;
  91651. }
  91652. /**
  91653. * This defines an action responsible to stop an animation once triggered.
  91654. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91655. */
  91656. export class StopAnimationAction extends Action {
  91657. private _target;
  91658. /**
  91659. * Instantiate the action
  91660. * @param triggerOptions defines the trigger options
  91661. * @param target defines the target animation or animation name
  91662. * @param condition defines the trigger related conditions
  91663. */
  91664. constructor(triggerOptions: any, target: any, condition?: Condition);
  91665. /** @hidden */
  91666. _prepare(): void;
  91667. /**
  91668. * Execute the action and stop the animation.
  91669. */
  91670. execute(): void;
  91671. /**
  91672. * Serializes the actions and its related information.
  91673. * @param parent defines the object to serialize in
  91674. * @returns the serialized object
  91675. */
  91676. serialize(parent: any): any;
  91677. }
  91678. /**
  91679. * This defines an action responsible that does nothing once triggered.
  91680. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91681. */
  91682. export class DoNothingAction extends Action {
  91683. /**
  91684. * Instantiate the action
  91685. * @param triggerOptions defines the trigger options
  91686. * @param condition defines the trigger related conditions
  91687. */
  91688. constructor(triggerOptions?: any, condition?: Condition);
  91689. /**
  91690. * Execute the action and do nothing.
  91691. */
  91692. execute(): void;
  91693. /**
  91694. * Serializes the actions and its related information.
  91695. * @param parent defines the object to serialize in
  91696. * @returns the serialized object
  91697. */
  91698. serialize(parent: any): any;
  91699. }
  91700. /**
  91701. * This defines an action responsible to trigger several actions once triggered.
  91702. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91703. */
  91704. export class CombineAction extends Action {
  91705. /**
  91706. * The list of aggregated animations to run.
  91707. */
  91708. children: Action[];
  91709. /**
  91710. * Instantiate the action
  91711. * @param triggerOptions defines the trigger options
  91712. * @param children defines the list of aggregated animations to run
  91713. * @param condition defines the trigger related conditions
  91714. */
  91715. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91716. /** @hidden */
  91717. _prepare(): void;
  91718. /**
  91719. * Execute the action and executes all the aggregated actions.
  91720. */
  91721. execute(evt: ActionEvent): void;
  91722. /**
  91723. * Serializes the actions and its related information.
  91724. * @param parent defines the object to serialize in
  91725. * @returns the serialized object
  91726. */
  91727. serialize(parent: any): any;
  91728. }
  91729. /**
  91730. * This defines an action responsible to run code (external event) once triggered.
  91731. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91732. */
  91733. export class ExecuteCodeAction extends Action {
  91734. /**
  91735. * The callback function to run.
  91736. */
  91737. func: (evt: ActionEvent) => void;
  91738. /**
  91739. * Instantiate the action
  91740. * @param triggerOptions defines the trigger options
  91741. * @param func defines the callback function to run
  91742. * @param condition defines the trigger related conditions
  91743. */
  91744. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91745. /**
  91746. * Execute the action and run the attached code.
  91747. */
  91748. execute(evt: ActionEvent): void;
  91749. }
  91750. /**
  91751. * This defines an action responsible to set the parent property of the target once triggered.
  91752. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91753. */
  91754. export class SetParentAction extends Action {
  91755. private _parent;
  91756. private _target;
  91757. /**
  91758. * Instantiate the action
  91759. * @param triggerOptions defines the trigger options
  91760. * @param target defines the target containing the parent property
  91761. * @param parent defines from where the animation should start (animation frame)
  91762. * @param condition defines the trigger related conditions
  91763. */
  91764. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91765. /** @hidden */
  91766. _prepare(): void;
  91767. /**
  91768. * Execute the action and set the parent property.
  91769. */
  91770. execute(): void;
  91771. /**
  91772. * Serializes the actions and its related information.
  91773. * @param parent defines the object to serialize in
  91774. * @returns the serialized object
  91775. */
  91776. serialize(parent: any): any;
  91777. }
  91778. }
  91779. declare module BABYLON {
  91780. /**
  91781. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91782. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91783. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91784. */
  91785. export class ActionManager extends AbstractActionManager {
  91786. /**
  91787. * Nothing
  91788. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91789. */
  91790. static readonly NothingTrigger: number;
  91791. /**
  91792. * On pick
  91793. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91794. */
  91795. static readonly OnPickTrigger: number;
  91796. /**
  91797. * On left pick
  91798. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91799. */
  91800. static readonly OnLeftPickTrigger: number;
  91801. /**
  91802. * On right pick
  91803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91804. */
  91805. static readonly OnRightPickTrigger: number;
  91806. /**
  91807. * On center pick
  91808. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91809. */
  91810. static readonly OnCenterPickTrigger: number;
  91811. /**
  91812. * On pick down
  91813. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91814. */
  91815. static readonly OnPickDownTrigger: number;
  91816. /**
  91817. * On double pick
  91818. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91819. */
  91820. static readonly OnDoublePickTrigger: number;
  91821. /**
  91822. * On pick up
  91823. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91824. */
  91825. static readonly OnPickUpTrigger: number;
  91826. /**
  91827. * On pick out.
  91828. * This trigger will only be raised if you also declared a OnPickDown
  91829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91830. */
  91831. static readonly OnPickOutTrigger: number;
  91832. /**
  91833. * On long press
  91834. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91835. */
  91836. static readonly OnLongPressTrigger: number;
  91837. /**
  91838. * On pointer over
  91839. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91840. */
  91841. static readonly OnPointerOverTrigger: number;
  91842. /**
  91843. * On pointer out
  91844. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91845. */
  91846. static readonly OnPointerOutTrigger: number;
  91847. /**
  91848. * On every frame
  91849. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91850. */
  91851. static readonly OnEveryFrameTrigger: number;
  91852. /**
  91853. * On intersection enter
  91854. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91855. */
  91856. static readonly OnIntersectionEnterTrigger: number;
  91857. /**
  91858. * On intersection exit
  91859. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91860. */
  91861. static readonly OnIntersectionExitTrigger: number;
  91862. /**
  91863. * On key down
  91864. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91865. */
  91866. static readonly OnKeyDownTrigger: number;
  91867. /**
  91868. * On key up
  91869. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91870. */
  91871. static readonly OnKeyUpTrigger: number;
  91872. private _scene;
  91873. /**
  91874. * Creates a new action manager
  91875. * @param scene defines the hosting scene
  91876. */
  91877. constructor(scene: Scene);
  91878. /**
  91879. * Releases all associated resources
  91880. */
  91881. dispose(): void;
  91882. /**
  91883. * Gets hosting scene
  91884. * @returns the hosting scene
  91885. */
  91886. getScene(): Scene;
  91887. /**
  91888. * Does this action manager handles actions of any of the given triggers
  91889. * @param triggers defines the triggers to be tested
  91890. * @return a boolean indicating whether one (or more) of the triggers is handled
  91891. */
  91892. hasSpecificTriggers(triggers: number[]): boolean;
  91893. /**
  91894. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91895. * speed.
  91896. * @param triggerA defines the trigger to be tested
  91897. * @param triggerB defines the trigger to be tested
  91898. * @return a boolean indicating whether one (or more) of the triggers is handled
  91899. */
  91900. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91901. /**
  91902. * Does this action manager handles actions of a given trigger
  91903. * @param trigger defines the trigger to be tested
  91904. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91905. * @return whether the trigger is handled
  91906. */
  91907. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91908. /**
  91909. * Does this action manager has pointer triggers
  91910. */
  91911. get hasPointerTriggers(): boolean;
  91912. /**
  91913. * Does this action manager has pick triggers
  91914. */
  91915. get hasPickTriggers(): boolean;
  91916. /**
  91917. * Registers an action to this action manager
  91918. * @param action defines the action to be registered
  91919. * @return the action amended (prepared) after registration
  91920. */
  91921. registerAction(action: IAction): Nullable<IAction>;
  91922. /**
  91923. * Unregisters an action to this action manager
  91924. * @param action defines the action to be unregistered
  91925. * @return a boolean indicating whether the action has been unregistered
  91926. */
  91927. unregisterAction(action: IAction): Boolean;
  91928. /**
  91929. * Process a specific trigger
  91930. * @param trigger defines the trigger to process
  91931. * @param evt defines the event details to be processed
  91932. */
  91933. processTrigger(trigger: number, evt?: IActionEvent): void;
  91934. /** @hidden */
  91935. _getEffectiveTarget(target: any, propertyPath: string): any;
  91936. /** @hidden */
  91937. _getProperty(propertyPath: string): string;
  91938. /**
  91939. * Serialize this manager to a JSON object
  91940. * @param name defines the property name to store this manager
  91941. * @returns a JSON representation of this manager
  91942. */
  91943. serialize(name: string): any;
  91944. /**
  91945. * Creates a new ActionManager from a JSON data
  91946. * @param parsedActions defines the JSON data to read from
  91947. * @param object defines the hosting mesh
  91948. * @param scene defines the hosting scene
  91949. */
  91950. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91951. /**
  91952. * Get a trigger name by index
  91953. * @param trigger defines the trigger index
  91954. * @returns a trigger name
  91955. */
  91956. static GetTriggerName(trigger: number): string;
  91957. }
  91958. }
  91959. declare module BABYLON {
  91960. /**
  91961. * Class representing a ray with position and direction
  91962. */
  91963. export class Ray {
  91964. /** origin point */
  91965. origin: Vector3;
  91966. /** direction */
  91967. direction: Vector3;
  91968. /** length of the ray */
  91969. length: number;
  91970. private static readonly _TmpVector3;
  91971. private _tmpRay;
  91972. /**
  91973. * Creates a new ray
  91974. * @param origin origin point
  91975. * @param direction direction
  91976. * @param length length of the ray
  91977. */
  91978. constructor(
  91979. /** origin point */
  91980. origin: Vector3,
  91981. /** direction */
  91982. direction: Vector3,
  91983. /** length of the ray */
  91984. length?: number);
  91985. /**
  91986. * Checks if the ray intersects a box
  91987. * This does not account for the ray lenght by design to improve perfs.
  91988. * @param minimum bound of the box
  91989. * @param maximum bound of the box
  91990. * @param intersectionTreshold extra extend to be added to the box in all direction
  91991. * @returns if the box was hit
  91992. */
  91993. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91994. /**
  91995. * Checks if the ray intersects a box
  91996. * This does not account for the ray lenght by design to improve perfs.
  91997. * @param box the bounding box to check
  91998. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91999. * @returns if the box was hit
  92000. */
  92001. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  92002. /**
  92003. * If the ray hits a sphere
  92004. * @param sphere the bounding sphere to check
  92005. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  92006. * @returns true if it hits the sphere
  92007. */
  92008. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  92009. /**
  92010. * If the ray hits a triange
  92011. * @param vertex0 triangle vertex
  92012. * @param vertex1 triangle vertex
  92013. * @param vertex2 triangle vertex
  92014. * @returns intersection information if hit
  92015. */
  92016. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  92017. /**
  92018. * Checks if ray intersects a plane
  92019. * @param plane the plane to check
  92020. * @returns the distance away it was hit
  92021. */
  92022. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  92023. /**
  92024. * Calculate the intercept of a ray on a given axis
  92025. * @param axis to check 'x' | 'y' | 'z'
  92026. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  92027. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  92028. */
  92029. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  92030. /**
  92031. * Checks if ray intersects a mesh
  92032. * @param mesh the mesh to check
  92033. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92034. * @returns picking info of the intersecton
  92035. */
  92036. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  92037. /**
  92038. * Checks if ray intersects a mesh
  92039. * @param meshes the meshes to check
  92040. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92041. * @param results array to store result in
  92042. * @returns Array of picking infos
  92043. */
  92044. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  92045. private _comparePickingInfo;
  92046. private static smallnum;
  92047. private static rayl;
  92048. /**
  92049. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  92050. * @param sega the first point of the segment to test the intersection against
  92051. * @param segb the second point of the segment to test the intersection against
  92052. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  92053. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  92054. */
  92055. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  92056. /**
  92057. * Update the ray from viewport position
  92058. * @param x position
  92059. * @param y y position
  92060. * @param viewportWidth viewport width
  92061. * @param viewportHeight viewport height
  92062. * @param world world matrix
  92063. * @param view view matrix
  92064. * @param projection projection matrix
  92065. * @returns this ray updated
  92066. */
  92067. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  92068. /**
  92069. * Creates a ray with origin and direction of 0,0,0
  92070. * @returns the new ray
  92071. */
  92072. static Zero(): Ray;
  92073. /**
  92074. * Creates a new ray from screen space and viewport
  92075. * @param x position
  92076. * @param y y position
  92077. * @param viewportWidth viewport width
  92078. * @param viewportHeight viewport height
  92079. * @param world world matrix
  92080. * @param view view matrix
  92081. * @param projection projection matrix
  92082. * @returns new ray
  92083. */
  92084. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  92085. /**
  92086. * 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
  92087. * transformed to the given world matrix.
  92088. * @param origin The origin point
  92089. * @param end The end point
  92090. * @param world a matrix to transform the ray to. Default is the identity matrix.
  92091. * @returns the new ray
  92092. */
  92093. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  92094. /**
  92095. * Transforms a ray by a matrix
  92096. * @param ray ray to transform
  92097. * @param matrix matrix to apply
  92098. * @returns the resulting new ray
  92099. */
  92100. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  92101. /**
  92102. * Transforms a ray by a matrix
  92103. * @param ray ray to transform
  92104. * @param matrix matrix to apply
  92105. * @param result ray to store result in
  92106. */
  92107. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  92108. /**
  92109. * Unproject a ray from screen space to object space
  92110. * @param sourceX defines the screen space x coordinate to use
  92111. * @param sourceY defines the screen space y coordinate to use
  92112. * @param viewportWidth defines the current width of the viewport
  92113. * @param viewportHeight defines the current height of the viewport
  92114. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  92115. * @param view defines the view matrix to use
  92116. * @param projection defines the projection matrix to use
  92117. */
  92118. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  92119. }
  92120. /**
  92121. * Type used to define predicate used to select faces when a mesh intersection is detected
  92122. */
  92123. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  92124. interface Scene {
  92125. /** @hidden */
  92126. _tempPickingRay: Nullable<Ray>;
  92127. /** @hidden */
  92128. _cachedRayForTransform: Ray;
  92129. /** @hidden */
  92130. _pickWithRayInverseMatrix: Matrix;
  92131. /** @hidden */
  92132. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92133. /** @hidden */
  92134. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92135. /** @hidden */
  92136. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  92137. }
  92138. }
  92139. declare module BABYLON {
  92140. /**
  92141. * Groups all the scene component constants in one place to ease maintenance.
  92142. * @hidden
  92143. */
  92144. export class SceneComponentConstants {
  92145. static readonly NAME_EFFECTLAYER: string;
  92146. static readonly NAME_LAYER: string;
  92147. static readonly NAME_LENSFLARESYSTEM: string;
  92148. static readonly NAME_BOUNDINGBOXRENDERER: string;
  92149. static readonly NAME_PARTICLESYSTEM: string;
  92150. static readonly NAME_GAMEPAD: string;
  92151. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  92152. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  92153. static readonly NAME_PREPASSRENDERER: string;
  92154. static readonly NAME_DEPTHRENDERER: string;
  92155. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  92156. static readonly NAME_SPRITE: string;
  92157. static readonly NAME_SUBSURFACE: string;
  92158. static readonly NAME_OUTLINERENDERER: string;
  92159. static readonly NAME_PROCEDURALTEXTURE: string;
  92160. static readonly NAME_SHADOWGENERATOR: string;
  92161. static readonly NAME_OCTREE: string;
  92162. static readonly NAME_PHYSICSENGINE: string;
  92163. static readonly NAME_AUDIO: string;
  92164. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  92165. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  92166. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  92167. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  92168. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  92169. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  92170. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  92171. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  92172. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  92173. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  92174. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  92175. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  92176. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  92177. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  92178. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  92179. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  92180. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  92181. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  92182. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  92183. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  92184. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  92185. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  92186. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  92187. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  92188. static readonly STEP_AFTERRENDER_AUDIO: number;
  92189. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  92190. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  92191. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  92192. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  92193. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  92194. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  92195. static readonly STEP_POINTERMOVE_SPRITE: number;
  92196. static readonly STEP_POINTERDOWN_SPRITE: number;
  92197. static readonly STEP_POINTERUP_SPRITE: number;
  92198. }
  92199. /**
  92200. * This represents a scene component.
  92201. *
  92202. * This is used to decouple the dependency the scene is having on the different workloads like
  92203. * layers, post processes...
  92204. */
  92205. export interface ISceneComponent {
  92206. /**
  92207. * The name of the component. Each component must have a unique name.
  92208. */
  92209. name: string;
  92210. /**
  92211. * The scene the component belongs to.
  92212. */
  92213. scene: Scene;
  92214. /**
  92215. * Register the component to one instance of a scene.
  92216. */
  92217. register(): void;
  92218. /**
  92219. * Rebuilds the elements related to this component in case of
  92220. * context lost for instance.
  92221. */
  92222. rebuild(): void;
  92223. /**
  92224. * Disposes the component and the associated ressources.
  92225. */
  92226. dispose(): void;
  92227. }
  92228. /**
  92229. * This represents a SERIALIZABLE scene component.
  92230. *
  92231. * This extends Scene Component to add Serialization methods on top.
  92232. */
  92233. export interface ISceneSerializableComponent extends ISceneComponent {
  92234. /**
  92235. * Adds all the elements from the container to the scene
  92236. * @param container the container holding the elements
  92237. */
  92238. addFromContainer(container: AbstractScene): void;
  92239. /**
  92240. * Removes all the elements in the container from the scene
  92241. * @param container contains the elements to remove
  92242. * @param dispose if the removed element should be disposed (default: false)
  92243. */
  92244. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  92245. /**
  92246. * Serializes the component data to the specified json object
  92247. * @param serializationObject The object to serialize to
  92248. */
  92249. serialize(serializationObject: any): void;
  92250. }
  92251. /**
  92252. * Strong typing of a Mesh related stage step action
  92253. */
  92254. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  92255. /**
  92256. * Strong typing of a Evaluate Sub Mesh related stage step action
  92257. */
  92258. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  92259. /**
  92260. * Strong typing of a pre active Mesh related stage step action
  92261. */
  92262. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  92263. /**
  92264. * Strong typing of a Camera related stage step action
  92265. */
  92266. export type CameraStageAction = (camera: Camera) => void;
  92267. /**
  92268. * Strong typing of a Camera Frame buffer related stage step action
  92269. */
  92270. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  92271. /**
  92272. * Strong typing of a Render Target related stage step action
  92273. */
  92274. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  92275. /**
  92276. * Strong typing of a RenderingGroup related stage step action
  92277. */
  92278. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  92279. /**
  92280. * Strong typing of a Mesh Render related stage step action
  92281. */
  92282. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  92283. /**
  92284. * Strong typing of a simple stage step action
  92285. */
  92286. export type SimpleStageAction = () => void;
  92287. /**
  92288. * Strong typing of a render target action.
  92289. */
  92290. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  92291. /**
  92292. * Strong typing of a pointer move action.
  92293. */
  92294. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  92295. /**
  92296. * Strong typing of a pointer up/down action.
  92297. */
  92298. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  92299. /**
  92300. * Representation of a stage in the scene (Basically a list of ordered steps)
  92301. * @hidden
  92302. */
  92303. export class Stage<T extends Function> extends Array<{
  92304. index: number;
  92305. component: ISceneComponent;
  92306. action: T;
  92307. }> {
  92308. /**
  92309. * Hide ctor from the rest of the world.
  92310. * @param items The items to add.
  92311. */
  92312. private constructor();
  92313. /**
  92314. * Creates a new Stage.
  92315. * @returns A new instance of a Stage
  92316. */
  92317. static Create<T extends Function>(): Stage<T>;
  92318. /**
  92319. * Registers a step in an ordered way in the targeted stage.
  92320. * @param index Defines the position to register the step in
  92321. * @param component Defines the component attached to the step
  92322. * @param action Defines the action to launch during the step
  92323. */
  92324. registerStep(index: number, component: ISceneComponent, action: T): void;
  92325. /**
  92326. * Clears all the steps from the stage.
  92327. */
  92328. clear(): void;
  92329. }
  92330. }
  92331. declare module BABYLON {
  92332. interface Scene {
  92333. /** @hidden */
  92334. _pointerOverSprite: Nullable<Sprite>;
  92335. /** @hidden */
  92336. _pickedDownSprite: Nullable<Sprite>;
  92337. /** @hidden */
  92338. _tempSpritePickingRay: Nullable<Ray>;
  92339. /**
  92340. * All of the sprite managers added to this scene
  92341. * @see https://doc.babylonjs.com/babylon101/sprites
  92342. */
  92343. spriteManagers: Array<ISpriteManager>;
  92344. /**
  92345. * An event triggered when sprites rendering is about to start
  92346. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92347. */
  92348. onBeforeSpritesRenderingObservable: Observable<Scene>;
  92349. /**
  92350. * An event triggered when sprites rendering is done
  92351. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92352. */
  92353. onAfterSpritesRenderingObservable: Observable<Scene>;
  92354. /** @hidden */
  92355. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92356. /** Launch a ray to try to pick a sprite in the scene
  92357. * @param x position on screen
  92358. * @param y position on screen
  92359. * @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
  92360. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92361. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92362. * @returns a PickingInfo
  92363. */
  92364. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92365. /** Use the given ray to pick a sprite in the scene
  92366. * @param ray The ray (in world space) to use to pick meshes
  92367. * @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
  92368. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92369. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92370. * @returns a PickingInfo
  92371. */
  92372. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92373. /** @hidden */
  92374. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92375. /** Launch a ray to try to pick sprites in the scene
  92376. * @param x position on screen
  92377. * @param y position on screen
  92378. * @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
  92379. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92380. * @returns a PickingInfo array
  92381. */
  92382. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92383. /** Use the given ray to pick sprites in the scene
  92384. * @param ray The ray (in world space) to use to pick meshes
  92385. * @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
  92386. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92387. * @returns a PickingInfo array
  92388. */
  92389. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92390. /**
  92391. * Force the sprite under the pointer
  92392. * @param sprite defines the sprite to use
  92393. */
  92394. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  92395. /**
  92396. * Gets the sprite under the pointer
  92397. * @returns a Sprite or null if no sprite is under the pointer
  92398. */
  92399. getPointerOverSprite(): Nullable<Sprite>;
  92400. }
  92401. /**
  92402. * Defines the sprite scene component responsible to manage sprites
  92403. * in a given scene.
  92404. */
  92405. export class SpriteSceneComponent implements ISceneComponent {
  92406. /**
  92407. * The component name helpfull to identify the component in the list of scene components.
  92408. */
  92409. readonly name: string;
  92410. /**
  92411. * The scene the component belongs to.
  92412. */
  92413. scene: Scene;
  92414. /** @hidden */
  92415. private _spritePredicate;
  92416. /**
  92417. * Creates a new instance of the component for the given scene
  92418. * @param scene Defines the scene to register the component in
  92419. */
  92420. constructor(scene: Scene);
  92421. /**
  92422. * Registers the component in a given scene
  92423. */
  92424. register(): void;
  92425. /**
  92426. * Rebuilds the elements related to this component in case of
  92427. * context lost for instance.
  92428. */
  92429. rebuild(): void;
  92430. /**
  92431. * Disposes the component and the associated ressources.
  92432. */
  92433. dispose(): void;
  92434. private _pickSpriteButKeepRay;
  92435. private _pointerMove;
  92436. private _pointerDown;
  92437. private _pointerUp;
  92438. }
  92439. }
  92440. declare module BABYLON {
  92441. /**
  92442. * Class used to provide helper for timing
  92443. */
  92444. export class TimingTools {
  92445. /**
  92446. * Polyfill for setImmediate
  92447. * @param action defines the action to execute after the current execution block
  92448. */
  92449. static SetImmediate(action: () => void): void;
  92450. }
  92451. }
  92452. declare module BABYLON {
  92453. /**
  92454. * Class used to enable instatition of objects by class name
  92455. */
  92456. export class InstantiationTools {
  92457. /**
  92458. * Use this object to register external classes like custom textures or material
  92459. * to allow the laoders to instantiate them
  92460. */
  92461. static RegisteredExternalClasses: {
  92462. [key: string]: Object;
  92463. };
  92464. /**
  92465. * Tries to instantiate a new object from a given class name
  92466. * @param className defines the class name to instantiate
  92467. * @returns the new object or null if the system was not able to do the instantiation
  92468. */
  92469. static Instantiate(className: string): any;
  92470. }
  92471. }
  92472. declare module BABYLON {
  92473. /**
  92474. * Class used to host copy specific utilities
  92475. */
  92476. export class CopyTools {
  92477. /**
  92478. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  92479. * @param texture defines the texture to read pixels from
  92480. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92481. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92482. * @returns The base64 encoded string or null
  92483. */
  92484. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  92485. }
  92486. }
  92487. declare module BABYLON {
  92488. /**
  92489. * Define options used to create a depth texture
  92490. */
  92491. export class DepthTextureCreationOptions {
  92492. /** Specifies whether or not a stencil should be allocated in the texture */
  92493. generateStencil?: boolean;
  92494. /** Specifies whether or not bilinear filtering is enable on the texture */
  92495. bilinearFiltering?: boolean;
  92496. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  92497. comparisonFunction?: number;
  92498. /** Specifies if the created texture is a cube texture */
  92499. isCube?: boolean;
  92500. }
  92501. }
  92502. declare module BABYLON {
  92503. interface ThinEngine {
  92504. /**
  92505. * Creates a depth stencil cube texture.
  92506. * This is only available in WebGL 2.
  92507. * @param size The size of face edge in the cube texture.
  92508. * @param options The options defining the cube texture.
  92509. * @returns The cube texture
  92510. */
  92511. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  92512. /**
  92513. * Creates a cube texture
  92514. * @param rootUrl defines the url where the files to load is located
  92515. * @param scene defines the current scene
  92516. * @param files defines the list of files to load (1 per face)
  92517. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92518. * @param onLoad defines an optional callback raised when the texture is loaded
  92519. * @param onError defines an optional callback raised if there is an issue to load the texture
  92520. * @param format defines the format of the data
  92521. * @param forcedExtension defines the extension to use to pick the right loader
  92522. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92523. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92524. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92525. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  92526. * @param loaderOptions options to be passed to the loader
  92527. * @returns the cube texture as an InternalTexture
  92528. */
  92529. 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;
  92530. /**
  92531. * Creates a cube texture
  92532. * @param rootUrl defines the url where the files to load is located
  92533. * @param scene defines the current scene
  92534. * @param files defines the list of files to load (1 per face)
  92535. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92536. * @param onLoad defines an optional callback raised when the texture is loaded
  92537. * @param onError defines an optional callback raised if there is an issue to load the texture
  92538. * @param format defines the format of the data
  92539. * @param forcedExtension defines the extension to use to pick the right loader
  92540. * @returns the cube texture as an InternalTexture
  92541. */
  92542. 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;
  92543. /**
  92544. * Creates a cube texture
  92545. * @param rootUrl defines the url where the files to load is located
  92546. * @param scene defines the current scene
  92547. * @param files defines the list of files to load (1 per face)
  92548. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92549. * @param onLoad defines an optional callback raised when the texture is loaded
  92550. * @param onError defines an optional callback raised if there is an issue to load the texture
  92551. * @param format defines the format of the data
  92552. * @param forcedExtension defines the extension to use to pick the right loader
  92553. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92554. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92555. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92556. * @returns the cube texture as an InternalTexture
  92557. */
  92558. 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;
  92559. /** @hidden */
  92560. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  92561. /** @hidden */
  92562. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  92563. /** @hidden */
  92564. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92565. /** @hidden */
  92566. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92567. /**
  92568. * @hidden
  92569. */
  92570. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  92571. }
  92572. }
  92573. declare module BABYLON {
  92574. /**
  92575. * Class for creating a cube texture
  92576. */
  92577. export class CubeTexture extends BaseTexture {
  92578. private _delayedOnLoad;
  92579. /**
  92580. * Observable triggered once the texture has been loaded.
  92581. */
  92582. onLoadObservable: Observable<CubeTexture>;
  92583. /**
  92584. * The url of the texture
  92585. */
  92586. url: string;
  92587. /**
  92588. * Gets or sets the center of the bounding box associated with the cube texture.
  92589. * It must define where the camera used to render the texture was set
  92590. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92591. */
  92592. boundingBoxPosition: Vector3;
  92593. private _boundingBoxSize;
  92594. /**
  92595. * Gets or sets the size of the bounding box associated with the cube texture
  92596. * When defined, the cubemap will switch to local mode
  92597. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  92598. * @example https://www.babylonjs-playground.com/#RNASML
  92599. */
  92600. set boundingBoxSize(value: Vector3);
  92601. /**
  92602. * Returns the bounding box size
  92603. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92604. */
  92605. get boundingBoxSize(): Vector3;
  92606. protected _rotationY: number;
  92607. /**
  92608. * Sets texture matrix rotation angle around Y axis in radians.
  92609. */
  92610. set rotationY(value: number);
  92611. /**
  92612. * Gets texture matrix rotation angle around Y axis radians.
  92613. */
  92614. get rotationY(): number;
  92615. /**
  92616. * Are mip maps generated for this texture or not.
  92617. */
  92618. get noMipmap(): boolean;
  92619. private _noMipmap;
  92620. private _files;
  92621. protected _forcedExtension: Nullable<string>;
  92622. private _extensions;
  92623. private _textureMatrix;
  92624. private _format;
  92625. private _createPolynomials;
  92626. private _loaderOptions;
  92627. /**
  92628. * Creates a cube texture from an array of image urls
  92629. * @param files defines an array of image urls
  92630. * @param scene defines the hosting scene
  92631. * @param noMipmap specifies if mip maps are not used
  92632. * @returns a cube texture
  92633. */
  92634. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  92635. /**
  92636. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  92637. * @param url defines the url of the prefiltered texture
  92638. * @param scene defines the scene the texture is attached to
  92639. * @param forcedExtension defines the extension of the file if different from the url
  92640. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92641. * @return the prefiltered texture
  92642. */
  92643. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  92644. /**
  92645. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  92646. * as prefiltered data.
  92647. * @param rootUrl defines the url of the texture or the root name of the six images
  92648. * @param null defines the scene or engine the texture is attached to
  92649. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  92650. * @param noMipmap defines if mipmaps should be created or not
  92651. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  92652. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  92653. * @param onError defines a callback triggered in case of error during load
  92654. * @param format defines the internal format to use for the texture once loaded
  92655. * @param prefiltered defines whether or not the texture is created from prefiltered data
  92656. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  92657. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92660. * @param loaderOptions options to be passed to the loader
  92661. * @return the cube texture
  92662. */
  92663. 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);
  92664. /**
  92665. * Get the current class name of the texture useful for serialization or dynamic coding.
  92666. * @returns "CubeTexture"
  92667. */
  92668. getClassName(): string;
  92669. /**
  92670. * Update the url (and optional buffer) of this texture if url was null during construction.
  92671. * @param url the url of the texture
  92672. * @param forcedExtension defines the extension to use
  92673. * @param onLoad callback called when the texture is loaded (defaults to null)
  92674. * @param prefiltered Defines whether the updated texture is prefiltered or not
  92675. */
  92676. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  92677. /**
  92678. * Delays loading of the cube texture
  92679. * @param forcedExtension defines the extension to use
  92680. */
  92681. delayLoad(forcedExtension?: string): void;
  92682. /**
  92683. * Returns the reflection texture matrix
  92684. * @returns the reflection texture matrix
  92685. */
  92686. getReflectionTextureMatrix(): Matrix;
  92687. /**
  92688. * Sets the reflection texture matrix
  92689. * @param value Reflection texture matrix
  92690. */
  92691. setReflectionTextureMatrix(value: Matrix): void;
  92692. /**
  92693. * Parses text to create a cube texture
  92694. * @param parsedTexture define the serialized text to read from
  92695. * @param scene defines the hosting scene
  92696. * @param rootUrl defines the root url of the cube texture
  92697. * @returns a cube texture
  92698. */
  92699. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  92700. /**
  92701. * Makes a clone, or deep copy, of the cube texture
  92702. * @returns a new cube texture
  92703. */
  92704. clone(): CubeTexture;
  92705. }
  92706. }
  92707. declare module BABYLON {
  92708. /**
  92709. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92710. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92711. * 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;
  92712. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92713. */
  92714. export class ColorCurves {
  92715. private _dirty;
  92716. private _tempColor;
  92717. private _globalCurve;
  92718. private _highlightsCurve;
  92719. private _midtonesCurve;
  92720. private _shadowsCurve;
  92721. private _positiveCurve;
  92722. private _negativeCurve;
  92723. private _globalHue;
  92724. private _globalDensity;
  92725. private _globalSaturation;
  92726. private _globalExposure;
  92727. /**
  92728. * Gets the global Hue value.
  92729. * 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).
  92730. */
  92731. get globalHue(): number;
  92732. /**
  92733. * Sets the global Hue value.
  92734. * 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).
  92735. */
  92736. set globalHue(value: number);
  92737. /**
  92738. * Gets the global Density value.
  92739. * 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.
  92740. * Values less than zero provide a filter of opposite hue.
  92741. */
  92742. get globalDensity(): number;
  92743. /**
  92744. * Sets the global Density value.
  92745. * 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.
  92746. * Values less than zero provide a filter of opposite hue.
  92747. */
  92748. set globalDensity(value: number);
  92749. /**
  92750. * Gets the global Saturation value.
  92751. * 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.
  92752. */
  92753. get globalSaturation(): number;
  92754. /**
  92755. * Sets the global Saturation value.
  92756. * 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.
  92757. */
  92758. set globalSaturation(value: number);
  92759. /**
  92760. * Gets the global Exposure value.
  92761. * 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.
  92762. */
  92763. get globalExposure(): number;
  92764. /**
  92765. * Sets the global Exposure value.
  92766. * 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.
  92767. */
  92768. set globalExposure(value: number);
  92769. private _highlightsHue;
  92770. private _highlightsDensity;
  92771. private _highlightsSaturation;
  92772. private _highlightsExposure;
  92773. /**
  92774. * Gets the highlights Hue value.
  92775. * 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).
  92776. */
  92777. get highlightsHue(): number;
  92778. /**
  92779. * Sets the highlights Hue value.
  92780. * 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).
  92781. */
  92782. set highlightsHue(value: number);
  92783. /**
  92784. * Gets the highlights Density value.
  92785. * 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.
  92786. * Values less than zero provide a filter of opposite hue.
  92787. */
  92788. get highlightsDensity(): number;
  92789. /**
  92790. * Sets the highlights Density value.
  92791. * 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.
  92792. * Values less than zero provide a filter of opposite hue.
  92793. */
  92794. set highlightsDensity(value: number);
  92795. /**
  92796. * Gets the highlights Saturation value.
  92797. * 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.
  92798. */
  92799. get highlightsSaturation(): number;
  92800. /**
  92801. * Sets the highlights Saturation value.
  92802. * 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.
  92803. */
  92804. set highlightsSaturation(value: number);
  92805. /**
  92806. * Gets the highlights Exposure value.
  92807. * 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.
  92808. */
  92809. get highlightsExposure(): number;
  92810. /**
  92811. * Sets the highlights Exposure value.
  92812. * 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.
  92813. */
  92814. set highlightsExposure(value: number);
  92815. private _midtonesHue;
  92816. private _midtonesDensity;
  92817. private _midtonesSaturation;
  92818. private _midtonesExposure;
  92819. /**
  92820. * Gets the midtones Hue value.
  92821. * 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).
  92822. */
  92823. get midtonesHue(): number;
  92824. /**
  92825. * Sets the midtones Hue value.
  92826. * 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).
  92827. */
  92828. set midtonesHue(value: number);
  92829. /**
  92830. * Gets the midtones Density value.
  92831. * 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.
  92832. * Values less than zero provide a filter of opposite hue.
  92833. */
  92834. get midtonesDensity(): number;
  92835. /**
  92836. * Sets the midtones Density value.
  92837. * 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.
  92838. * Values less than zero provide a filter of opposite hue.
  92839. */
  92840. set midtonesDensity(value: number);
  92841. /**
  92842. * Gets the midtones Saturation value.
  92843. * 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.
  92844. */
  92845. get midtonesSaturation(): number;
  92846. /**
  92847. * Sets the midtones Saturation value.
  92848. * 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.
  92849. */
  92850. set midtonesSaturation(value: number);
  92851. /**
  92852. * Gets the midtones Exposure value.
  92853. * 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.
  92854. */
  92855. get midtonesExposure(): number;
  92856. /**
  92857. * Sets the midtones Exposure value.
  92858. * 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.
  92859. */
  92860. set midtonesExposure(value: number);
  92861. private _shadowsHue;
  92862. private _shadowsDensity;
  92863. private _shadowsSaturation;
  92864. private _shadowsExposure;
  92865. /**
  92866. * Gets the shadows Hue value.
  92867. * 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).
  92868. */
  92869. get shadowsHue(): number;
  92870. /**
  92871. * Sets the shadows Hue value.
  92872. * 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).
  92873. */
  92874. set shadowsHue(value: number);
  92875. /**
  92876. * Gets the shadows Density value.
  92877. * 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.
  92878. * Values less than zero provide a filter of opposite hue.
  92879. */
  92880. get shadowsDensity(): number;
  92881. /**
  92882. * Sets the shadows Density value.
  92883. * 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.
  92884. * Values less than zero provide a filter of opposite hue.
  92885. */
  92886. set shadowsDensity(value: number);
  92887. /**
  92888. * Gets the shadows Saturation value.
  92889. * 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.
  92890. */
  92891. get shadowsSaturation(): number;
  92892. /**
  92893. * Sets the shadows Saturation value.
  92894. * 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.
  92895. */
  92896. set shadowsSaturation(value: number);
  92897. /**
  92898. * Gets the shadows Exposure value.
  92899. * 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.
  92900. */
  92901. get shadowsExposure(): number;
  92902. /**
  92903. * Sets the shadows Exposure value.
  92904. * 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.
  92905. */
  92906. set shadowsExposure(value: number);
  92907. /**
  92908. * Returns the class name
  92909. * @returns The class name
  92910. */
  92911. getClassName(): string;
  92912. /**
  92913. * Binds the color curves to the shader.
  92914. * @param colorCurves The color curve to bind
  92915. * @param effect The effect to bind to
  92916. * @param positiveUniform The positive uniform shader parameter
  92917. * @param neutralUniform The neutral uniform shader parameter
  92918. * @param negativeUniform The negative uniform shader parameter
  92919. */
  92920. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92921. /**
  92922. * Prepare the list of uniforms associated with the ColorCurves effects.
  92923. * @param uniformsList The list of uniforms used in the effect
  92924. */
  92925. static PrepareUniforms(uniformsList: string[]): void;
  92926. /**
  92927. * Returns color grading data based on a hue, density, saturation and exposure value.
  92928. * @param filterHue The hue of the color filter.
  92929. * @param filterDensity The density of the color filter.
  92930. * @param saturation The saturation.
  92931. * @param exposure The exposure.
  92932. * @param result The result data container.
  92933. */
  92934. private getColorGradingDataToRef;
  92935. /**
  92936. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92937. * @param value The input slider value in range [-100,100].
  92938. * @returns Adjusted value.
  92939. */
  92940. private static applyColorGradingSliderNonlinear;
  92941. /**
  92942. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92943. * @param hue The hue (H) input.
  92944. * @param saturation The saturation (S) input.
  92945. * @param brightness The brightness (B) input.
  92946. * @result An RGBA color represented as Vector4.
  92947. */
  92948. private static fromHSBToRef;
  92949. /**
  92950. * Returns a value clamped between min and max
  92951. * @param value The value to clamp
  92952. * @param min The minimum of value
  92953. * @param max The maximum of value
  92954. * @returns The clamped value.
  92955. */
  92956. private static clamp;
  92957. /**
  92958. * Clones the current color curve instance.
  92959. * @return The cloned curves
  92960. */
  92961. clone(): ColorCurves;
  92962. /**
  92963. * Serializes the current color curve instance to a json representation.
  92964. * @return a JSON representation
  92965. */
  92966. serialize(): any;
  92967. /**
  92968. * Parses the color curve from a json representation.
  92969. * @param source the JSON source to parse
  92970. * @return The parsed curves
  92971. */
  92972. static Parse(source: any): ColorCurves;
  92973. }
  92974. }
  92975. declare module BABYLON {
  92976. /**
  92977. * Interface to follow in your material defines to integrate easily the
  92978. * Image proccessing functions.
  92979. * @hidden
  92980. */
  92981. export interface IImageProcessingConfigurationDefines {
  92982. IMAGEPROCESSING: boolean;
  92983. VIGNETTE: boolean;
  92984. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92985. VIGNETTEBLENDMODEOPAQUE: boolean;
  92986. TONEMAPPING: boolean;
  92987. TONEMAPPING_ACES: boolean;
  92988. CONTRAST: boolean;
  92989. EXPOSURE: boolean;
  92990. COLORCURVES: boolean;
  92991. COLORGRADING: boolean;
  92992. COLORGRADING3D: boolean;
  92993. SAMPLER3DGREENDEPTH: boolean;
  92994. SAMPLER3DBGRMAP: boolean;
  92995. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92996. }
  92997. /**
  92998. * @hidden
  92999. */
  93000. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93001. IMAGEPROCESSING: boolean;
  93002. VIGNETTE: boolean;
  93003. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93004. VIGNETTEBLENDMODEOPAQUE: boolean;
  93005. TONEMAPPING: boolean;
  93006. TONEMAPPING_ACES: boolean;
  93007. CONTRAST: boolean;
  93008. COLORCURVES: boolean;
  93009. COLORGRADING: boolean;
  93010. COLORGRADING3D: boolean;
  93011. SAMPLER3DGREENDEPTH: boolean;
  93012. SAMPLER3DBGRMAP: boolean;
  93013. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93014. EXPOSURE: boolean;
  93015. constructor();
  93016. }
  93017. /**
  93018. * This groups together the common properties used for image processing either in direct forward pass
  93019. * or through post processing effect depending on the use of the image processing pipeline in your scene
  93020. * or not.
  93021. */
  93022. export class ImageProcessingConfiguration {
  93023. /**
  93024. * Default tone mapping applied in BabylonJS.
  93025. */
  93026. static readonly TONEMAPPING_STANDARD: number;
  93027. /**
  93028. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  93029. * to other engines rendering to increase portability.
  93030. */
  93031. static readonly TONEMAPPING_ACES: number;
  93032. /**
  93033. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  93034. */
  93035. colorCurves: Nullable<ColorCurves>;
  93036. private _colorCurvesEnabled;
  93037. /**
  93038. * Gets wether the color curves effect is enabled.
  93039. */
  93040. get colorCurvesEnabled(): boolean;
  93041. /**
  93042. * Sets wether the color curves effect is enabled.
  93043. */
  93044. set colorCurvesEnabled(value: boolean);
  93045. private _colorGradingTexture;
  93046. /**
  93047. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93048. */
  93049. get colorGradingTexture(): Nullable<BaseTexture>;
  93050. /**
  93051. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  93052. */
  93053. set colorGradingTexture(value: Nullable<BaseTexture>);
  93054. private _colorGradingEnabled;
  93055. /**
  93056. * Gets wether the color grading effect is enabled.
  93057. */
  93058. get colorGradingEnabled(): boolean;
  93059. /**
  93060. * Sets wether the color grading effect is enabled.
  93061. */
  93062. set colorGradingEnabled(value: boolean);
  93063. private _colorGradingWithGreenDepth;
  93064. /**
  93065. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  93066. */
  93067. get colorGradingWithGreenDepth(): boolean;
  93068. /**
  93069. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  93070. */
  93071. set colorGradingWithGreenDepth(value: boolean);
  93072. private _colorGradingBGR;
  93073. /**
  93074. * Gets wether the color grading texture contains BGR values.
  93075. */
  93076. get colorGradingBGR(): boolean;
  93077. /**
  93078. * Sets wether the color grading texture contains BGR values.
  93079. */
  93080. set colorGradingBGR(value: boolean);
  93081. /** @hidden */
  93082. _exposure: number;
  93083. /**
  93084. * Gets the Exposure used in the effect.
  93085. */
  93086. get exposure(): number;
  93087. /**
  93088. * Sets the Exposure used in the effect.
  93089. */
  93090. set exposure(value: number);
  93091. private _toneMappingEnabled;
  93092. /**
  93093. * Gets wether the tone mapping effect is enabled.
  93094. */
  93095. get toneMappingEnabled(): boolean;
  93096. /**
  93097. * Sets wether the tone mapping effect is enabled.
  93098. */
  93099. set toneMappingEnabled(value: boolean);
  93100. private _toneMappingType;
  93101. /**
  93102. * Gets the type of tone mapping effect.
  93103. */
  93104. get toneMappingType(): number;
  93105. /**
  93106. * Sets the type of tone mapping effect used in BabylonJS.
  93107. */
  93108. set toneMappingType(value: number);
  93109. protected _contrast: number;
  93110. /**
  93111. * Gets the contrast used in the effect.
  93112. */
  93113. get contrast(): number;
  93114. /**
  93115. * Sets the contrast used in the effect.
  93116. */
  93117. set contrast(value: number);
  93118. /**
  93119. * Vignette stretch size.
  93120. */
  93121. vignetteStretch: number;
  93122. /**
  93123. * Vignette centre X Offset.
  93124. */
  93125. vignetteCentreX: number;
  93126. /**
  93127. * Vignette centre Y Offset.
  93128. */
  93129. vignetteCentreY: number;
  93130. /**
  93131. * Vignette weight or intensity of the vignette effect.
  93132. */
  93133. vignetteWeight: number;
  93134. /**
  93135. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  93136. * if vignetteEnabled is set to true.
  93137. */
  93138. vignetteColor: Color4;
  93139. /**
  93140. * Camera field of view used by the Vignette effect.
  93141. */
  93142. vignetteCameraFov: number;
  93143. private _vignetteBlendMode;
  93144. /**
  93145. * Gets the vignette blend mode allowing different kind of effect.
  93146. */
  93147. get vignetteBlendMode(): number;
  93148. /**
  93149. * Sets the vignette blend mode allowing different kind of effect.
  93150. */
  93151. set vignetteBlendMode(value: number);
  93152. private _vignetteEnabled;
  93153. /**
  93154. * Gets wether the vignette effect is enabled.
  93155. */
  93156. get vignetteEnabled(): boolean;
  93157. /**
  93158. * Sets wether the vignette effect is enabled.
  93159. */
  93160. set vignetteEnabled(value: boolean);
  93161. private _applyByPostProcess;
  93162. /**
  93163. * Gets wether the image processing is applied through a post process or not.
  93164. */
  93165. get applyByPostProcess(): boolean;
  93166. /**
  93167. * Sets wether the image processing is applied through a post process or not.
  93168. */
  93169. set applyByPostProcess(value: boolean);
  93170. private _isEnabled;
  93171. /**
  93172. * Gets wether the image processing is enabled or not.
  93173. */
  93174. get isEnabled(): boolean;
  93175. /**
  93176. * Sets wether the image processing is enabled or not.
  93177. */
  93178. set isEnabled(value: boolean);
  93179. /**
  93180. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  93181. */
  93182. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  93183. /**
  93184. * Method called each time the image processing information changes requires to recompile the effect.
  93185. */
  93186. protected _updateParameters(): void;
  93187. /**
  93188. * Gets the current class name.
  93189. * @return "ImageProcessingConfiguration"
  93190. */
  93191. getClassName(): string;
  93192. /**
  93193. * Prepare the list of uniforms associated with the Image Processing effects.
  93194. * @param uniforms The list of uniforms used in the effect
  93195. * @param defines the list of defines currently in use
  93196. */
  93197. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93198. /**
  93199. * Prepare the list of samplers associated with the Image Processing effects.
  93200. * @param samplersList The list of uniforms used in the effect
  93201. * @param defines the list of defines currently in use
  93202. */
  93203. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93204. /**
  93205. * Prepare the list of defines associated to the shader.
  93206. * @param defines the list of defines to complete
  93207. * @param forPostProcess Define if we are currently in post process mode or not
  93208. */
  93209. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93210. /**
  93211. * Returns true if all the image processing information are ready.
  93212. * @returns True if ready, otherwise, false
  93213. */
  93214. isReady(): boolean;
  93215. /**
  93216. * Binds the image processing to the shader.
  93217. * @param effect The effect to bind to
  93218. * @param overrideAspectRatio Override the aspect ratio of the effect
  93219. */
  93220. bind(effect: Effect, overrideAspectRatio?: number): void;
  93221. /**
  93222. * Clones the current image processing instance.
  93223. * @return The cloned image processing
  93224. */
  93225. clone(): ImageProcessingConfiguration;
  93226. /**
  93227. * Serializes the current image processing instance to a json representation.
  93228. * @return a JSON representation
  93229. */
  93230. serialize(): any;
  93231. /**
  93232. * Parses the image processing from a json representation.
  93233. * @param source the JSON source to parse
  93234. * @return The parsed image processing
  93235. */
  93236. static Parse(source: any): ImageProcessingConfiguration;
  93237. private static _VIGNETTEMODE_MULTIPLY;
  93238. private static _VIGNETTEMODE_OPAQUE;
  93239. /**
  93240. * Used to apply the vignette as a mix with the pixel color.
  93241. */
  93242. static get VIGNETTEMODE_MULTIPLY(): number;
  93243. /**
  93244. * Used to apply the vignette as a replacement of the pixel color.
  93245. */
  93246. static get VIGNETTEMODE_OPAQUE(): number;
  93247. }
  93248. }
  93249. declare module BABYLON {
  93250. /** @hidden */
  93251. export var postprocessVertexShader: {
  93252. name: string;
  93253. shader: string;
  93254. };
  93255. }
  93256. declare module BABYLON {
  93257. /**
  93258. * Type used to define a render target texture size (either with a number or with a rect width and height)
  93259. */
  93260. export type RenderTargetTextureSize = number | {
  93261. width: number;
  93262. height: number;
  93263. layers?: number;
  93264. };
  93265. interface ThinEngine {
  93266. /**
  93267. * Creates a new render target texture
  93268. * @param size defines the size of the texture
  93269. * @param options defines the options used to create the texture
  93270. * @returns a new render target texture stored in an InternalTexture
  93271. */
  93272. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  93273. /**
  93274. * Creates a depth stencil texture.
  93275. * This is only available in WebGL 2 or with the depth texture extension available.
  93276. * @param size The size of face edge in the texture.
  93277. * @param options The options defining the texture.
  93278. * @returns The texture
  93279. */
  93280. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  93281. /** @hidden */
  93282. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  93283. }
  93284. }
  93285. declare module BABYLON {
  93286. /**
  93287. * Defines the kind of connection point for node based material
  93288. */
  93289. export enum NodeMaterialBlockConnectionPointTypes {
  93290. /** Float */
  93291. Float = 1,
  93292. /** Int */
  93293. Int = 2,
  93294. /** Vector2 */
  93295. Vector2 = 4,
  93296. /** Vector3 */
  93297. Vector3 = 8,
  93298. /** Vector4 */
  93299. Vector4 = 16,
  93300. /** Color3 */
  93301. Color3 = 32,
  93302. /** Color4 */
  93303. Color4 = 64,
  93304. /** Matrix */
  93305. Matrix = 128,
  93306. /** Custom object */
  93307. Object = 256,
  93308. /** Detect type based on connection */
  93309. AutoDetect = 1024,
  93310. /** Output type that will be defined by input type */
  93311. BasedOnInput = 2048
  93312. }
  93313. }
  93314. declare module BABYLON {
  93315. /**
  93316. * Enum used to define the target of a block
  93317. */
  93318. export enum NodeMaterialBlockTargets {
  93319. /** Vertex shader */
  93320. Vertex = 1,
  93321. /** Fragment shader */
  93322. Fragment = 2,
  93323. /** Neutral */
  93324. Neutral = 4,
  93325. /** Vertex and Fragment */
  93326. VertexAndFragment = 3
  93327. }
  93328. }
  93329. declare module BABYLON {
  93330. /**
  93331. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  93332. */
  93333. export enum NodeMaterialBlockConnectionPointMode {
  93334. /** Value is an uniform */
  93335. Uniform = 0,
  93336. /** Value is a mesh attribute */
  93337. Attribute = 1,
  93338. /** Value is a varying between vertex and fragment shaders */
  93339. Varying = 2,
  93340. /** Mode is undefined */
  93341. Undefined = 3
  93342. }
  93343. }
  93344. declare module BABYLON {
  93345. /**
  93346. * Enum used to define system values e.g. values automatically provided by the system
  93347. */
  93348. export enum NodeMaterialSystemValues {
  93349. /** World */
  93350. World = 1,
  93351. /** View */
  93352. View = 2,
  93353. /** Projection */
  93354. Projection = 3,
  93355. /** ViewProjection */
  93356. ViewProjection = 4,
  93357. /** WorldView */
  93358. WorldView = 5,
  93359. /** WorldViewProjection */
  93360. WorldViewProjection = 6,
  93361. /** CameraPosition */
  93362. CameraPosition = 7,
  93363. /** Fog Color */
  93364. FogColor = 8,
  93365. /** Delta time */
  93366. DeltaTime = 9
  93367. }
  93368. }
  93369. declare module BABYLON {
  93370. /**
  93371. * Represents a camera frustum
  93372. */
  93373. export class Frustum {
  93374. /**
  93375. * Gets the planes representing the frustum
  93376. * @param transform matrix to be applied to the returned planes
  93377. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93378. */
  93379. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93380. /**
  93381. * Gets the near frustum plane transformed by the transform matrix
  93382. * @param transform transformation matrix to be applied to the resulting frustum plane
  93383. * @param frustumPlane the resuling frustum plane
  93384. */
  93385. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93386. /**
  93387. * Gets the far frustum plane transformed by the transform matrix
  93388. * @param transform transformation matrix to be applied to the resulting frustum plane
  93389. * @param frustumPlane the resuling frustum plane
  93390. */
  93391. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93392. /**
  93393. * Gets the left frustum plane transformed by the transform matrix
  93394. * @param transform transformation matrix to be applied to the resulting frustum plane
  93395. * @param frustumPlane the resuling frustum plane
  93396. */
  93397. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93398. /**
  93399. * Gets the right frustum plane transformed by the transform matrix
  93400. * @param transform transformation matrix to be applied to the resulting frustum plane
  93401. * @param frustumPlane the resuling frustum plane
  93402. */
  93403. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93404. /**
  93405. * Gets the top frustum plane transformed by the transform matrix
  93406. * @param transform transformation matrix to be applied to the resulting frustum plane
  93407. * @param frustumPlane the resuling frustum plane
  93408. */
  93409. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93410. /**
  93411. * Gets the bottom frustum plane transformed by the transform matrix
  93412. * @param transform transformation matrix to be applied to the resulting frustum plane
  93413. * @param frustumPlane the resuling frustum plane
  93414. */
  93415. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93416. /**
  93417. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93418. * @param transform transformation matrix to be applied to the resulting frustum planes
  93419. * @param frustumPlanes the resuling frustum planes
  93420. */
  93421. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93422. }
  93423. }
  93424. declare module BABYLON {
  93425. /**
  93426. * Contains position and normal vectors for a vertex
  93427. */
  93428. export class PositionNormalVertex {
  93429. /** the position of the vertex (defaut: 0,0,0) */
  93430. position: Vector3;
  93431. /** the normal of the vertex (defaut: 0,1,0) */
  93432. normal: Vector3;
  93433. /**
  93434. * Creates a PositionNormalVertex
  93435. * @param position the position of the vertex (defaut: 0,0,0)
  93436. * @param normal the normal of the vertex (defaut: 0,1,0)
  93437. */
  93438. constructor(
  93439. /** the position of the vertex (defaut: 0,0,0) */
  93440. position?: Vector3,
  93441. /** the normal of the vertex (defaut: 0,1,0) */
  93442. normal?: Vector3);
  93443. /**
  93444. * Clones the PositionNormalVertex
  93445. * @returns the cloned PositionNormalVertex
  93446. */
  93447. clone(): PositionNormalVertex;
  93448. }
  93449. /**
  93450. * Contains position, normal and uv vectors for a vertex
  93451. */
  93452. export class PositionNormalTextureVertex {
  93453. /** the position of the vertex (defaut: 0,0,0) */
  93454. position: Vector3;
  93455. /** the normal of the vertex (defaut: 0,1,0) */
  93456. normal: Vector3;
  93457. /** the uv of the vertex (default: 0,0) */
  93458. uv: Vector2;
  93459. /**
  93460. * Creates a PositionNormalTextureVertex
  93461. * @param position the position of the vertex (defaut: 0,0,0)
  93462. * @param normal the normal of the vertex (defaut: 0,1,0)
  93463. * @param uv the uv of the vertex (default: 0,0)
  93464. */
  93465. constructor(
  93466. /** the position of the vertex (defaut: 0,0,0) */
  93467. position?: Vector3,
  93468. /** the normal of the vertex (defaut: 0,1,0) */
  93469. normal?: Vector3,
  93470. /** the uv of the vertex (default: 0,0) */
  93471. uv?: Vector2);
  93472. /**
  93473. * Clones the PositionNormalTextureVertex
  93474. * @returns the cloned PositionNormalTextureVertex
  93475. */
  93476. clone(): PositionNormalTextureVertex;
  93477. }
  93478. }
  93479. declare module BABYLON {
  93480. /**
  93481. * Enum defining the type of animations supported by InputBlock
  93482. */
  93483. export enum AnimatedInputBlockTypes {
  93484. /** No animation */
  93485. None = 0,
  93486. /** Time based animation. Will only work for floats */
  93487. Time = 1
  93488. }
  93489. }
  93490. declare module BABYLON {
  93491. /**
  93492. * Block used to expose an input value
  93493. */
  93494. export class InputBlock extends NodeMaterialBlock {
  93495. private _mode;
  93496. private _associatedVariableName;
  93497. private _storedValue;
  93498. private _valueCallback;
  93499. private _type;
  93500. private _animationType;
  93501. /** Gets or set a value used to limit the range of float values */
  93502. min: number;
  93503. /** Gets or set a value used to limit the range of float values */
  93504. max: number;
  93505. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  93506. isBoolean: boolean;
  93507. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  93508. matrixMode: number;
  93509. /** @hidden */
  93510. _systemValue: Nullable<NodeMaterialSystemValues>;
  93511. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  93512. isConstant: boolean;
  93513. /** Gets or sets the group to use to display this block in the Inspector */
  93514. groupInInspector: string;
  93515. /** Gets an observable raised when the value is changed */
  93516. onValueChangedObservable: Observable<InputBlock>;
  93517. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  93518. convertToGammaSpace: boolean;
  93519. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  93520. convertToLinearSpace: boolean;
  93521. /**
  93522. * Gets or sets the connection point type (default is float)
  93523. */
  93524. get type(): NodeMaterialBlockConnectionPointTypes;
  93525. /**
  93526. * Creates a new InputBlock
  93527. * @param name defines the block name
  93528. * @param target defines the target of that block (Vertex by default)
  93529. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  93530. */
  93531. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  93532. /**
  93533. * Validates if a name is a reserve word.
  93534. * @param newName the new name to be given to the node.
  93535. * @returns false if the name is a reserve word, else true.
  93536. */
  93537. validateBlockName(newName: string): boolean;
  93538. /**
  93539. * Gets the output component
  93540. */
  93541. get output(): NodeMaterialConnectionPoint;
  93542. /**
  93543. * Set the source of this connection point to a vertex attribute
  93544. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  93545. * @returns the current connection point
  93546. */
  93547. setAsAttribute(attributeName?: string): InputBlock;
  93548. /**
  93549. * Set the source of this connection point to a system value
  93550. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  93551. * @returns the current connection point
  93552. */
  93553. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  93554. /**
  93555. * Gets or sets the value of that point.
  93556. * Please note that this value will be ignored if valueCallback is defined
  93557. */
  93558. get value(): any;
  93559. set value(value: any);
  93560. /**
  93561. * Gets or sets a callback used to get the value of that point.
  93562. * Please note that setting this value will force the connection point to ignore the value property
  93563. */
  93564. get valueCallback(): () => any;
  93565. set valueCallback(value: () => any);
  93566. /**
  93567. * Gets or sets the associated variable name in the shader
  93568. */
  93569. get associatedVariableName(): string;
  93570. set associatedVariableName(value: string);
  93571. /** Gets or sets the type of animation applied to the input */
  93572. get animationType(): AnimatedInputBlockTypes;
  93573. set animationType(value: AnimatedInputBlockTypes);
  93574. /**
  93575. * Gets a boolean indicating that this connection point not defined yet
  93576. */
  93577. get isUndefined(): boolean;
  93578. /**
  93579. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  93580. * In this case the connection point name must be the name of the uniform to use.
  93581. * Can only be set on inputs
  93582. */
  93583. get isUniform(): boolean;
  93584. set isUniform(value: boolean);
  93585. /**
  93586. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  93587. * In this case the connection point name must be the name of the attribute to use
  93588. * Can only be set on inputs
  93589. */
  93590. get isAttribute(): boolean;
  93591. set isAttribute(value: boolean);
  93592. /**
  93593. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  93594. * Can only be set on exit points
  93595. */
  93596. get isVarying(): boolean;
  93597. set isVarying(value: boolean);
  93598. /**
  93599. * Gets a boolean indicating that the current connection point is a system value
  93600. */
  93601. get isSystemValue(): boolean;
  93602. /**
  93603. * Gets or sets the current well known value or null if not defined as a system value
  93604. */
  93605. get systemValue(): Nullable<NodeMaterialSystemValues>;
  93606. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  93607. /**
  93608. * Gets the current class name
  93609. * @returns the class name
  93610. */
  93611. getClassName(): string;
  93612. /**
  93613. * Animate the input if animationType !== None
  93614. * @param scene defines the rendering scene
  93615. */
  93616. animate(scene: Scene): void;
  93617. private _emitDefine;
  93618. initialize(state: NodeMaterialBuildState): void;
  93619. /**
  93620. * Set the input block to its default value (based on its type)
  93621. */
  93622. setDefaultValue(): void;
  93623. private _emitConstant;
  93624. /** @hidden */
  93625. get _noContextSwitch(): boolean;
  93626. private _emit;
  93627. /** @hidden */
  93628. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  93629. /** @hidden */
  93630. _transmit(effect: Effect, scene: Scene): void;
  93631. protected _buildBlock(state: NodeMaterialBuildState): void;
  93632. protected _dumpPropertiesCode(): string;
  93633. dispose(): void;
  93634. serialize(): any;
  93635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93636. }
  93637. }
  93638. declare module BABYLON {
  93639. /**
  93640. * Enum used to define the compatibility state between two connection points
  93641. */
  93642. export enum NodeMaterialConnectionPointCompatibilityStates {
  93643. /** Points are compatibles */
  93644. Compatible = 0,
  93645. /** Points are incompatible because of their types */
  93646. TypeIncompatible = 1,
  93647. /** Points are incompatible because of their targets (vertex vs fragment) */
  93648. TargetIncompatible = 2
  93649. }
  93650. /**
  93651. * Defines the direction of a connection point
  93652. */
  93653. export enum NodeMaterialConnectionPointDirection {
  93654. /** Input */
  93655. Input = 0,
  93656. /** Output */
  93657. Output = 1
  93658. }
  93659. /**
  93660. * Defines a connection point for a block
  93661. */
  93662. export class NodeMaterialConnectionPoint {
  93663. /**
  93664. * Checks if two types are equivalent
  93665. * @param type1 type 1 to check
  93666. * @param type2 type 2 to check
  93667. * @returns true if both types are equivalent, else false
  93668. */
  93669. static AreEquivalentTypes(type1: number, type2: number): boolean;
  93670. /** @hidden */
  93671. _ownerBlock: NodeMaterialBlock;
  93672. /** @hidden */
  93673. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  93674. private _endpoints;
  93675. private _associatedVariableName;
  93676. private _direction;
  93677. /** @hidden */
  93678. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93679. /** @hidden */
  93680. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93681. /** @hidden */
  93682. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  93683. private _type;
  93684. /** @hidden */
  93685. _enforceAssociatedVariableName: boolean;
  93686. /** Gets the direction of the point */
  93687. get direction(): NodeMaterialConnectionPointDirection;
  93688. /** Indicates that this connection point needs dual validation before being connected to another point */
  93689. needDualDirectionValidation: boolean;
  93690. /**
  93691. * Gets or sets the additional types supported by this connection point
  93692. */
  93693. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93694. /**
  93695. * Gets or sets the additional types excluded by this connection point
  93696. */
  93697. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93698. /**
  93699. * Observable triggered when this point is connected
  93700. */
  93701. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  93702. /**
  93703. * Gets or sets the associated variable name in the shader
  93704. */
  93705. get associatedVariableName(): string;
  93706. set associatedVariableName(value: string);
  93707. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  93708. get innerType(): NodeMaterialBlockConnectionPointTypes;
  93709. /**
  93710. * Gets or sets the connection point type (default is float)
  93711. */
  93712. get type(): NodeMaterialBlockConnectionPointTypes;
  93713. set type(value: NodeMaterialBlockConnectionPointTypes);
  93714. /**
  93715. * Gets or sets the connection point name
  93716. */
  93717. name: string;
  93718. /**
  93719. * Gets or sets the connection point name
  93720. */
  93721. displayName: string;
  93722. /**
  93723. * Gets or sets a boolean indicating that this connection point can be omitted
  93724. */
  93725. isOptional: boolean;
  93726. /**
  93727. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  93728. */
  93729. isExposedOnFrame: boolean;
  93730. /**
  93731. * Gets or sets number indicating the position that the port is exposed to on a frame
  93732. */
  93733. exposedPortPosition: number;
  93734. /**
  93735. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  93736. */
  93737. define: string;
  93738. /** @hidden */
  93739. _prioritizeVertex: boolean;
  93740. private _target;
  93741. /** Gets or sets the target of that connection point */
  93742. get target(): NodeMaterialBlockTargets;
  93743. set target(value: NodeMaterialBlockTargets);
  93744. /**
  93745. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  93746. */
  93747. get isConnected(): boolean;
  93748. /**
  93749. * Gets a boolean indicating that the current point is connected to an input block
  93750. */
  93751. get isConnectedToInputBlock(): boolean;
  93752. /**
  93753. * Gets a the connected input block (if any)
  93754. */
  93755. get connectInputBlock(): Nullable<InputBlock>;
  93756. /** Get the other side of the connection (if any) */
  93757. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  93758. /** Get the block that owns this connection point */
  93759. get ownerBlock(): NodeMaterialBlock;
  93760. /** Get the block connected on the other side of this connection (if any) */
  93761. get sourceBlock(): Nullable<NodeMaterialBlock>;
  93762. /** Get the block connected on the endpoints of this connection (if any) */
  93763. get connectedBlocks(): Array<NodeMaterialBlock>;
  93764. /** Gets the list of connected endpoints */
  93765. get endpoints(): NodeMaterialConnectionPoint[];
  93766. /** Gets a boolean indicating if that output point is connected to at least one input */
  93767. get hasEndpoints(): boolean;
  93768. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  93769. get isConnectedInVertexShader(): boolean;
  93770. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  93771. get isConnectedInFragmentShader(): boolean;
  93772. /**
  93773. * Creates a block suitable to be used as an input for this input point.
  93774. * If null is returned, a block based on the point type will be created.
  93775. * @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
  93776. */
  93777. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  93778. /**
  93779. * Creates a new connection point
  93780. * @param name defines the connection point name
  93781. * @param ownerBlock defines the block hosting this connection point
  93782. * @param direction defines the direction of the connection point
  93783. */
  93784. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  93785. /**
  93786. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  93787. * @returns the class name
  93788. */
  93789. getClassName(): string;
  93790. /**
  93791. * Gets a boolean indicating if the current point can be connected to another point
  93792. * @param connectionPoint defines the other connection point
  93793. * @returns a boolean
  93794. */
  93795. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  93796. /**
  93797. * Gets a number indicating if the current point can be connected to another point
  93798. * @param connectionPoint defines the other connection point
  93799. * @returns a number defining the compatibility state
  93800. */
  93801. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  93802. /**
  93803. * Connect this point to another connection point
  93804. * @param connectionPoint defines the other connection point
  93805. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  93806. * @returns the current connection point
  93807. */
  93808. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  93809. /**
  93810. * Disconnect this point from one of his endpoint
  93811. * @param endpoint defines the other connection point
  93812. * @returns the current connection point
  93813. */
  93814. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  93815. /**
  93816. * Serializes this point in a JSON representation
  93817. * @param isInput defines if the connection point is an input (default is true)
  93818. * @returns the serialized point object
  93819. */
  93820. serialize(isInput?: boolean): any;
  93821. /**
  93822. * Release resources
  93823. */
  93824. dispose(): void;
  93825. }
  93826. }
  93827. declare module BABYLON {
  93828. /**
  93829. * Enum used to define the material modes
  93830. */
  93831. export enum NodeMaterialModes {
  93832. /** Regular material */
  93833. Material = 0,
  93834. /** For post process */
  93835. PostProcess = 1,
  93836. /** For particle system */
  93837. Particle = 2,
  93838. /** For procedural texture */
  93839. ProceduralTexture = 3
  93840. }
  93841. }
  93842. declare module BABYLON {
  93843. /** @hidden */
  93844. export var helperFunctions: {
  93845. name: string;
  93846. shader: string;
  93847. };
  93848. }
  93849. declare module BABYLON {
  93850. /**
  93851. * Block used to read a texture from a sampler
  93852. */
  93853. export class TextureBlock extends NodeMaterialBlock {
  93854. private _defineName;
  93855. private _linearDefineName;
  93856. private _gammaDefineName;
  93857. private _tempTextureRead;
  93858. private _samplerName;
  93859. private _transformedUVName;
  93860. private _textureTransformName;
  93861. private _textureInfoName;
  93862. private _mainUVName;
  93863. private _mainUVDefineName;
  93864. private _fragmentOnly;
  93865. /**
  93866. * Gets or sets the texture associated with the node
  93867. */
  93868. texture: Nullable<Texture>;
  93869. /**
  93870. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  93871. */
  93872. convertToGammaSpace: boolean;
  93873. /**
  93874. * Gets or sets a boolean indicating if content needs to be converted to linear space
  93875. */
  93876. convertToLinearSpace: boolean;
  93877. /**
  93878. * Create a new TextureBlock
  93879. * @param name defines the block name
  93880. */
  93881. constructor(name: string, fragmentOnly?: boolean);
  93882. /**
  93883. * Gets the current class name
  93884. * @returns the class name
  93885. */
  93886. getClassName(): string;
  93887. /**
  93888. * Gets the uv input component
  93889. */
  93890. get uv(): NodeMaterialConnectionPoint;
  93891. /**
  93892. * Gets the rgba output component
  93893. */
  93894. get rgba(): NodeMaterialConnectionPoint;
  93895. /**
  93896. * Gets the rgb output component
  93897. */
  93898. get rgb(): NodeMaterialConnectionPoint;
  93899. /**
  93900. * Gets the r output component
  93901. */
  93902. get r(): NodeMaterialConnectionPoint;
  93903. /**
  93904. * Gets the g output component
  93905. */
  93906. get g(): NodeMaterialConnectionPoint;
  93907. /**
  93908. * Gets the b output component
  93909. */
  93910. get b(): NodeMaterialConnectionPoint;
  93911. /**
  93912. * Gets the a output component
  93913. */
  93914. get a(): NodeMaterialConnectionPoint;
  93915. get target(): NodeMaterialBlockTargets;
  93916. autoConfigure(material: NodeMaterial): void;
  93917. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  93918. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93919. isReady(): boolean;
  93920. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93921. private get _isMixed();
  93922. private _injectVertexCode;
  93923. private _writeTextureRead;
  93924. private _writeOutput;
  93925. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  93926. protected _dumpPropertiesCode(): string;
  93927. serialize(): any;
  93928. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93929. }
  93930. }
  93931. declare module BABYLON {
  93932. /** @hidden */
  93933. export var reflectionFunction: {
  93934. name: string;
  93935. shader: string;
  93936. };
  93937. }
  93938. declare module BABYLON {
  93939. /**
  93940. * Base block used to read a reflection texture from a sampler
  93941. */
  93942. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  93943. /** @hidden */
  93944. _define3DName: string;
  93945. /** @hidden */
  93946. _defineCubicName: string;
  93947. /** @hidden */
  93948. _defineExplicitName: string;
  93949. /** @hidden */
  93950. _defineProjectionName: string;
  93951. /** @hidden */
  93952. _defineLocalCubicName: string;
  93953. /** @hidden */
  93954. _defineSphericalName: string;
  93955. /** @hidden */
  93956. _definePlanarName: string;
  93957. /** @hidden */
  93958. _defineEquirectangularName: string;
  93959. /** @hidden */
  93960. _defineMirroredEquirectangularFixedName: string;
  93961. /** @hidden */
  93962. _defineEquirectangularFixedName: string;
  93963. /** @hidden */
  93964. _defineSkyboxName: string;
  93965. /** @hidden */
  93966. _defineOppositeZ: string;
  93967. /** @hidden */
  93968. _cubeSamplerName: string;
  93969. /** @hidden */
  93970. _2DSamplerName: string;
  93971. protected _positionUVWName: string;
  93972. protected _directionWName: string;
  93973. protected _reflectionVectorName: string;
  93974. /** @hidden */
  93975. _reflectionCoordsName: string;
  93976. /** @hidden */
  93977. _reflectionMatrixName: string;
  93978. protected _reflectionColorName: string;
  93979. /**
  93980. * Gets or sets the texture associated with the node
  93981. */
  93982. texture: Nullable<BaseTexture>;
  93983. /**
  93984. * Create a new ReflectionTextureBaseBlock
  93985. * @param name defines the block name
  93986. */
  93987. constructor(name: string);
  93988. /**
  93989. * Gets the current class name
  93990. * @returns the class name
  93991. */
  93992. getClassName(): string;
  93993. /**
  93994. * Gets the world position input component
  93995. */
  93996. abstract get position(): NodeMaterialConnectionPoint;
  93997. /**
  93998. * Gets the world position input component
  93999. */
  94000. abstract get worldPosition(): NodeMaterialConnectionPoint;
  94001. /**
  94002. * Gets the world normal input component
  94003. */
  94004. abstract get worldNormal(): NodeMaterialConnectionPoint;
  94005. /**
  94006. * Gets the world input component
  94007. */
  94008. abstract get world(): NodeMaterialConnectionPoint;
  94009. /**
  94010. * Gets the camera (or eye) position component
  94011. */
  94012. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  94013. /**
  94014. * Gets the view input component
  94015. */
  94016. abstract get view(): NodeMaterialConnectionPoint;
  94017. protected _getTexture(): Nullable<BaseTexture>;
  94018. autoConfigure(material: NodeMaterial): void;
  94019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94020. isReady(): boolean;
  94021. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  94022. /**
  94023. * Gets the code to inject in the vertex shader
  94024. * @param state current state of the node material building
  94025. * @returns the shader code
  94026. */
  94027. handleVertexSide(state: NodeMaterialBuildState): string;
  94028. /**
  94029. * Handles the inits for the fragment code path
  94030. * @param state node material build state
  94031. */
  94032. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  94033. /**
  94034. * Generates the reflection coords code for the fragment code path
  94035. * @param worldNormalVarName name of the world normal variable
  94036. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  94037. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  94038. * @returns the shader code
  94039. */
  94040. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  94041. /**
  94042. * Generates the reflection color code for the fragment code path
  94043. * @param lodVarName name of the lod variable
  94044. * @param swizzleLookupTexture swizzle to use for the final color variable
  94045. * @returns the shader code
  94046. */
  94047. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  94048. /**
  94049. * Generates the code corresponding to the connected output points
  94050. * @param state node material build state
  94051. * @param varName name of the variable to output
  94052. * @returns the shader code
  94053. */
  94054. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  94055. protected _buildBlock(state: NodeMaterialBuildState): this;
  94056. protected _dumpPropertiesCode(): string;
  94057. serialize(): any;
  94058. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94059. }
  94060. }
  94061. declare module BABYLON {
  94062. /**
  94063. * Defines a connection point to be used for points with a custom object type
  94064. */
  94065. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  94066. private _blockType;
  94067. private _blockName;
  94068. private _nameForCheking?;
  94069. /**
  94070. * Creates a new connection point
  94071. * @param name defines the connection point name
  94072. * @param ownerBlock defines the block hosting this connection point
  94073. * @param direction defines the direction of the connection point
  94074. */
  94075. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  94076. /**
  94077. * Gets a number indicating if the current point can be connected to another point
  94078. * @param connectionPoint defines the other connection point
  94079. * @returns a number defining the compatibility state
  94080. */
  94081. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  94082. /**
  94083. * Creates a block suitable to be used as an input for this input point.
  94084. * If null is returned, a block based on the point type will be created.
  94085. * @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
  94086. */
  94087. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  94088. }
  94089. }
  94090. declare module BABYLON {
  94091. /**
  94092. * Enum defining the type of properties that can be edited in the property pages in the NME
  94093. */
  94094. export enum PropertyTypeForEdition {
  94095. /** property is a boolean */
  94096. Boolean = 0,
  94097. /** property is a float */
  94098. Float = 1,
  94099. /** property is a Vector2 */
  94100. Vector2 = 2,
  94101. /** property is a list of values */
  94102. List = 3
  94103. }
  94104. /**
  94105. * Interface that defines an option in a variable of type list
  94106. */
  94107. export interface IEditablePropertyListOption {
  94108. /** label of the option */
  94109. "label": string;
  94110. /** value of the option */
  94111. "value": number;
  94112. }
  94113. /**
  94114. * Interface that defines the options available for an editable property
  94115. */
  94116. export interface IEditablePropertyOption {
  94117. /** min value */
  94118. "min"?: number;
  94119. /** max value */
  94120. "max"?: number;
  94121. /** notifiers: indicates which actions to take when the property is changed */
  94122. "notifiers"?: {
  94123. /** the material should be rebuilt */
  94124. "rebuild"?: boolean;
  94125. /** the preview should be updated */
  94126. "update"?: boolean;
  94127. };
  94128. /** list of the options for a variable of type list */
  94129. "options"?: IEditablePropertyListOption[];
  94130. }
  94131. /**
  94132. * Interface that describes an editable property
  94133. */
  94134. export interface IPropertyDescriptionForEdition {
  94135. /** name of the property */
  94136. "propertyName": string;
  94137. /** display name of the property */
  94138. "displayName": string;
  94139. /** type of the property */
  94140. "type": PropertyTypeForEdition;
  94141. /** group of the property - all properties with the same group value will be displayed in a specific section */
  94142. "groupName": string;
  94143. /** options for the property */
  94144. "options": IEditablePropertyOption;
  94145. }
  94146. /**
  94147. * Decorator that flags a property in a node material block as being editable
  94148. */
  94149. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  94150. }
  94151. declare module BABYLON {
  94152. /**
  94153. * Block used to implement the refraction part of the sub surface module of the PBR material
  94154. */
  94155. export class RefractionBlock extends NodeMaterialBlock {
  94156. /** @hidden */
  94157. _define3DName: string;
  94158. /** @hidden */
  94159. _refractionMatrixName: string;
  94160. /** @hidden */
  94161. _defineLODRefractionAlpha: string;
  94162. /** @hidden */
  94163. _defineLinearSpecularRefraction: string;
  94164. /** @hidden */
  94165. _defineOppositeZ: string;
  94166. /** @hidden */
  94167. _cubeSamplerName: string;
  94168. /** @hidden */
  94169. _2DSamplerName: string;
  94170. /** @hidden */
  94171. _vRefractionMicrosurfaceInfosName: string;
  94172. /** @hidden */
  94173. _vRefractionInfosName: string;
  94174. /** @hidden */
  94175. _vRefractionFilteringInfoName: string;
  94176. private _scene;
  94177. /**
  94178. * The properties below are set by the main PBR block prior to calling methods of this class.
  94179. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  94180. * It's less burden on the user side in the editor part.
  94181. */
  94182. /** @hidden */
  94183. viewConnectionPoint: NodeMaterialConnectionPoint;
  94184. /** @hidden */
  94185. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  94186. /**
  94187. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  94188. * Materials half opaque for instance using refraction could benefit from this control.
  94189. */
  94190. linkRefractionWithTransparency: boolean;
  94191. /**
  94192. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  94193. */
  94194. invertRefractionY: boolean;
  94195. /**
  94196. * Gets or sets the texture associated with the node
  94197. */
  94198. texture: Nullable<BaseTexture>;
  94199. /**
  94200. * Create a new RefractionBlock
  94201. * @param name defines the block name
  94202. */
  94203. constructor(name: string);
  94204. /**
  94205. * Gets the current class name
  94206. * @returns the class name
  94207. */
  94208. getClassName(): string;
  94209. /**
  94210. * Gets the intensity input component
  94211. */
  94212. get intensity(): NodeMaterialConnectionPoint;
  94213. /**
  94214. * Gets the tint at distance input component
  94215. */
  94216. get tintAtDistance(): NodeMaterialConnectionPoint;
  94217. /**
  94218. * Gets the view input component
  94219. */
  94220. get view(): NodeMaterialConnectionPoint;
  94221. /**
  94222. * Gets the refraction object output component
  94223. */
  94224. get refraction(): NodeMaterialConnectionPoint;
  94225. /**
  94226. * Returns true if the block has a texture
  94227. */
  94228. get hasTexture(): boolean;
  94229. protected _getTexture(): Nullable<BaseTexture>;
  94230. autoConfigure(material: NodeMaterial): void;
  94231. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94232. isReady(): boolean;
  94233. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  94234. /**
  94235. * Gets the main code of the block (fragment side)
  94236. * @param state current state of the node material building
  94237. * @returns the shader code
  94238. */
  94239. getCode(state: NodeMaterialBuildState): string;
  94240. protected _buildBlock(state: NodeMaterialBuildState): this;
  94241. protected _dumpPropertiesCode(): string;
  94242. serialize(): any;
  94243. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94244. }
  94245. }
  94246. declare module BABYLON {
  94247. /**
  94248. * Base block used as input for post process
  94249. */
  94250. export class CurrentScreenBlock extends NodeMaterialBlock {
  94251. private _samplerName;
  94252. private _linearDefineName;
  94253. private _gammaDefineName;
  94254. private _mainUVName;
  94255. private _tempTextureRead;
  94256. /**
  94257. * Gets or sets the texture associated with the node
  94258. */
  94259. texture: Nullable<BaseTexture>;
  94260. /**
  94261. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94262. */
  94263. convertToGammaSpace: boolean;
  94264. /**
  94265. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94266. */
  94267. convertToLinearSpace: boolean;
  94268. /**
  94269. * Create a new CurrentScreenBlock
  94270. * @param name defines the block name
  94271. */
  94272. constructor(name: string);
  94273. /**
  94274. * Gets the current class name
  94275. * @returns the class name
  94276. */
  94277. getClassName(): string;
  94278. /**
  94279. * Gets the uv input component
  94280. */
  94281. get uv(): NodeMaterialConnectionPoint;
  94282. /**
  94283. * Gets the rgba output component
  94284. */
  94285. get rgba(): NodeMaterialConnectionPoint;
  94286. /**
  94287. * Gets the rgb output component
  94288. */
  94289. get rgb(): NodeMaterialConnectionPoint;
  94290. /**
  94291. * Gets the r output component
  94292. */
  94293. get r(): NodeMaterialConnectionPoint;
  94294. /**
  94295. * Gets the g output component
  94296. */
  94297. get g(): NodeMaterialConnectionPoint;
  94298. /**
  94299. * Gets the b output component
  94300. */
  94301. get b(): NodeMaterialConnectionPoint;
  94302. /**
  94303. * Gets the a output component
  94304. */
  94305. get a(): NodeMaterialConnectionPoint;
  94306. /**
  94307. * Initialize the block and prepare the context for build
  94308. * @param state defines the state that will be used for the build
  94309. */
  94310. initialize(state: NodeMaterialBuildState): void;
  94311. get target(): NodeMaterialBlockTargets;
  94312. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94313. isReady(): boolean;
  94314. private _injectVertexCode;
  94315. private _writeTextureRead;
  94316. private _writeOutput;
  94317. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94318. serialize(): any;
  94319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94320. }
  94321. }
  94322. declare module BABYLON {
  94323. /**
  94324. * Base block used for the particle texture
  94325. */
  94326. export class ParticleTextureBlock extends NodeMaterialBlock {
  94327. private _samplerName;
  94328. private _linearDefineName;
  94329. private _gammaDefineName;
  94330. private _tempTextureRead;
  94331. /**
  94332. * Gets or sets the texture associated with the node
  94333. */
  94334. texture: Nullable<BaseTexture>;
  94335. /**
  94336. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94337. */
  94338. convertToGammaSpace: boolean;
  94339. /**
  94340. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94341. */
  94342. convertToLinearSpace: boolean;
  94343. /**
  94344. * Create a new ParticleTextureBlock
  94345. * @param name defines the block name
  94346. */
  94347. constructor(name: string);
  94348. /**
  94349. * Gets the current class name
  94350. * @returns the class name
  94351. */
  94352. getClassName(): string;
  94353. /**
  94354. * Gets the uv input component
  94355. */
  94356. get uv(): NodeMaterialConnectionPoint;
  94357. /**
  94358. * Gets the rgba output component
  94359. */
  94360. get rgba(): NodeMaterialConnectionPoint;
  94361. /**
  94362. * Gets the rgb output component
  94363. */
  94364. get rgb(): NodeMaterialConnectionPoint;
  94365. /**
  94366. * Gets the r output component
  94367. */
  94368. get r(): NodeMaterialConnectionPoint;
  94369. /**
  94370. * Gets the g output component
  94371. */
  94372. get g(): NodeMaterialConnectionPoint;
  94373. /**
  94374. * Gets the b output component
  94375. */
  94376. get b(): NodeMaterialConnectionPoint;
  94377. /**
  94378. * Gets the a output component
  94379. */
  94380. get a(): NodeMaterialConnectionPoint;
  94381. /**
  94382. * Initialize the block and prepare the context for build
  94383. * @param state defines the state that will be used for the build
  94384. */
  94385. initialize(state: NodeMaterialBuildState): void;
  94386. autoConfigure(material: NodeMaterial): void;
  94387. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94388. isReady(): boolean;
  94389. private _writeOutput;
  94390. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94391. serialize(): any;
  94392. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94393. }
  94394. }
  94395. declare module BABYLON {
  94396. /**
  94397. * Class used to store shared data between 2 NodeMaterialBuildState
  94398. */
  94399. export class NodeMaterialBuildStateSharedData {
  94400. /**
  94401. * Gets the list of emitted varyings
  94402. */
  94403. temps: string[];
  94404. /**
  94405. * Gets the list of emitted varyings
  94406. */
  94407. varyings: string[];
  94408. /**
  94409. * Gets the varying declaration string
  94410. */
  94411. varyingDeclaration: string;
  94412. /**
  94413. * Input blocks
  94414. */
  94415. inputBlocks: InputBlock[];
  94416. /**
  94417. * Input blocks
  94418. */
  94419. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  94420. /**
  94421. * Bindable blocks (Blocks that need to set data to the effect)
  94422. */
  94423. bindableBlocks: NodeMaterialBlock[];
  94424. /**
  94425. * List of blocks that can provide a compilation fallback
  94426. */
  94427. blocksWithFallbacks: NodeMaterialBlock[];
  94428. /**
  94429. * List of blocks that can provide a define update
  94430. */
  94431. blocksWithDefines: NodeMaterialBlock[];
  94432. /**
  94433. * List of blocks that can provide a repeatable content
  94434. */
  94435. repeatableContentBlocks: NodeMaterialBlock[];
  94436. /**
  94437. * List of blocks that can provide a dynamic list of uniforms
  94438. */
  94439. dynamicUniformBlocks: NodeMaterialBlock[];
  94440. /**
  94441. * List of blocks that can block the isReady function for the material
  94442. */
  94443. blockingBlocks: NodeMaterialBlock[];
  94444. /**
  94445. * Gets the list of animated inputs
  94446. */
  94447. animatedInputs: InputBlock[];
  94448. /**
  94449. * Build Id used to avoid multiple recompilations
  94450. */
  94451. buildId: number;
  94452. /** List of emitted variables */
  94453. variableNames: {
  94454. [key: string]: number;
  94455. };
  94456. /** List of emitted defines */
  94457. defineNames: {
  94458. [key: string]: number;
  94459. };
  94460. /** Should emit comments? */
  94461. emitComments: boolean;
  94462. /** Emit build activity */
  94463. verbose: boolean;
  94464. /** Gets or sets the hosting scene */
  94465. scene: Scene;
  94466. /**
  94467. * Gets the compilation hints emitted at compilation time
  94468. */
  94469. hints: {
  94470. needWorldViewMatrix: boolean;
  94471. needWorldViewProjectionMatrix: boolean;
  94472. needAlphaBlending: boolean;
  94473. needAlphaTesting: boolean;
  94474. };
  94475. /**
  94476. * List of compilation checks
  94477. */
  94478. checks: {
  94479. emitVertex: boolean;
  94480. emitFragment: boolean;
  94481. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  94482. };
  94483. /**
  94484. * Is vertex program allowed to be empty?
  94485. */
  94486. allowEmptyVertexProgram: boolean;
  94487. /** Creates a new shared data */
  94488. constructor();
  94489. /**
  94490. * Emits console errors and exceptions if there is a failing check
  94491. */
  94492. emitErrors(): void;
  94493. }
  94494. }
  94495. declare module BABYLON {
  94496. /**
  94497. * Class used to store node based material build state
  94498. */
  94499. export class NodeMaterialBuildState {
  94500. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  94501. supportUniformBuffers: boolean;
  94502. /**
  94503. * Gets the list of emitted attributes
  94504. */
  94505. attributes: string[];
  94506. /**
  94507. * Gets the list of emitted uniforms
  94508. */
  94509. uniforms: string[];
  94510. /**
  94511. * Gets the list of emitted constants
  94512. */
  94513. constants: string[];
  94514. /**
  94515. * Gets the list of emitted samplers
  94516. */
  94517. samplers: string[];
  94518. /**
  94519. * Gets the list of emitted functions
  94520. */
  94521. functions: {
  94522. [key: string]: string;
  94523. };
  94524. /**
  94525. * Gets the list of emitted extensions
  94526. */
  94527. extensions: {
  94528. [key: string]: string;
  94529. };
  94530. /**
  94531. * Gets the target of the compilation state
  94532. */
  94533. target: NodeMaterialBlockTargets;
  94534. /**
  94535. * Gets the list of emitted counters
  94536. */
  94537. counters: {
  94538. [key: string]: number;
  94539. };
  94540. /**
  94541. * Shared data between multiple NodeMaterialBuildState instances
  94542. */
  94543. sharedData: NodeMaterialBuildStateSharedData;
  94544. /** @hidden */
  94545. _vertexState: NodeMaterialBuildState;
  94546. /** @hidden */
  94547. _attributeDeclaration: string;
  94548. /** @hidden */
  94549. _uniformDeclaration: string;
  94550. /** @hidden */
  94551. _constantDeclaration: string;
  94552. /** @hidden */
  94553. _samplerDeclaration: string;
  94554. /** @hidden */
  94555. _varyingTransfer: string;
  94556. /** @hidden */
  94557. _injectAtEnd: string;
  94558. private _repeatableContentAnchorIndex;
  94559. /** @hidden */
  94560. _builtCompilationString: string;
  94561. /**
  94562. * Gets the emitted compilation strings
  94563. */
  94564. compilationString: string;
  94565. /**
  94566. * Finalize the compilation strings
  94567. * @param state defines the current compilation state
  94568. */
  94569. finalize(state: NodeMaterialBuildState): void;
  94570. /** @hidden */
  94571. get _repeatableContentAnchor(): string;
  94572. /** @hidden */
  94573. _getFreeVariableName(prefix: string): string;
  94574. /** @hidden */
  94575. _getFreeDefineName(prefix: string): string;
  94576. /** @hidden */
  94577. _excludeVariableName(name: string): void;
  94578. /** @hidden */
  94579. _emit2DSampler(name: string): void;
  94580. /** @hidden */
  94581. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  94582. /** @hidden */
  94583. _emitExtension(name: string, extension: string, define?: string): void;
  94584. /** @hidden */
  94585. _emitFunction(name: string, code: string, comments: string): void;
  94586. /** @hidden */
  94587. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  94588. replaceStrings?: {
  94589. search: RegExp;
  94590. replace: string;
  94591. }[];
  94592. repeatKey?: string;
  94593. }): string;
  94594. /** @hidden */
  94595. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  94596. repeatKey?: string;
  94597. removeAttributes?: boolean;
  94598. removeUniforms?: boolean;
  94599. removeVaryings?: boolean;
  94600. removeIfDef?: boolean;
  94601. replaceStrings?: {
  94602. search: RegExp;
  94603. replace: string;
  94604. }[];
  94605. }, storeKey?: string): void;
  94606. /** @hidden */
  94607. _registerTempVariable(name: string): boolean;
  94608. /** @hidden */
  94609. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  94610. /** @hidden */
  94611. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  94612. /** @hidden */
  94613. _emitFloat(value: number): string;
  94614. }
  94615. }
  94616. declare module BABYLON {
  94617. /**
  94618. * Helper class used to generate session unique ID
  94619. */
  94620. export class UniqueIdGenerator {
  94621. private static _UniqueIdCounter;
  94622. /**
  94623. * Gets an unique (relatively to the current scene) Id
  94624. */
  94625. static get UniqueId(): number;
  94626. }
  94627. }
  94628. declare module BABYLON {
  94629. /**
  94630. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94631. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94632. */
  94633. export class EffectFallbacks implements IEffectFallbacks {
  94634. private _defines;
  94635. private _currentRank;
  94636. private _maxRank;
  94637. private _mesh;
  94638. /**
  94639. * Removes the fallback from the bound mesh.
  94640. */
  94641. unBindMesh(): void;
  94642. /**
  94643. * Adds a fallback on the specified property.
  94644. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94645. * @param define The name of the define in the shader
  94646. */
  94647. addFallback(rank: number, define: string): void;
  94648. /**
  94649. * Sets the mesh to use CPU skinning when needing to fallback.
  94650. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94651. * @param mesh The mesh to use the fallbacks.
  94652. */
  94653. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94654. /**
  94655. * Checks to see if more fallbacks are still availible.
  94656. */
  94657. get hasMoreFallbacks(): boolean;
  94658. /**
  94659. * Removes the defines that should be removed when falling back.
  94660. * @param currentDefines defines the current define statements for the shader.
  94661. * @param effect defines the current effect we try to compile
  94662. * @returns The resulting defines with defines of the current rank removed.
  94663. */
  94664. reduce(currentDefines: string, effect: Effect): string;
  94665. }
  94666. }
  94667. declare module BABYLON {
  94668. /**
  94669. * Defines a block that can be used inside a node based material
  94670. */
  94671. export class NodeMaterialBlock {
  94672. private _buildId;
  94673. private _buildTarget;
  94674. private _target;
  94675. private _isFinalMerger;
  94676. private _isInput;
  94677. private _name;
  94678. protected _isUnique: boolean;
  94679. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  94680. inputsAreExclusive: boolean;
  94681. /** @hidden */
  94682. _codeVariableName: string;
  94683. /** @hidden */
  94684. _inputs: NodeMaterialConnectionPoint[];
  94685. /** @hidden */
  94686. _outputs: NodeMaterialConnectionPoint[];
  94687. /** @hidden */
  94688. _preparationId: number;
  94689. /**
  94690. * Gets the name of the block
  94691. */
  94692. get name(): string;
  94693. /**
  94694. * Sets the name of the block. Will check if the name is valid.
  94695. */
  94696. set name(newName: string);
  94697. /**
  94698. * Gets or sets the unique id of the node
  94699. */
  94700. uniqueId: number;
  94701. /**
  94702. * Gets or sets the comments associated with this block
  94703. */
  94704. comments: string;
  94705. /**
  94706. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  94707. */
  94708. get isUnique(): boolean;
  94709. /**
  94710. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  94711. */
  94712. get isFinalMerger(): boolean;
  94713. /**
  94714. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  94715. */
  94716. get isInput(): boolean;
  94717. /**
  94718. * Gets or sets the build Id
  94719. */
  94720. get buildId(): number;
  94721. set buildId(value: number);
  94722. /**
  94723. * Gets or sets the target of the block
  94724. */
  94725. get target(): NodeMaterialBlockTargets;
  94726. set target(value: NodeMaterialBlockTargets);
  94727. /**
  94728. * Gets the list of input points
  94729. */
  94730. get inputs(): NodeMaterialConnectionPoint[];
  94731. /** Gets the list of output points */
  94732. get outputs(): NodeMaterialConnectionPoint[];
  94733. /**
  94734. * Find an input by its name
  94735. * @param name defines the name of the input to look for
  94736. * @returns the input or null if not found
  94737. */
  94738. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94739. /**
  94740. * Find an output by its name
  94741. * @param name defines the name of the outputto look for
  94742. * @returns the output or null if not found
  94743. */
  94744. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94745. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  94746. visibleInInspector: boolean;
  94747. /**
  94748. * Creates a new NodeMaterialBlock
  94749. * @param name defines the block name
  94750. * @param target defines the target of that block (Vertex by default)
  94751. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  94752. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  94753. */
  94754. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  94755. /**
  94756. * Initialize the block and prepare the context for build
  94757. * @param state defines the state that will be used for the build
  94758. */
  94759. initialize(state: NodeMaterialBuildState): void;
  94760. /**
  94761. * Bind data to effect. Will only be called for blocks with isBindable === true
  94762. * @param effect defines the effect to bind data to
  94763. * @param nodeMaterial defines the hosting NodeMaterial
  94764. * @param mesh defines the mesh that will be rendered
  94765. * @param subMesh defines the submesh that will be rendered
  94766. */
  94767. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  94768. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  94769. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  94770. protected _writeFloat(value: number): string;
  94771. /**
  94772. * Gets the current class name e.g. "NodeMaterialBlock"
  94773. * @returns the class name
  94774. */
  94775. getClassName(): string;
  94776. /**
  94777. * Register a new input. Must be called inside a block constructor
  94778. * @param name defines the connection point name
  94779. * @param type defines the connection point type
  94780. * @param isOptional defines a boolean indicating that this input can be omitted
  94781. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94782. * @param point an already created connection point. If not provided, create a new one
  94783. * @returns the current block
  94784. */
  94785. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94786. /**
  94787. * Register a new output. Must be called inside a block constructor
  94788. * @param name defines the connection point name
  94789. * @param type defines the connection point type
  94790. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94791. * @param point an already created connection point. If not provided, create a new one
  94792. * @returns the current block
  94793. */
  94794. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94795. /**
  94796. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  94797. * @param forOutput defines an optional connection point to check compatibility with
  94798. * @returns the first available input or null
  94799. */
  94800. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  94801. /**
  94802. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  94803. * @param forBlock defines an optional block to check compatibility with
  94804. * @returns the first available input or null
  94805. */
  94806. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  94807. /**
  94808. * Gets the sibling of the given output
  94809. * @param current defines the current output
  94810. * @returns the next output in the list or null
  94811. */
  94812. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  94813. /**
  94814. * Connect current block with another block
  94815. * @param other defines the block to connect with
  94816. * @param options define the various options to help pick the right connections
  94817. * @returns the current block
  94818. */
  94819. connectTo(other: NodeMaterialBlock, options?: {
  94820. input?: string;
  94821. output?: string;
  94822. outputSwizzle?: string;
  94823. }): this | undefined;
  94824. protected _buildBlock(state: NodeMaterialBuildState): void;
  94825. /**
  94826. * Add uniforms, samplers and uniform buffers at compilation time
  94827. * @param state defines the state to update
  94828. * @param nodeMaterial defines the node material requesting the update
  94829. * @param defines defines the material defines to update
  94830. * @param uniformBuffers defines the list of uniform buffer names
  94831. */
  94832. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  94833. /**
  94834. * Add potential fallbacks if shader compilation fails
  94835. * @param mesh defines the mesh to be rendered
  94836. * @param fallbacks defines the current prioritized list of fallbacks
  94837. */
  94838. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  94839. /**
  94840. * Initialize defines for shader compilation
  94841. * @param mesh defines the mesh to be rendered
  94842. * @param nodeMaterial defines the node material requesting the update
  94843. * @param defines defines the material defines to update
  94844. * @param useInstances specifies that instances should be used
  94845. */
  94846. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  94847. /**
  94848. * Update defines for shader compilation
  94849. * @param mesh defines the mesh to be rendered
  94850. * @param nodeMaterial defines the node material requesting the update
  94851. * @param defines defines the material defines to update
  94852. * @param useInstances specifies that instances should be used
  94853. * @param subMesh defines which submesh to render
  94854. */
  94855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94856. /**
  94857. * Lets the block try to connect some inputs automatically
  94858. * @param material defines the hosting NodeMaterial
  94859. */
  94860. autoConfigure(material: NodeMaterial): void;
  94861. /**
  94862. * Function called when a block is declared as repeatable content generator
  94863. * @param vertexShaderState defines the current compilation state for the vertex shader
  94864. * @param fragmentShaderState defines the current compilation state for the fragment shader
  94865. * @param mesh defines the mesh to be rendered
  94866. * @param defines defines the material defines to update
  94867. */
  94868. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  94869. /**
  94870. * Checks if the block is ready
  94871. * @param mesh defines the mesh to be rendered
  94872. * @param nodeMaterial defines the node material requesting the update
  94873. * @param defines defines the material defines to update
  94874. * @param useInstances specifies that instances should be used
  94875. * @returns true if the block is ready
  94876. */
  94877. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  94878. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  94879. private _processBuild;
  94880. /**
  94881. * Validates the new name for the block node.
  94882. * @param newName the new name to be given to the node.
  94883. * @returns false if the name is a reserve word, else true.
  94884. */
  94885. validateBlockName(newName: string): boolean;
  94886. /**
  94887. * Compile the current node and generate the shader code
  94888. * @param state defines the current compilation state (uniforms, samplers, current string)
  94889. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  94890. * @returns true if already built
  94891. */
  94892. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  94893. protected _inputRename(name: string): string;
  94894. protected _outputRename(name: string): string;
  94895. protected _dumpPropertiesCode(): string;
  94896. /** @hidden */
  94897. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  94898. /** @hidden */
  94899. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  94900. /**
  94901. * Clone the current block to a new identical block
  94902. * @param scene defines the hosting scene
  94903. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94904. * @returns a copy of the current block
  94905. */
  94906. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  94907. /**
  94908. * Serializes this block in a JSON representation
  94909. * @returns the serialized block object
  94910. */
  94911. serialize(): any;
  94912. /** @hidden */
  94913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94914. private _deserializePortDisplayNamesAndExposedOnFrame;
  94915. /**
  94916. * Release resources
  94917. */
  94918. dispose(): void;
  94919. }
  94920. }
  94921. declare module BABYLON {
  94922. /**
  94923. * Base class of materials working in push mode in babylon JS
  94924. * @hidden
  94925. */
  94926. export class PushMaterial extends Material {
  94927. protected _activeEffect: Effect;
  94928. protected _normalMatrix: Matrix;
  94929. constructor(name: string, scene: Scene);
  94930. getEffect(): Effect;
  94931. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94932. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  94933. /**
  94934. * Binds the given world matrix to the active effect
  94935. *
  94936. * @param world the matrix to bind
  94937. */
  94938. bindOnlyWorldMatrix(world: Matrix): void;
  94939. /**
  94940. * Binds the given normal matrix to the active effect
  94941. *
  94942. * @param normalMatrix the matrix to bind
  94943. */
  94944. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94945. bind(world: Matrix, mesh?: Mesh): void;
  94946. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94947. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94948. }
  94949. }
  94950. declare module BABYLON {
  94951. /**
  94952. * Root class for all node material optimizers
  94953. */
  94954. export class NodeMaterialOptimizer {
  94955. /**
  94956. * Function used to optimize a NodeMaterial graph
  94957. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  94958. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  94959. */
  94960. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  94961. }
  94962. }
  94963. declare module BABYLON {
  94964. /**
  94965. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  94966. */
  94967. export class TransformBlock extends NodeMaterialBlock {
  94968. /**
  94969. * Defines the value to use to complement W value to transform it to a Vector4
  94970. */
  94971. complementW: number;
  94972. /**
  94973. * Defines the value to use to complement z value to transform it to a Vector4
  94974. */
  94975. complementZ: number;
  94976. /**
  94977. * Creates a new TransformBlock
  94978. * @param name defines the block name
  94979. */
  94980. constructor(name: string);
  94981. /**
  94982. * Gets the current class name
  94983. * @returns the class name
  94984. */
  94985. getClassName(): string;
  94986. /**
  94987. * Gets the vector input
  94988. */
  94989. get vector(): NodeMaterialConnectionPoint;
  94990. /**
  94991. * Gets the output component
  94992. */
  94993. get output(): NodeMaterialConnectionPoint;
  94994. /**
  94995. * Gets the xyz output component
  94996. */
  94997. get xyz(): NodeMaterialConnectionPoint;
  94998. /**
  94999. * Gets the matrix transform input
  95000. */
  95001. get transform(): NodeMaterialConnectionPoint;
  95002. protected _buildBlock(state: NodeMaterialBuildState): this;
  95003. /**
  95004. * Update defines for shader compilation
  95005. * @param mesh defines the mesh to be rendered
  95006. * @param nodeMaterial defines the node material requesting the update
  95007. * @param defines defines the material defines to update
  95008. * @param useInstances specifies that instances should be used
  95009. * @param subMesh defines which submesh to render
  95010. */
  95011. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  95012. serialize(): any;
  95013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  95014. protected _dumpPropertiesCode(): string;
  95015. }
  95016. }
  95017. declare module BABYLON {
  95018. /**
  95019. * Block used to output the vertex position
  95020. */
  95021. export class VertexOutputBlock extends NodeMaterialBlock {
  95022. /**
  95023. * Creates a new VertexOutputBlock
  95024. * @param name defines the block name
  95025. */
  95026. constructor(name: string);
  95027. /**
  95028. * Gets the current class name
  95029. * @returns the class name
  95030. */
  95031. getClassName(): string;
  95032. /**
  95033. * Gets the vector input component
  95034. */
  95035. get vector(): NodeMaterialConnectionPoint;
  95036. protected _buildBlock(state: NodeMaterialBuildState): this;
  95037. }
  95038. }
  95039. declare module BABYLON {
  95040. /**
  95041. * Block used to output the final color
  95042. */
  95043. export class FragmentOutputBlock extends NodeMaterialBlock {
  95044. /**
  95045. * Create a new FragmentOutputBlock
  95046. * @param name defines the block name
  95047. */
  95048. constructor(name: string);
  95049. /**
  95050. * Gets the current class name
  95051. * @returns the class name
  95052. */
  95053. getClassName(): string;
  95054. /**
  95055. * Gets the rgba input component
  95056. */
  95057. get rgba(): NodeMaterialConnectionPoint;
  95058. /**
  95059. * Gets the rgb input component
  95060. */
  95061. get rgb(): NodeMaterialConnectionPoint;
  95062. /**
  95063. * Gets the a input component
  95064. */
  95065. get a(): NodeMaterialConnectionPoint;
  95066. protected _buildBlock(state: NodeMaterialBuildState): this;
  95067. }
  95068. }
  95069. declare module BABYLON {
  95070. /**
  95071. * Block used for the particle ramp gradient section
  95072. */
  95073. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  95074. /**
  95075. * Create a new ParticleRampGradientBlock
  95076. * @param name defines the block name
  95077. */
  95078. constructor(name: string);
  95079. /**
  95080. * Gets the current class name
  95081. * @returns the class name
  95082. */
  95083. getClassName(): string;
  95084. /**
  95085. * Gets the color input component
  95086. */
  95087. get color(): NodeMaterialConnectionPoint;
  95088. /**
  95089. * Gets the rampColor output component
  95090. */
  95091. get rampColor(): NodeMaterialConnectionPoint;
  95092. /**
  95093. * Initialize the block and prepare the context for build
  95094. * @param state defines the state that will be used for the build
  95095. */
  95096. initialize(state: NodeMaterialBuildState): void;
  95097. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  95098. }
  95099. }
  95100. declare module BABYLON {
  95101. /**
  95102. * Block used for the particle blend multiply section
  95103. */
  95104. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  95105. /**
  95106. * Create a new ParticleBlendMultiplyBlock
  95107. * @param name defines the block name
  95108. */
  95109. constructor(name: string);
  95110. /**
  95111. * Gets the current class name
  95112. * @returns the class name
  95113. */
  95114. getClassName(): string;
  95115. /**
  95116. * Gets the color input component
  95117. */
  95118. get color(): NodeMaterialConnectionPoint;
  95119. /**
  95120. * Gets the alphaTexture input component
  95121. */
  95122. get alphaTexture(): NodeMaterialConnectionPoint;
  95123. /**
  95124. * Gets the alphaColor input component
  95125. */
  95126. get alphaColor(): NodeMaterialConnectionPoint;
  95127. /**
  95128. * Gets the blendColor output component
  95129. */
  95130. get blendColor(): NodeMaterialConnectionPoint;
  95131. /**
  95132. * Initialize the block and prepare the context for build
  95133. * @param state defines the state that will be used for the build
  95134. */
  95135. initialize(state: NodeMaterialBuildState): void;
  95136. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  95137. }
  95138. }
  95139. declare module BABYLON {
  95140. /**
  95141. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  95142. */
  95143. export class VectorMergerBlock extends NodeMaterialBlock {
  95144. /**
  95145. * Create a new VectorMergerBlock
  95146. * @param name defines the block name
  95147. */
  95148. constructor(name: string);
  95149. /**
  95150. * Gets the current class name
  95151. * @returns the class name
  95152. */
  95153. getClassName(): string;
  95154. /**
  95155. * Gets the xyz component (input)
  95156. */
  95157. get xyzIn(): NodeMaterialConnectionPoint;
  95158. /**
  95159. * Gets the xy component (input)
  95160. */
  95161. get xyIn(): NodeMaterialConnectionPoint;
  95162. /**
  95163. * Gets the x component (input)
  95164. */
  95165. get x(): NodeMaterialConnectionPoint;
  95166. /**
  95167. * Gets the y component (input)
  95168. */
  95169. get y(): NodeMaterialConnectionPoint;
  95170. /**
  95171. * Gets the z component (input)
  95172. */
  95173. get z(): NodeMaterialConnectionPoint;
  95174. /**
  95175. * Gets the w component (input)
  95176. */
  95177. get w(): NodeMaterialConnectionPoint;
  95178. /**
  95179. * Gets the xyzw component (output)
  95180. */
  95181. get xyzw(): NodeMaterialConnectionPoint;
  95182. /**
  95183. * Gets the xyz component (output)
  95184. */
  95185. get xyzOut(): NodeMaterialConnectionPoint;
  95186. /**
  95187. * Gets the xy component (output)
  95188. */
  95189. get xyOut(): NodeMaterialConnectionPoint;
  95190. /**
  95191. * Gets the xy component (output)
  95192. * @deprecated Please use xyOut instead.
  95193. */
  95194. get xy(): NodeMaterialConnectionPoint;
  95195. /**
  95196. * Gets the xyz component (output)
  95197. * @deprecated Please use xyzOut instead.
  95198. */
  95199. get xyz(): NodeMaterialConnectionPoint;
  95200. protected _buildBlock(state: NodeMaterialBuildState): this;
  95201. }
  95202. }
  95203. declare module BABYLON {
  95204. /**
  95205. * Block used to remap a float from a range to a new one
  95206. */
  95207. export class RemapBlock extends NodeMaterialBlock {
  95208. /**
  95209. * Gets or sets the source range
  95210. */
  95211. sourceRange: Vector2;
  95212. /**
  95213. * Gets or sets the target range
  95214. */
  95215. targetRange: Vector2;
  95216. /**
  95217. * Creates a new RemapBlock
  95218. * @param name defines the block name
  95219. */
  95220. constructor(name: string);
  95221. /**
  95222. * Gets the current class name
  95223. * @returns the class name
  95224. */
  95225. getClassName(): string;
  95226. /**
  95227. * Gets the input component
  95228. */
  95229. get input(): NodeMaterialConnectionPoint;
  95230. /**
  95231. * Gets the source min input component
  95232. */
  95233. get sourceMin(): NodeMaterialConnectionPoint;
  95234. /**
  95235. * Gets the source max input component
  95236. */
  95237. get sourceMax(): NodeMaterialConnectionPoint;
  95238. /**
  95239. * Gets the target min input component
  95240. */
  95241. get targetMin(): NodeMaterialConnectionPoint;
  95242. /**
  95243. * Gets the target max input component
  95244. */
  95245. get targetMax(): NodeMaterialConnectionPoint;
  95246. /**
  95247. * Gets the output component
  95248. */
  95249. get output(): NodeMaterialConnectionPoint;
  95250. protected _buildBlock(state: NodeMaterialBuildState): this;
  95251. protected _dumpPropertiesCode(): string;
  95252. serialize(): any;
  95253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  95254. }
  95255. }
  95256. declare module BABYLON {
  95257. /**
  95258. * Block used to multiply 2 values
  95259. */
  95260. export class MultiplyBlock extends NodeMaterialBlock {
  95261. /**
  95262. * Creates a new MultiplyBlock
  95263. * @param name defines the block name
  95264. */
  95265. constructor(name: string);
  95266. /**
  95267. * Gets the current class name
  95268. * @returns the class name
  95269. */
  95270. getClassName(): string;
  95271. /**
  95272. * Gets the left operand input component
  95273. */
  95274. get left(): NodeMaterialConnectionPoint;
  95275. /**
  95276. * Gets the right operand input component
  95277. */
  95278. get right(): NodeMaterialConnectionPoint;
  95279. /**
  95280. * Gets the output component
  95281. */
  95282. get output(): NodeMaterialConnectionPoint;
  95283. protected _buildBlock(state: NodeMaterialBuildState): this;
  95284. }
  95285. }
  95286. declare module BABYLON {
  95287. /** Interface used by value gradients (color, factor, ...) */
  95288. export interface IValueGradient {
  95289. /**
  95290. * Gets or sets the gradient value (between 0 and 1)
  95291. */
  95292. gradient: number;
  95293. }
  95294. /** Class used to store color4 gradient */
  95295. export class ColorGradient implements IValueGradient {
  95296. /**
  95297. * Gets or sets the gradient value (between 0 and 1)
  95298. */
  95299. gradient: number;
  95300. /**
  95301. * Gets or sets first associated color
  95302. */
  95303. color1: Color4;
  95304. /**
  95305. * Gets or sets second associated color
  95306. */
  95307. color2?: Color4 | undefined;
  95308. /**
  95309. * Creates a new color4 gradient
  95310. * @param gradient gets or sets the gradient value (between 0 and 1)
  95311. * @param color1 gets or sets first associated color
  95312. * @param color2 gets or sets first second color
  95313. */
  95314. constructor(
  95315. /**
  95316. * Gets or sets the gradient value (between 0 and 1)
  95317. */
  95318. gradient: number,
  95319. /**
  95320. * Gets or sets first associated color
  95321. */
  95322. color1: Color4,
  95323. /**
  95324. * Gets or sets second associated color
  95325. */
  95326. color2?: Color4 | undefined);
  95327. /**
  95328. * Will get a color picked randomly between color1 and color2.
  95329. * If color2 is undefined then color1 will be used
  95330. * @param result defines the target Color4 to store the result in
  95331. */
  95332. getColorToRef(result: Color4): void;
  95333. }
  95334. /** Class used to store color 3 gradient */
  95335. export class Color3Gradient implements IValueGradient {
  95336. /**
  95337. * Gets or sets the gradient value (between 0 and 1)
  95338. */
  95339. gradient: number;
  95340. /**
  95341. * Gets or sets the associated color
  95342. */
  95343. color: Color3;
  95344. /**
  95345. * Creates a new color3 gradient
  95346. * @param gradient gets or sets the gradient value (between 0 and 1)
  95347. * @param color gets or sets associated color
  95348. */
  95349. constructor(
  95350. /**
  95351. * Gets or sets the gradient value (between 0 and 1)
  95352. */
  95353. gradient: number,
  95354. /**
  95355. * Gets or sets the associated color
  95356. */
  95357. color: Color3);
  95358. }
  95359. /** Class used to store factor gradient */
  95360. export class FactorGradient implements IValueGradient {
  95361. /**
  95362. * Gets or sets the gradient value (between 0 and 1)
  95363. */
  95364. gradient: number;
  95365. /**
  95366. * Gets or sets first associated factor
  95367. */
  95368. factor1: number;
  95369. /**
  95370. * Gets or sets second associated factor
  95371. */
  95372. factor2?: number | undefined;
  95373. /**
  95374. * Creates a new factor gradient
  95375. * @param gradient gets or sets the gradient value (between 0 and 1)
  95376. * @param factor1 gets or sets first associated factor
  95377. * @param factor2 gets or sets second associated factor
  95378. */
  95379. constructor(
  95380. /**
  95381. * Gets or sets the gradient value (between 0 and 1)
  95382. */
  95383. gradient: number,
  95384. /**
  95385. * Gets or sets first associated factor
  95386. */
  95387. factor1: number,
  95388. /**
  95389. * Gets or sets second associated factor
  95390. */
  95391. factor2?: number | undefined);
  95392. /**
  95393. * Will get a number picked randomly between factor1 and factor2.
  95394. * If factor2 is undefined then factor1 will be used
  95395. * @returns the picked number
  95396. */
  95397. getFactor(): number;
  95398. }
  95399. /**
  95400. * Helper used to simplify some generic gradient tasks
  95401. */
  95402. export class GradientHelper {
  95403. /**
  95404. * Gets the current gradient from an array of IValueGradient
  95405. * @param ratio defines the current ratio to get
  95406. * @param gradients defines the array of IValueGradient
  95407. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  95408. */
  95409. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  95410. }
  95411. }
  95412. declare module BABYLON {
  95413. interface ThinEngine {
  95414. /**
  95415. * Creates a raw texture
  95416. * @param data defines the data to store in the texture
  95417. * @param width defines the width of the texture
  95418. * @param height defines the height of the texture
  95419. * @param format defines the format of the data
  95420. * @param generateMipMaps defines if the engine should generate the mip levels
  95421. * @param invertY defines if data must be stored with Y axis inverted
  95422. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95423. * @param compression defines the compression used (null by default)
  95424. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95425. * @returns the raw texture inside an InternalTexture
  95426. */
  95427. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  95428. /**
  95429. * Update a raw texture
  95430. * @param texture defines the texture to update
  95431. * @param data defines the data to store in the texture
  95432. * @param format defines the format of the data
  95433. * @param invertY defines if data must be stored with Y axis inverted
  95434. */
  95435. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95436. /**
  95437. * Update a raw texture
  95438. * @param texture defines the texture to update
  95439. * @param data defines the data to store in the texture
  95440. * @param format defines the format of the data
  95441. * @param invertY defines if data must be stored with Y axis inverted
  95442. * @param compression defines the compression used (null by default)
  95443. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95444. */
  95445. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  95446. /**
  95447. * Creates a new raw cube texture
  95448. * @param data defines the array of data to use to create each face
  95449. * @param size defines the size of the textures
  95450. * @param format defines the format of the data
  95451. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95452. * @param generateMipMaps defines if the engine should generate the mip levels
  95453. * @param invertY defines if data must be stored with Y axis inverted
  95454. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95455. * @param compression defines the compression used (null by default)
  95456. * @returns the cube texture as an InternalTexture
  95457. */
  95458. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  95459. /**
  95460. * Update a raw cube texture
  95461. * @param texture defines the texture to udpdate
  95462. * @param data defines the data to store
  95463. * @param format defines the data format
  95464. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95465. * @param invertY defines if data must be stored with Y axis inverted
  95466. */
  95467. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  95468. /**
  95469. * Update a raw cube texture
  95470. * @param texture defines the texture to udpdate
  95471. * @param data defines the data to store
  95472. * @param format defines the data format
  95473. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95474. * @param invertY defines if data must be stored with Y axis inverted
  95475. * @param compression defines the compression used (null by default)
  95476. */
  95477. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  95478. /**
  95479. * Update a raw cube texture
  95480. * @param texture defines the texture to udpdate
  95481. * @param data defines the data to store
  95482. * @param format defines the data format
  95483. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95484. * @param invertY defines if data must be stored with Y axis inverted
  95485. * @param compression defines the compression used (null by default)
  95486. * @param level defines which level of the texture to update
  95487. */
  95488. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  95489. /**
  95490. * Creates a new raw cube texture from a specified url
  95491. * @param url defines the url where the data is located
  95492. * @param scene defines the current scene
  95493. * @param size defines the size of the textures
  95494. * @param format defines the format of the data
  95495. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95496. * @param noMipmap defines if the engine should avoid generating the mip levels
  95497. * @param callback defines a callback used to extract texture data from loaded data
  95498. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95499. * @param onLoad defines a callback called when texture is loaded
  95500. * @param onError defines a callback called if there is an error
  95501. * @returns the cube texture as an InternalTexture
  95502. */
  95503. 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;
  95504. /**
  95505. * Creates a new raw cube texture from a specified url
  95506. * @param url defines the url where the data is located
  95507. * @param scene defines the current scene
  95508. * @param size defines the size of the textures
  95509. * @param format defines the format of the data
  95510. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95511. * @param noMipmap defines if the engine should avoid generating the mip levels
  95512. * @param callback defines a callback used to extract texture data from loaded data
  95513. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95514. * @param onLoad defines a callback called when texture is loaded
  95515. * @param onError defines a callback called if there is an error
  95516. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95517. * @param invertY defines if data must be stored with Y axis inverted
  95518. * @returns the cube texture as an InternalTexture
  95519. */
  95520. 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;
  95521. /**
  95522. * Creates a new raw 3D texture
  95523. * @param data defines the data used to create the texture
  95524. * @param width defines the width of the texture
  95525. * @param height defines the height of the texture
  95526. * @param depth defines the depth of the texture
  95527. * @param format defines the format of the texture
  95528. * @param generateMipMaps defines if the engine must generate mip levels
  95529. * @param invertY defines if data must be stored with Y axis inverted
  95530. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95531. * @param compression defines the compressed used (can be null)
  95532. * @param textureType defines the compressed used (can be null)
  95533. * @returns a new raw 3D texture (stored in an InternalTexture)
  95534. */
  95535. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95536. /**
  95537. * Update a raw 3D texture
  95538. * @param texture defines the texture to update
  95539. * @param data defines the data to store
  95540. * @param format defines the data format
  95541. * @param invertY defines if data must be stored with Y axis inverted
  95542. */
  95543. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95544. /**
  95545. * Update a raw 3D texture
  95546. * @param texture defines the texture to update
  95547. * @param data defines the data to store
  95548. * @param format defines the data format
  95549. * @param invertY defines if data must be stored with Y axis inverted
  95550. * @param compression defines the used compression (can be null)
  95551. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95552. */
  95553. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95554. /**
  95555. * Creates a new raw 2D array texture
  95556. * @param data defines the data used to create the texture
  95557. * @param width defines the width of the texture
  95558. * @param height defines the height of the texture
  95559. * @param depth defines the number of layers of the texture
  95560. * @param format defines the format of the texture
  95561. * @param generateMipMaps defines if the engine must generate mip levels
  95562. * @param invertY defines if data must be stored with Y axis inverted
  95563. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95564. * @param compression defines the compressed used (can be null)
  95565. * @param textureType defines the compressed used (can be null)
  95566. * @returns a new raw 2D array texture (stored in an InternalTexture)
  95567. */
  95568. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95569. /**
  95570. * Update a raw 2D array texture
  95571. * @param texture defines the texture to update
  95572. * @param data defines the data to store
  95573. * @param format defines the data format
  95574. * @param invertY defines if data must be stored with Y axis inverted
  95575. */
  95576. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95577. /**
  95578. * Update a raw 2D array texture
  95579. * @param texture defines the texture to update
  95580. * @param data defines the data to store
  95581. * @param format defines the data format
  95582. * @param invertY defines if data must be stored with Y axis inverted
  95583. * @param compression defines the used compression (can be null)
  95584. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95585. */
  95586. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95587. }
  95588. }
  95589. declare module BABYLON {
  95590. /**
  95591. * Raw texture can help creating a texture directly from an array of data.
  95592. * This can be super useful if you either get the data from an uncompressed source or
  95593. * if you wish to create your texture pixel by pixel.
  95594. */
  95595. export class RawTexture extends Texture {
  95596. /**
  95597. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95598. */
  95599. format: number;
  95600. /**
  95601. * Instantiates a new RawTexture.
  95602. * Raw texture can help creating a texture directly from an array of data.
  95603. * This can be super useful if you either get the data from an uncompressed source or
  95604. * if you wish to create your texture pixel by pixel.
  95605. * @param data define the array of data to use to create the texture
  95606. * @param width define the width of the texture
  95607. * @param height define the height of the texture
  95608. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95609. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95610. * @param generateMipMaps define whether mip maps should be generated or not
  95611. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95612. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95613. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95614. */
  95615. constructor(data: ArrayBufferView, width: number, height: number,
  95616. /**
  95617. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95618. */
  95619. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  95620. /**
  95621. * Updates the texture underlying data.
  95622. * @param data Define the new data of the texture
  95623. */
  95624. update(data: ArrayBufferView): void;
  95625. /**
  95626. * Creates a luminance texture from some data.
  95627. * @param data Define the texture data
  95628. * @param width Define the width of the texture
  95629. * @param height Define the height of the texture
  95630. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95631. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95632. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95633. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95634. * @returns the luminance texture
  95635. */
  95636. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95637. /**
  95638. * Creates a luminance alpha texture from some data.
  95639. * @param data Define the texture data
  95640. * @param width Define the width of the texture
  95641. * @param height Define the height of the texture
  95642. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95646. * @returns the luminance alpha texture
  95647. */
  95648. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95649. /**
  95650. * Creates an alpha texture from some data.
  95651. * @param data Define the texture data
  95652. * @param width Define the width of the texture
  95653. * @param height Define the height of the texture
  95654. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95655. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95656. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95657. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95658. * @returns the alpha texture
  95659. */
  95660. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95661. /**
  95662. * Creates a RGB texture from some data.
  95663. * @param data Define the texture data
  95664. * @param width Define the width of the texture
  95665. * @param height Define the height of the texture
  95666. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95667. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95668. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95669. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95670. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95671. * @returns the RGB alpha texture
  95672. */
  95673. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95674. /**
  95675. * Creates a RGBA texture from some data.
  95676. * @param data Define the texture data
  95677. * @param width Define the width of the texture
  95678. * @param height Define the height of the texture
  95679. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95680. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95681. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95682. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95683. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95684. * @returns the RGBA texture
  95685. */
  95686. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95687. /**
  95688. * Creates a R texture from some data.
  95689. * @param data Define the texture data
  95690. * @param width Define the width of the texture
  95691. * @param height Define the height of the texture
  95692. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95693. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95694. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95695. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95696. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95697. * @returns the R texture
  95698. */
  95699. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95700. }
  95701. }
  95702. declare module BABYLON {
  95703. interface ThinEngine {
  95704. /**
  95705. * Update a dynamic index buffer
  95706. * @param indexBuffer defines the target index buffer
  95707. * @param indices defines the data to update
  95708. * @param offset defines the offset in the target index buffer where update should start
  95709. */
  95710. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95711. /**
  95712. * Updates a dynamic vertex buffer.
  95713. * @param vertexBuffer the vertex buffer to update
  95714. * @param data the data used to update the vertex buffer
  95715. * @param byteOffset the byte offset of the data
  95716. * @param byteLength the byte length of the data
  95717. */
  95718. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95719. }
  95720. }
  95721. declare module BABYLON {
  95722. interface AbstractScene {
  95723. /**
  95724. * The list of procedural textures added to the scene
  95725. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95726. */
  95727. proceduralTextures: Array<ProceduralTexture>;
  95728. }
  95729. /**
  95730. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  95731. * in a given scene.
  95732. */
  95733. export class ProceduralTextureSceneComponent implements ISceneComponent {
  95734. /**
  95735. * The component name helpfull to identify the component in the list of scene components.
  95736. */
  95737. readonly name: string;
  95738. /**
  95739. * The scene the component belongs to.
  95740. */
  95741. scene: Scene;
  95742. /**
  95743. * Creates a new instance of the component for the given scene
  95744. * @param scene Defines the scene to register the component in
  95745. */
  95746. constructor(scene: Scene);
  95747. /**
  95748. * Registers the component in a given scene
  95749. */
  95750. register(): void;
  95751. /**
  95752. * Rebuilds the elements related to this component in case of
  95753. * context lost for instance.
  95754. */
  95755. rebuild(): void;
  95756. /**
  95757. * Disposes the component and the associated ressources.
  95758. */
  95759. dispose(): void;
  95760. private _beforeClear;
  95761. }
  95762. }
  95763. declare module BABYLON {
  95764. interface ThinEngine {
  95765. /**
  95766. * Creates a new render target cube texture
  95767. * @param size defines the size of the texture
  95768. * @param options defines the options used to create the texture
  95769. * @returns a new render target cube texture stored in an InternalTexture
  95770. */
  95771. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  95772. }
  95773. }
  95774. declare module BABYLON {
  95775. /** @hidden */
  95776. export var proceduralVertexShader: {
  95777. name: string;
  95778. shader: string;
  95779. };
  95780. }
  95781. declare module BABYLON {
  95782. /**
  95783. * 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.
  95784. * This is the base class of any Procedural texture and contains most of the shareable code.
  95785. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95786. */
  95787. export class ProceduralTexture extends Texture {
  95788. /**
  95789. * Define if the texture is enabled or not (disabled texture will not render)
  95790. */
  95791. isEnabled: boolean;
  95792. /**
  95793. * Define if the texture must be cleared before rendering (default is true)
  95794. */
  95795. autoClear: boolean;
  95796. /**
  95797. * Callback called when the texture is generated
  95798. */
  95799. onGenerated: () => void;
  95800. /**
  95801. * Event raised when the texture is generated
  95802. */
  95803. onGeneratedObservable: Observable<ProceduralTexture>;
  95804. /**
  95805. * Event raised before the texture is generated
  95806. */
  95807. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  95808. /**
  95809. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  95810. */
  95811. nodeMaterialSource: Nullable<NodeMaterial>;
  95812. /** @hidden */
  95813. _generateMipMaps: boolean;
  95814. /** @hidden **/
  95815. _effect: Effect;
  95816. /** @hidden */
  95817. _textures: {
  95818. [key: string]: Texture;
  95819. };
  95820. /** @hidden */
  95821. protected _fallbackTexture: Nullable<Texture>;
  95822. private _size;
  95823. private _currentRefreshId;
  95824. private _frameId;
  95825. private _refreshRate;
  95826. private _vertexBuffers;
  95827. private _indexBuffer;
  95828. private _uniforms;
  95829. private _samplers;
  95830. private _fragment;
  95831. private _floats;
  95832. private _ints;
  95833. private _floatsArrays;
  95834. private _colors3;
  95835. private _colors4;
  95836. private _vectors2;
  95837. private _vectors3;
  95838. private _matrices;
  95839. private _fallbackTextureUsed;
  95840. private _fullEngine;
  95841. private _cachedDefines;
  95842. private _contentUpdateId;
  95843. private _contentData;
  95844. /**
  95845. * Instantiates a new procedural texture.
  95846. * 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.
  95847. * This is the base class of any Procedural texture and contains most of the shareable code.
  95848. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95849. * @param name Define the name of the texture
  95850. * @param size Define the size of the texture to create
  95851. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  95852. * @param scene Define the scene the texture belongs to
  95853. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  95854. * @param generateMipMaps Define if the texture should creates mip maps or not
  95855. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  95856. * @param textureType The FBO internal texture type
  95857. */
  95858. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  95859. /**
  95860. * The effect that is created when initializing the post process.
  95861. * @returns The created effect corresponding the the postprocess.
  95862. */
  95863. getEffect(): Effect;
  95864. /**
  95865. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  95866. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  95867. */
  95868. getContent(): Nullable<ArrayBufferView>;
  95869. private _createIndexBuffer;
  95870. /** @hidden */
  95871. _rebuild(): void;
  95872. /**
  95873. * Resets the texture in order to recreate its associated resources.
  95874. * This can be called in case of context loss
  95875. */
  95876. reset(): void;
  95877. protected _getDefines(): string;
  95878. /**
  95879. * Is the texture ready to be used ? (rendered at least once)
  95880. * @returns true if ready, otherwise, false.
  95881. */
  95882. isReady(): boolean;
  95883. /**
  95884. * Resets the refresh counter of the texture and start bak from scratch.
  95885. * Could be useful to regenerate the texture if it is setup to render only once.
  95886. */
  95887. resetRefreshCounter(): void;
  95888. /**
  95889. * Set the fragment shader to use in order to render the texture.
  95890. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  95891. */
  95892. setFragment(fragment: any): void;
  95893. /**
  95894. * Define the refresh rate of the texture or the rendering frequency.
  95895. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95896. */
  95897. get refreshRate(): number;
  95898. set refreshRate(value: number);
  95899. /** @hidden */
  95900. _shouldRender(): boolean;
  95901. /**
  95902. * Get the size the texture is rendering at.
  95903. * @returns the size (on cube texture it is always squared)
  95904. */
  95905. getRenderSize(): RenderTargetTextureSize;
  95906. /**
  95907. * Resize the texture to new value.
  95908. * @param size Define the new size the texture should have
  95909. * @param generateMipMaps Define whether the new texture should create mip maps
  95910. */
  95911. resize(size: number, generateMipMaps: boolean): void;
  95912. private _checkUniform;
  95913. /**
  95914. * Set a texture in the shader program used to render.
  95915. * @param name Define the name of the uniform samplers as defined in the shader
  95916. * @param texture Define the texture to bind to this sampler
  95917. * @return the texture itself allowing "fluent" like uniform updates
  95918. */
  95919. setTexture(name: string, texture: Texture): ProceduralTexture;
  95920. /**
  95921. * Set a float in the shader.
  95922. * @param name Define the name of the uniform as defined in the shader
  95923. * @param value Define the value to give to the uniform
  95924. * @return the texture itself allowing "fluent" like uniform updates
  95925. */
  95926. setFloat(name: string, value: number): ProceduralTexture;
  95927. /**
  95928. * Set a int in the shader.
  95929. * @param name Define the name of the uniform as defined in the shader
  95930. * @param value Define the value to give to the uniform
  95931. * @return the texture itself allowing "fluent" like uniform updates
  95932. */
  95933. setInt(name: string, value: number): ProceduralTexture;
  95934. /**
  95935. * Set an array of floats in the shader.
  95936. * @param name Define the name of the uniform as defined in the shader
  95937. * @param value Define the value to give to the uniform
  95938. * @return the texture itself allowing "fluent" like uniform updates
  95939. */
  95940. setFloats(name: string, value: number[]): ProceduralTexture;
  95941. /**
  95942. * Set a vec3 in the shader from a Color3.
  95943. * @param name Define the name of the uniform as defined in the shader
  95944. * @param value Define the value to give to the uniform
  95945. * @return the texture itself allowing "fluent" like uniform updates
  95946. */
  95947. setColor3(name: string, value: Color3): ProceduralTexture;
  95948. /**
  95949. * Set a vec4 in the shader from a Color4.
  95950. * @param name Define the name of the uniform as defined in the shader
  95951. * @param value Define the value to give to the uniform
  95952. * @return the texture itself allowing "fluent" like uniform updates
  95953. */
  95954. setColor4(name: string, value: Color4): ProceduralTexture;
  95955. /**
  95956. * Set a vec2 in the shader from a Vector2.
  95957. * @param name Define the name of the uniform as defined in the shader
  95958. * @param value Define the value to give to the uniform
  95959. * @return the texture itself allowing "fluent" like uniform updates
  95960. */
  95961. setVector2(name: string, value: Vector2): ProceduralTexture;
  95962. /**
  95963. * Set a vec3 in the shader from a Vector3.
  95964. * @param name Define the name of the uniform as defined in the shader
  95965. * @param value Define the value to give to the uniform
  95966. * @return the texture itself allowing "fluent" like uniform updates
  95967. */
  95968. setVector3(name: string, value: Vector3): ProceduralTexture;
  95969. /**
  95970. * Set a mat4 in the shader from a MAtrix.
  95971. * @param name Define the name of the uniform as defined in the shader
  95972. * @param value Define the value to give to the uniform
  95973. * @return the texture itself allowing "fluent" like uniform updates
  95974. */
  95975. setMatrix(name: string, value: Matrix): ProceduralTexture;
  95976. /**
  95977. * Render the texture to its associated render target.
  95978. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  95979. */
  95980. render(useCameraPostProcess?: boolean): void;
  95981. /**
  95982. * Clone the texture.
  95983. * @returns the cloned texture
  95984. */
  95985. clone(): ProceduralTexture;
  95986. /**
  95987. * Dispose the texture and release its asoociated resources.
  95988. */
  95989. dispose(): void;
  95990. }
  95991. }
  95992. declare module BABYLON {
  95993. /**
  95994. * This represents the base class for particle system in Babylon.
  95995. * 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.
  95996. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  95997. * @example https://doc.babylonjs.com/babylon101/particles
  95998. */
  95999. export class BaseParticleSystem {
  96000. /**
  96001. * Source color is added to the destination color without alpha affecting the result
  96002. */
  96003. static BLENDMODE_ONEONE: number;
  96004. /**
  96005. * Blend current color and particle color using particle’s alpha
  96006. */
  96007. static BLENDMODE_STANDARD: number;
  96008. /**
  96009. * Add current color and particle color multiplied by particle’s alpha
  96010. */
  96011. static BLENDMODE_ADD: number;
  96012. /**
  96013. * Multiply current color with particle color
  96014. */
  96015. static BLENDMODE_MULTIPLY: number;
  96016. /**
  96017. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  96018. */
  96019. static BLENDMODE_MULTIPLYADD: number;
  96020. /**
  96021. * List of animations used by the particle system.
  96022. */
  96023. animations: Animation[];
  96024. /**
  96025. * Gets or sets the unique id of the particle system
  96026. */
  96027. uniqueId: number;
  96028. /**
  96029. * The id of the Particle system.
  96030. */
  96031. id: string;
  96032. /**
  96033. * The friendly name of the Particle system.
  96034. */
  96035. name: string;
  96036. /**
  96037. * Snippet ID if the particle system was created from the snippet server
  96038. */
  96039. snippetId: string;
  96040. /**
  96041. * The rendering group used by the Particle system to chose when to render.
  96042. */
  96043. renderingGroupId: number;
  96044. /**
  96045. * The emitter represents the Mesh or position we are attaching the particle system to.
  96046. */
  96047. emitter: Nullable<AbstractMesh | Vector3>;
  96048. /**
  96049. * The maximum number of particles to emit per frame
  96050. */
  96051. emitRate: number;
  96052. /**
  96053. * If you want to launch only a few particles at once, that can be done, as well.
  96054. */
  96055. manualEmitCount: number;
  96056. /**
  96057. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  96058. */
  96059. updateSpeed: number;
  96060. /**
  96061. * The amount of time the particle system is running (depends of the overall update speed).
  96062. */
  96063. targetStopDuration: number;
  96064. /**
  96065. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  96066. */
  96067. disposeOnStop: boolean;
  96068. /**
  96069. * Minimum power of emitting particles.
  96070. */
  96071. minEmitPower: number;
  96072. /**
  96073. * Maximum power of emitting particles.
  96074. */
  96075. maxEmitPower: number;
  96076. /**
  96077. * Minimum life time of emitting particles.
  96078. */
  96079. minLifeTime: number;
  96080. /**
  96081. * Maximum life time of emitting particles.
  96082. */
  96083. maxLifeTime: number;
  96084. /**
  96085. * Minimum Size of emitting particles.
  96086. */
  96087. minSize: number;
  96088. /**
  96089. * Maximum Size of emitting particles.
  96090. */
  96091. maxSize: number;
  96092. /**
  96093. * Minimum scale of emitting particles on X axis.
  96094. */
  96095. minScaleX: number;
  96096. /**
  96097. * Maximum scale of emitting particles on X axis.
  96098. */
  96099. maxScaleX: number;
  96100. /**
  96101. * Minimum scale of emitting particles on Y axis.
  96102. */
  96103. minScaleY: number;
  96104. /**
  96105. * Maximum scale of emitting particles on Y axis.
  96106. */
  96107. maxScaleY: number;
  96108. /**
  96109. * Gets or sets the minimal initial rotation in radians.
  96110. */
  96111. minInitialRotation: number;
  96112. /**
  96113. * Gets or sets the maximal initial rotation in radians.
  96114. */
  96115. maxInitialRotation: number;
  96116. /**
  96117. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  96118. */
  96119. minAngularSpeed: number;
  96120. /**
  96121. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  96122. */
  96123. maxAngularSpeed: number;
  96124. /**
  96125. * The texture used to render each particle. (this can be a spritesheet)
  96126. */
  96127. particleTexture: Nullable<BaseTexture>;
  96128. /**
  96129. * The layer mask we are rendering the particles through.
  96130. */
  96131. layerMask: number;
  96132. /**
  96133. * This can help using your own shader to render the particle system.
  96134. * The according effect will be created
  96135. */
  96136. customShader: any;
  96137. /**
  96138. * By default particle system starts as soon as they are created. This prevents the
  96139. * automatic start to happen and let you decide when to start emitting particles.
  96140. */
  96141. preventAutoStart: boolean;
  96142. private _noiseTexture;
  96143. /**
  96144. * Gets or sets a texture used to add random noise to particle positions
  96145. */
  96146. get noiseTexture(): Nullable<ProceduralTexture>;
  96147. set noiseTexture(value: Nullable<ProceduralTexture>);
  96148. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  96149. noiseStrength: Vector3;
  96150. /**
  96151. * Callback triggered when the particle animation is ending.
  96152. */
  96153. onAnimationEnd: Nullable<() => void>;
  96154. /**
  96155. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  96156. */
  96157. blendMode: number;
  96158. /**
  96159. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  96160. * to override the particles.
  96161. */
  96162. forceDepthWrite: boolean;
  96163. /** 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 */
  96164. preWarmCycles: number;
  96165. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  96166. preWarmStepOffset: number;
  96167. /**
  96168. * 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)
  96169. */
  96170. spriteCellChangeSpeed: number;
  96171. /**
  96172. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  96173. */
  96174. startSpriteCellID: number;
  96175. /**
  96176. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  96177. */
  96178. endSpriteCellID: number;
  96179. /**
  96180. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  96181. */
  96182. spriteCellWidth: number;
  96183. /**
  96184. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  96185. */
  96186. spriteCellHeight: number;
  96187. /**
  96188. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  96189. */
  96190. spriteRandomStartCell: boolean;
  96191. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  96192. translationPivot: Vector2;
  96193. /** @hidden */
  96194. protected _isAnimationSheetEnabled: boolean;
  96195. /**
  96196. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  96197. */
  96198. beginAnimationOnStart: boolean;
  96199. /**
  96200. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  96201. */
  96202. beginAnimationFrom: number;
  96203. /**
  96204. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  96205. */
  96206. beginAnimationTo: number;
  96207. /**
  96208. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  96209. */
  96210. beginAnimationLoop: boolean;
  96211. /**
  96212. * Gets or sets a world offset applied to all particles
  96213. */
  96214. worldOffset: Vector3;
  96215. /**
  96216. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  96217. */
  96218. get isAnimationSheetEnabled(): boolean;
  96219. set isAnimationSheetEnabled(value: boolean);
  96220. /**
  96221. * Get hosting scene
  96222. * @returns the scene
  96223. */
  96224. getScene(): Nullable<Scene>;
  96225. /**
  96226. * You can use gravity if you want to give an orientation to your particles.
  96227. */
  96228. gravity: Vector3;
  96229. protected _colorGradients: Nullable<Array<ColorGradient>>;
  96230. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  96231. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  96232. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  96233. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  96234. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  96235. protected _dragGradients: Nullable<Array<FactorGradient>>;
  96236. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  96237. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  96238. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  96239. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  96240. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  96241. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  96242. /**
  96243. * Defines the delay in milliseconds before starting the system (0 by default)
  96244. */
  96245. startDelay: number;
  96246. /**
  96247. * Gets the current list of drag gradients.
  96248. * You must use addDragGradient and removeDragGradient to udpate this list
  96249. * @returns the list of drag gradients
  96250. */
  96251. getDragGradients(): Nullable<Array<FactorGradient>>;
  96252. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  96253. limitVelocityDamping: number;
  96254. /**
  96255. * Gets the current list of limit velocity gradients.
  96256. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  96257. * @returns the list of limit velocity gradients
  96258. */
  96259. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  96260. /**
  96261. * Gets the current list of color gradients.
  96262. * You must use addColorGradient and removeColorGradient to udpate this list
  96263. * @returns the list of color gradients
  96264. */
  96265. getColorGradients(): Nullable<Array<ColorGradient>>;
  96266. /**
  96267. * Gets the current list of size gradients.
  96268. * You must use addSizeGradient and removeSizeGradient to udpate this list
  96269. * @returns the list of size gradients
  96270. */
  96271. getSizeGradients(): Nullable<Array<FactorGradient>>;
  96272. /**
  96273. * Gets the current list of color remap gradients.
  96274. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  96275. * @returns the list of color remap gradients
  96276. */
  96277. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  96278. /**
  96279. * Gets the current list of alpha remap gradients.
  96280. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  96281. * @returns the list of alpha remap gradients
  96282. */
  96283. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  96284. /**
  96285. * Gets the current list of life time gradients.
  96286. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  96287. * @returns the list of life time gradients
  96288. */
  96289. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  96290. /**
  96291. * Gets the current list of angular speed gradients.
  96292. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  96293. * @returns the list of angular speed gradients
  96294. */
  96295. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  96296. /**
  96297. * Gets the current list of velocity gradients.
  96298. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  96299. * @returns the list of velocity gradients
  96300. */
  96301. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  96302. /**
  96303. * Gets the current list of start size gradients.
  96304. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  96305. * @returns the list of start size gradients
  96306. */
  96307. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  96308. /**
  96309. * Gets the current list of emit rate gradients.
  96310. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  96311. * @returns the list of emit rate gradients
  96312. */
  96313. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  96314. /**
  96315. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96316. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96317. */
  96318. get direction1(): Vector3;
  96319. set direction1(value: Vector3);
  96320. /**
  96321. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96322. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96323. */
  96324. get direction2(): Vector3;
  96325. set direction2(value: Vector3);
  96326. /**
  96327. * 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.
  96328. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96329. */
  96330. get minEmitBox(): Vector3;
  96331. set minEmitBox(value: Vector3);
  96332. /**
  96333. * 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.
  96334. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96335. */
  96336. get maxEmitBox(): Vector3;
  96337. set maxEmitBox(value: Vector3);
  96338. /**
  96339. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96340. */
  96341. color1: Color4;
  96342. /**
  96343. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96344. */
  96345. color2: Color4;
  96346. /**
  96347. * Color the particle will have at the end of its lifetime
  96348. */
  96349. colorDead: Color4;
  96350. /**
  96351. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  96352. */
  96353. textureMask: Color4;
  96354. /**
  96355. * The particle emitter type defines the emitter used by the particle system.
  96356. * It can be for example box, sphere, or cone...
  96357. */
  96358. particleEmitterType: IParticleEmitterType;
  96359. /** @hidden */
  96360. _isSubEmitter: boolean;
  96361. /**
  96362. * Gets or sets the billboard mode to use when isBillboardBased = true.
  96363. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  96364. */
  96365. billboardMode: number;
  96366. protected _isBillboardBased: boolean;
  96367. /**
  96368. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  96369. */
  96370. get isBillboardBased(): boolean;
  96371. set isBillboardBased(value: boolean);
  96372. /**
  96373. * The scene the particle system belongs to.
  96374. */
  96375. protected _scene: Nullable<Scene>;
  96376. /**
  96377. * The engine the particle system belongs to.
  96378. */
  96379. protected _engine: ThinEngine;
  96380. /**
  96381. * Local cache of defines for image processing.
  96382. */
  96383. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  96384. /**
  96385. * Default configuration related to image processing available in the standard Material.
  96386. */
  96387. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  96388. /**
  96389. * Gets the image processing configuration used either in this material.
  96390. */
  96391. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  96392. /**
  96393. * Sets the Default image processing configuration used either in the this material.
  96394. *
  96395. * If sets to null, the scene one is in use.
  96396. */
  96397. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  96398. /**
  96399. * Attaches a new image processing configuration to the Standard Material.
  96400. * @param configuration
  96401. */
  96402. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96403. /** @hidden */
  96404. protected _reset(): void;
  96405. /** @hidden */
  96406. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  96407. /**
  96408. * Instantiates a particle system.
  96409. * 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.
  96410. * @param name The name of the particle system
  96411. */
  96412. constructor(name: string);
  96413. /**
  96414. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  96415. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96416. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96417. * @returns the emitter
  96418. */
  96419. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  96420. /**
  96421. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  96422. * @param radius The radius of the hemisphere to emit from
  96423. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96424. * @returns the emitter
  96425. */
  96426. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  96427. /**
  96428. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  96429. * @param radius The radius of the sphere to emit from
  96430. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96431. * @returns the emitter
  96432. */
  96433. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  96434. /**
  96435. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  96436. * @param radius The radius of the sphere to emit from
  96437. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  96438. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  96439. * @returns the emitter
  96440. */
  96441. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  96442. /**
  96443. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  96444. * @param radius The radius of the emission cylinder
  96445. * @param height The height of the emission cylinder
  96446. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  96447. * @param directionRandomizer How much to randomize the particle direction [0-1]
  96448. * @returns the emitter
  96449. */
  96450. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  96451. /**
  96452. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  96453. * @param radius The radius of the cylinder to emit from
  96454. * @param height The height of the emission cylinder
  96455. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  96456. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  96457. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  96458. * @returns the emitter
  96459. */
  96460. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  96461. /**
  96462. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  96463. * @param radius The radius of the cone to emit from
  96464. * @param angle The base angle of the cone
  96465. * @returns the emitter
  96466. */
  96467. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  96468. /**
  96469. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  96470. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96471. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96472. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96473. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96474. * @returns the emitter
  96475. */
  96476. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  96477. }
  96478. }
  96479. declare module BABYLON {
  96480. /**
  96481. * Type of sub emitter
  96482. */
  96483. export enum SubEmitterType {
  96484. /**
  96485. * Attached to the particle over it's lifetime
  96486. */
  96487. ATTACHED = 0,
  96488. /**
  96489. * Created when the particle dies
  96490. */
  96491. END = 1
  96492. }
  96493. /**
  96494. * Sub emitter class used to emit particles from an existing particle
  96495. */
  96496. export class SubEmitter {
  96497. /**
  96498. * the particle system to be used by the sub emitter
  96499. */
  96500. particleSystem: ParticleSystem;
  96501. /**
  96502. * Type of the submitter (Default: END)
  96503. */
  96504. type: SubEmitterType;
  96505. /**
  96506. * 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)
  96507. * Note: This only is supported when using an emitter of type Mesh
  96508. */
  96509. inheritDirection: boolean;
  96510. /**
  96511. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  96512. */
  96513. inheritedVelocityAmount: number;
  96514. /**
  96515. * Creates a sub emitter
  96516. * @param particleSystem the particle system to be used by the sub emitter
  96517. */
  96518. constructor(
  96519. /**
  96520. * the particle system to be used by the sub emitter
  96521. */
  96522. particleSystem: ParticleSystem);
  96523. /**
  96524. * Clones the sub emitter
  96525. * @returns the cloned sub emitter
  96526. */
  96527. clone(): SubEmitter;
  96528. /**
  96529. * Serialize current object to a JSON object
  96530. * @returns the serialized object
  96531. */
  96532. serialize(): any;
  96533. /** @hidden */
  96534. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  96535. /**
  96536. * Creates a new SubEmitter from a serialized JSON version
  96537. * @param serializationObject defines the JSON object to read from
  96538. * @param sceneOrEngine defines the hosting scene or the hosting engine
  96539. * @param rootUrl defines the rootUrl for data loading
  96540. * @returns a new SubEmitter
  96541. */
  96542. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  96543. /** Release associated resources */
  96544. dispose(): void;
  96545. }
  96546. }
  96547. declare module BABYLON {
  96548. /** @hidden */
  96549. export var clipPlaneFragmentDeclaration: {
  96550. name: string;
  96551. shader: string;
  96552. };
  96553. }
  96554. declare module BABYLON {
  96555. /** @hidden */
  96556. export var imageProcessingDeclaration: {
  96557. name: string;
  96558. shader: string;
  96559. };
  96560. }
  96561. declare module BABYLON {
  96562. /** @hidden */
  96563. export var imageProcessingFunctions: {
  96564. name: string;
  96565. shader: string;
  96566. };
  96567. }
  96568. declare module BABYLON {
  96569. /** @hidden */
  96570. export var clipPlaneFragment: {
  96571. name: string;
  96572. shader: string;
  96573. };
  96574. }
  96575. declare module BABYLON {
  96576. /** @hidden */
  96577. export var particlesPixelShader: {
  96578. name: string;
  96579. shader: string;
  96580. };
  96581. }
  96582. declare module BABYLON {
  96583. /** @hidden */
  96584. export var clipPlaneVertexDeclaration: {
  96585. name: string;
  96586. shader: string;
  96587. };
  96588. }
  96589. declare module BABYLON {
  96590. /** @hidden */
  96591. export var clipPlaneVertex: {
  96592. name: string;
  96593. shader: string;
  96594. };
  96595. }
  96596. declare module BABYLON {
  96597. /** @hidden */
  96598. export var particlesVertexShader: {
  96599. name: string;
  96600. shader: string;
  96601. };
  96602. }
  96603. declare module BABYLON {
  96604. /**
  96605. * Interface used to define entities containing multiple clip planes
  96606. */
  96607. export interface IClipPlanesHolder {
  96608. /**
  96609. * Gets or sets the active clipplane 1
  96610. */
  96611. clipPlane: Nullable<Plane>;
  96612. /**
  96613. * Gets or sets the active clipplane 2
  96614. */
  96615. clipPlane2: Nullable<Plane>;
  96616. /**
  96617. * Gets or sets the active clipplane 3
  96618. */
  96619. clipPlane3: Nullable<Plane>;
  96620. /**
  96621. * Gets or sets the active clipplane 4
  96622. */
  96623. clipPlane4: Nullable<Plane>;
  96624. /**
  96625. * Gets or sets the active clipplane 5
  96626. */
  96627. clipPlane5: Nullable<Plane>;
  96628. /**
  96629. * Gets or sets the active clipplane 6
  96630. */
  96631. clipPlane6: Nullable<Plane>;
  96632. }
  96633. }
  96634. declare module BABYLON {
  96635. /**
  96636. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  96637. *
  96638. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  96639. *
  96640. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  96641. */
  96642. export class ThinMaterialHelper {
  96643. /**
  96644. * Binds the clip plane information from the holder to the effect.
  96645. * @param effect The effect we are binding the data to
  96646. * @param holder The entity containing the clip plane information
  96647. */
  96648. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  96649. }
  96650. }
  96651. declare module BABYLON {
  96652. interface ThinEngine {
  96653. /**
  96654. * Sets alpha constants used by some alpha blending modes
  96655. * @param r defines the red component
  96656. * @param g defines the green component
  96657. * @param b defines the blue component
  96658. * @param a defines the alpha component
  96659. */
  96660. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96661. /**
  96662. * Sets the current alpha mode
  96663. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96664. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96665. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96666. */
  96667. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96668. /**
  96669. * Gets the current alpha mode
  96670. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96671. * @returns the current alpha mode
  96672. */
  96673. getAlphaMode(): number;
  96674. /**
  96675. * Sets the current alpha equation
  96676. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  96677. */
  96678. setAlphaEquation(equation: number): void;
  96679. /**
  96680. * Gets the current alpha equation.
  96681. * @returns the current alpha equation
  96682. */
  96683. getAlphaEquation(): number;
  96684. }
  96685. }
  96686. declare module BABYLON {
  96687. /**
  96688. * This represents a particle system in Babylon.
  96689. * 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.
  96690. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  96691. * @example https://doc.babylonjs.com/babylon101/particles
  96692. */
  96693. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  96694. /**
  96695. * Billboard mode will only apply to Y axis
  96696. */
  96697. static readonly BILLBOARDMODE_Y: number;
  96698. /**
  96699. * Billboard mode will apply to all axes
  96700. */
  96701. static readonly BILLBOARDMODE_ALL: number;
  96702. /**
  96703. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  96704. */
  96705. static readonly BILLBOARDMODE_STRETCHED: number;
  96706. /**
  96707. * This function can be defined to provide custom update for active particles.
  96708. * This function will be called instead of regular update (age, position, color, etc.).
  96709. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  96710. */
  96711. updateFunction: (particles: Particle[]) => void;
  96712. private _emitterWorldMatrix;
  96713. /**
  96714. * This function can be defined to specify initial direction for every new particle.
  96715. * It by default use the emitterType defined function
  96716. */
  96717. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96718. /**
  96719. * This function can be defined to specify initial position for every new particle.
  96720. * It by default use the emitterType defined function
  96721. */
  96722. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96723. /**
  96724. * @hidden
  96725. */
  96726. _inheritedVelocityOffset: Vector3;
  96727. /**
  96728. * An event triggered when the system is disposed
  96729. */
  96730. onDisposeObservable: Observable<IParticleSystem>;
  96731. /**
  96732. * An event triggered when the system is stopped
  96733. */
  96734. onStoppedObservable: Observable<IParticleSystem>;
  96735. private _onDisposeObserver;
  96736. /**
  96737. * Sets a callback that will be triggered when the system is disposed
  96738. */
  96739. set onDispose(callback: () => void);
  96740. private _particles;
  96741. private _epsilon;
  96742. private _capacity;
  96743. private _stockParticles;
  96744. private _newPartsExcess;
  96745. private _vertexData;
  96746. private _vertexBuffer;
  96747. private _vertexBuffers;
  96748. private _spriteBuffer;
  96749. private _indexBuffer;
  96750. private _effect;
  96751. private _customEffect;
  96752. private _cachedDefines;
  96753. private _scaledColorStep;
  96754. private _colorDiff;
  96755. private _scaledDirection;
  96756. private _scaledGravity;
  96757. private _currentRenderId;
  96758. private _alive;
  96759. private _useInstancing;
  96760. private _vertexArrayObject;
  96761. private _started;
  96762. private _stopped;
  96763. private _actualFrame;
  96764. private _scaledUpdateSpeed;
  96765. private _vertexBufferSize;
  96766. /** @hidden */
  96767. _currentEmitRateGradient: Nullable<FactorGradient>;
  96768. /** @hidden */
  96769. _currentEmitRate1: number;
  96770. /** @hidden */
  96771. _currentEmitRate2: number;
  96772. /** @hidden */
  96773. _currentStartSizeGradient: Nullable<FactorGradient>;
  96774. /** @hidden */
  96775. _currentStartSize1: number;
  96776. /** @hidden */
  96777. _currentStartSize2: number;
  96778. private readonly _rawTextureWidth;
  96779. private _rampGradientsTexture;
  96780. private _useRampGradients;
  96781. /** Gets or sets a matrix to use to compute projection */
  96782. defaultProjectionMatrix: Matrix;
  96783. /** Gets or sets a matrix to use to compute view */
  96784. defaultViewMatrix: Matrix;
  96785. /** Gets or sets a boolean indicating that ramp gradients must be used
  96786. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  96787. */
  96788. get useRampGradients(): boolean;
  96789. set useRampGradients(value: boolean);
  96790. /**
  96791. * 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.
  96792. * 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: [])
  96793. */
  96794. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  96795. private _subEmitters;
  96796. /**
  96797. * @hidden
  96798. * If the particle systems emitter should be disposed when the particle system is disposed
  96799. */
  96800. _disposeEmitterOnDispose: boolean;
  96801. /**
  96802. * The current active Sub-systems, this property is used by the root particle system only.
  96803. */
  96804. activeSubSystems: Array<ParticleSystem>;
  96805. /**
  96806. * Specifies if the particles are updated in emitter local space or world space
  96807. */
  96808. isLocal: boolean;
  96809. private _rootParticleSystem;
  96810. /**
  96811. * Gets the current list of active particles
  96812. */
  96813. get particles(): Particle[];
  96814. /**
  96815. * Gets the number of particles active at the same time.
  96816. * @returns The number of active particles.
  96817. */
  96818. getActiveCount(): number;
  96819. /**
  96820. * Returns the string "ParticleSystem"
  96821. * @returns a string containing the class name
  96822. */
  96823. getClassName(): string;
  96824. /**
  96825. * Gets a boolean indicating that the system is stopping
  96826. * @returns true if the system is currently stopping
  96827. */
  96828. isStopping(): boolean;
  96829. /**
  96830. * Gets the custom effect used to render the particles
  96831. * @param blendMode Blend mode for which the effect should be retrieved
  96832. * @returns The effect
  96833. */
  96834. getCustomEffect(blendMode?: number): Nullable<Effect>;
  96835. /**
  96836. * Sets the custom effect used to render the particles
  96837. * @param effect The effect to set
  96838. * @param blendMode Blend mode for which the effect should be set
  96839. */
  96840. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  96841. /** @hidden */
  96842. private _onBeforeDrawParticlesObservable;
  96843. /**
  96844. * Observable that will be called just before the particles are drawn
  96845. */
  96846. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  96847. /**
  96848. * Gets the name of the particle vertex shader
  96849. */
  96850. get vertexShaderName(): string;
  96851. /**
  96852. * Instantiates a particle system.
  96853. * 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.
  96854. * @param name The name of the particle system
  96855. * @param capacity The max number of particles alive at the same time
  96856. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  96857. * @param customEffect a custom effect used to change the way particles are rendered by default
  96858. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  96859. * @param epsilon Offset used to render the particles
  96860. */
  96861. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  96862. private _addFactorGradient;
  96863. private _removeFactorGradient;
  96864. /**
  96865. * Adds a new life time gradient
  96866. * @param gradient defines the gradient to use (between 0 and 1)
  96867. * @param factor defines the life time factor to affect to the specified gradient
  96868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96869. * @returns the current particle system
  96870. */
  96871. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96872. /**
  96873. * Remove a specific life time gradient
  96874. * @param gradient defines the gradient to remove
  96875. * @returns the current particle system
  96876. */
  96877. removeLifeTimeGradient(gradient: number): IParticleSystem;
  96878. /**
  96879. * Adds a new size gradient
  96880. * @param gradient defines the gradient to use (between 0 and 1)
  96881. * @param factor defines the size factor to affect to the specified gradient
  96882. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96883. * @returns the current particle system
  96884. */
  96885. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96886. /**
  96887. * Remove a specific size gradient
  96888. * @param gradient defines the gradient to remove
  96889. * @returns the current particle system
  96890. */
  96891. removeSizeGradient(gradient: number): IParticleSystem;
  96892. /**
  96893. * Adds a new color remap gradient
  96894. * @param gradient defines the gradient to use (between 0 and 1)
  96895. * @param min defines the color remap minimal range
  96896. * @param max defines the color remap maximal range
  96897. * @returns the current particle system
  96898. */
  96899. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96900. /**
  96901. * Remove a specific color remap gradient
  96902. * @param gradient defines the gradient to remove
  96903. * @returns the current particle system
  96904. */
  96905. removeColorRemapGradient(gradient: number): IParticleSystem;
  96906. /**
  96907. * Adds a new alpha remap gradient
  96908. * @param gradient defines the gradient to use (between 0 and 1)
  96909. * @param min defines the alpha remap minimal range
  96910. * @param max defines the alpha remap maximal range
  96911. * @returns the current particle system
  96912. */
  96913. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96914. /**
  96915. * Remove a specific alpha remap gradient
  96916. * @param gradient defines the gradient to remove
  96917. * @returns the current particle system
  96918. */
  96919. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  96920. /**
  96921. * Adds a new angular speed gradient
  96922. * @param gradient defines the gradient to use (between 0 and 1)
  96923. * @param factor defines the angular speed to affect to the specified gradient
  96924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96925. * @returns the current particle system
  96926. */
  96927. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96928. /**
  96929. * Remove a specific angular speed gradient
  96930. * @param gradient defines the gradient to remove
  96931. * @returns the current particle system
  96932. */
  96933. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  96934. /**
  96935. * Adds a new velocity gradient
  96936. * @param gradient defines the gradient to use (between 0 and 1)
  96937. * @param factor defines the velocity to affect to the specified gradient
  96938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96939. * @returns the current particle system
  96940. */
  96941. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96942. /**
  96943. * Remove a specific velocity gradient
  96944. * @param gradient defines the gradient to remove
  96945. * @returns the current particle system
  96946. */
  96947. removeVelocityGradient(gradient: number): IParticleSystem;
  96948. /**
  96949. * Adds a new limit velocity gradient
  96950. * @param gradient defines the gradient to use (between 0 and 1)
  96951. * @param factor defines the limit velocity value to affect to the specified gradient
  96952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96953. * @returns the current particle system
  96954. */
  96955. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96956. /**
  96957. * Remove a specific limit velocity gradient
  96958. * @param gradient defines the gradient to remove
  96959. * @returns the current particle system
  96960. */
  96961. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  96962. /**
  96963. * Adds a new drag gradient
  96964. * @param gradient defines the gradient to use (between 0 and 1)
  96965. * @param factor defines the drag value to affect to the specified gradient
  96966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96967. * @returns the current particle system
  96968. */
  96969. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96970. /**
  96971. * Remove a specific drag gradient
  96972. * @param gradient defines the gradient to remove
  96973. * @returns the current particle system
  96974. */
  96975. removeDragGradient(gradient: number): IParticleSystem;
  96976. /**
  96977. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  96978. * @param gradient defines the gradient to use (between 0 and 1)
  96979. * @param factor defines the emit rate value to affect to the specified gradient
  96980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96981. * @returns the current particle system
  96982. */
  96983. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96984. /**
  96985. * Remove a specific emit rate gradient
  96986. * @param gradient defines the gradient to remove
  96987. * @returns the current particle system
  96988. */
  96989. removeEmitRateGradient(gradient: number): IParticleSystem;
  96990. /**
  96991. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  96992. * @param gradient defines the gradient to use (between 0 and 1)
  96993. * @param factor defines the start size value to affect to the specified gradient
  96994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96995. * @returns the current particle system
  96996. */
  96997. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96998. /**
  96999. * Remove a specific start size gradient
  97000. * @param gradient defines the gradient to remove
  97001. * @returns the current particle system
  97002. */
  97003. removeStartSizeGradient(gradient: number): IParticleSystem;
  97004. private _createRampGradientTexture;
  97005. /**
  97006. * Gets the current list of ramp gradients.
  97007. * You must use addRampGradient and removeRampGradient to udpate this list
  97008. * @returns the list of ramp gradients
  97009. */
  97010. getRampGradients(): Nullable<Array<Color3Gradient>>;
  97011. /** Force the system to rebuild all gradients that need to be resync */
  97012. forceRefreshGradients(): void;
  97013. private _syncRampGradientTexture;
  97014. /**
  97015. * Adds a new ramp gradient used to remap particle colors
  97016. * @param gradient defines the gradient to use (between 0 and 1)
  97017. * @param color defines the color to affect to the specified gradient
  97018. * @returns the current particle system
  97019. */
  97020. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  97021. /**
  97022. * Remove a specific ramp gradient
  97023. * @param gradient defines the gradient to remove
  97024. * @returns the current particle system
  97025. */
  97026. removeRampGradient(gradient: number): ParticleSystem;
  97027. /**
  97028. * Adds a new color gradient
  97029. * @param gradient defines the gradient to use (between 0 and 1)
  97030. * @param color1 defines the color to affect to the specified gradient
  97031. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  97032. * @returns this particle system
  97033. */
  97034. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  97035. /**
  97036. * Remove a specific color gradient
  97037. * @param gradient defines the gradient to remove
  97038. * @returns this particle system
  97039. */
  97040. removeColorGradient(gradient: number): IParticleSystem;
  97041. private _fetchR;
  97042. protected _reset(): void;
  97043. private _resetEffect;
  97044. private _createVertexBuffers;
  97045. private _createIndexBuffer;
  97046. /**
  97047. * Gets the maximum number of particles active at the same time.
  97048. * @returns The max number of active particles.
  97049. */
  97050. getCapacity(): number;
  97051. /**
  97052. * Gets whether there are still active particles in the system.
  97053. * @returns True if it is alive, otherwise false.
  97054. */
  97055. isAlive(): boolean;
  97056. /**
  97057. * Gets if the system has been started. (Note: this will still be true after stop is called)
  97058. * @returns True if it has been started, otherwise false.
  97059. */
  97060. isStarted(): boolean;
  97061. private _prepareSubEmitterInternalArray;
  97062. /**
  97063. * Starts the particle system and begins to emit
  97064. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  97065. */
  97066. start(delay?: number): void;
  97067. /**
  97068. * Stops the particle system.
  97069. * @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.
  97070. */
  97071. stop(stopSubEmitters?: boolean): void;
  97072. /**
  97073. * Remove all active particles
  97074. */
  97075. reset(): void;
  97076. /**
  97077. * @hidden (for internal use only)
  97078. */
  97079. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  97080. /**
  97081. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  97082. * Its lifetime will start back at 0.
  97083. */
  97084. recycleParticle: (particle: Particle) => void;
  97085. private _stopSubEmitters;
  97086. private _createParticle;
  97087. private _removeFromRoot;
  97088. private _emitFromParticle;
  97089. private _update;
  97090. /** @hidden */
  97091. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  97092. /** @hidden */
  97093. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  97094. /**
  97095. * Fill the defines array according to the current settings of the particle system
  97096. * @param defines Array to be updated
  97097. * @param blendMode blend mode to take into account when updating the array
  97098. */
  97099. fillDefines(defines: Array<string>, blendMode: number): void;
  97100. /**
  97101. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  97102. * @param uniforms Uniforms array to fill
  97103. * @param attributes Attributes array to fill
  97104. * @param samplers Samplers array to fill
  97105. */
  97106. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  97107. /** @hidden */
  97108. private _getEffect;
  97109. /**
  97110. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  97111. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  97112. */
  97113. animate(preWarmOnly?: boolean): void;
  97114. private _appendParticleVertices;
  97115. /**
  97116. * Rebuilds the particle system.
  97117. */
  97118. rebuild(): void;
  97119. /**
  97120. * Is this system ready to be used/rendered
  97121. * @return true if the system is ready
  97122. */
  97123. isReady(): boolean;
  97124. private _render;
  97125. /**
  97126. * Renders the particle system in its current state.
  97127. * @returns the current number of particles
  97128. */
  97129. render(): number;
  97130. /**
  97131. * Disposes the particle system and free the associated resources
  97132. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  97133. */
  97134. dispose(disposeTexture?: boolean): void;
  97135. /**
  97136. * Clones the particle system.
  97137. * @param name The name of the cloned object
  97138. * @param newEmitter The new emitter to use
  97139. * @returns the cloned particle system
  97140. */
  97141. clone(name: string, newEmitter: any): ParticleSystem;
  97142. /**
  97143. * Serializes the particle system to a JSON object
  97144. * @param serializeTexture defines if the texture must be serialized as well
  97145. * @returns the JSON object
  97146. */
  97147. serialize(serializeTexture?: boolean): any;
  97148. /** @hidden */
  97149. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  97150. /** @hidden */
  97151. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  97152. /**
  97153. * Parses a JSON object to create a particle system.
  97154. * @param parsedParticleSystem The JSON object to parse
  97155. * @param sceneOrEngine The scene or the engine to create the particle system in
  97156. * @param rootUrl The root url to use to load external dependencies like texture
  97157. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  97158. * @returns the Parsed particle system
  97159. */
  97160. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  97161. }
  97162. }
  97163. declare module BABYLON {
  97164. /**
  97165. * A particle represents one of the element emitted by a particle system.
  97166. * This is mainly define by its coordinates, direction, velocity and age.
  97167. */
  97168. export class Particle {
  97169. /**
  97170. * The particle system the particle belongs to.
  97171. */
  97172. particleSystem: ParticleSystem;
  97173. private static _Count;
  97174. /**
  97175. * Unique ID of the particle
  97176. */
  97177. id: number;
  97178. /**
  97179. * The world position of the particle in the scene.
  97180. */
  97181. position: Vector3;
  97182. /**
  97183. * The world direction of the particle in the scene.
  97184. */
  97185. direction: Vector3;
  97186. /**
  97187. * The color of the particle.
  97188. */
  97189. color: Color4;
  97190. /**
  97191. * The color change of the particle per step.
  97192. */
  97193. colorStep: Color4;
  97194. /**
  97195. * Defines how long will the life of the particle be.
  97196. */
  97197. lifeTime: number;
  97198. /**
  97199. * The current age of the particle.
  97200. */
  97201. age: number;
  97202. /**
  97203. * The current size of the particle.
  97204. */
  97205. size: number;
  97206. /**
  97207. * The current scale of the particle.
  97208. */
  97209. scale: Vector2;
  97210. /**
  97211. * The current angle of the particle.
  97212. */
  97213. angle: number;
  97214. /**
  97215. * Defines how fast is the angle changing.
  97216. */
  97217. angularSpeed: number;
  97218. /**
  97219. * Defines the cell index used by the particle to be rendered from a sprite.
  97220. */
  97221. cellIndex: number;
  97222. /**
  97223. * The information required to support color remapping
  97224. */
  97225. remapData: Vector4;
  97226. /** @hidden */
  97227. _randomCellOffset?: number;
  97228. /** @hidden */
  97229. _initialDirection: Nullable<Vector3>;
  97230. /** @hidden */
  97231. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  97232. /** @hidden */
  97233. _initialStartSpriteCellID: number;
  97234. /** @hidden */
  97235. _initialEndSpriteCellID: number;
  97236. /** @hidden */
  97237. _currentColorGradient: Nullable<ColorGradient>;
  97238. /** @hidden */
  97239. _currentColor1: Color4;
  97240. /** @hidden */
  97241. _currentColor2: Color4;
  97242. /** @hidden */
  97243. _currentSizeGradient: Nullable<FactorGradient>;
  97244. /** @hidden */
  97245. _currentSize1: number;
  97246. /** @hidden */
  97247. _currentSize2: number;
  97248. /** @hidden */
  97249. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  97250. /** @hidden */
  97251. _currentAngularSpeed1: number;
  97252. /** @hidden */
  97253. _currentAngularSpeed2: number;
  97254. /** @hidden */
  97255. _currentVelocityGradient: Nullable<FactorGradient>;
  97256. /** @hidden */
  97257. _currentVelocity1: number;
  97258. /** @hidden */
  97259. _currentVelocity2: number;
  97260. /** @hidden */
  97261. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  97262. /** @hidden */
  97263. _currentLimitVelocity1: number;
  97264. /** @hidden */
  97265. _currentLimitVelocity2: number;
  97266. /** @hidden */
  97267. _currentDragGradient: Nullable<FactorGradient>;
  97268. /** @hidden */
  97269. _currentDrag1: number;
  97270. /** @hidden */
  97271. _currentDrag2: number;
  97272. /** @hidden */
  97273. _randomNoiseCoordinates1: Vector3;
  97274. /** @hidden */
  97275. _randomNoiseCoordinates2: Vector3;
  97276. /** @hidden */
  97277. _localPosition?: Vector3;
  97278. /**
  97279. * Creates a new instance Particle
  97280. * @param particleSystem the particle system the particle belongs to
  97281. */
  97282. constructor(
  97283. /**
  97284. * The particle system the particle belongs to.
  97285. */
  97286. particleSystem: ParticleSystem);
  97287. private updateCellInfoFromSystem;
  97288. /**
  97289. * Defines how the sprite cell index is updated for the particle
  97290. */
  97291. updateCellIndex(): void;
  97292. /** @hidden */
  97293. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  97294. /** @hidden */
  97295. _inheritParticleInfoToSubEmitters(): void;
  97296. /** @hidden */
  97297. _reset(): void;
  97298. /**
  97299. * Copy the properties of particle to another one.
  97300. * @param other the particle to copy the information to.
  97301. */
  97302. copyTo(other: Particle): void;
  97303. }
  97304. }
  97305. declare module BABYLON {
  97306. /**
  97307. * Particle emitter represents a volume emitting particles.
  97308. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  97309. */
  97310. export interface IParticleEmitterType {
  97311. /**
  97312. * Called by the particle System when the direction is computed for the created particle.
  97313. * @param worldMatrix is the world matrix of the particle system
  97314. * @param directionToUpdate is the direction vector to update with the result
  97315. * @param particle is the particle we are computed the direction for
  97316. * @param isLocal defines if the direction should be set in local space
  97317. */
  97318. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97319. /**
  97320. * Called by the particle System when the position is computed for the created particle.
  97321. * @param worldMatrix is the world matrix of the particle system
  97322. * @param positionToUpdate is the position vector to update with the result
  97323. * @param particle is the particle we are computed the position for
  97324. * @param isLocal defines if the position should be set in local space
  97325. */
  97326. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97327. /**
  97328. * Clones the current emitter and returns a copy of it
  97329. * @returns the new emitter
  97330. */
  97331. clone(): IParticleEmitterType;
  97332. /**
  97333. * Called by the GPUParticleSystem to setup the update shader
  97334. * @param effect defines the update shader
  97335. */
  97336. applyToShader(effect: Effect): void;
  97337. /**
  97338. * Returns a string to use to update the GPU particles update shader
  97339. * @returns the effect defines string
  97340. */
  97341. getEffectDefines(): string;
  97342. /**
  97343. * Returns a string representing the class name
  97344. * @returns a string containing the class name
  97345. */
  97346. getClassName(): string;
  97347. /**
  97348. * Serializes the particle system to a JSON object.
  97349. * @returns the JSON object
  97350. */
  97351. serialize(): any;
  97352. /**
  97353. * Parse properties from a JSON object
  97354. * @param serializationObject defines the JSON object
  97355. * @param scene defines the hosting scene
  97356. */
  97357. parse(serializationObject: any, scene: Nullable<Scene>): void;
  97358. }
  97359. }
  97360. declare module BABYLON {
  97361. /**
  97362. * Particle emitter emitting particles from the inside of a box.
  97363. * It emits the particles randomly between 2 given directions.
  97364. */
  97365. export class BoxParticleEmitter implements IParticleEmitterType {
  97366. /**
  97367. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97368. */
  97369. direction1: Vector3;
  97370. /**
  97371. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97372. */
  97373. direction2: Vector3;
  97374. /**
  97375. * 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.
  97376. */
  97377. minEmitBox: Vector3;
  97378. /**
  97379. * 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.
  97380. */
  97381. maxEmitBox: Vector3;
  97382. /**
  97383. * Creates a new instance BoxParticleEmitter
  97384. */
  97385. constructor();
  97386. /**
  97387. * Called by the particle System when the direction is computed for the created particle.
  97388. * @param worldMatrix is the world matrix of the particle system
  97389. * @param directionToUpdate is the direction vector to update with the result
  97390. * @param particle is the particle we are computed the direction for
  97391. * @param isLocal defines if the direction should be set in local space
  97392. */
  97393. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97394. /**
  97395. * Called by the particle System when the position is computed for the created particle.
  97396. * @param worldMatrix is the world matrix of the particle system
  97397. * @param positionToUpdate is the position vector to update with the result
  97398. * @param particle is the particle we are computed the position for
  97399. * @param isLocal defines if the position should be set in local space
  97400. */
  97401. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97402. /**
  97403. * Clones the current emitter and returns a copy of it
  97404. * @returns the new emitter
  97405. */
  97406. clone(): BoxParticleEmitter;
  97407. /**
  97408. * Called by the GPUParticleSystem to setup the update shader
  97409. * @param effect defines the update shader
  97410. */
  97411. applyToShader(effect: Effect): void;
  97412. /**
  97413. * Returns a string to use to update the GPU particles update shader
  97414. * @returns a string containng the defines string
  97415. */
  97416. getEffectDefines(): string;
  97417. /**
  97418. * Returns the string "BoxParticleEmitter"
  97419. * @returns a string containing the class name
  97420. */
  97421. getClassName(): string;
  97422. /**
  97423. * Serializes the particle system to a JSON object.
  97424. * @returns the JSON object
  97425. */
  97426. serialize(): any;
  97427. /**
  97428. * Parse properties from a JSON object
  97429. * @param serializationObject defines the JSON object
  97430. */
  97431. parse(serializationObject: any): void;
  97432. }
  97433. }
  97434. declare module BABYLON {
  97435. /**
  97436. * Particle emitter emitting particles from the inside of a cone.
  97437. * It emits the particles alongside the cone volume from the base to the particle.
  97438. * The emission direction might be randomized.
  97439. */
  97440. export class ConeParticleEmitter implements IParticleEmitterType {
  97441. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97442. directionRandomizer: number;
  97443. private _radius;
  97444. private _angle;
  97445. private _height;
  97446. /**
  97447. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  97448. */
  97449. radiusRange: number;
  97450. /**
  97451. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  97452. */
  97453. heightRange: number;
  97454. /**
  97455. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  97456. */
  97457. emitFromSpawnPointOnly: boolean;
  97458. /**
  97459. * Gets or sets the radius of the emission cone
  97460. */
  97461. get radius(): number;
  97462. set radius(value: number);
  97463. /**
  97464. * Gets or sets the angle of the emission cone
  97465. */
  97466. get angle(): number;
  97467. set angle(value: number);
  97468. private _buildHeight;
  97469. /**
  97470. * Creates a new instance ConeParticleEmitter
  97471. * @param radius the radius of the emission cone (1 by default)
  97472. * @param angle the cone base angle (PI by default)
  97473. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  97474. */
  97475. constructor(radius?: number, angle?: number,
  97476. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97477. directionRandomizer?: number);
  97478. /**
  97479. * Called by the particle System when the direction is computed for the created particle.
  97480. * @param worldMatrix is the world matrix of the particle system
  97481. * @param directionToUpdate is the direction vector to update with the result
  97482. * @param particle is the particle we are computed the direction for
  97483. * @param isLocal defines if the direction should be set in local space
  97484. */
  97485. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97486. /**
  97487. * Called by the particle System when the position is computed for the created particle.
  97488. * @param worldMatrix is the world matrix of the particle system
  97489. * @param positionToUpdate is the position vector to update with the result
  97490. * @param particle is the particle we are computed the position for
  97491. * @param isLocal defines if the position should be set in local space
  97492. */
  97493. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97494. /**
  97495. * Clones the current emitter and returns a copy of it
  97496. * @returns the new emitter
  97497. */
  97498. clone(): ConeParticleEmitter;
  97499. /**
  97500. * Called by the GPUParticleSystem to setup the update shader
  97501. * @param effect defines the update shader
  97502. */
  97503. applyToShader(effect: Effect): void;
  97504. /**
  97505. * Returns a string to use to update the GPU particles update shader
  97506. * @returns a string containng the defines string
  97507. */
  97508. getEffectDefines(): string;
  97509. /**
  97510. * Returns the string "ConeParticleEmitter"
  97511. * @returns a string containing the class name
  97512. */
  97513. getClassName(): string;
  97514. /**
  97515. * Serializes the particle system to a JSON object.
  97516. * @returns the JSON object
  97517. */
  97518. serialize(): any;
  97519. /**
  97520. * Parse properties from a JSON object
  97521. * @param serializationObject defines the JSON object
  97522. */
  97523. parse(serializationObject: any): void;
  97524. }
  97525. }
  97526. declare module BABYLON {
  97527. /**
  97528. * Particle emitter emitting particles from the inside of a cylinder.
  97529. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  97530. */
  97531. export class CylinderParticleEmitter implements IParticleEmitterType {
  97532. /**
  97533. * The radius of the emission cylinder.
  97534. */
  97535. radius: number;
  97536. /**
  97537. * The height of the emission cylinder.
  97538. */
  97539. height: number;
  97540. /**
  97541. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97542. */
  97543. radiusRange: number;
  97544. /**
  97545. * How much to randomize the particle direction [0-1].
  97546. */
  97547. directionRandomizer: number;
  97548. /**
  97549. * Creates a new instance CylinderParticleEmitter
  97550. * @param radius the radius of the emission cylinder (1 by default)
  97551. * @param height the height of the emission cylinder (1 by default)
  97552. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97553. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97554. */
  97555. constructor(
  97556. /**
  97557. * The radius of the emission cylinder.
  97558. */
  97559. radius?: number,
  97560. /**
  97561. * The height of the emission cylinder.
  97562. */
  97563. height?: number,
  97564. /**
  97565. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97566. */
  97567. radiusRange?: number,
  97568. /**
  97569. * How much to randomize the particle direction [0-1].
  97570. */
  97571. directionRandomizer?: number);
  97572. /**
  97573. * Called by the particle System when the direction is computed for the created particle.
  97574. * @param worldMatrix is the world matrix of the particle system
  97575. * @param directionToUpdate is the direction vector to update with the result
  97576. * @param particle is the particle we are computed the direction for
  97577. * @param isLocal defines if the direction should be set in local space
  97578. */
  97579. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97580. /**
  97581. * Called by the particle System when the position is computed for the created particle.
  97582. * @param worldMatrix is the world matrix of the particle system
  97583. * @param positionToUpdate is the position vector to update with the result
  97584. * @param particle is the particle we are computed the position for
  97585. * @param isLocal defines if the position should be set in local space
  97586. */
  97587. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97588. /**
  97589. * Clones the current emitter and returns a copy of it
  97590. * @returns the new emitter
  97591. */
  97592. clone(): CylinderParticleEmitter;
  97593. /**
  97594. * Called by the GPUParticleSystem to setup the update shader
  97595. * @param effect defines the update shader
  97596. */
  97597. applyToShader(effect: Effect): void;
  97598. /**
  97599. * Returns a string to use to update the GPU particles update shader
  97600. * @returns a string containng the defines string
  97601. */
  97602. getEffectDefines(): string;
  97603. /**
  97604. * Returns the string "CylinderParticleEmitter"
  97605. * @returns a string containing the class name
  97606. */
  97607. getClassName(): string;
  97608. /**
  97609. * Serializes the particle system to a JSON object.
  97610. * @returns the JSON object
  97611. */
  97612. serialize(): any;
  97613. /**
  97614. * Parse properties from a JSON object
  97615. * @param serializationObject defines the JSON object
  97616. */
  97617. parse(serializationObject: any): void;
  97618. }
  97619. /**
  97620. * Particle emitter emitting particles from the inside of a cylinder.
  97621. * It emits the particles randomly between two vectors.
  97622. */
  97623. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  97624. /**
  97625. * The min limit of the emission direction.
  97626. */
  97627. direction1: Vector3;
  97628. /**
  97629. * The max limit of the emission direction.
  97630. */
  97631. direction2: Vector3;
  97632. /**
  97633. * Creates a new instance CylinderDirectedParticleEmitter
  97634. * @param radius the radius of the emission cylinder (1 by default)
  97635. * @param height the height of the emission cylinder (1 by default)
  97636. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97637. * @param direction1 the min limit of the emission direction (up vector by default)
  97638. * @param direction2 the max limit of the emission direction (up vector by default)
  97639. */
  97640. constructor(radius?: number, height?: number, radiusRange?: number,
  97641. /**
  97642. * The min limit of the emission direction.
  97643. */
  97644. direction1?: Vector3,
  97645. /**
  97646. * The max limit of the emission direction.
  97647. */
  97648. direction2?: Vector3);
  97649. /**
  97650. * Called by the particle System when the direction is computed for the created particle.
  97651. * @param worldMatrix is the world matrix of the particle system
  97652. * @param directionToUpdate is the direction vector to update with the result
  97653. * @param particle is the particle we are computed the direction for
  97654. */
  97655. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97656. /**
  97657. * Clones the current emitter and returns a copy of it
  97658. * @returns the new emitter
  97659. */
  97660. clone(): CylinderDirectedParticleEmitter;
  97661. /**
  97662. * Called by the GPUParticleSystem to setup the update shader
  97663. * @param effect defines the update shader
  97664. */
  97665. applyToShader(effect: Effect): void;
  97666. /**
  97667. * Returns a string to use to update the GPU particles update shader
  97668. * @returns a string containng the defines string
  97669. */
  97670. getEffectDefines(): string;
  97671. /**
  97672. * Returns the string "CylinderDirectedParticleEmitter"
  97673. * @returns a string containing the class name
  97674. */
  97675. getClassName(): string;
  97676. /**
  97677. * Serializes the particle system to a JSON object.
  97678. * @returns the JSON object
  97679. */
  97680. serialize(): any;
  97681. /**
  97682. * Parse properties from a JSON object
  97683. * @param serializationObject defines the JSON object
  97684. */
  97685. parse(serializationObject: any): void;
  97686. }
  97687. }
  97688. declare module BABYLON {
  97689. /**
  97690. * Particle emitter emitting particles from the inside of a hemisphere.
  97691. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  97692. */
  97693. export class HemisphericParticleEmitter implements IParticleEmitterType {
  97694. /**
  97695. * The radius of the emission hemisphere.
  97696. */
  97697. radius: number;
  97698. /**
  97699. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97700. */
  97701. radiusRange: number;
  97702. /**
  97703. * How much to randomize the particle direction [0-1].
  97704. */
  97705. directionRandomizer: number;
  97706. /**
  97707. * Creates a new instance HemisphericParticleEmitter
  97708. * @param radius the radius of the emission hemisphere (1 by default)
  97709. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97710. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97711. */
  97712. constructor(
  97713. /**
  97714. * The radius of the emission hemisphere.
  97715. */
  97716. radius?: number,
  97717. /**
  97718. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97719. */
  97720. radiusRange?: number,
  97721. /**
  97722. * How much to randomize the particle direction [0-1].
  97723. */
  97724. directionRandomizer?: number);
  97725. /**
  97726. * Called by the particle System when the direction is computed for the created particle.
  97727. * @param worldMatrix is the world matrix of the particle system
  97728. * @param directionToUpdate is the direction vector to update with the result
  97729. * @param particle is the particle we are computed the direction for
  97730. * @param isLocal defines if the direction should be set in local space
  97731. */
  97732. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97733. /**
  97734. * Called by the particle System when the position is computed for the created particle.
  97735. * @param worldMatrix is the world matrix of the particle system
  97736. * @param positionToUpdate is the position vector to update with the result
  97737. * @param particle is the particle we are computed the position for
  97738. * @param isLocal defines if the position should be set in local space
  97739. */
  97740. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97741. /**
  97742. * Clones the current emitter and returns a copy of it
  97743. * @returns the new emitter
  97744. */
  97745. clone(): HemisphericParticleEmitter;
  97746. /**
  97747. * Called by the GPUParticleSystem to setup the update shader
  97748. * @param effect defines the update shader
  97749. */
  97750. applyToShader(effect: Effect): void;
  97751. /**
  97752. * Returns a string to use to update the GPU particles update shader
  97753. * @returns a string containng the defines string
  97754. */
  97755. getEffectDefines(): string;
  97756. /**
  97757. * Returns the string "HemisphericParticleEmitter"
  97758. * @returns a string containing the class name
  97759. */
  97760. getClassName(): string;
  97761. /**
  97762. * Serializes the particle system to a JSON object.
  97763. * @returns the JSON object
  97764. */
  97765. serialize(): any;
  97766. /**
  97767. * Parse properties from a JSON object
  97768. * @param serializationObject defines the JSON object
  97769. */
  97770. parse(serializationObject: any): void;
  97771. }
  97772. }
  97773. declare module BABYLON {
  97774. /**
  97775. * Particle emitter emitting particles from a point.
  97776. * It emits the particles randomly between 2 given directions.
  97777. */
  97778. export class PointParticleEmitter implements IParticleEmitterType {
  97779. /**
  97780. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97781. */
  97782. direction1: Vector3;
  97783. /**
  97784. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97785. */
  97786. direction2: Vector3;
  97787. /**
  97788. * Creates a new instance PointParticleEmitter
  97789. */
  97790. constructor();
  97791. /**
  97792. * Called by the particle System when the direction is computed for the created particle.
  97793. * @param worldMatrix is the world matrix of the particle system
  97794. * @param directionToUpdate is the direction vector to update with the result
  97795. * @param particle is the particle we are computed the direction for
  97796. * @param isLocal defines if the direction should be set in local space
  97797. */
  97798. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97799. /**
  97800. * Called by the particle System when the position is computed for the created particle.
  97801. * @param worldMatrix is the world matrix of the particle system
  97802. * @param positionToUpdate is the position vector to update with the result
  97803. * @param particle is the particle we are computed the position for
  97804. * @param isLocal defines if the position should be set in local space
  97805. */
  97806. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97807. /**
  97808. * Clones the current emitter and returns a copy of it
  97809. * @returns the new emitter
  97810. */
  97811. clone(): PointParticleEmitter;
  97812. /**
  97813. * Called by the GPUParticleSystem to setup the update shader
  97814. * @param effect defines the update shader
  97815. */
  97816. applyToShader(effect: Effect): void;
  97817. /**
  97818. * Returns a string to use to update the GPU particles update shader
  97819. * @returns a string containng the defines string
  97820. */
  97821. getEffectDefines(): string;
  97822. /**
  97823. * Returns the string "PointParticleEmitter"
  97824. * @returns a string containing the class name
  97825. */
  97826. getClassName(): string;
  97827. /**
  97828. * Serializes the particle system to a JSON object.
  97829. * @returns the JSON object
  97830. */
  97831. serialize(): any;
  97832. /**
  97833. * Parse properties from a JSON object
  97834. * @param serializationObject defines the JSON object
  97835. */
  97836. parse(serializationObject: any): void;
  97837. }
  97838. }
  97839. declare module BABYLON {
  97840. /**
  97841. * Particle emitter emitting particles from the inside of a sphere.
  97842. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  97843. */
  97844. export class SphereParticleEmitter implements IParticleEmitterType {
  97845. /**
  97846. * The radius of the emission sphere.
  97847. */
  97848. radius: number;
  97849. /**
  97850. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97851. */
  97852. radiusRange: number;
  97853. /**
  97854. * How much to randomize the particle direction [0-1].
  97855. */
  97856. directionRandomizer: number;
  97857. /**
  97858. * Creates a new instance SphereParticleEmitter
  97859. * @param radius the radius of the emission sphere (1 by default)
  97860. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97861. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97862. */
  97863. constructor(
  97864. /**
  97865. * The radius of the emission sphere.
  97866. */
  97867. radius?: number,
  97868. /**
  97869. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97870. */
  97871. radiusRange?: number,
  97872. /**
  97873. * How much to randomize the particle direction [0-1].
  97874. */
  97875. directionRandomizer?: number);
  97876. /**
  97877. * Called by the particle System when the direction is computed for the created particle.
  97878. * @param worldMatrix is the world matrix of the particle system
  97879. * @param directionToUpdate is the direction vector to update with the result
  97880. * @param particle is the particle we are computed the direction for
  97881. * @param isLocal defines if the direction should be set in local space
  97882. */
  97883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97884. /**
  97885. * Called by the particle System when the position is computed for the created particle.
  97886. * @param worldMatrix is the world matrix of the particle system
  97887. * @param positionToUpdate is the position vector to update with the result
  97888. * @param particle is the particle we are computed the position for
  97889. * @param isLocal defines if the position should be set in local space
  97890. */
  97891. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97892. /**
  97893. * Clones the current emitter and returns a copy of it
  97894. * @returns the new emitter
  97895. */
  97896. clone(): SphereParticleEmitter;
  97897. /**
  97898. * Called by the GPUParticleSystem to setup the update shader
  97899. * @param effect defines the update shader
  97900. */
  97901. applyToShader(effect: Effect): void;
  97902. /**
  97903. * Returns a string to use to update the GPU particles update shader
  97904. * @returns a string containng the defines string
  97905. */
  97906. getEffectDefines(): string;
  97907. /**
  97908. * Returns the string "SphereParticleEmitter"
  97909. * @returns a string containing the class name
  97910. */
  97911. getClassName(): string;
  97912. /**
  97913. * Serializes the particle system to a JSON object.
  97914. * @returns the JSON object
  97915. */
  97916. serialize(): any;
  97917. /**
  97918. * Parse properties from a JSON object
  97919. * @param serializationObject defines the JSON object
  97920. */
  97921. parse(serializationObject: any): void;
  97922. }
  97923. /**
  97924. * Particle emitter emitting particles from the inside of a sphere.
  97925. * It emits the particles randomly between two vectors.
  97926. */
  97927. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  97928. /**
  97929. * The min limit of the emission direction.
  97930. */
  97931. direction1: Vector3;
  97932. /**
  97933. * The max limit of the emission direction.
  97934. */
  97935. direction2: Vector3;
  97936. /**
  97937. * Creates a new instance SphereDirectedParticleEmitter
  97938. * @param radius the radius of the emission sphere (1 by default)
  97939. * @param direction1 the min limit of the emission direction (up vector by default)
  97940. * @param direction2 the max limit of the emission direction (up vector by default)
  97941. */
  97942. constructor(radius?: number,
  97943. /**
  97944. * The min limit of the emission direction.
  97945. */
  97946. direction1?: Vector3,
  97947. /**
  97948. * The max limit of the emission direction.
  97949. */
  97950. direction2?: Vector3);
  97951. /**
  97952. * Called by the particle System when the direction is computed for the created particle.
  97953. * @param worldMatrix is the world matrix of the particle system
  97954. * @param directionToUpdate is the direction vector to update with the result
  97955. * @param particle is the particle we are computed the direction for
  97956. */
  97957. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97958. /**
  97959. * Clones the current emitter and returns a copy of it
  97960. * @returns the new emitter
  97961. */
  97962. clone(): SphereDirectedParticleEmitter;
  97963. /**
  97964. * Called by the GPUParticleSystem to setup the update shader
  97965. * @param effect defines the update shader
  97966. */
  97967. applyToShader(effect: Effect): void;
  97968. /**
  97969. * Returns a string to use to update the GPU particles update shader
  97970. * @returns a string containng the defines string
  97971. */
  97972. getEffectDefines(): string;
  97973. /**
  97974. * Returns the string "SphereDirectedParticleEmitter"
  97975. * @returns a string containing the class name
  97976. */
  97977. getClassName(): string;
  97978. /**
  97979. * Serializes the particle system to a JSON object.
  97980. * @returns the JSON object
  97981. */
  97982. serialize(): any;
  97983. /**
  97984. * Parse properties from a JSON object
  97985. * @param serializationObject defines the JSON object
  97986. */
  97987. parse(serializationObject: any): void;
  97988. }
  97989. }
  97990. declare module BABYLON {
  97991. /**
  97992. * Particle emitter emitting particles from a custom list of positions.
  97993. */
  97994. export class CustomParticleEmitter implements IParticleEmitterType {
  97995. /**
  97996. * Gets or sets the position generator that will create the inital position of each particle.
  97997. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97998. */
  97999. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  98000. /**
  98001. * Gets or sets the destination generator that will create the final destination of each particle.
  98002. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  98003. */
  98004. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  98005. /**
  98006. * Creates a new instance CustomParticleEmitter
  98007. */
  98008. constructor();
  98009. /**
  98010. * Called by the particle System when the direction is computed for the created particle.
  98011. * @param worldMatrix is the world matrix of the particle system
  98012. * @param directionToUpdate is the direction vector to update with the result
  98013. * @param particle is the particle we are computed the direction for
  98014. * @param isLocal defines if the direction should be set in local space
  98015. */
  98016. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  98017. /**
  98018. * Called by the particle System when the position is computed for the created particle.
  98019. * @param worldMatrix is the world matrix of the particle system
  98020. * @param positionToUpdate is the position vector to update with the result
  98021. * @param particle is the particle we are computed the position for
  98022. * @param isLocal defines if the position should be set in local space
  98023. */
  98024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  98025. /**
  98026. * Clones the current emitter and returns a copy of it
  98027. * @returns the new emitter
  98028. */
  98029. clone(): CustomParticleEmitter;
  98030. /**
  98031. * Called by the GPUParticleSystem to setup the update shader
  98032. * @param effect defines the update shader
  98033. */
  98034. applyToShader(effect: Effect): void;
  98035. /**
  98036. * Returns a string to use to update the GPU particles update shader
  98037. * @returns a string containng the defines string
  98038. */
  98039. getEffectDefines(): string;
  98040. /**
  98041. * Returns the string "PointParticleEmitter"
  98042. * @returns a string containing the class name
  98043. */
  98044. getClassName(): string;
  98045. /**
  98046. * Serializes the particle system to a JSON object.
  98047. * @returns the JSON object
  98048. */
  98049. serialize(): any;
  98050. /**
  98051. * Parse properties from a JSON object
  98052. * @param serializationObject defines the JSON object
  98053. */
  98054. parse(serializationObject: any): void;
  98055. }
  98056. }
  98057. declare module BABYLON {
  98058. /**
  98059. * Particle emitter emitting particles from the inside of a box.
  98060. * It emits the particles randomly between 2 given directions.
  98061. */
  98062. export class MeshParticleEmitter implements IParticleEmitterType {
  98063. private _indices;
  98064. private _positions;
  98065. private _normals;
  98066. private _storedNormal;
  98067. private _mesh;
  98068. /**
  98069. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  98070. */
  98071. direction1: Vector3;
  98072. /**
  98073. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  98074. */
  98075. direction2: Vector3;
  98076. /**
  98077. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  98078. */
  98079. useMeshNormalsForDirection: boolean;
  98080. /** Defines the mesh to use as source */
  98081. get mesh(): Nullable<AbstractMesh>;
  98082. set mesh(value: Nullable<AbstractMesh>);
  98083. /**
  98084. * Creates a new instance MeshParticleEmitter
  98085. * @param mesh defines the mesh to use as source
  98086. */
  98087. constructor(mesh?: Nullable<AbstractMesh>);
  98088. /**
  98089. * Called by the particle System when the direction is computed for the created particle.
  98090. * @param worldMatrix is the world matrix of the particle system
  98091. * @param directionToUpdate is the direction vector to update with the result
  98092. * @param particle is the particle we are computed the direction for
  98093. * @param isLocal defines if the direction should be set in local space
  98094. */
  98095. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  98096. /**
  98097. * Called by the particle System when the position is computed for the created particle.
  98098. * @param worldMatrix is the world matrix of the particle system
  98099. * @param positionToUpdate is the position vector to update with the result
  98100. * @param particle is the particle we are computed the position for
  98101. * @param isLocal defines if the position should be set in local space
  98102. */
  98103. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  98104. /**
  98105. * Clones the current emitter and returns a copy of it
  98106. * @returns the new emitter
  98107. */
  98108. clone(): MeshParticleEmitter;
  98109. /**
  98110. * Called by the GPUParticleSystem to setup the update shader
  98111. * @param effect defines the update shader
  98112. */
  98113. applyToShader(effect: Effect): void;
  98114. /**
  98115. * Returns a string to use to update the GPU particles update shader
  98116. * @returns a string containng the defines string
  98117. */
  98118. getEffectDefines(): string;
  98119. /**
  98120. * Returns the string "BoxParticleEmitter"
  98121. * @returns a string containing the class name
  98122. */
  98123. getClassName(): string;
  98124. /**
  98125. * Serializes the particle system to a JSON object.
  98126. * @returns the JSON object
  98127. */
  98128. serialize(): any;
  98129. /**
  98130. * Parse properties from a JSON object
  98131. * @param serializationObject defines the JSON object
  98132. * @param scene defines the hosting scene
  98133. */
  98134. parse(serializationObject: any, scene: Nullable<Scene>): void;
  98135. }
  98136. }
  98137. declare module BABYLON {
  98138. /**
  98139. * Interface representing a particle system in Babylon.js.
  98140. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  98141. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  98142. */
  98143. export interface IParticleSystem {
  98144. /**
  98145. * List of animations used by the particle system.
  98146. */
  98147. animations: Animation[];
  98148. /**
  98149. * The id of the Particle system.
  98150. */
  98151. id: string;
  98152. /**
  98153. * The name of the Particle system.
  98154. */
  98155. name: string;
  98156. /**
  98157. * The emitter represents the Mesh or position we are attaching the particle system to.
  98158. */
  98159. emitter: Nullable<AbstractMesh | Vector3>;
  98160. /**
  98161. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  98162. */
  98163. isBillboardBased: boolean;
  98164. /**
  98165. * The rendering group used by the Particle system to chose when to render.
  98166. */
  98167. renderingGroupId: number;
  98168. /**
  98169. * The layer mask we are rendering the particles through.
  98170. */
  98171. layerMask: number;
  98172. /**
  98173. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  98174. */
  98175. updateSpeed: number;
  98176. /**
  98177. * The amount of time the particle system is running (depends of the overall update speed).
  98178. */
  98179. targetStopDuration: number;
  98180. /**
  98181. * The texture used to render each particle. (this can be a spritesheet)
  98182. */
  98183. particleTexture: Nullable<BaseTexture>;
  98184. /**
  98185. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  98186. */
  98187. blendMode: number;
  98188. /**
  98189. * Minimum life time of emitting particles.
  98190. */
  98191. minLifeTime: number;
  98192. /**
  98193. * Maximum life time of emitting particles.
  98194. */
  98195. maxLifeTime: number;
  98196. /**
  98197. * Minimum Size of emitting particles.
  98198. */
  98199. minSize: number;
  98200. /**
  98201. * Maximum Size of emitting particles.
  98202. */
  98203. maxSize: number;
  98204. /**
  98205. * Minimum scale of emitting particles on X axis.
  98206. */
  98207. minScaleX: number;
  98208. /**
  98209. * Maximum scale of emitting particles on X axis.
  98210. */
  98211. maxScaleX: number;
  98212. /**
  98213. * Minimum scale of emitting particles on Y axis.
  98214. */
  98215. minScaleY: number;
  98216. /**
  98217. * Maximum scale of emitting particles on Y axis.
  98218. */
  98219. maxScaleY: number;
  98220. /**
  98221. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  98222. */
  98223. color1: Color4;
  98224. /**
  98225. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  98226. */
  98227. color2: Color4;
  98228. /**
  98229. * Color the particle will have at the end of its lifetime.
  98230. */
  98231. colorDead: Color4;
  98232. /**
  98233. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  98234. */
  98235. emitRate: number;
  98236. /**
  98237. * You can use gravity if you want to give an orientation to your particles.
  98238. */
  98239. gravity: Vector3;
  98240. /**
  98241. * Minimum power of emitting particles.
  98242. */
  98243. minEmitPower: number;
  98244. /**
  98245. * Maximum power of emitting particles.
  98246. */
  98247. maxEmitPower: number;
  98248. /**
  98249. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  98250. */
  98251. minAngularSpeed: number;
  98252. /**
  98253. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  98254. */
  98255. maxAngularSpeed: number;
  98256. /**
  98257. * Gets or sets the minimal initial rotation in radians.
  98258. */
  98259. minInitialRotation: number;
  98260. /**
  98261. * Gets or sets the maximal initial rotation in radians.
  98262. */
  98263. maxInitialRotation: number;
  98264. /**
  98265. * The particle emitter type defines the emitter used by the particle system.
  98266. * It can be for example box, sphere, or cone...
  98267. */
  98268. particleEmitterType: Nullable<IParticleEmitterType>;
  98269. /**
  98270. * Defines the delay in milliseconds before starting the system (0 by default)
  98271. */
  98272. startDelay: number;
  98273. /**
  98274. * 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
  98275. */
  98276. preWarmCycles: number;
  98277. /**
  98278. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  98279. */
  98280. preWarmStepOffset: number;
  98281. /**
  98282. * 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)
  98283. */
  98284. spriteCellChangeSpeed: number;
  98285. /**
  98286. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  98287. */
  98288. startSpriteCellID: number;
  98289. /**
  98290. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  98291. */
  98292. endSpriteCellID: number;
  98293. /**
  98294. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  98295. */
  98296. spriteCellWidth: number;
  98297. /**
  98298. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  98299. */
  98300. spriteCellHeight: number;
  98301. /**
  98302. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  98303. */
  98304. spriteRandomStartCell: boolean;
  98305. /**
  98306. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  98307. */
  98308. isAnimationSheetEnabled: boolean;
  98309. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  98310. translationPivot: Vector2;
  98311. /**
  98312. * Gets or sets a texture used to add random noise to particle positions
  98313. */
  98314. noiseTexture: Nullable<BaseTexture>;
  98315. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  98316. noiseStrength: Vector3;
  98317. /**
  98318. * Gets or sets the billboard mode to use when isBillboardBased = true.
  98319. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  98320. */
  98321. billboardMode: number;
  98322. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  98323. limitVelocityDamping: number;
  98324. /**
  98325. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  98326. */
  98327. beginAnimationOnStart: boolean;
  98328. /**
  98329. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  98330. */
  98331. beginAnimationFrom: number;
  98332. /**
  98333. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  98334. */
  98335. beginAnimationTo: number;
  98336. /**
  98337. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  98338. */
  98339. beginAnimationLoop: boolean;
  98340. /**
  98341. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  98342. */
  98343. disposeOnStop: boolean;
  98344. /**
  98345. * Specifies if the particles are updated in emitter local space or world space
  98346. */
  98347. isLocal: boolean;
  98348. /** Snippet ID if the particle system was created from the snippet server */
  98349. snippetId: string;
  98350. /** Gets or sets a matrix to use to compute projection */
  98351. defaultProjectionMatrix: Matrix;
  98352. /**
  98353. * Gets the maximum number of particles active at the same time.
  98354. * @returns The max number of active particles.
  98355. */
  98356. getCapacity(): number;
  98357. /**
  98358. * Gets the number of particles active at the same time.
  98359. * @returns The number of active particles.
  98360. */
  98361. getActiveCount(): number;
  98362. /**
  98363. * Gets if the system has been started. (Note: this will still be true after stop is called)
  98364. * @returns True if it has been started, otherwise false.
  98365. */
  98366. isStarted(): boolean;
  98367. /**
  98368. * Animates the particle system for this frame.
  98369. */
  98370. animate(): void;
  98371. /**
  98372. * Renders the particle system in its current state.
  98373. * @returns the current number of particles
  98374. */
  98375. render(): number;
  98376. /**
  98377. * Dispose the particle system and frees its associated resources.
  98378. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  98379. */
  98380. dispose(disposeTexture?: boolean): void;
  98381. /**
  98382. * An event triggered when the system is disposed
  98383. */
  98384. onDisposeObservable: Observable<IParticleSystem>;
  98385. /**
  98386. * An event triggered when the system is stopped
  98387. */
  98388. onStoppedObservable: Observable<IParticleSystem>;
  98389. /**
  98390. * Clones the particle system.
  98391. * @param name The name of the cloned object
  98392. * @param newEmitter The new emitter to use
  98393. * @returns the cloned particle system
  98394. */
  98395. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  98396. /**
  98397. * Serializes the particle system to a JSON object
  98398. * @param serializeTexture defines if the texture must be serialized as well
  98399. * @returns the JSON object
  98400. */
  98401. serialize(serializeTexture: boolean): any;
  98402. /**
  98403. * Rebuild the particle system
  98404. */
  98405. rebuild(): void;
  98406. /** Force the system to rebuild all gradients that need to be resync */
  98407. forceRefreshGradients(): void;
  98408. /**
  98409. * Starts the particle system and begins to emit
  98410. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  98411. */
  98412. start(delay?: number): void;
  98413. /**
  98414. * Stops the particle system.
  98415. */
  98416. stop(): void;
  98417. /**
  98418. * Remove all active particles
  98419. */
  98420. reset(): void;
  98421. /**
  98422. * Gets a boolean indicating that the system is stopping
  98423. * @returns true if the system is currently stopping
  98424. */
  98425. isStopping(): boolean;
  98426. /**
  98427. * Is this system ready to be used/rendered
  98428. * @return true if the system is ready
  98429. */
  98430. isReady(): boolean;
  98431. /**
  98432. * Returns the string "ParticleSystem"
  98433. * @returns a string containing the class name
  98434. */
  98435. getClassName(): string;
  98436. /**
  98437. * Gets the custom effect used to render the particles
  98438. * @param blendMode Blend mode for which the effect should be retrieved
  98439. * @returns The effect
  98440. */
  98441. getCustomEffect(blendMode: number): Nullable<Effect>;
  98442. /**
  98443. * Sets the custom effect used to render the particles
  98444. * @param effect The effect to set
  98445. * @param blendMode Blend mode for which the effect should be set
  98446. */
  98447. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  98448. /**
  98449. * Fill the defines array according to the current settings of the particle system
  98450. * @param defines Array to be updated
  98451. * @param blendMode blend mode to take into account when updating the array
  98452. */
  98453. fillDefines(defines: Array<string>, blendMode: number): void;
  98454. /**
  98455. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  98456. * @param uniforms Uniforms array to fill
  98457. * @param attributes Attributes array to fill
  98458. * @param samplers Samplers array to fill
  98459. */
  98460. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  98461. /**
  98462. * Observable that will be called just before the particles are drawn
  98463. */
  98464. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  98465. /**
  98466. * Gets the name of the particle vertex shader
  98467. */
  98468. vertexShaderName: string;
  98469. /**
  98470. * Adds a new color gradient
  98471. * @param gradient defines the gradient to use (between 0 and 1)
  98472. * @param color1 defines the color to affect to the specified gradient
  98473. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  98474. * @returns the current particle system
  98475. */
  98476. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  98477. /**
  98478. * Remove a specific color gradient
  98479. * @param gradient defines the gradient to remove
  98480. * @returns the current particle system
  98481. */
  98482. removeColorGradient(gradient: number): IParticleSystem;
  98483. /**
  98484. * Adds a new size gradient
  98485. * @param gradient defines the gradient to use (between 0 and 1)
  98486. * @param factor defines the size factor to affect to the specified gradient
  98487. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98488. * @returns the current particle system
  98489. */
  98490. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98491. /**
  98492. * Remove a specific size gradient
  98493. * @param gradient defines the gradient to remove
  98494. * @returns the current particle system
  98495. */
  98496. removeSizeGradient(gradient: number): IParticleSystem;
  98497. /**
  98498. * Gets the current list of color gradients.
  98499. * You must use addColorGradient and removeColorGradient to udpate this list
  98500. * @returns the list of color gradients
  98501. */
  98502. getColorGradients(): Nullable<Array<ColorGradient>>;
  98503. /**
  98504. * Gets the current list of size gradients.
  98505. * You must use addSizeGradient and removeSizeGradient to udpate this list
  98506. * @returns the list of size gradients
  98507. */
  98508. getSizeGradients(): Nullable<Array<FactorGradient>>;
  98509. /**
  98510. * Gets the current list of angular speed gradients.
  98511. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  98512. * @returns the list of angular speed gradients
  98513. */
  98514. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  98515. /**
  98516. * Adds a new angular speed gradient
  98517. * @param gradient defines the gradient to use (between 0 and 1)
  98518. * @param factor defines the angular speed to affect to the specified gradient
  98519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98520. * @returns the current particle system
  98521. */
  98522. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98523. /**
  98524. * Remove a specific angular speed gradient
  98525. * @param gradient defines the gradient to remove
  98526. * @returns the current particle system
  98527. */
  98528. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  98529. /**
  98530. * Gets the current list of velocity gradients.
  98531. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  98532. * @returns the list of velocity gradients
  98533. */
  98534. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  98535. /**
  98536. * Adds a new velocity gradient
  98537. * @param gradient defines the gradient to use (between 0 and 1)
  98538. * @param factor defines the velocity to affect to the specified gradient
  98539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98540. * @returns the current particle system
  98541. */
  98542. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98543. /**
  98544. * Remove a specific velocity gradient
  98545. * @param gradient defines the gradient to remove
  98546. * @returns the current particle system
  98547. */
  98548. removeVelocityGradient(gradient: number): IParticleSystem;
  98549. /**
  98550. * Gets the current list of limit velocity gradients.
  98551. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  98552. * @returns the list of limit velocity gradients
  98553. */
  98554. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  98555. /**
  98556. * Adds a new limit velocity gradient
  98557. * @param gradient defines the gradient to use (between 0 and 1)
  98558. * @param factor defines the limit velocity to affect to the specified gradient
  98559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98560. * @returns the current particle system
  98561. */
  98562. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98563. /**
  98564. * Remove a specific limit velocity gradient
  98565. * @param gradient defines the gradient to remove
  98566. * @returns the current particle system
  98567. */
  98568. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  98569. /**
  98570. * Adds a new drag gradient
  98571. * @param gradient defines the gradient to use (between 0 and 1)
  98572. * @param factor defines the drag to affect to the specified gradient
  98573. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98574. * @returns the current particle system
  98575. */
  98576. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98577. /**
  98578. * Remove a specific drag gradient
  98579. * @param gradient defines the gradient to remove
  98580. * @returns the current particle system
  98581. */
  98582. removeDragGradient(gradient: number): IParticleSystem;
  98583. /**
  98584. * Gets the current list of drag gradients.
  98585. * You must use addDragGradient and removeDragGradient to udpate this list
  98586. * @returns the list of drag gradients
  98587. */
  98588. getDragGradients(): Nullable<Array<FactorGradient>>;
  98589. /**
  98590. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  98591. * @param gradient defines the gradient to use (between 0 and 1)
  98592. * @param factor defines the emit rate to affect to the specified gradient
  98593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98594. * @returns the current particle system
  98595. */
  98596. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98597. /**
  98598. * Remove a specific emit rate gradient
  98599. * @param gradient defines the gradient to remove
  98600. * @returns the current particle system
  98601. */
  98602. removeEmitRateGradient(gradient: number): IParticleSystem;
  98603. /**
  98604. * Gets the current list of emit rate gradients.
  98605. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  98606. * @returns the list of emit rate gradients
  98607. */
  98608. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  98609. /**
  98610. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  98611. * @param gradient defines the gradient to use (between 0 and 1)
  98612. * @param factor defines the start size to affect to the specified gradient
  98613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98614. * @returns the current particle system
  98615. */
  98616. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98617. /**
  98618. * Remove a specific start size gradient
  98619. * @param gradient defines the gradient to remove
  98620. * @returns the current particle system
  98621. */
  98622. removeStartSizeGradient(gradient: number): IParticleSystem;
  98623. /**
  98624. * Gets the current list of start size gradients.
  98625. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  98626. * @returns the list of start size gradients
  98627. */
  98628. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  98629. /**
  98630. * Adds a new life time gradient
  98631. * @param gradient defines the gradient to use (between 0 and 1)
  98632. * @param factor defines the life time factor to affect to the specified gradient
  98633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98634. * @returns the current particle system
  98635. */
  98636. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98637. /**
  98638. * Remove a specific life time gradient
  98639. * @param gradient defines the gradient to remove
  98640. * @returns the current particle system
  98641. */
  98642. removeLifeTimeGradient(gradient: number): IParticleSystem;
  98643. /**
  98644. * Gets the current list of life time gradients.
  98645. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  98646. * @returns the list of life time gradients
  98647. */
  98648. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  98649. /**
  98650. * Gets the current list of color gradients.
  98651. * You must use addColorGradient and removeColorGradient to udpate this list
  98652. * @returns the list of color gradients
  98653. */
  98654. getColorGradients(): Nullable<Array<ColorGradient>>;
  98655. /**
  98656. * Adds a new ramp gradient used to remap particle colors
  98657. * @param gradient defines the gradient to use (between 0 and 1)
  98658. * @param color defines the color to affect to the specified gradient
  98659. * @returns the current particle system
  98660. */
  98661. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  98662. /**
  98663. * Gets the current list of ramp gradients.
  98664. * You must use addRampGradient and removeRampGradient to udpate this list
  98665. * @returns the list of ramp gradients
  98666. */
  98667. getRampGradients(): Nullable<Array<Color3Gradient>>;
  98668. /** Gets or sets a boolean indicating that ramp gradients must be used
  98669. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  98670. */
  98671. useRampGradients: boolean;
  98672. /**
  98673. * Adds a new color remap gradient
  98674. * @param gradient defines the gradient to use (between 0 and 1)
  98675. * @param min defines the color remap minimal range
  98676. * @param max defines the color remap maximal range
  98677. * @returns the current particle system
  98678. */
  98679. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98680. /**
  98681. * Gets the current list of color remap gradients.
  98682. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  98683. * @returns the list of color remap gradients
  98684. */
  98685. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  98686. /**
  98687. * Adds a new alpha remap gradient
  98688. * @param gradient defines the gradient to use (between 0 and 1)
  98689. * @param min defines the alpha remap minimal range
  98690. * @param max defines the alpha remap maximal range
  98691. * @returns the current particle system
  98692. */
  98693. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98694. /**
  98695. * Gets the current list of alpha remap gradients.
  98696. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  98697. * @returns the list of alpha remap gradients
  98698. */
  98699. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  98700. /**
  98701. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  98702. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98703. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98704. * @returns the emitter
  98705. */
  98706. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  98707. /**
  98708. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  98709. * @param radius The radius of the hemisphere to emit from
  98710. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98711. * @returns the emitter
  98712. */
  98713. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  98714. /**
  98715. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  98716. * @param radius The radius of the sphere to emit from
  98717. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98718. * @returns the emitter
  98719. */
  98720. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  98721. /**
  98722. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  98723. * @param radius The radius of the sphere to emit from
  98724. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  98725. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  98726. * @returns the emitter
  98727. */
  98728. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98729. /**
  98730. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  98731. * @param radius The radius of the emission cylinder
  98732. * @param height The height of the emission cylinder
  98733. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  98734. * @param directionRandomizer How much to randomize the particle direction [0-1]
  98735. * @returns the emitter
  98736. */
  98737. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  98738. /**
  98739. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  98740. * @param radius The radius of the cylinder to emit from
  98741. * @param height The height of the emission cylinder
  98742. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  98743. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  98744. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  98745. * @returns the emitter
  98746. */
  98747. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98748. /**
  98749. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  98750. * @param radius The radius of the cone to emit from
  98751. * @param angle The base angle of the cone
  98752. * @returns the emitter
  98753. */
  98754. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  98755. /**
  98756. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  98757. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98758. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98759. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98760. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98761. * @returns the emitter
  98762. */
  98763. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  98764. /**
  98765. * Get hosting scene
  98766. * @returns the scene
  98767. */
  98768. getScene(): Nullable<Scene>;
  98769. }
  98770. }
  98771. declare module BABYLON {
  98772. /**
  98773. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  98774. */
  98775. export class ColorSplitterBlock extends NodeMaterialBlock {
  98776. /**
  98777. * Create a new ColorSplitterBlock
  98778. * @param name defines the block name
  98779. */
  98780. constructor(name: string);
  98781. /**
  98782. * Gets the current class name
  98783. * @returns the class name
  98784. */
  98785. getClassName(): string;
  98786. /**
  98787. * Gets the rgba component (input)
  98788. */
  98789. get rgba(): NodeMaterialConnectionPoint;
  98790. /**
  98791. * Gets the rgb component (input)
  98792. */
  98793. get rgbIn(): NodeMaterialConnectionPoint;
  98794. /**
  98795. * Gets the rgb component (output)
  98796. */
  98797. get rgbOut(): NodeMaterialConnectionPoint;
  98798. /**
  98799. * Gets the r component (output)
  98800. */
  98801. get r(): NodeMaterialConnectionPoint;
  98802. /**
  98803. * Gets the g component (output)
  98804. */
  98805. get g(): NodeMaterialConnectionPoint;
  98806. /**
  98807. * Gets the b component (output)
  98808. */
  98809. get b(): NodeMaterialConnectionPoint;
  98810. /**
  98811. * Gets the a component (output)
  98812. */
  98813. get a(): NodeMaterialConnectionPoint;
  98814. protected _inputRename(name: string): string;
  98815. protected _outputRename(name: string): string;
  98816. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98817. }
  98818. }
  98819. declare module BABYLON {
  98820. /**
  98821. * Operations supported by the Trigonometry block
  98822. */
  98823. export enum TrigonometryBlockOperations {
  98824. /** Cos */
  98825. Cos = 0,
  98826. /** Sin */
  98827. Sin = 1,
  98828. /** Abs */
  98829. Abs = 2,
  98830. /** Exp */
  98831. Exp = 3,
  98832. /** Exp2 */
  98833. Exp2 = 4,
  98834. /** Round */
  98835. Round = 5,
  98836. /** Floor */
  98837. Floor = 6,
  98838. /** Ceiling */
  98839. Ceiling = 7,
  98840. /** Square root */
  98841. Sqrt = 8,
  98842. /** Log */
  98843. Log = 9,
  98844. /** Tangent */
  98845. Tan = 10,
  98846. /** Arc tangent */
  98847. ArcTan = 11,
  98848. /** Arc cosinus */
  98849. ArcCos = 12,
  98850. /** Arc sinus */
  98851. ArcSin = 13,
  98852. /** Fraction */
  98853. Fract = 14,
  98854. /** Sign */
  98855. Sign = 15,
  98856. /** To radians (from degrees) */
  98857. Radians = 16,
  98858. /** To degrees (from radians) */
  98859. Degrees = 17
  98860. }
  98861. /**
  98862. * Block used to apply trigonometry operation to floats
  98863. */
  98864. export class TrigonometryBlock extends NodeMaterialBlock {
  98865. /**
  98866. * Gets or sets the operation applied by the block
  98867. */
  98868. operation: TrigonometryBlockOperations;
  98869. /**
  98870. * Creates a new TrigonometryBlock
  98871. * @param name defines the block name
  98872. */
  98873. constructor(name: string);
  98874. /**
  98875. * Gets the current class name
  98876. * @returns the class name
  98877. */
  98878. getClassName(): string;
  98879. /**
  98880. * Gets the input component
  98881. */
  98882. get input(): NodeMaterialConnectionPoint;
  98883. /**
  98884. * Gets the output component
  98885. */
  98886. get output(): NodeMaterialConnectionPoint;
  98887. protected _buildBlock(state: NodeMaterialBuildState): this;
  98888. serialize(): any;
  98889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98890. protected _dumpPropertiesCode(): string;
  98891. }
  98892. }
  98893. declare module BABYLON {
  98894. /**
  98895. * Interface used to configure the node material editor
  98896. */
  98897. export interface INodeMaterialEditorOptions {
  98898. /** Define the URl to load node editor script */
  98899. editorURL?: string;
  98900. }
  98901. /** @hidden */
  98902. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98903. NORMAL: boolean;
  98904. TANGENT: boolean;
  98905. UV1: boolean;
  98906. /** BONES */
  98907. NUM_BONE_INFLUENCERS: number;
  98908. BonesPerMesh: number;
  98909. BONETEXTURE: boolean;
  98910. /** MORPH TARGETS */
  98911. MORPHTARGETS: boolean;
  98912. MORPHTARGETS_NORMAL: boolean;
  98913. MORPHTARGETS_TANGENT: boolean;
  98914. MORPHTARGETS_UV: boolean;
  98915. NUM_MORPH_INFLUENCERS: number;
  98916. /** IMAGE PROCESSING */
  98917. IMAGEPROCESSING: boolean;
  98918. VIGNETTE: boolean;
  98919. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98920. VIGNETTEBLENDMODEOPAQUE: boolean;
  98921. TONEMAPPING: boolean;
  98922. TONEMAPPING_ACES: boolean;
  98923. CONTRAST: boolean;
  98924. EXPOSURE: boolean;
  98925. COLORCURVES: boolean;
  98926. COLORGRADING: boolean;
  98927. COLORGRADING3D: boolean;
  98928. SAMPLER3DGREENDEPTH: boolean;
  98929. SAMPLER3DBGRMAP: boolean;
  98930. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98931. /** MISC. */
  98932. BUMPDIRECTUV: number;
  98933. constructor();
  98934. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  98935. }
  98936. /**
  98937. * Class used to configure NodeMaterial
  98938. */
  98939. export interface INodeMaterialOptions {
  98940. /**
  98941. * Defines if blocks should emit comments
  98942. */
  98943. emitComments: boolean;
  98944. }
  98945. /**
  98946. * Class used to create a node based material built by assembling shader blocks
  98947. */
  98948. export class NodeMaterial extends PushMaterial {
  98949. private static _BuildIdGenerator;
  98950. private _options;
  98951. private _vertexCompilationState;
  98952. private _fragmentCompilationState;
  98953. private _sharedData;
  98954. private _buildId;
  98955. private _buildWasSuccessful;
  98956. private _cachedWorldViewMatrix;
  98957. private _cachedWorldViewProjectionMatrix;
  98958. private _optimizers;
  98959. private _animationFrame;
  98960. /** Define the Url to load node editor script */
  98961. static EditorURL: string;
  98962. /** Define the Url to load snippets */
  98963. static SnippetUrl: string;
  98964. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  98965. static IgnoreTexturesAtLoadTime: boolean;
  98966. private BJSNODEMATERIALEDITOR;
  98967. /** Get the inspector from bundle or global */
  98968. private _getGlobalNodeMaterialEditor;
  98969. /**
  98970. * Snippet ID if the material was created from the snippet server
  98971. */
  98972. snippetId: string;
  98973. /**
  98974. * Gets or sets data used by visual editor
  98975. * @see https://nme.babylonjs.com
  98976. */
  98977. editorData: any;
  98978. /**
  98979. * 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)
  98980. */
  98981. ignoreAlpha: boolean;
  98982. /**
  98983. * Defines the maximum number of lights that can be used in the material
  98984. */
  98985. maxSimultaneousLights: number;
  98986. /**
  98987. * Observable raised when the material is built
  98988. */
  98989. onBuildObservable: Observable<NodeMaterial>;
  98990. /**
  98991. * Gets or sets the root nodes of the material vertex shader
  98992. */
  98993. _vertexOutputNodes: NodeMaterialBlock[];
  98994. /**
  98995. * Gets or sets the root nodes of the material fragment (pixel) shader
  98996. */
  98997. _fragmentOutputNodes: NodeMaterialBlock[];
  98998. /** Gets or sets options to control the node material overall behavior */
  98999. get options(): INodeMaterialOptions;
  99000. set options(options: INodeMaterialOptions);
  99001. /**
  99002. * Default configuration related to image processing available in the standard Material.
  99003. */
  99004. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99005. /**
  99006. * Gets the image processing configuration used either in this material.
  99007. */
  99008. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99009. /**
  99010. * Sets the Default image processing configuration used either in the this material.
  99011. *
  99012. * If sets to null, the scene one is in use.
  99013. */
  99014. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99015. /**
  99016. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99017. */
  99018. attachedBlocks: NodeMaterialBlock[];
  99019. /**
  99020. * Specifies the mode of the node material
  99021. * @hidden
  99022. */
  99023. _mode: NodeMaterialModes;
  99024. /**
  99025. * Gets the mode property
  99026. */
  99027. get mode(): NodeMaterialModes;
  99028. /**
  99029. * A free comment about the material
  99030. */
  99031. comment: string;
  99032. /**
  99033. * Create a new node based material
  99034. * @param name defines the material name
  99035. * @param scene defines the hosting scene
  99036. * @param options defines creation option
  99037. */
  99038. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99039. /**
  99040. * Gets the current class name of the material e.g. "NodeMaterial"
  99041. * @returns the class name
  99042. */
  99043. getClassName(): string;
  99044. /**
  99045. * Keep track of the image processing observer to allow dispose and replace.
  99046. */
  99047. private _imageProcessingObserver;
  99048. /**
  99049. * Attaches a new image processing configuration to the Standard Material.
  99050. * @param configuration
  99051. */
  99052. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99053. /**
  99054. * Get a block by its name
  99055. * @param name defines the name of the block to retrieve
  99056. * @returns the required block or null if not found
  99057. */
  99058. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99059. /**
  99060. * Get a block by its name
  99061. * @param predicate defines the predicate used to find the good candidate
  99062. * @returns the required block or null if not found
  99063. */
  99064. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99065. /**
  99066. * Get an input block by its name
  99067. * @param predicate defines the predicate used to find the good candidate
  99068. * @returns the required input block or null if not found
  99069. */
  99070. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99071. /**
  99072. * Gets the list of input blocks attached to this material
  99073. * @returns an array of InputBlocks
  99074. */
  99075. getInputBlocks(): InputBlock[];
  99076. /**
  99077. * Adds a new optimizer to the list of optimizers
  99078. * @param optimizer defines the optimizers to add
  99079. * @returns the current material
  99080. */
  99081. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99082. /**
  99083. * Remove an optimizer from the list of optimizers
  99084. * @param optimizer defines the optimizers to remove
  99085. * @returns the current material
  99086. */
  99087. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99088. /**
  99089. * Add a new block to the list of output nodes
  99090. * @param node defines the node to add
  99091. * @returns the current material
  99092. */
  99093. addOutputNode(node: NodeMaterialBlock): this;
  99094. /**
  99095. * Remove a block from the list of root nodes
  99096. * @param node defines the node to remove
  99097. * @returns the current material
  99098. */
  99099. removeOutputNode(node: NodeMaterialBlock): this;
  99100. private _addVertexOutputNode;
  99101. private _removeVertexOutputNode;
  99102. private _addFragmentOutputNode;
  99103. private _removeFragmentOutputNode;
  99104. /**
  99105. * Specifies if the material will require alpha blending
  99106. * @returns a boolean specifying if alpha blending is needed
  99107. */
  99108. needAlphaBlending(): boolean;
  99109. /**
  99110. * Specifies if this material should be rendered in alpha test mode
  99111. * @returns a boolean specifying if an alpha test is needed.
  99112. */
  99113. needAlphaTesting(): boolean;
  99114. private _initializeBlock;
  99115. private _resetDualBlocks;
  99116. /**
  99117. * Remove a block from the current node material
  99118. * @param block defines the block to remove
  99119. */
  99120. removeBlock(block: NodeMaterialBlock): void;
  99121. /**
  99122. * Build the material and generates the inner effect
  99123. * @param verbose defines if the build should log activity
  99124. */
  99125. build(verbose?: boolean): void;
  99126. /**
  99127. * Runs an otpimization phase to try to improve the shader code
  99128. */
  99129. optimize(): void;
  99130. private _prepareDefinesForAttributes;
  99131. /**
  99132. * Create a post process from the material
  99133. * @param camera The camera to apply the render pass to.
  99134. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99135. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99136. * @param engine The engine which the post process will be applied. (default: current engine)
  99137. * @param reusable If the post process can be reused on the same frame. (default: false)
  99138. * @param textureType Type of textures used when performing the post process. (default: 0)
  99139. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99140. * @returns the post process created
  99141. */
  99142. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  99143. /**
  99144. * Create the post process effect from the material
  99145. * @param postProcess The post process to create the effect for
  99146. */
  99147. createEffectForPostProcess(postProcess: PostProcess): void;
  99148. private _createEffectForPostProcess;
  99149. /**
  99150. * Create a new procedural texture based on this node material
  99151. * @param size defines the size of the texture
  99152. * @param scene defines the hosting scene
  99153. * @returns the new procedural texture attached to this node material
  99154. */
  99155. createProceduralTexture(size: number | {
  99156. width: number;
  99157. height: number;
  99158. layers?: number;
  99159. }, scene: Scene): Nullable<ProceduralTexture>;
  99160. private _createEffectForParticles;
  99161. private _checkInternals;
  99162. /**
  99163. * Create the effect to be used as the custom effect for a particle system
  99164. * @param particleSystem Particle system to create the effect for
  99165. * @param onCompiled defines a function to call when the effect creation is successful
  99166. * @param onError defines a function to call when the effect creation has failed
  99167. */
  99168. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99169. private _processDefines;
  99170. /**
  99171. * Get if the submesh is ready to be used and all its information available.
  99172. * Child classes can use it to update shaders
  99173. * @param mesh defines the mesh to check
  99174. * @param subMesh defines which submesh to check
  99175. * @param useInstances specifies that instances should be used
  99176. * @returns a boolean indicating that the submesh is ready or not
  99177. */
  99178. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99179. /**
  99180. * Get a string representing the shaders built by the current node graph
  99181. */
  99182. get compiledShaders(): string;
  99183. /**
  99184. * Binds the world matrix to the material
  99185. * @param world defines the world transformation matrix
  99186. */
  99187. bindOnlyWorldMatrix(world: Matrix): void;
  99188. /**
  99189. * Binds the submesh to this material by preparing the effect and shader to draw
  99190. * @param world defines the world transformation matrix
  99191. * @param mesh defines the mesh containing the submesh
  99192. * @param subMesh defines the submesh to bind the material to
  99193. */
  99194. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99195. /**
  99196. * Gets the active textures from the material
  99197. * @returns an array of textures
  99198. */
  99199. getActiveTextures(): BaseTexture[];
  99200. /**
  99201. * Gets the list of texture blocks
  99202. * @returns an array of texture blocks
  99203. */
  99204. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99205. /**
  99206. * Specifies if the material uses a texture
  99207. * @param texture defines the texture to check against the material
  99208. * @returns a boolean specifying if the material uses the texture
  99209. */
  99210. hasTexture(texture: BaseTexture): boolean;
  99211. /**
  99212. * Disposes the material
  99213. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99214. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99215. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99216. */
  99217. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99218. /** Creates the node editor window. */
  99219. private _createNodeEditor;
  99220. /**
  99221. * Launch the node material editor
  99222. * @param config Define the configuration of the editor
  99223. * @return a promise fulfilled when the node editor is visible
  99224. */
  99225. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99226. /**
  99227. * Clear the current material
  99228. */
  99229. clear(): void;
  99230. /**
  99231. * Clear the current material and set it to a default state
  99232. */
  99233. setToDefault(): void;
  99234. /**
  99235. * Clear the current material and set it to a default state for post process
  99236. */
  99237. setToDefaultPostProcess(): void;
  99238. /**
  99239. * Clear the current material and set it to a default state for procedural texture
  99240. */
  99241. setToDefaultProceduralTexture(): void;
  99242. /**
  99243. * Clear the current material and set it to a default state for particle
  99244. */
  99245. setToDefaultParticle(): void;
  99246. /**
  99247. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99248. * @param url defines the url to load from
  99249. * @returns a promise that will fullfil when the material is fully loaded
  99250. */
  99251. loadAsync(url: string): Promise<void>;
  99252. private _gatherBlocks;
  99253. /**
  99254. * Generate a string containing the code declaration required to create an equivalent of this material
  99255. * @returns a string
  99256. */
  99257. generateCode(): string;
  99258. /**
  99259. * Serializes this material in a JSON representation
  99260. * @returns the serialized material object
  99261. */
  99262. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99263. private _restoreConnections;
  99264. /**
  99265. * Clear the current graph and load a new one from a serialization object
  99266. * @param source defines the JSON representation of the material
  99267. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99268. * @param merge defines whether or not the source must be merged or replace the current content
  99269. */
  99270. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  99271. /**
  99272. * Makes a duplicate of the current material.
  99273. * @param name - name to use for the new material.
  99274. */
  99275. clone(name: string): NodeMaterial;
  99276. /**
  99277. * Creates a node material from parsed material data
  99278. * @param source defines the JSON representation of the material
  99279. * @param scene defines the hosting scene
  99280. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99281. * @returns a new node material
  99282. */
  99283. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99284. /**
  99285. * Creates a node material from a snippet saved in a remote file
  99286. * @param name defines the name of the material to create
  99287. * @param url defines the url to load from
  99288. * @param scene defines the hosting scene
  99289. * @returns a promise that will resolve to the new node material
  99290. */
  99291. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99292. /**
  99293. * Creates a node material from a snippet saved by the node material editor
  99294. * @param snippetId defines the snippet to load
  99295. * @param scene defines the hosting scene
  99296. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99297. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99298. * @returns a promise that will resolve to the new node material
  99299. */
  99300. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99301. /**
  99302. * Creates a new node material set to default basic configuration
  99303. * @param name defines the name of the material
  99304. * @param scene defines the hosting scene
  99305. * @returns a new NodeMaterial
  99306. */
  99307. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99308. }
  99309. }
  99310. declare module BABYLON {
  99311. interface ThinEngine {
  99312. /**
  99313. * Unbind a list of render target textures from the webGL context
  99314. * This is used only when drawBuffer extension or webGL2 are active
  99315. * @param textures defines the render target textures to unbind
  99316. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99317. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99318. */
  99319. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  99320. /**
  99321. * Create a multi render target texture
  99322. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  99323. * @param size defines the size of the texture
  99324. * @param options defines the creation options
  99325. * @returns the cube texture as an InternalTexture
  99326. */
  99327. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  99328. /**
  99329. * Update the sample count for a given multiple render target texture
  99330. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99331. * @param textures defines the textures to update
  99332. * @param samples defines the sample count to set
  99333. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99334. */
  99335. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  99336. /**
  99337. * Select a subsets of attachments to draw to.
  99338. * @param attachments gl attachments
  99339. */
  99340. bindAttachments(attachments: number[]): void;
  99341. /**
  99342. * Creates a layout object to draw/clear on specific textures in a MRT
  99343. * @param textureStatus textureStatus[i] indicates if the i-th is active
  99344. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  99345. */
  99346. buildTextureLayout(textureStatus: boolean[]): number[];
  99347. /**
  99348. * Restores the webgl state to only draw on the main color attachment
  99349. */
  99350. restoreSingleAttachment(): void;
  99351. }
  99352. }
  99353. declare module BABYLON {
  99354. /**
  99355. * Creation options of the multi render target texture.
  99356. */
  99357. export interface IMultiRenderTargetOptions {
  99358. /**
  99359. * Define if the texture needs to create mip maps after render.
  99360. */
  99361. generateMipMaps?: boolean;
  99362. /**
  99363. * Define the types of all the draw buffers we want to create
  99364. */
  99365. types?: number[];
  99366. /**
  99367. * Define the sampling modes of all the draw buffers we want to create
  99368. */
  99369. samplingModes?: number[];
  99370. /**
  99371. * Define if a depth buffer is required
  99372. */
  99373. generateDepthBuffer?: boolean;
  99374. /**
  99375. * Define if a stencil buffer is required
  99376. */
  99377. generateStencilBuffer?: boolean;
  99378. /**
  99379. * Define if a depth texture is required instead of a depth buffer
  99380. */
  99381. generateDepthTexture?: boolean;
  99382. /**
  99383. * Define the number of desired draw buffers
  99384. */
  99385. textureCount?: number;
  99386. /**
  99387. * Define if aspect ratio should be adapted to the texture or stay the scene one
  99388. */
  99389. doNotChangeAspectRatio?: boolean;
  99390. /**
  99391. * Define the default type of the buffers we are creating
  99392. */
  99393. defaultType?: number;
  99394. }
  99395. /**
  99396. * A multi render target, like a render target provides the ability to render to a texture.
  99397. * Unlike the render target, it can render to several draw buffers in one draw.
  99398. * This is specially interesting in deferred rendering or for any effects requiring more than
  99399. * just one color from a single pass.
  99400. */
  99401. export class MultiRenderTarget extends RenderTargetTexture {
  99402. private _internalTextures;
  99403. private _textures;
  99404. private _multiRenderTargetOptions;
  99405. private _count;
  99406. /**
  99407. * Get if draw buffers are currently supported by the used hardware and browser.
  99408. */
  99409. get isSupported(): boolean;
  99410. /**
  99411. * Get the list of textures generated by the multi render target.
  99412. */
  99413. get textures(): Texture[];
  99414. /**
  99415. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  99416. */
  99417. get count(): number;
  99418. /**
  99419. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  99420. */
  99421. get depthTexture(): Texture;
  99422. /**
  99423. * Set the wrapping mode on U of all the textures we are rendering to.
  99424. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99425. */
  99426. set wrapU(wrap: number);
  99427. /**
  99428. * Set the wrapping mode on V of all the textures we are rendering to.
  99429. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99430. */
  99431. set wrapV(wrap: number);
  99432. /**
  99433. * Instantiate a new multi render target texture.
  99434. * A multi render target, like a render target provides the ability to render to a texture.
  99435. * Unlike the render target, it can render to several draw buffers in one draw.
  99436. * This is specially interesting in deferred rendering or for any effects requiring more than
  99437. * just one color from a single pass.
  99438. * @param name Define the name of the texture
  99439. * @param size Define the size of the buffers to render to
  99440. * @param count Define the number of target we are rendering into
  99441. * @param scene Define the scene the texture belongs to
  99442. * @param options Define the options used to create the multi render target
  99443. */
  99444. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  99445. private _initTypes;
  99446. /** @hidden */
  99447. _rebuild(forceFullRebuild?: boolean): void;
  99448. private _createInternalTextures;
  99449. private _createTextures;
  99450. /**
  99451. * Replaces a texture within the MRT.
  99452. * @param texture The new texture to insert in the MRT
  99453. * @param index The index of the texture to replace
  99454. */
  99455. replaceTexture(texture: Texture, index: number): void;
  99456. /**
  99457. * Define the number of samples used if MSAA is enabled.
  99458. */
  99459. get samples(): number;
  99460. set samples(value: number);
  99461. /**
  99462. * Resize all the textures in the multi render target.
  99463. * Be careful as it will recreate all the data in the new texture.
  99464. * @param size Define the new size
  99465. */
  99466. resize(size: any): void;
  99467. /**
  99468. * Changes the number of render targets in this MRT
  99469. * Be careful as it will recreate all the data in the new texture.
  99470. * @param count new texture count
  99471. * @param options Specifies texture types and sampling modes for new textures
  99472. */
  99473. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  99474. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  99475. /**
  99476. * Dispose the render targets and their associated resources
  99477. */
  99478. dispose(): void;
  99479. /**
  99480. * Release all the underlying texture used as draw buffers.
  99481. */
  99482. releaseInternalTextures(): void;
  99483. }
  99484. }
  99485. declare module BABYLON {
  99486. /** @hidden */
  99487. export var imageProcessingPixelShader: {
  99488. name: string;
  99489. shader: string;
  99490. };
  99491. }
  99492. declare module BABYLON {
  99493. /**
  99494. * ImageProcessingPostProcess
  99495. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99496. */
  99497. export class ImageProcessingPostProcess extends PostProcess {
  99498. /**
  99499. * Default configuration related to image processing available in the PBR Material.
  99500. */
  99501. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99502. /**
  99503. * Gets the image processing configuration used either in this material.
  99504. */
  99505. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99506. /**
  99507. * Sets the Default image processing configuration used either in the this material.
  99508. *
  99509. * If sets to null, the scene one is in use.
  99510. */
  99511. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99512. /**
  99513. * Keep track of the image processing observer to allow dispose and replace.
  99514. */
  99515. private _imageProcessingObserver;
  99516. /**
  99517. * Attaches a new image processing configuration to the PBR Material.
  99518. * @param configuration
  99519. */
  99520. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99521. /**
  99522. * If the post process is supported.
  99523. */
  99524. get isSupported(): boolean;
  99525. /**
  99526. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99527. */
  99528. get colorCurves(): Nullable<ColorCurves>;
  99529. /**
  99530. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99531. */
  99532. set colorCurves(value: Nullable<ColorCurves>);
  99533. /**
  99534. * Gets wether the color curves effect is enabled.
  99535. */
  99536. get colorCurvesEnabled(): boolean;
  99537. /**
  99538. * Sets wether the color curves effect is enabled.
  99539. */
  99540. set colorCurvesEnabled(value: boolean);
  99541. /**
  99542. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99543. */
  99544. get colorGradingTexture(): Nullable<BaseTexture>;
  99545. /**
  99546. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99547. */
  99548. set colorGradingTexture(value: Nullable<BaseTexture>);
  99549. /**
  99550. * Gets wether the color grading effect is enabled.
  99551. */
  99552. get colorGradingEnabled(): boolean;
  99553. /**
  99554. * Gets wether the color grading effect is enabled.
  99555. */
  99556. set colorGradingEnabled(value: boolean);
  99557. /**
  99558. * Gets exposure used in the effect.
  99559. */
  99560. get exposure(): number;
  99561. /**
  99562. * Sets exposure used in the effect.
  99563. */
  99564. set exposure(value: number);
  99565. /**
  99566. * Gets wether tonemapping is enabled or not.
  99567. */
  99568. get toneMappingEnabled(): boolean;
  99569. /**
  99570. * Sets wether tonemapping is enabled or not
  99571. */
  99572. set toneMappingEnabled(value: boolean);
  99573. /**
  99574. * Gets the type of tone mapping effect.
  99575. */
  99576. get toneMappingType(): number;
  99577. /**
  99578. * Sets the type of tone mapping effect.
  99579. */
  99580. set toneMappingType(value: number);
  99581. /**
  99582. * Gets contrast used in the effect.
  99583. */
  99584. get contrast(): number;
  99585. /**
  99586. * Sets contrast used in the effect.
  99587. */
  99588. set contrast(value: number);
  99589. /**
  99590. * Gets Vignette stretch size.
  99591. */
  99592. get vignetteStretch(): number;
  99593. /**
  99594. * Sets Vignette stretch size.
  99595. */
  99596. set vignetteStretch(value: number);
  99597. /**
  99598. * Gets Vignette centre X Offset.
  99599. */
  99600. get vignetteCentreX(): number;
  99601. /**
  99602. * Sets Vignette centre X Offset.
  99603. */
  99604. set vignetteCentreX(value: number);
  99605. /**
  99606. * Gets Vignette centre Y Offset.
  99607. */
  99608. get vignetteCentreY(): number;
  99609. /**
  99610. * Sets Vignette centre Y Offset.
  99611. */
  99612. set vignetteCentreY(value: number);
  99613. /**
  99614. * Gets Vignette weight or intensity of the vignette effect.
  99615. */
  99616. get vignetteWeight(): number;
  99617. /**
  99618. * Sets Vignette weight or intensity of the vignette effect.
  99619. */
  99620. set vignetteWeight(value: number);
  99621. /**
  99622. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99623. * if vignetteEnabled is set to true.
  99624. */
  99625. get vignetteColor(): Color4;
  99626. /**
  99627. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99628. * if vignetteEnabled is set to true.
  99629. */
  99630. set vignetteColor(value: Color4);
  99631. /**
  99632. * Gets Camera field of view used by the Vignette effect.
  99633. */
  99634. get vignetteCameraFov(): number;
  99635. /**
  99636. * Sets Camera field of view used by the Vignette effect.
  99637. */
  99638. set vignetteCameraFov(value: number);
  99639. /**
  99640. * Gets the vignette blend mode allowing different kind of effect.
  99641. */
  99642. get vignetteBlendMode(): number;
  99643. /**
  99644. * Sets the vignette blend mode allowing different kind of effect.
  99645. */
  99646. set vignetteBlendMode(value: number);
  99647. /**
  99648. * Gets wether the vignette effect is enabled.
  99649. */
  99650. get vignetteEnabled(): boolean;
  99651. /**
  99652. * Sets wether the vignette effect is enabled.
  99653. */
  99654. set vignetteEnabled(value: boolean);
  99655. private _fromLinearSpace;
  99656. /**
  99657. * Gets wether the input of the processing is in Gamma or Linear Space.
  99658. */
  99659. get fromLinearSpace(): boolean;
  99660. /**
  99661. * Sets wether the input of the processing is in Gamma or Linear Space.
  99662. */
  99663. set fromLinearSpace(value: boolean);
  99664. /**
  99665. * Defines cache preventing GC.
  99666. */
  99667. private _defines;
  99668. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99669. /**
  99670. * "ImageProcessingPostProcess"
  99671. * @returns "ImageProcessingPostProcess"
  99672. */
  99673. getClassName(): string;
  99674. /**
  99675. * @hidden
  99676. */
  99677. _updateParameters(): void;
  99678. dispose(camera?: Camera): void;
  99679. }
  99680. }
  99681. declare module BABYLON {
  99682. /**
  99683. * Interface for defining prepass effects in the prepass post-process pipeline
  99684. */
  99685. export interface PrePassEffectConfiguration {
  99686. /**
  99687. * Name of the effect
  99688. */
  99689. name: string;
  99690. /**
  99691. * Post process to attach for this effect
  99692. */
  99693. postProcess?: PostProcess;
  99694. /**
  99695. * Textures required in the MRT
  99696. */
  99697. texturesRequired: number[];
  99698. /**
  99699. * Is the effect enabled
  99700. */
  99701. enabled: boolean;
  99702. /**
  99703. * Disposes the effect configuration
  99704. */
  99705. dispose?: () => void;
  99706. /**
  99707. * Creates the associated post process
  99708. */
  99709. createPostProcess?: () => PostProcess;
  99710. }
  99711. }
  99712. declare module BABYLON {
  99713. /**
  99714. * Options to be used when creating a FresnelParameters.
  99715. */
  99716. export type IFresnelParametersCreationOptions = {
  99717. /**
  99718. * Define the color used on edges (grazing angle)
  99719. */
  99720. leftColor?: Color3;
  99721. /**
  99722. * Define the color used on center
  99723. */
  99724. rightColor?: Color3;
  99725. /**
  99726. * Define bias applied to computed fresnel term
  99727. */
  99728. bias?: number;
  99729. /**
  99730. * Defined the power exponent applied to fresnel term
  99731. */
  99732. power?: number;
  99733. /**
  99734. * Define if the fresnel effect is enable or not.
  99735. */
  99736. isEnabled?: boolean;
  99737. };
  99738. /**
  99739. * Serialized format for FresnelParameters.
  99740. */
  99741. export type IFresnelParametersSerialized = {
  99742. /**
  99743. * Define the color used on edges (grazing angle) [as an array]
  99744. */
  99745. leftColor: number[];
  99746. /**
  99747. * Define the color used on center [as an array]
  99748. */
  99749. rightColor: number[];
  99750. /**
  99751. * Define bias applied to computed fresnel term
  99752. */
  99753. bias: number;
  99754. /**
  99755. * Defined the power exponent applied to fresnel term
  99756. */
  99757. power?: number;
  99758. /**
  99759. * Define if the fresnel effect is enable or not.
  99760. */
  99761. isEnabled: boolean;
  99762. };
  99763. /**
  99764. * This represents all the required information to add a fresnel effect on a material:
  99765. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99766. */
  99767. export class FresnelParameters {
  99768. private _isEnabled;
  99769. /**
  99770. * Define if the fresnel effect is enable or not.
  99771. */
  99772. get isEnabled(): boolean;
  99773. set isEnabled(value: boolean);
  99774. /**
  99775. * Define the color used on edges (grazing angle)
  99776. */
  99777. leftColor: Color3;
  99778. /**
  99779. * Define the color used on center
  99780. */
  99781. rightColor: Color3;
  99782. /**
  99783. * Define bias applied to computed fresnel term
  99784. */
  99785. bias: number;
  99786. /**
  99787. * Defined the power exponent applied to fresnel term
  99788. */
  99789. power: number;
  99790. /**
  99791. * Creates a new FresnelParameters object.
  99792. *
  99793. * @param options provide your own settings to optionally to override defaults
  99794. */
  99795. constructor(options?: IFresnelParametersCreationOptions);
  99796. /**
  99797. * Clones the current fresnel and its valuues
  99798. * @returns a clone fresnel configuration
  99799. */
  99800. clone(): FresnelParameters;
  99801. /**
  99802. * Determines equality between FresnelParameters objects
  99803. * @param otherFresnelParameters defines the second operand
  99804. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  99805. */
  99806. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  99807. /**
  99808. * Serializes the current fresnel parameters to a JSON representation.
  99809. * @return the JSON serialization
  99810. */
  99811. serialize(): IFresnelParametersSerialized;
  99812. /**
  99813. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99814. * @param parsedFresnelParameters Define the JSON representation
  99815. * @returns the parsed parameters
  99816. */
  99817. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  99818. }
  99819. }
  99820. declare module BABYLON {
  99821. /**
  99822. * This groups all the flags used to control the materials channel.
  99823. */
  99824. export class MaterialFlags {
  99825. private static _DiffuseTextureEnabled;
  99826. /**
  99827. * Are diffuse textures enabled in the application.
  99828. */
  99829. static get DiffuseTextureEnabled(): boolean;
  99830. static set DiffuseTextureEnabled(value: boolean);
  99831. private static _DetailTextureEnabled;
  99832. /**
  99833. * Are detail textures enabled in the application.
  99834. */
  99835. static get DetailTextureEnabled(): boolean;
  99836. static set DetailTextureEnabled(value: boolean);
  99837. private static _AmbientTextureEnabled;
  99838. /**
  99839. * Are ambient textures enabled in the application.
  99840. */
  99841. static get AmbientTextureEnabled(): boolean;
  99842. static set AmbientTextureEnabled(value: boolean);
  99843. private static _OpacityTextureEnabled;
  99844. /**
  99845. * Are opacity textures enabled in the application.
  99846. */
  99847. static get OpacityTextureEnabled(): boolean;
  99848. static set OpacityTextureEnabled(value: boolean);
  99849. private static _ReflectionTextureEnabled;
  99850. /**
  99851. * Are reflection textures enabled in the application.
  99852. */
  99853. static get ReflectionTextureEnabled(): boolean;
  99854. static set ReflectionTextureEnabled(value: boolean);
  99855. private static _EmissiveTextureEnabled;
  99856. /**
  99857. * Are emissive textures enabled in the application.
  99858. */
  99859. static get EmissiveTextureEnabled(): boolean;
  99860. static set EmissiveTextureEnabled(value: boolean);
  99861. private static _SpecularTextureEnabled;
  99862. /**
  99863. * Are specular textures enabled in the application.
  99864. */
  99865. static get SpecularTextureEnabled(): boolean;
  99866. static set SpecularTextureEnabled(value: boolean);
  99867. private static _BumpTextureEnabled;
  99868. /**
  99869. * Are bump textures enabled in the application.
  99870. */
  99871. static get BumpTextureEnabled(): boolean;
  99872. static set BumpTextureEnabled(value: boolean);
  99873. private static _LightmapTextureEnabled;
  99874. /**
  99875. * Are lightmap textures enabled in the application.
  99876. */
  99877. static get LightmapTextureEnabled(): boolean;
  99878. static set LightmapTextureEnabled(value: boolean);
  99879. private static _RefractionTextureEnabled;
  99880. /**
  99881. * Are refraction textures enabled in the application.
  99882. */
  99883. static get RefractionTextureEnabled(): boolean;
  99884. static set RefractionTextureEnabled(value: boolean);
  99885. private static _ColorGradingTextureEnabled;
  99886. /**
  99887. * Are color grading textures enabled in the application.
  99888. */
  99889. static get ColorGradingTextureEnabled(): boolean;
  99890. static set ColorGradingTextureEnabled(value: boolean);
  99891. private static _FresnelEnabled;
  99892. /**
  99893. * Are fresnels enabled in the application.
  99894. */
  99895. static get FresnelEnabled(): boolean;
  99896. static set FresnelEnabled(value: boolean);
  99897. private static _ClearCoatTextureEnabled;
  99898. /**
  99899. * Are clear coat textures enabled in the application.
  99900. */
  99901. static get ClearCoatTextureEnabled(): boolean;
  99902. static set ClearCoatTextureEnabled(value: boolean);
  99903. private static _ClearCoatBumpTextureEnabled;
  99904. /**
  99905. * Are clear coat bump textures enabled in the application.
  99906. */
  99907. static get ClearCoatBumpTextureEnabled(): boolean;
  99908. static set ClearCoatBumpTextureEnabled(value: boolean);
  99909. private static _ClearCoatTintTextureEnabled;
  99910. /**
  99911. * Are clear coat tint textures enabled in the application.
  99912. */
  99913. static get ClearCoatTintTextureEnabled(): boolean;
  99914. static set ClearCoatTintTextureEnabled(value: boolean);
  99915. private static _SheenTextureEnabled;
  99916. /**
  99917. * Are sheen textures enabled in the application.
  99918. */
  99919. static get SheenTextureEnabled(): boolean;
  99920. static set SheenTextureEnabled(value: boolean);
  99921. private static _AnisotropicTextureEnabled;
  99922. /**
  99923. * Are anisotropic textures enabled in the application.
  99924. */
  99925. static get AnisotropicTextureEnabled(): boolean;
  99926. static set AnisotropicTextureEnabled(value: boolean);
  99927. private static _ThicknessTextureEnabled;
  99928. /**
  99929. * Are thickness textures enabled in the application.
  99930. */
  99931. static get ThicknessTextureEnabled(): boolean;
  99932. static set ThicknessTextureEnabled(value: boolean);
  99933. }
  99934. }
  99935. declare module BABYLON {
  99936. /** @hidden */
  99937. export var defaultFragmentDeclaration: {
  99938. name: string;
  99939. shader: string;
  99940. };
  99941. }
  99942. declare module BABYLON {
  99943. /** @hidden */
  99944. export var defaultUboDeclaration: {
  99945. name: string;
  99946. shader: string;
  99947. };
  99948. }
  99949. declare module BABYLON {
  99950. /** @hidden */
  99951. export var prePassDeclaration: {
  99952. name: string;
  99953. shader: string;
  99954. };
  99955. }
  99956. declare module BABYLON {
  99957. /** @hidden */
  99958. export var lightFragmentDeclaration: {
  99959. name: string;
  99960. shader: string;
  99961. };
  99962. }
  99963. declare module BABYLON {
  99964. /** @hidden */
  99965. export var lightUboDeclaration: {
  99966. name: string;
  99967. shader: string;
  99968. };
  99969. }
  99970. declare module BABYLON {
  99971. /** @hidden */
  99972. export var lightsFragmentFunctions: {
  99973. name: string;
  99974. shader: string;
  99975. };
  99976. }
  99977. declare module BABYLON {
  99978. /** @hidden */
  99979. export var shadowsFragmentFunctions: {
  99980. name: string;
  99981. shader: string;
  99982. };
  99983. }
  99984. declare module BABYLON {
  99985. /** @hidden */
  99986. export var fresnelFunction: {
  99987. name: string;
  99988. shader: string;
  99989. };
  99990. }
  99991. declare module BABYLON {
  99992. /** @hidden */
  99993. export var bumpFragmentMainFunctions: {
  99994. name: string;
  99995. shader: string;
  99996. };
  99997. }
  99998. declare module BABYLON {
  99999. /** @hidden */
  100000. export var bumpFragmentFunctions: {
  100001. name: string;
  100002. shader: string;
  100003. };
  100004. }
  100005. declare module BABYLON {
  100006. /** @hidden */
  100007. export var logDepthDeclaration: {
  100008. name: string;
  100009. shader: string;
  100010. };
  100011. }
  100012. declare module BABYLON {
  100013. /** @hidden */
  100014. export var fogFragmentDeclaration: {
  100015. name: string;
  100016. shader: string;
  100017. };
  100018. }
  100019. declare module BABYLON {
  100020. /** @hidden */
  100021. export var bumpFragment: {
  100022. name: string;
  100023. shader: string;
  100024. };
  100025. }
  100026. declare module BABYLON {
  100027. /** @hidden */
  100028. export var depthPrePass: {
  100029. name: string;
  100030. shader: string;
  100031. };
  100032. }
  100033. declare module BABYLON {
  100034. /** @hidden */
  100035. export var lightFragment: {
  100036. name: string;
  100037. shader: string;
  100038. };
  100039. }
  100040. declare module BABYLON {
  100041. /** @hidden */
  100042. export var logDepthFragment: {
  100043. name: string;
  100044. shader: string;
  100045. };
  100046. }
  100047. declare module BABYLON {
  100048. /** @hidden */
  100049. export var fogFragment: {
  100050. name: string;
  100051. shader: string;
  100052. };
  100053. }
  100054. declare module BABYLON {
  100055. /** @hidden */
  100056. export var defaultPixelShader: {
  100057. name: string;
  100058. shader: string;
  100059. };
  100060. }
  100061. declare module BABYLON {
  100062. /** @hidden */
  100063. export var defaultVertexDeclaration: {
  100064. name: string;
  100065. shader: string;
  100066. };
  100067. }
  100068. declare module BABYLON {
  100069. /** @hidden */
  100070. export var bonesDeclaration: {
  100071. name: string;
  100072. shader: string;
  100073. };
  100074. }
  100075. declare module BABYLON {
  100076. /** @hidden */
  100077. export var instancesDeclaration: {
  100078. name: string;
  100079. shader: string;
  100080. };
  100081. }
  100082. declare module BABYLON {
  100083. /** @hidden */
  100084. export var prePassVertexDeclaration: {
  100085. name: string;
  100086. shader: string;
  100087. };
  100088. }
  100089. declare module BABYLON {
  100090. /** @hidden */
  100091. export var bumpVertexDeclaration: {
  100092. name: string;
  100093. shader: string;
  100094. };
  100095. }
  100096. declare module BABYLON {
  100097. /** @hidden */
  100098. export var fogVertexDeclaration: {
  100099. name: string;
  100100. shader: string;
  100101. };
  100102. }
  100103. declare module BABYLON {
  100104. /** @hidden */
  100105. export var morphTargetsVertexGlobalDeclaration: {
  100106. name: string;
  100107. shader: string;
  100108. };
  100109. }
  100110. declare module BABYLON {
  100111. /** @hidden */
  100112. export var morphTargetsVertexDeclaration: {
  100113. name: string;
  100114. shader: string;
  100115. };
  100116. }
  100117. declare module BABYLON {
  100118. /** @hidden */
  100119. export var morphTargetsVertex: {
  100120. name: string;
  100121. shader: string;
  100122. };
  100123. }
  100124. declare module BABYLON {
  100125. /** @hidden */
  100126. export var instancesVertex: {
  100127. name: string;
  100128. shader: string;
  100129. };
  100130. }
  100131. declare module BABYLON {
  100132. /** @hidden */
  100133. export var bonesVertex: {
  100134. name: string;
  100135. shader: string;
  100136. };
  100137. }
  100138. declare module BABYLON {
  100139. /** @hidden */
  100140. export var prePassVertex: {
  100141. name: string;
  100142. shader: string;
  100143. };
  100144. }
  100145. declare module BABYLON {
  100146. /** @hidden */
  100147. export var bumpVertex: {
  100148. name: string;
  100149. shader: string;
  100150. };
  100151. }
  100152. declare module BABYLON {
  100153. /** @hidden */
  100154. export var fogVertex: {
  100155. name: string;
  100156. shader: string;
  100157. };
  100158. }
  100159. declare module BABYLON {
  100160. /** @hidden */
  100161. export var shadowsVertex: {
  100162. name: string;
  100163. shader: string;
  100164. };
  100165. }
  100166. declare module BABYLON {
  100167. /** @hidden */
  100168. export var pointCloudVertex: {
  100169. name: string;
  100170. shader: string;
  100171. };
  100172. }
  100173. declare module BABYLON {
  100174. /** @hidden */
  100175. export var logDepthVertex: {
  100176. name: string;
  100177. shader: string;
  100178. };
  100179. }
  100180. declare module BABYLON {
  100181. /** @hidden */
  100182. export var defaultVertexShader: {
  100183. name: string;
  100184. shader: string;
  100185. };
  100186. }
  100187. declare module BABYLON {
  100188. /**
  100189. * @hidden
  100190. */
  100191. export interface IMaterialDetailMapDefines {
  100192. DETAIL: boolean;
  100193. DETAILDIRECTUV: number;
  100194. DETAIL_NORMALBLENDMETHOD: number;
  100195. /** @hidden */
  100196. _areTexturesDirty: boolean;
  100197. }
  100198. /**
  100199. * Define the code related to the detail map parameters of a material
  100200. *
  100201. * Inspired from:
  100202. * 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
  100203. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  100204. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  100205. */
  100206. export class DetailMapConfiguration {
  100207. private _texture;
  100208. /**
  100209. * The detail texture of the material.
  100210. */
  100211. texture: Nullable<BaseTexture>;
  100212. /**
  100213. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  100214. * Bigger values mean stronger blending
  100215. */
  100216. diffuseBlendLevel: number;
  100217. /**
  100218. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  100219. * Bigger values mean stronger blending. Only used with PBR materials
  100220. */
  100221. roughnessBlendLevel: number;
  100222. /**
  100223. * Defines how strong the bump effect from the detail map is
  100224. * Bigger values mean stronger effect
  100225. */
  100226. bumpLevel: number;
  100227. private _normalBlendMethod;
  100228. /**
  100229. * The method used to blend the bump and detail normals together
  100230. */
  100231. normalBlendMethod: number;
  100232. private _isEnabled;
  100233. /**
  100234. * Enable or disable the detail map on this material
  100235. */
  100236. isEnabled: boolean;
  100237. /** @hidden */
  100238. private _internalMarkAllSubMeshesAsTexturesDirty;
  100239. /** @hidden */
  100240. _markAllSubMeshesAsTexturesDirty(): void;
  100241. /**
  100242. * Instantiate a new detail map
  100243. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100244. */
  100245. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100246. /**
  100247. * Gets whether the submesh is ready to be used or not.
  100248. * @param defines the list of "defines" to update.
  100249. * @param scene defines the scene the material belongs to.
  100250. * @returns - boolean indicating that the submesh is ready or not.
  100251. */
  100252. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  100253. /**
  100254. * Update the defines for detail map usage
  100255. * @param defines the list of "defines" to update.
  100256. * @param scene defines the scene the material belongs to.
  100257. */
  100258. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  100259. /**
  100260. * Binds the material data.
  100261. * @param uniformBuffer defines the Uniform buffer to fill in.
  100262. * @param scene defines the scene the material belongs to.
  100263. * @param isFrozen defines whether the material is frozen or not.
  100264. */
  100265. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100266. /**
  100267. * Checks to see if a texture is used in the material.
  100268. * @param texture - Base texture to use.
  100269. * @returns - Boolean specifying if a texture is used in the material.
  100270. */
  100271. hasTexture(texture: BaseTexture): boolean;
  100272. /**
  100273. * Returns an array of the actively used textures.
  100274. * @param activeTextures Array of BaseTextures
  100275. */
  100276. getActiveTextures(activeTextures: BaseTexture[]): void;
  100277. /**
  100278. * Returns the animatable textures.
  100279. * @param animatables Array of animatable textures.
  100280. */
  100281. getAnimatables(animatables: IAnimatable[]): void;
  100282. /**
  100283. * Disposes the resources of the material.
  100284. * @param forceDisposeTextures - Forces the disposal of all textures.
  100285. */
  100286. dispose(forceDisposeTextures?: boolean): void;
  100287. /**
  100288. * Get the current class name useful for serialization or dynamic coding.
  100289. * @returns "DetailMap"
  100290. */
  100291. getClassName(): string;
  100292. /**
  100293. * Add the required uniforms to the current list.
  100294. * @param uniforms defines the current uniform list.
  100295. */
  100296. static AddUniforms(uniforms: string[]): void;
  100297. /**
  100298. * Add the required samplers to the current list.
  100299. * @param samplers defines the current sampler list.
  100300. */
  100301. static AddSamplers(samplers: string[]): void;
  100302. /**
  100303. * Add the required uniforms to the current buffer.
  100304. * @param uniformBuffer defines the current uniform buffer.
  100305. */
  100306. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100307. /**
  100308. * Makes a duplicate of the current instance into another one.
  100309. * @param detailMap define the instance where to copy the info
  100310. */
  100311. copyTo(detailMap: DetailMapConfiguration): void;
  100312. /**
  100313. * Serializes this detail map instance
  100314. * @returns - An object with the serialized instance.
  100315. */
  100316. serialize(): any;
  100317. /**
  100318. * Parses a detail map setting from a serialized object.
  100319. * @param source - Serialized object.
  100320. * @param scene Defines the scene we are parsing for
  100321. * @param rootUrl Defines the rootUrl to load from
  100322. */
  100323. parse(source: any, scene: Scene, rootUrl: string): void;
  100324. }
  100325. }
  100326. declare module BABYLON {
  100327. /** @hidden */
  100328. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  100329. MAINUV1: boolean;
  100330. MAINUV2: boolean;
  100331. DIFFUSE: boolean;
  100332. DIFFUSEDIRECTUV: number;
  100333. DETAIL: boolean;
  100334. DETAILDIRECTUV: number;
  100335. DETAIL_NORMALBLENDMETHOD: number;
  100336. AMBIENT: boolean;
  100337. AMBIENTDIRECTUV: number;
  100338. OPACITY: boolean;
  100339. OPACITYDIRECTUV: number;
  100340. OPACITYRGB: boolean;
  100341. REFLECTION: boolean;
  100342. EMISSIVE: boolean;
  100343. EMISSIVEDIRECTUV: number;
  100344. SPECULAR: boolean;
  100345. SPECULARDIRECTUV: number;
  100346. BUMP: boolean;
  100347. BUMPDIRECTUV: number;
  100348. PARALLAX: boolean;
  100349. PARALLAXOCCLUSION: boolean;
  100350. SPECULAROVERALPHA: boolean;
  100351. CLIPPLANE: boolean;
  100352. CLIPPLANE2: boolean;
  100353. CLIPPLANE3: boolean;
  100354. CLIPPLANE4: boolean;
  100355. CLIPPLANE5: boolean;
  100356. CLIPPLANE6: boolean;
  100357. ALPHATEST: boolean;
  100358. DEPTHPREPASS: boolean;
  100359. ALPHAFROMDIFFUSE: boolean;
  100360. POINTSIZE: boolean;
  100361. FOG: boolean;
  100362. SPECULARTERM: boolean;
  100363. DIFFUSEFRESNEL: boolean;
  100364. OPACITYFRESNEL: boolean;
  100365. REFLECTIONFRESNEL: boolean;
  100366. REFRACTIONFRESNEL: boolean;
  100367. EMISSIVEFRESNEL: boolean;
  100368. FRESNEL: boolean;
  100369. NORMAL: boolean;
  100370. UV1: boolean;
  100371. UV2: boolean;
  100372. VERTEXCOLOR: boolean;
  100373. VERTEXALPHA: boolean;
  100374. NUM_BONE_INFLUENCERS: number;
  100375. BonesPerMesh: number;
  100376. BONETEXTURE: boolean;
  100377. BONES_VELOCITY_ENABLED: boolean;
  100378. INSTANCES: boolean;
  100379. THIN_INSTANCES: boolean;
  100380. GLOSSINESS: boolean;
  100381. ROUGHNESS: boolean;
  100382. EMISSIVEASILLUMINATION: boolean;
  100383. LINKEMISSIVEWITHDIFFUSE: boolean;
  100384. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100385. LIGHTMAP: boolean;
  100386. LIGHTMAPDIRECTUV: number;
  100387. OBJECTSPACE_NORMALMAP: boolean;
  100388. USELIGHTMAPASSHADOWMAP: boolean;
  100389. REFLECTIONMAP_3D: boolean;
  100390. REFLECTIONMAP_SPHERICAL: boolean;
  100391. REFLECTIONMAP_PLANAR: boolean;
  100392. REFLECTIONMAP_CUBIC: boolean;
  100393. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100394. REFLECTIONMAP_PROJECTION: boolean;
  100395. REFLECTIONMAP_SKYBOX: boolean;
  100396. REFLECTIONMAP_EXPLICIT: boolean;
  100397. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100398. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100399. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100400. INVERTCUBICMAP: boolean;
  100401. LOGARITHMICDEPTH: boolean;
  100402. REFRACTION: boolean;
  100403. REFRACTIONMAP_3D: boolean;
  100404. REFLECTIONOVERALPHA: boolean;
  100405. TWOSIDEDLIGHTING: boolean;
  100406. SHADOWFLOAT: boolean;
  100407. MORPHTARGETS: boolean;
  100408. MORPHTARGETS_NORMAL: boolean;
  100409. MORPHTARGETS_TANGENT: boolean;
  100410. MORPHTARGETS_UV: boolean;
  100411. NUM_MORPH_INFLUENCERS: number;
  100412. NONUNIFORMSCALING: boolean;
  100413. PREMULTIPLYALPHA: boolean;
  100414. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100415. ALPHABLEND: boolean;
  100416. PREPASS: boolean;
  100417. PREPASS_IRRADIANCE: boolean;
  100418. PREPASS_IRRADIANCE_INDEX: number;
  100419. PREPASS_ALBEDO: boolean;
  100420. PREPASS_ALBEDO_INDEX: number;
  100421. PREPASS_DEPTHNORMAL: boolean;
  100422. PREPASS_DEPTHNORMAL_INDEX: number;
  100423. PREPASS_POSITION: boolean;
  100424. PREPASS_POSITION_INDEX: number;
  100425. PREPASS_VELOCITY: boolean;
  100426. PREPASS_VELOCITY_INDEX: number;
  100427. PREPASS_REFLECTIVITY: boolean;
  100428. PREPASS_REFLECTIVITY_INDEX: number;
  100429. SCENE_MRT_COUNT: number;
  100430. RGBDLIGHTMAP: boolean;
  100431. RGBDREFLECTION: boolean;
  100432. RGBDREFRACTION: boolean;
  100433. IMAGEPROCESSING: boolean;
  100434. VIGNETTE: boolean;
  100435. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100436. VIGNETTEBLENDMODEOPAQUE: boolean;
  100437. TONEMAPPING: boolean;
  100438. TONEMAPPING_ACES: boolean;
  100439. CONTRAST: boolean;
  100440. COLORCURVES: boolean;
  100441. COLORGRADING: boolean;
  100442. COLORGRADING3D: boolean;
  100443. SAMPLER3DGREENDEPTH: boolean;
  100444. SAMPLER3DBGRMAP: boolean;
  100445. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100446. MULTIVIEW: boolean;
  100447. /**
  100448. * If the reflection texture on this material is in linear color space
  100449. * @hidden
  100450. */
  100451. IS_REFLECTION_LINEAR: boolean;
  100452. /**
  100453. * If the refraction texture on this material is in linear color space
  100454. * @hidden
  100455. */
  100456. IS_REFRACTION_LINEAR: boolean;
  100457. EXPOSURE: boolean;
  100458. constructor();
  100459. setReflectionMode(modeToEnable: string): void;
  100460. }
  100461. /**
  100462. * This is the default material used in Babylon. It is the best trade off between quality
  100463. * and performances.
  100464. * @see https://doc.babylonjs.com/babylon101/materials
  100465. */
  100466. export class StandardMaterial extends PushMaterial {
  100467. private _diffuseTexture;
  100468. /**
  100469. * The basic texture of the material as viewed under a light.
  100470. */
  100471. diffuseTexture: Nullable<BaseTexture>;
  100472. private _ambientTexture;
  100473. /**
  100474. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100475. */
  100476. ambientTexture: Nullable<BaseTexture>;
  100477. private _opacityTexture;
  100478. /**
  100479. * Define the transparency of the material from a texture.
  100480. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100481. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100482. */
  100483. opacityTexture: Nullable<BaseTexture>;
  100484. private _reflectionTexture;
  100485. /**
  100486. * Define the texture used to display the reflection.
  100487. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100488. */
  100489. reflectionTexture: Nullable<BaseTexture>;
  100490. private _emissiveTexture;
  100491. /**
  100492. * Define texture of the material as if self lit.
  100493. * This will be mixed in the final result even in the absence of light.
  100494. */
  100495. emissiveTexture: Nullable<BaseTexture>;
  100496. private _specularTexture;
  100497. /**
  100498. * Define how the color and intensity of the highlight given by the light in the material.
  100499. */
  100500. specularTexture: Nullable<BaseTexture>;
  100501. private _bumpTexture;
  100502. /**
  100503. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100504. * 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.
  100505. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  100506. */
  100507. bumpTexture: Nullable<BaseTexture>;
  100508. private _lightmapTexture;
  100509. /**
  100510. * Complex lighting can be computationally expensive to compute at runtime.
  100511. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100512. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  100513. */
  100514. lightmapTexture: Nullable<BaseTexture>;
  100515. private _refractionTexture;
  100516. /**
  100517. * Define the texture used to display the refraction.
  100518. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100519. */
  100520. refractionTexture: Nullable<BaseTexture>;
  100521. /**
  100522. * The color of the material lit by the environmental background lighting.
  100523. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100524. */
  100525. ambientColor: Color3;
  100526. /**
  100527. * The basic color of the material as viewed under a light.
  100528. */
  100529. diffuseColor: Color3;
  100530. /**
  100531. * Define how the color and intensity of the highlight given by the light in the material.
  100532. */
  100533. specularColor: Color3;
  100534. /**
  100535. * Define the color of the material as if self lit.
  100536. * This will be mixed in the final result even in the absence of light.
  100537. */
  100538. emissiveColor: Color3;
  100539. /**
  100540. * Defines how sharp are the highlights in the material.
  100541. * The bigger the value the sharper giving a more glossy feeling to the result.
  100542. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100543. */
  100544. specularPower: number;
  100545. private _useAlphaFromDiffuseTexture;
  100546. /**
  100547. * Does the transparency come from the diffuse texture alpha channel.
  100548. */
  100549. useAlphaFromDiffuseTexture: boolean;
  100550. private _useEmissiveAsIllumination;
  100551. /**
  100552. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100553. */
  100554. useEmissiveAsIllumination: boolean;
  100555. private _linkEmissiveWithDiffuse;
  100556. /**
  100557. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100558. * the emissive level when the final color is close to one.
  100559. */
  100560. linkEmissiveWithDiffuse: boolean;
  100561. private _useSpecularOverAlpha;
  100562. /**
  100563. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100564. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100565. */
  100566. useSpecularOverAlpha: boolean;
  100567. private _useReflectionOverAlpha;
  100568. /**
  100569. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100570. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100571. */
  100572. useReflectionOverAlpha: boolean;
  100573. private _disableLighting;
  100574. /**
  100575. * Does lights from the scene impacts this material.
  100576. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100577. */
  100578. disableLighting: boolean;
  100579. private _useObjectSpaceNormalMap;
  100580. /**
  100581. * Allows using an object space normal map (instead of tangent space).
  100582. */
  100583. useObjectSpaceNormalMap: boolean;
  100584. private _useParallax;
  100585. /**
  100586. * Is parallax enabled or not.
  100587. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100588. */
  100589. useParallax: boolean;
  100590. private _useParallaxOcclusion;
  100591. /**
  100592. * Is parallax occlusion enabled or not.
  100593. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100594. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100595. */
  100596. useParallaxOcclusion: boolean;
  100597. /**
  100598. * 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.
  100599. */
  100600. parallaxScaleBias: number;
  100601. private _roughness;
  100602. /**
  100603. * Helps to define how blurry the reflections should appears in the material.
  100604. */
  100605. roughness: number;
  100606. /**
  100607. * In case of refraction, define the value of the index of refraction.
  100608. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100609. */
  100610. indexOfRefraction: number;
  100611. /**
  100612. * Invert the refraction texture alongside the y axis.
  100613. * It can be useful with procedural textures or probe for instance.
  100614. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100615. */
  100616. invertRefractionY: boolean;
  100617. /**
  100618. * Defines the alpha limits in alpha test mode.
  100619. */
  100620. alphaCutOff: number;
  100621. private _useLightmapAsShadowmap;
  100622. /**
  100623. * In case of light mapping, define whether the map contains light or shadow informations.
  100624. */
  100625. useLightmapAsShadowmap: boolean;
  100626. private _diffuseFresnelParameters;
  100627. /**
  100628. * Define the diffuse fresnel parameters of the material.
  100629. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100630. */
  100631. diffuseFresnelParameters: FresnelParameters;
  100632. private _opacityFresnelParameters;
  100633. /**
  100634. * Define the opacity fresnel parameters of the material.
  100635. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100636. */
  100637. opacityFresnelParameters: FresnelParameters;
  100638. private _reflectionFresnelParameters;
  100639. /**
  100640. * Define the reflection fresnel parameters of the material.
  100641. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100642. */
  100643. reflectionFresnelParameters: FresnelParameters;
  100644. private _refractionFresnelParameters;
  100645. /**
  100646. * Define the refraction fresnel parameters of the material.
  100647. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100648. */
  100649. refractionFresnelParameters: FresnelParameters;
  100650. private _emissiveFresnelParameters;
  100651. /**
  100652. * Define the emissive fresnel parameters of the material.
  100653. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100654. */
  100655. emissiveFresnelParameters: FresnelParameters;
  100656. private _useReflectionFresnelFromSpecular;
  100657. /**
  100658. * If true automatically deducts the fresnels values from the material specularity.
  100659. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100660. */
  100661. useReflectionFresnelFromSpecular: boolean;
  100662. private _useGlossinessFromSpecularMapAlpha;
  100663. /**
  100664. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100665. */
  100666. useGlossinessFromSpecularMapAlpha: boolean;
  100667. private _maxSimultaneousLights;
  100668. /**
  100669. * Defines the maximum number of lights that can be used in the material
  100670. */
  100671. maxSimultaneousLights: number;
  100672. private _invertNormalMapX;
  100673. /**
  100674. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100675. */
  100676. invertNormalMapX: boolean;
  100677. private _invertNormalMapY;
  100678. /**
  100679. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100680. */
  100681. invertNormalMapY: boolean;
  100682. private _twoSidedLighting;
  100683. /**
  100684. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100685. */
  100686. twoSidedLighting: boolean;
  100687. /**
  100688. * Default configuration related to image processing available in the standard Material.
  100689. */
  100690. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100691. /**
  100692. * Gets the image processing configuration used either in this material.
  100693. */
  100694. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100695. /**
  100696. * Sets the Default image processing configuration used either in the this material.
  100697. *
  100698. * If sets to null, the scene one is in use.
  100699. */
  100700. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100701. /**
  100702. * Keep track of the image processing observer to allow dispose and replace.
  100703. */
  100704. private _imageProcessingObserver;
  100705. /**
  100706. * Attaches a new image processing configuration to the Standard Material.
  100707. * @param configuration
  100708. */
  100709. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100710. /**
  100711. * Defines additionnal PrePass parameters for the material.
  100712. */
  100713. readonly prePassConfiguration: PrePassConfiguration;
  100714. /**
  100715. * Gets wether the color curves effect is enabled.
  100716. */
  100717. get cameraColorCurvesEnabled(): boolean;
  100718. /**
  100719. * Sets wether the color curves effect is enabled.
  100720. */
  100721. set cameraColorCurvesEnabled(value: boolean);
  100722. /**
  100723. * Gets wether the color grading effect is enabled.
  100724. */
  100725. get cameraColorGradingEnabled(): boolean;
  100726. /**
  100727. * Gets wether the color grading effect is enabled.
  100728. */
  100729. set cameraColorGradingEnabled(value: boolean);
  100730. /**
  100731. * Gets wether tonemapping is enabled or not.
  100732. */
  100733. get cameraToneMappingEnabled(): boolean;
  100734. /**
  100735. * Sets wether tonemapping is enabled or not
  100736. */
  100737. set cameraToneMappingEnabled(value: boolean);
  100738. /**
  100739. * The camera exposure used on this material.
  100740. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100741. * This corresponds to a photographic exposure.
  100742. */
  100743. get cameraExposure(): number;
  100744. /**
  100745. * The camera exposure used on this material.
  100746. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100747. * This corresponds to a photographic exposure.
  100748. */
  100749. set cameraExposure(value: number);
  100750. /**
  100751. * Gets The camera contrast used on this material.
  100752. */
  100753. get cameraContrast(): number;
  100754. /**
  100755. * Sets The camera contrast used on this material.
  100756. */
  100757. set cameraContrast(value: number);
  100758. /**
  100759. * Gets the Color Grading 2D Lookup Texture.
  100760. */
  100761. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100762. /**
  100763. * Sets the Color Grading 2D Lookup Texture.
  100764. */
  100765. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100766. /**
  100767. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100768. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100769. * 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;
  100770. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100771. */
  100772. get cameraColorCurves(): Nullable<ColorCurves>;
  100773. /**
  100774. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100775. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100776. * 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;
  100777. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100778. */
  100779. set cameraColorCurves(value: Nullable<ColorCurves>);
  100780. /**
  100781. * Can this material render to several textures at once
  100782. */
  100783. get canRenderToMRT(): boolean;
  100784. /**
  100785. * Defines the detail map parameters for the material.
  100786. */
  100787. readonly detailMap: DetailMapConfiguration;
  100788. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100789. protected _worldViewProjectionMatrix: Matrix;
  100790. protected _globalAmbientColor: Color3;
  100791. protected _useLogarithmicDepth: boolean;
  100792. protected _rebuildInParallel: boolean;
  100793. /**
  100794. * Instantiates a new standard material.
  100795. * This is the default material used in Babylon. It is the best trade off between quality
  100796. * and performances.
  100797. * @see https://doc.babylonjs.com/babylon101/materials
  100798. * @param name Define the name of the material in the scene
  100799. * @param scene Define the scene the material belong to
  100800. */
  100801. constructor(name: string, scene: Scene);
  100802. /**
  100803. * Gets a boolean indicating that current material needs to register RTT
  100804. */
  100805. get hasRenderTargetTextures(): boolean;
  100806. /**
  100807. * Gets the current class name of the material e.g. "StandardMaterial"
  100808. * Mainly use in serialization.
  100809. * @returns the class name
  100810. */
  100811. getClassName(): string;
  100812. /**
  100813. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100814. * You can try switching to logarithmic depth.
  100815. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100816. */
  100817. get useLogarithmicDepth(): boolean;
  100818. set useLogarithmicDepth(value: boolean);
  100819. /**
  100820. * Specifies if the material will require alpha blending
  100821. * @returns a boolean specifying if alpha blending is needed
  100822. */
  100823. needAlphaBlending(): boolean;
  100824. /**
  100825. * Specifies if this material should be rendered in alpha test mode
  100826. * @returns a boolean specifying if an alpha test is needed.
  100827. */
  100828. needAlphaTesting(): boolean;
  100829. /**
  100830. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  100831. */
  100832. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100833. /**
  100834. * Specifies whether or not there is a usable alpha channel for transparency.
  100835. */
  100836. protected _hasAlphaChannel(): boolean;
  100837. /**
  100838. * Get the texture used for alpha test purpose.
  100839. * @returns the diffuse texture in case of the standard material.
  100840. */
  100841. getAlphaTestTexture(): Nullable<BaseTexture>;
  100842. /**
  100843. * Get if the submesh is ready to be used and all its information available.
  100844. * Child classes can use it to update shaders
  100845. * @param mesh defines the mesh to check
  100846. * @param subMesh defines which submesh to check
  100847. * @param useInstances specifies that instances should be used
  100848. * @returns a boolean indicating that the submesh is ready or not
  100849. */
  100850. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100851. /**
  100852. * Builds the material UBO layouts.
  100853. * Used internally during the effect preparation.
  100854. */
  100855. buildUniformLayout(): void;
  100856. /**
  100857. * Unbinds the material from the mesh
  100858. */
  100859. unbind(): void;
  100860. /**
  100861. * Binds the submesh to this material by preparing the effect and shader to draw
  100862. * @param world defines the world transformation matrix
  100863. * @param mesh defines the mesh containing the submesh
  100864. * @param subMesh defines the submesh to bind the material to
  100865. */
  100866. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100867. /**
  100868. * Get the list of animatables in the material.
  100869. * @returns the list of animatables object used in the material
  100870. */
  100871. getAnimatables(): IAnimatable[];
  100872. /**
  100873. * Gets the active textures from the material
  100874. * @returns an array of textures
  100875. */
  100876. getActiveTextures(): BaseTexture[];
  100877. /**
  100878. * Specifies if the material uses a texture
  100879. * @param texture defines the texture to check against the material
  100880. * @returns a boolean specifying if the material uses the texture
  100881. */
  100882. hasTexture(texture: BaseTexture): boolean;
  100883. /**
  100884. * Disposes the material
  100885. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100886. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100887. */
  100888. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100889. /**
  100890. * Makes a duplicate of the material, and gives it a new name
  100891. * @param name defines the new name for the duplicated material
  100892. * @returns the cloned material
  100893. */
  100894. clone(name: string): StandardMaterial;
  100895. /**
  100896. * Serializes this material in a JSON representation
  100897. * @returns the serialized material object
  100898. */
  100899. serialize(): any;
  100900. /**
  100901. * Creates a standard material from parsed material data
  100902. * @param source defines the JSON representation of the material
  100903. * @param scene defines the hosting scene
  100904. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100905. * @returns a new standard material
  100906. */
  100907. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100908. /**
  100909. * Are diffuse textures enabled in the application.
  100910. */
  100911. static get DiffuseTextureEnabled(): boolean;
  100912. static set DiffuseTextureEnabled(value: boolean);
  100913. /**
  100914. * Are detail textures enabled in the application.
  100915. */
  100916. static get DetailTextureEnabled(): boolean;
  100917. static set DetailTextureEnabled(value: boolean);
  100918. /**
  100919. * Are ambient textures enabled in the application.
  100920. */
  100921. static get AmbientTextureEnabled(): boolean;
  100922. static set AmbientTextureEnabled(value: boolean);
  100923. /**
  100924. * Are opacity textures enabled in the application.
  100925. */
  100926. static get OpacityTextureEnabled(): boolean;
  100927. static set OpacityTextureEnabled(value: boolean);
  100928. /**
  100929. * Are reflection textures enabled in the application.
  100930. */
  100931. static get ReflectionTextureEnabled(): boolean;
  100932. static set ReflectionTextureEnabled(value: boolean);
  100933. /**
  100934. * Are emissive textures enabled in the application.
  100935. */
  100936. static get EmissiveTextureEnabled(): boolean;
  100937. static set EmissiveTextureEnabled(value: boolean);
  100938. /**
  100939. * Are specular textures enabled in the application.
  100940. */
  100941. static get SpecularTextureEnabled(): boolean;
  100942. static set SpecularTextureEnabled(value: boolean);
  100943. /**
  100944. * Are bump textures enabled in the application.
  100945. */
  100946. static get BumpTextureEnabled(): boolean;
  100947. static set BumpTextureEnabled(value: boolean);
  100948. /**
  100949. * Are lightmap textures enabled in the application.
  100950. */
  100951. static get LightmapTextureEnabled(): boolean;
  100952. static set LightmapTextureEnabled(value: boolean);
  100953. /**
  100954. * Are refraction textures enabled in the application.
  100955. */
  100956. static get RefractionTextureEnabled(): boolean;
  100957. static set RefractionTextureEnabled(value: boolean);
  100958. /**
  100959. * Are color grading textures enabled in the application.
  100960. */
  100961. static get ColorGradingTextureEnabled(): boolean;
  100962. static set ColorGradingTextureEnabled(value: boolean);
  100963. /**
  100964. * Are fresnels enabled in the application.
  100965. */
  100966. static get FresnelEnabled(): boolean;
  100967. static set FresnelEnabled(value: boolean);
  100968. }
  100969. }
  100970. declare module BABYLON {
  100971. /** @hidden */
  100972. export var rgbdDecodePixelShader: {
  100973. name: string;
  100974. shader: string;
  100975. };
  100976. }
  100977. declare module BABYLON {
  100978. /**
  100979. * Class used to host RGBD texture specific utilities
  100980. */
  100981. export class RGBDTextureTools {
  100982. /**
  100983. * Expand the RGBD Texture from RGBD to Half Float if possible.
  100984. * @param texture the texture to expand.
  100985. */
  100986. static ExpandRGBDTexture(texture: Texture): void;
  100987. }
  100988. }
  100989. declare module BABYLON {
  100990. /**
  100991. * Class used to host texture specific utilities
  100992. */
  100993. export class BRDFTextureTools {
  100994. /**
  100995. * Prevents texture cache collision
  100996. */
  100997. private static _instanceNumber;
  100998. /**
  100999. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  101000. * @param scene defines the hosting scene
  101001. * @returns the environment BRDF texture
  101002. */
  101003. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  101004. private static _environmentBRDFBase64Texture;
  101005. }
  101006. }
  101007. declare module BABYLON {
  101008. /**
  101009. * @hidden
  101010. */
  101011. export interface IMaterialClearCoatDefines {
  101012. CLEARCOAT: boolean;
  101013. CLEARCOAT_DEFAULTIOR: boolean;
  101014. CLEARCOAT_TEXTURE: boolean;
  101015. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  101016. CLEARCOAT_TEXTUREDIRECTUV: number;
  101017. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  101018. CLEARCOAT_BUMP: boolean;
  101019. CLEARCOAT_BUMPDIRECTUV: number;
  101020. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  101021. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  101022. CLEARCOAT_REMAP_F0: boolean;
  101023. CLEARCOAT_TINT: boolean;
  101024. CLEARCOAT_TINT_TEXTURE: boolean;
  101025. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  101026. /** @hidden */
  101027. _areTexturesDirty: boolean;
  101028. }
  101029. /**
  101030. * Define the code related to the clear coat parameters of the pbr material.
  101031. */
  101032. export class PBRClearCoatConfiguration {
  101033. /**
  101034. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101035. * The default fits with a polyurethane material.
  101036. * @hidden
  101037. */
  101038. static readonly _DefaultIndexOfRefraction: number;
  101039. private _isEnabled;
  101040. /**
  101041. * Defines if the clear coat is enabled in the material.
  101042. */
  101043. isEnabled: boolean;
  101044. /**
  101045. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  101046. */
  101047. intensity: number;
  101048. /**
  101049. * Defines the clear coat layer roughness.
  101050. */
  101051. roughness: number;
  101052. private _indexOfRefraction;
  101053. /**
  101054. * Defines the index of refraction of the clear coat.
  101055. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101056. * The default fits with a polyurethane material.
  101057. * Changing the default value is more performance intensive.
  101058. */
  101059. indexOfRefraction: number;
  101060. private _texture;
  101061. /**
  101062. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  101063. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  101064. * if textureRoughness is not empty, else no texture roughness is used
  101065. */
  101066. texture: Nullable<BaseTexture>;
  101067. private _useRoughnessFromMainTexture;
  101068. /**
  101069. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  101070. * If false, the green channel from textureRoughness is used for roughness
  101071. */
  101072. useRoughnessFromMainTexture: boolean;
  101073. private _textureRoughness;
  101074. /**
  101075. * Stores the clear coat roughness in a texture (green channel)
  101076. * Not used if useRoughnessFromMainTexture is true
  101077. */
  101078. textureRoughness: Nullable<BaseTexture>;
  101079. private _remapF0OnInterfaceChange;
  101080. /**
  101081. * Defines if the F0 value should be remapped to account for the interface change in the material.
  101082. */
  101083. remapF0OnInterfaceChange: boolean;
  101084. private _bumpTexture;
  101085. /**
  101086. * Define the clear coat specific bump texture.
  101087. */
  101088. bumpTexture: Nullable<BaseTexture>;
  101089. private _isTintEnabled;
  101090. /**
  101091. * Defines if the clear coat tint is enabled in the material.
  101092. */
  101093. isTintEnabled: boolean;
  101094. /**
  101095. * Defines the clear coat tint of the material.
  101096. * This is only use if tint is enabled
  101097. */
  101098. tintColor: Color3;
  101099. /**
  101100. * Defines the distance at which the tint color should be found in the
  101101. * clear coat media.
  101102. * This is only use if tint is enabled
  101103. */
  101104. tintColorAtDistance: number;
  101105. /**
  101106. * Defines the clear coat layer thickness.
  101107. * This is only use if tint is enabled
  101108. */
  101109. tintThickness: number;
  101110. private _tintTexture;
  101111. /**
  101112. * Stores the clear tint values in a texture.
  101113. * rgb is tint
  101114. * a is a thickness factor
  101115. */
  101116. tintTexture: Nullable<BaseTexture>;
  101117. /** @hidden */
  101118. private _internalMarkAllSubMeshesAsTexturesDirty;
  101119. /** @hidden */
  101120. _markAllSubMeshesAsTexturesDirty(): void;
  101121. /**
  101122. * Instantiate a new istance of clear coat configuration.
  101123. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101124. */
  101125. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101126. /**
  101127. * Gets wehter the submesh is ready to be used or not.
  101128. * @param defines the list of "defines" to update.
  101129. * @param scene defines the scene the material belongs to.
  101130. * @param engine defines the engine the material belongs to.
  101131. * @param disableBumpMap defines wether the material disables bump or not.
  101132. * @returns - boolean indicating that the submesh is ready or not.
  101133. */
  101134. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101135. /**
  101136. * Checks to see if a texture is used in the material.
  101137. * @param defines the list of "defines" to update.
  101138. * @param scene defines the scene to the material belongs to.
  101139. */
  101140. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101141. /**
  101142. * Binds the material data.
  101143. * @param uniformBuffer defines the Uniform buffer to fill in.
  101144. * @param scene defines the scene the material belongs to.
  101145. * @param engine defines the engine the material belongs to.
  101146. * @param disableBumpMap defines wether the material disables bump or not.
  101147. * @param isFrozen defines wether the material is frozen or not.
  101148. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101149. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101150. * @param subMesh the submesh to bind data for
  101151. */
  101152. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  101153. /**
  101154. * Checks to see if a texture is used in the material.
  101155. * @param texture - Base texture to use.
  101156. * @returns - Boolean specifying if a texture is used in the material.
  101157. */
  101158. hasTexture(texture: BaseTexture): boolean;
  101159. /**
  101160. * Returns an array of the actively used textures.
  101161. * @param activeTextures Array of BaseTextures
  101162. */
  101163. getActiveTextures(activeTextures: BaseTexture[]): void;
  101164. /**
  101165. * Returns the animatable textures.
  101166. * @param animatables Array of animatable textures.
  101167. */
  101168. getAnimatables(animatables: IAnimatable[]): void;
  101169. /**
  101170. * Disposes the resources of the material.
  101171. * @param forceDisposeTextures - Forces the disposal of all textures.
  101172. */
  101173. dispose(forceDisposeTextures?: boolean): void;
  101174. /**
  101175. * Get the current class name of the texture useful for serialization or dynamic coding.
  101176. * @returns "PBRClearCoatConfiguration"
  101177. */
  101178. getClassName(): string;
  101179. /**
  101180. * Add fallbacks to the effect fallbacks list.
  101181. * @param defines defines the Base texture to use.
  101182. * @param fallbacks defines the current fallback list.
  101183. * @param currentRank defines the current fallback rank.
  101184. * @returns the new fallback rank.
  101185. */
  101186. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101187. /**
  101188. * Add the required uniforms to the current list.
  101189. * @param uniforms defines the current uniform list.
  101190. */
  101191. static AddUniforms(uniforms: string[]): void;
  101192. /**
  101193. * Add the required samplers to the current list.
  101194. * @param samplers defines the current sampler list.
  101195. */
  101196. static AddSamplers(samplers: string[]): void;
  101197. /**
  101198. * Add the required uniforms to the current buffer.
  101199. * @param uniformBuffer defines the current uniform buffer.
  101200. */
  101201. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101202. /**
  101203. * Makes a duplicate of the current configuration into another one.
  101204. * @param clearCoatConfiguration define the config where to copy the info
  101205. */
  101206. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101207. /**
  101208. * Serializes this clear coat configuration.
  101209. * @returns - An object with the serialized config.
  101210. */
  101211. serialize(): any;
  101212. /**
  101213. * Parses a anisotropy Configuration from a serialized object.
  101214. * @param source - Serialized object.
  101215. * @param scene Defines the scene we are parsing for
  101216. * @param rootUrl Defines the rootUrl to load from
  101217. */
  101218. parse(source: any, scene: Scene, rootUrl: string): void;
  101219. }
  101220. }
  101221. declare module BABYLON {
  101222. /**
  101223. * @hidden
  101224. */
  101225. export interface IMaterialAnisotropicDefines {
  101226. ANISOTROPIC: boolean;
  101227. ANISOTROPIC_TEXTURE: boolean;
  101228. ANISOTROPIC_TEXTUREDIRECTUV: number;
  101229. MAINUV1: boolean;
  101230. _areTexturesDirty: boolean;
  101231. _needUVs: boolean;
  101232. }
  101233. /**
  101234. * Define the code related to the anisotropic parameters of the pbr material.
  101235. */
  101236. export class PBRAnisotropicConfiguration {
  101237. private _isEnabled;
  101238. /**
  101239. * Defines if the anisotropy is enabled in the material.
  101240. */
  101241. isEnabled: boolean;
  101242. /**
  101243. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  101244. */
  101245. intensity: number;
  101246. /**
  101247. * Defines if the effect is along the tangents, bitangents or in between.
  101248. * By default, the effect is "strectching" the highlights along the tangents.
  101249. */
  101250. direction: Vector2;
  101251. private _texture;
  101252. /**
  101253. * Stores the anisotropy values in a texture.
  101254. * rg is direction (like normal from -1 to 1)
  101255. * b is a intensity
  101256. */
  101257. texture: Nullable<BaseTexture>;
  101258. /** @hidden */
  101259. private _internalMarkAllSubMeshesAsTexturesDirty;
  101260. /** @hidden */
  101261. _markAllSubMeshesAsTexturesDirty(): void;
  101262. /**
  101263. * Instantiate a new istance of anisotropy configuration.
  101264. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101265. */
  101266. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101267. /**
  101268. * Specifies that the submesh is ready to be used.
  101269. * @param defines the list of "defines" to update.
  101270. * @param scene defines the scene the material belongs to.
  101271. * @returns - boolean indicating that the submesh is ready or not.
  101272. */
  101273. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101274. /**
  101275. * Checks to see if a texture is used in the material.
  101276. * @param defines the list of "defines" to update.
  101277. * @param mesh the mesh we are preparing the defines for.
  101278. * @param scene defines the scene the material belongs to.
  101279. */
  101280. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101281. /**
  101282. * Binds the material data.
  101283. * @param uniformBuffer defines the Uniform buffer to fill in.
  101284. * @param scene defines the scene the material belongs to.
  101285. * @param isFrozen defines wether the material is frozen or not.
  101286. */
  101287. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101288. /**
  101289. * Checks to see if a texture is used in the material.
  101290. * @param texture - Base texture to use.
  101291. * @returns - Boolean specifying if a texture is used in the material.
  101292. */
  101293. hasTexture(texture: BaseTexture): boolean;
  101294. /**
  101295. * Returns an array of the actively used textures.
  101296. * @param activeTextures Array of BaseTextures
  101297. */
  101298. getActiveTextures(activeTextures: BaseTexture[]): void;
  101299. /**
  101300. * Returns the animatable textures.
  101301. * @param animatables Array of animatable textures.
  101302. */
  101303. getAnimatables(animatables: IAnimatable[]): void;
  101304. /**
  101305. * Disposes the resources of the material.
  101306. * @param forceDisposeTextures - Forces the disposal of all textures.
  101307. */
  101308. dispose(forceDisposeTextures?: boolean): void;
  101309. /**
  101310. * Get the current class name of the texture useful for serialization or dynamic coding.
  101311. * @returns "PBRAnisotropicConfiguration"
  101312. */
  101313. getClassName(): string;
  101314. /**
  101315. * Add fallbacks to the effect fallbacks list.
  101316. * @param defines defines the Base texture to use.
  101317. * @param fallbacks defines the current fallback list.
  101318. * @param currentRank defines the current fallback rank.
  101319. * @returns the new fallback rank.
  101320. */
  101321. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101322. /**
  101323. * Add the required uniforms to the current list.
  101324. * @param uniforms defines the current uniform list.
  101325. */
  101326. static AddUniforms(uniforms: string[]): void;
  101327. /**
  101328. * Add the required uniforms to the current buffer.
  101329. * @param uniformBuffer defines the current uniform buffer.
  101330. */
  101331. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101332. /**
  101333. * Add the required samplers to the current list.
  101334. * @param samplers defines the current sampler list.
  101335. */
  101336. static AddSamplers(samplers: string[]): void;
  101337. /**
  101338. * Makes a duplicate of the current configuration into another one.
  101339. * @param anisotropicConfiguration define the config where to copy the info
  101340. */
  101341. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101342. /**
  101343. * Serializes this anisotropy configuration.
  101344. * @returns - An object with the serialized config.
  101345. */
  101346. serialize(): any;
  101347. /**
  101348. * Parses a anisotropy Configuration from a serialized object.
  101349. * @param source - Serialized object.
  101350. * @param scene Defines the scene we are parsing for
  101351. * @param rootUrl Defines the rootUrl to load from
  101352. */
  101353. parse(source: any, scene: Scene, rootUrl: string): void;
  101354. }
  101355. }
  101356. declare module BABYLON {
  101357. /**
  101358. * @hidden
  101359. */
  101360. export interface IMaterialBRDFDefines {
  101361. BRDF_V_HEIGHT_CORRELATED: boolean;
  101362. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101363. SPHERICAL_HARMONICS: boolean;
  101364. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  101365. /** @hidden */
  101366. _areMiscDirty: boolean;
  101367. }
  101368. /**
  101369. * Define the code related to the BRDF parameters of the pbr material.
  101370. */
  101371. export class PBRBRDFConfiguration {
  101372. /**
  101373. * Default value used for the energy conservation.
  101374. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101375. */
  101376. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  101377. /**
  101378. * Default value used for the Smith Visibility Height Correlated mode.
  101379. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101380. */
  101381. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  101382. /**
  101383. * Default value used for the IBL diffuse part.
  101384. * This can help switching back to the polynomials mode globally which is a tiny bit
  101385. * less GPU intensive at the drawback of a lower quality.
  101386. */
  101387. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  101388. /**
  101389. * Default value used for activating energy conservation for the specular workflow.
  101390. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101391. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101392. */
  101393. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  101394. private _useEnergyConservation;
  101395. /**
  101396. * Defines if the material uses energy conservation.
  101397. */
  101398. useEnergyConservation: boolean;
  101399. private _useSmithVisibilityHeightCorrelated;
  101400. /**
  101401. * LEGACY Mode set to false
  101402. * Defines if the material uses height smith correlated visibility term.
  101403. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101404. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101405. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101406. * Not relying on height correlated will also disable energy conservation.
  101407. */
  101408. useSmithVisibilityHeightCorrelated: boolean;
  101409. private _useSphericalHarmonics;
  101410. /**
  101411. * LEGACY Mode set to false
  101412. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  101413. * diffuse part of the IBL.
  101414. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  101415. * to the ground truth.
  101416. */
  101417. useSphericalHarmonics: boolean;
  101418. private _useSpecularGlossinessInputEnergyConservation;
  101419. /**
  101420. * Defines if the material uses energy conservation, when the specular workflow is active.
  101421. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101422. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101423. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  101424. */
  101425. useSpecularGlossinessInputEnergyConservation: boolean;
  101426. /** @hidden */
  101427. private _internalMarkAllSubMeshesAsMiscDirty;
  101428. /** @hidden */
  101429. _markAllSubMeshesAsMiscDirty(): void;
  101430. /**
  101431. * Instantiate a new istance of clear coat configuration.
  101432. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101433. */
  101434. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101435. /**
  101436. * Checks to see if a texture is used in the material.
  101437. * @param defines the list of "defines" to update.
  101438. */
  101439. prepareDefines(defines: IMaterialBRDFDefines): void;
  101440. /**
  101441. * Get the current class name of the texture useful for serialization or dynamic coding.
  101442. * @returns "PBRClearCoatConfiguration"
  101443. */
  101444. getClassName(): string;
  101445. /**
  101446. * Makes a duplicate of the current configuration into another one.
  101447. * @param brdfConfiguration define the config where to copy the info
  101448. */
  101449. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101450. /**
  101451. * Serializes this BRDF configuration.
  101452. * @returns - An object with the serialized config.
  101453. */
  101454. serialize(): any;
  101455. /**
  101456. * Parses a anisotropy Configuration from a serialized object.
  101457. * @param source - Serialized object.
  101458. * @param scene Defines the scene we are parsing for
  101459. * @param rootUrl Defines the rootUrl to load from
  101460. */
  101461. parse(source: any, scene: Scene, rootUrl: string): void;
  101462. }
  101463. }
  101464. declare module BABYLON {
  101465. /**
  101466. * @hidden
  101467. */
  101468. export interface IMaterialSheenDefines {
  101469. SHEEN: boolean;
  101470. SHEEN_TEXTURE: boolean;
  101471. SHEEN_TEXTURE_ROUGHNESS: boolean;
  101472. SHEEN_TEXTUREDIRECTUV: number;
  101473. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  101474. SHEEN_LINKWITHALBEDO: boolean;
  101475. SHEEN_ROUGHNESS: boolean;
  101476. SHEEN_ALBEDOSCALING: boolean;
  101477. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  101478. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  101479. /** @hidden */
  101480. _areTexturesDirty: boolean;
  101481. }
  101482. /**
  101483. * Define the code related to the Sheen parameters of the pbr material.
  101484. */
  101485. export class PBRSheenConfiguration {
  101486. private _isEnabled;
  101487. /**
  101488. * Defines if the material uses sheen.
  101489. */
  101490. isEnabled: boolean;
  101491. private _linkSheenWithAlbedo;
  101492. /**
  101493. * Defines if the sheen is linked to the sheen color.
  101494. */
  101495. linkSheenWithAlbedo: boolean;
  101496. /**
  101497. * Defines the sheen intensity.
  101498. */
  101499. intensity: number;
  101500. /**
  101501. * Defines the sheen color.
  101502. */
  101503. color: Color3;
  101504. private _texture;
  101505. /**
  101506. * Stores the sheen tint values in a texture.
  101507. * rgb is tint
  101508. * 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)
  101509. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  101510. */
  101511. texture: Nullable<BaseTexture>;
  101512. private _useRoughnessFromMainTexture;
  101513. /**
  101514. * Indicates that the alpha channel of the texture property will be used for roughness.
  101515. * Has no effect if the roughness (and texture!) property is not defined
  101516. */
  101517. useRoughnessFromMainTexture: boolean;
  101518. private _roughness;
  101519. /**
  101520. * Defines the sheen roughness.
  101521. * It is not taken into account if linkSheenWithAlbedo is true.
  101522. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  101523. */
  101524. roughness: Nullable<number>;
  101525. private _textureRoughness;
  101526. /**
  101527. * Stores the sheen roughness in a texture.
  101528. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  101529. */
  101530. textureRoughness: Nullable<BaseTexture>;
  101531. private _albedoScaling;
  101532. /**
  101533. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  101534. * It allows the strength of the sheen effect to not depend on the base color of the material,
  101535. * making it easier to setup and tweak the effect
  101536. */
  101537. albedoScaling: boolean;
  101538. /** @hidden */
  101539. private _internalMarkAllSubMeshesAsTexturesDirty;
  101540. /** @hidden */
  101541. _markAllSubMeshesAsTexturesDirty(): void;
  101542. /**
  101543. * Instantiate a new istance of clear coat configuration.
  101544. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101545. */
  101546. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101547. /**
  101548. * Specifies that the submesh is ready to be used.
  101549. * @param defines the list of "defines" to update.
  101550. * @param scene defines the scene the material belongs to.
  101551. * @returns - boolean indicating that the submesh is ready or not.
  101552. */
  101553. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101554. /**
  101555. * Checks to see if a texture is used in the material.
  101556. * @param defines the list of "defines" to update.
  101557. * @param scene defines the scene the material belongs to.
  101558. */
  101559. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101560. /**
  101561. * Binds the material data.
  101562. * @param uniformBuffer defines the Uniform buffer to fill in.
  101563. * @param scene defines the scene the material belongs to.
  101564. * @param isFrozen defines wether the material is frozen or not.
  101565. * @param subMesh the submesh to bind data for
  101566. */
  101567. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  101568. /**
  101569. * Checks to see if a texture is used in the material.
  101570. * @param texture - Base texture to use.
  101571. * @returns - Boolean specifying if a texture is used in the material.
  101572. */
  101573. hasTexture(texture: BaseTexture): boolean;
  101574. /**
  101575. * Returns an array of the actively used textures.
  101576. * @param activeTextures Array of BaseTextures
  101577. */
  101578. getActiveTextures(activeTextures: BaseTexture[]): void;
  101579. /**
  101580. * Returns the animatable textures.
  101581. * @param animatables Array of animatable textures.
  101582. */
  101583. getAnimatables(animatables: IAnimatable[]): void;
  101584. /**
  101585. * Disposes the resources of the material.
  101586. * @param forceDisposeTextures - Forces the disposal of all textures.
  101587. */
  101588. dispose(forceDisposeTextures?: boolean): void;
  101589. /**
  101590. * Get the current class name of the texture useful for serialization or dynamic coding.
  101591. * @returns "PBRSheenConfiguration"
  101592. */
  101593. getClassName(): string;
  101594. /**
  101595. * Add fallbacks to the effect fallbacks list.
  101596. * @param defines defines the Base texture to use.
  101597. * @param fallbacks defines the current fallback list.
  101598. * @param currentRank defines the current fallback rank.
  101599. * @returns the new fallback rank.
  101600. */
  101601. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101602. /**
  101603. * Add the required uniforms to the current list.
  101604. * @param uniforms defines the current uniform list.
  101605. */
  101606. static AddUniforms(uniforms: string[]): void;
  101607. /**
  101608. * Add the required uniforms to the current buffer.
  101609. * @param uniformBuffer defines the current uniform buffer.
  101610. */
  101611. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101612. /**
  101613. * Add the required samplers to the current list.
  101614. * @param samplers defines the current sampler list.
  101615. */
  101616. static AddSamplers(samplers: string[]): void;
  101617. /**
  101618. * Makes a duplicate of the current configuration into another one.
  101619. * @param sheenConfiguration define the config where to copy the info
  101620. */
  101621. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101622. /**
  101623. * Serializes this BRDF configuration.
  101624. * @returns - An object with the serialized config.
  101625. */
  101626. serialize(): any;
  101627. /**
  101628. * Parses a anisotropy Configuration from a serialized object.
  101629. * @param source - Serialized object.
  101630. * @param scene Defines the scene we are parsing for
  101631. * @param rootUrl Defines the rootUrl to load from
  101632. */
  101633. parse(source: any, scene: Scene, rootUrl: string): void;
  101634. }
  101635. }
  101636. declare module BABYLON {
  101637. /**
  101638. * @hidden
  101639. */
  101640. export interface IMaterialSubSurfaceDefines {
  101641. SUBSURFACE: boolean;
  101642. SS_REFRACTION: boolean;
  101643. SS_TRANSLUCENCY: boolean;
  101644. SS_SCATTERING: boolean;
  101645. SS_THICKNESSANDMASK_TEXTURE: boolean;
  101646. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  101647. SS_REFRACTIONMAP_3D: boolean;
  101648. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  101649. SS_LODINREFRACTIONALPHA: boolean;
  101650. SS_GAMMAREFRACTION: boolean;
  101651. SS_RGBDREFRACTION: boolean;
  101652. SS_LINEARSPECULARREFRACTION: boolean;
  101653. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  101654. SS_ALBEDOFORREFRACTIONTINT: boolean;
  101655. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  101656. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  101657. /** @hidden */
  101658. _areTexturesDirty: boolean;
  101659. }
  101660. /**
  101661. * Define the code related to the sub surface parameters of the pbr material.
  101662. */
  101663. export class PBRSubSurfaceConfiguration {
  101664. private _isRefractionEnabled;
  101665. /**
  101666. * Defines if the refraction is enabled in the material.
  101667. */
  101668. isRefractionEnabled: boolean;
  101669. private _isTranslucencyEnabled;
  101670. /**
  101671. * Defines if the translucency is enabled in the material.
  101672. */
  101673. isTranslucencyEnabled: boolean;
  101674. private _isScatteringEnabled;
  101675. /**
  101676. * Defines if the sub surface scattering is enabled in the material.
  101677. */
  101678. isScatteringEnabled: boolean;
  101679. private _scatteringDiffusionProfileIndex;
  101680. /**
  101681. * Diffusion profile for subsurface scattering.
  101682. * Useful for better scattering in the skins or foliages.
  101683. */
  101684. get scatteringDiffusionProfile(): Nullable<Color3>;
  101685. set scatteringDiffusionProfile(c: Nullable<Color3>);
  101686. /**
  101687. * Defines the refraction intensity of the material.
  101688. * The refraction when enabled replaces the Diffuse part of the material.
  101689. * The intensity helps transitionning between diffuse and refraction.
  101690. */
  101691. refractionIntensity: number;
  101692. /**
  101693. * Defines the translucency intensity of the material.
  101694. * When translucency has been enabled, this defines how much of the "translucency"
  101695. * is addded to the diffuse part of the material.
  101696. */
  101697. translucencyIntensity: number;
  101698. /**
  101699. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  101700. */
  101701. useAlbedoToTintRefraction: boolean;
  101702. private _thicknessTexture;
  101703. /**
  101704. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  101705. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  101706. * 0 would mean minimumThickness
  101707. * 1 would mean maximumThickness
  101708. * The other channels might be use as a mask to vary the different effects intensity.
  101709. */
  101710. thicknessTexture: Nullable<BaseTexture>;
  101711. private _refractionTexture;
  101712. /**
  101713. * Defines the texture to use for refraction.
  101714. */
  101715. refractionTexture: Nullable<BaseTexture>;
  101716. private _indexOfRefraction;
  101717. /**
  101718. * Index of refraction of the material base layer.
  101719. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101720. *
  101721. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  101722. *
  101723. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  101724. */
  101725. indexOfRefraction: number;
  101726. private _volumeIndexOfRefraction;
  101727. /**
  101728. * Index of refraction of the material's volume.
  101729. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101730. *
  101731. * This ONLY impacts refraction. If not provided or given a non-valid value,
  101732. * the volume will use the same IOR as the surface.
  101733. */
  101734. get volumeIndexOfRefraction(): number;
  101735. set volumeIndexOfRefraction(value: number);
  101736. private _invertRefractionY;
  101737. /**
  101738. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101739. */
  101740. invertRefractionY: boolean;
  101741. private _linkRefractionWithTransparency;
  101742. /**
  101743. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101744. * Materials half opaque for instance using refraction could benefit from this control.
  101745. */
  101746. linkRefractionWithTransparency: boolean;
  101747. /**
  101748. * Defines the minimum thickness stored in the thickness map.
  101749. * If no thickness map is defined, this value will be used to simulate thickness.
  101750. */
  101751. minimumThickness: number;
  101752. /**
  101753. * Defines the maximum thickness stored in the thickness map.
  101754. */
  101755. maximumThickness: number;
  101756. /**
  101757. * Defines the volume tint of the material.
  101758. * This is used for both translucency and scattering.
  101759. */
  101760. tintColor: Color3;
  101761. /**
  101762. * Defines the distance at which the tint color should be found in the media.
  101763. * This is used for refraction only.
  101764. */
  101765. tintColorAtDistance: number;
  101766. /**
  101767. * Defines how far each channel transmit through the media.
  101768. * It is defined as a color to simplify it selection.
  101769. */
  101770. diffusionDistance: Color3;
  101771. private _useMaskFromThicknessTexture;
  101772. /**
  101773. * Stores the intensity of the different subsurface effects in the thickness texture.
  101774. * * the green channel is the translucency intensity.
  101775. * * the blue channel is the scattering intensity.
  101776. * * the alpha channel is the refraction intensity.
  101777. */
  101778. useMaskFromThicknessTexture: boolean;
  101779. private _scene;
  101780. private _useMaskFromThicknessTextureGltf;
  101781. /**
  101782. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  101783. * matches the channel-packing that is used by glTF.
  101784. * * the red channel is the transmission/translucency intensity.
  101785. * * the green channel is the thickness.
  101786. */
  101787. useMaskFromThicknessTextureGltf: boolean;
  101788. /** @hidden */
  101789. private _internalMarkAllSubMeshesAsTexturesDirty;
  101790. private _internalMarkScenePrePassDirty;
  101791. /** @hidden */
  101792. _markAllSubMeshesAsTexturesDirty(): void;
  101793. /** @hidden */
  101794. _markScenePrePassDirty(): void;
  101795. /**
  101796. * Instantiate a new istance of sub surface configuration.
  101797. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101798. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  101799. * @param scene The scene
  101800. */
  101801. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  101802. /**
  101803. * Gets wehter the submesh is ready to be used or not.
  101804. * @param defines the list of "defines" to update.
  101805. * @param scene defines the scene the material belongs to.
  101806. * @returns - boolean indicating that the submesh is ready or not.
  101807. */
  101808. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  101809. /**
  101810. * Checks to see if a texture is used in the material.
  101811. * @param defines the list of "defines" to update.
  101812. * @param scene defines the scene to the material belongs to.
  101813. */
  101814. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  101815. /**
  101816. * Binds the material data.
  101817. * @param uniformBuffer defines the Uniform buffer to fill in.
  101818. * @param scene defines the scene the material belongs to.
  101819. * @param engine defines the engine the material belongs to.
  101820. * @param isFrozen defines whether the material is frozen or not.
  101821. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  101822. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  101823. */
  101824. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  101825. /**
  101826. * Unbinds the material from the mesh.
  101827. * @param activeEffect defines the effect that should be unbound from.
  101828. * @returns true if unbound, otherwise false
  101829. */
  101830. unbind(activeEffect: Effect): boolean;
  101831. /**
  101832. * Returns the texture used for refraction or null if none is used.
  101833. * @param scene defines the scene the material belongs to.
  101834. * @returns - Refraction texture if present. If no refraction texture and refraction
  101835. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101836. */
  101837. private _getRefractionTexture;
  101838. /**
  101839. * Returns true if alpha blending should be disabled.
  101840. */
  101841. get disableAlphaBlending(): boolean;
  101842. /**
  101843. * Fills the list of render target textures.
  101844. * @param renderTargets the list of render targets to update
  101845. */
  101846. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  101847. /**
  101848. * Checks to see if a texture is used in the material.
  101849. * @param texture - Base texture to use.
  101850. * @returns - Boolean specifying if a texture is used in the material.
  101851. */
  101852. hasTexture(texture: BaseTexture): boolean;
  101853. /**
  101854. * Gets a boolean indicating that current material needs to register RTT
  101855. * @returns true if this uses a render target otherwise false.
  101856. */
  101857. hasRenderTargetTextures(): boolean;
  101858. /**
  101859. * Returns an array of the actively used textures.
  101860. * @param activeTextures Array of BaseTextures
  101861. */
  101862. getActiveTextures(activeTextures: BaseTexture[]): void;
  101863. /**
  101864. * Returns the animatable textures.
  101865. * @param animatables Array of animatable textures.
  101866. */
  101867. getAnimatables(animatables: IAnimatable[]): void;
  101868. /**
  101869. * Disposes the resources of the material.
  101870. * @param forceDisposeTextures - Forces the disposal of all textures.
  101871. */
  101872. dispose(forceDisposeTextures?: boolean): void;
  101873. /**
  101874. * Get the current class name of the texture useful for serialization or dynamic coding.
  101875. * @returns "PBRSubSurfaceConfiguration"
  101876. */
  101877. getClassName(): string;
  101878. /**
  101879. * Add fallbacks to the effect fallbacks list.
  101880. * @param defines defines the Base texture to use.
  101881. * @param fallbacks defines the current fallback list.
  101882. * @param currentRank defines the current fallback rank.
  101883. * @returns the new fallback rank.
  101884. */
  101885. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101886. /**
  101887. * Add the required uniforms to the current list.
  101888. * @param uniforms defines the current uniform list.
  101889. */
  101890. static AddUniforms(uniforms: string[]): void;
  101891. /**
  101892. * Add the required samplers to the current list.
  101893. * @param samplers defines the current sampler list.
  101894. */
  101895. static AddSamplers(samplers: string[]): void;
  101896. /**
  101897. * Add the required uniforms to the current buffer.
  101898. * @param uniformBuffer defines the current uniform buffer.
  101899. */
  101900. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101901. /**
  101902. * Makes a duplicate of the current configuration into another one.
  101903. * @param configuration define the config where to copy the info
  101904. */
  101905. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  101906. /**
  101907. * Serializes this Sub Surface configuration.
  101908. * @returns - An object with the serialized config.
  101909. */
  101910. serialize(): any;
  101911. /**
  101912. * Parses a anisotropy Configuration from a serialized object.
  101913. * @param source - Serialized object.
  101914. * @param scene Defines the scene we are parsing for
  101915. * @param rootUrl Defines the rootUrl to load from
  101916. */
  101917. parse(source: any, scene: Scene, rootUrl: string): void;
  101918. }
  101919. }
  101920. declare module BABYLON {
  101921. /**
  101922. * Class representing spherical harmonics coefficients to the 3rd degree
  101923. */
  101924. export class SphericalHarmonics {
  101925. /**
  101926. * Defines whether or not the harmonics have been prescaled for rendering.
  101927. */
  101928. preScaled: boolean;
  101929. /**
  101930. * The l0,0 coefficients of the spherical harmonics
  101931. */
  101932. l00: Vector3;
  101933. /**
  101934. * The l1,-1 coefficients of the spherical harmonics
  101935. */
  101936. l1_1: Vector3;
  101937. /**
  101938. * The l1,0 coefficients of the spherical harmonics
  101939. */
  101940. l10: Vector3;
  101941. /**
  101942. * The l1,1 coefficients of the spherical harmonics
  101943. */
  101944. l11: Vector3;
  101945. /**
  101946. * The l2,-2 coefficients of the spherical harmonics
  101947. */
  101948. l2_2: Vector3;
  101949. /**
  101950. * The l2,-1 coefficients of the spherical harmonics
  101951. */
  101952. l2_1: Vector3;
  101953. /**
  101954. * The l2,0 coefficients of the spherical harmonics
  101955. */
  101956. l20: Vector3;
  101957. /**
  101958. * The l2,1 coefficients of the spherical harmonics
  101959. */
  101960. l21: Vector3;
  101961. /**
  101962. * The l2,2 coefficients of the spherical harmonics
  101963. */
  101964. l22: Vector3;
  101965. /**
  101966. * Adds a light to the spherical harmonics
  101967. * @param direction the direction of the light
  101968. * @param color the color of the light
  101969. * @param deltaSolidAngle the delta solid angle of the light
  101970. */
  101971. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  101972. /**
  101973. * Scales the spherical harmonics by the given amount
  101974. * @param scale the amount to scale
  101975. */
  101976. scaleInPlace(scale: number): void;
  101977. /**
  101978. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  101979. *
  101980. * ```
  101981. * E_lm = A_l * L_lm
  101982. * ```
  101983. *
  101984. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  101985. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  101986. * the scaling factors are given in equation 9.
  101987. */
  101988. convertIncidentRadianceToIrradiance(): void;
  101989. /**
  101990. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  101991. *
  101992. * ```
  101993. * L = (1/pi) * E * rho
  101994. * ```
  101995. *
  101996. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  101997. */
  101998. convertIrradianceToLambertianRadiance(): void;
  101999. /**
  102000. * Integrates the reconstruction coefficients directly in to the SH preventing further
  102001. * required operations at run time.
  102002. *
  102003. * This is simply done by scaling back the SH with Ylm constants parameter.
  102004. * The trigonometric part being applied by the shader at run time.
  102005. */
  102006. preScaleForRendering(): void;
  102007. /**
  102008. * Constructs a spherical harmonics from an array.
  102009. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  102010. * @returns the spherical harmonics
  102011. */
  102012. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  102013. /**
  102014. * Gets the spherical harmonics from polynomial
  102015. * @param polynomial the spherical polynomial
  102016. * @returns the spherical harmonics
  102017. */
  102018. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  102019. }
  102020. /**
  102021. * Class representing spherical polynomial coefficients to the 3rd degree
  102022. */
  102023. export class SphericalPolynomial {
  102024. private _harmonics;
  102025. /**
  102026. * The spherical harmonics used to create the polynomials.
  102027. */
  102028. get preScaledHarmonics(): SphericalHarmonics;
  102029. /**
  102030. * The x coefficients of the spherical polynomial
  102031. */
  102032. x: Vector3;
  102033. /**
  102034. * The y coefficients of the spherical polynomial
  102035. */
  102036. y: Vector3;
  102037. /**
  102038. * The z coefficients of the spherical polynomial
  102039. */
  102040. z: Vector3;
  102041. /**
  102042. * The xx coefficients of the spherical polynomial
  102043. */
  102044. xx: Vector3;
  102045. /**
  102046. * The yy coefficients of the spherical polynomial
  102047. */
  102048. yy: Vector3;
  102049. /**
  102050. * The zz coefficients of the spherical polynomial
  102051. */
  102052. zz: Vector3;
  102053. /**
  102054. * The xy coefficients of the spherical polynomial
  102055. */
  102056. xy: Vector3;
  102057. /**
  102058. * The yz coefficients of the spherical polynomial
  102059. */
  102060. yz: Vector3;
  102061. /**
  102062. * The zx coefficients of the spherical polynomial
  102063. */
  102064. zx: Vector3;
  102065. /**
  102066. * Adds an ambient color to the spherical polynomial
  102067. * @param color the color to add
  102068. */
  102069. addAmbient(color: Color3): void;
  102070. /**
  102071. * Scales the spherical polynomial by the given amount
  102072. * @param scale the amount to scale
  102073. */
  102074. scaleInPlace(scale: number): void;
  102075. /**
  102076. * Gets the spherical polynomial from harmonics
  102077. * @param harmonics the spherical harmonics
  102078. * @returns the spherical polynomial
  102079. */
  102080. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  102081. /**
  102082. * Constructs a spherical polynomial from an array.
  102083. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  102084. * @returns the spherical polynomial
  102085. */
  102086. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102087. }
  102088. }
  102089. declare module BABYLON {
  102090. /**
  102091. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  102092. */
  102093. export interface CubeMapInfo {
  102094. /**
  102095. * The pixel array for the front face.
  102096. * This is stored in format, left to right, up to down format.
  102097. */
  102098. front: Nullable<ArrayBufferView>;
  102099. /**
  102100. * The pixel array for the back face.
  102101. * This is stored in format, left to right, up to down format.
  102102. */
  102103. back: Nullable<ArrayBufferView>;
  102104. /**
  102105. * The pixel array for the left face.
  102106. * This is stored in format, left to right, up to down format.
  102107. */
  102108. left: Nullable<ArrayBufferView>;
  102109. /**
  102110. * The pixel array for the right face.
  102111. * This is stored in format, left to right, up to down format.
  102112. */
  102113. right: Nullable<ArrayBufferView>;
  102114. /**
  102115. * The pixel array for the up face.
  102116. * This is stored in format, left to right, up to down format.
  102117. */
  102118. up: Nullable<ArrayBufferView>;
  102119. /**
  102120. * The pixel array for the down face.
  102121. * This is stored in format, left to right, up to down format.
  102122. */
  102123. down: Nullable<ArrayBufferView>;
  102124. /**
  102125. * The size of the cubemap stored.
  102126. *
  102127. * Each faces will be size * size pixels.
  102128. */
  102129. size: number;
  102130. /**
  102131. * The format of the texture.
  102132. *
  102133. * RGBA, RGB.
  102134. */
  102135. format: number;
  102136. /**
  102137. * The type of the texture data.
  102138. *
  102139. * UNSIGNED_INT, FLOAT.
  102140. */
  102141. type: number;
  102142. /**
  102143. * Specifies whether the texture is in gamma space.
  102144. */
  102145. gammaSpace: boolean;
  102146. }
  102147. /**
  102148. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  102149. */
  102150. export class PanoramaToCubeMapTools {
  102151. private static FACE_LEFT;
  102152. private static FACE_RIGHT;
  102153. private static FACE_FRONT;
  102154. private static FACE_BACK;
  102155. private static FACE_DOWN;
  102156. private static FACE_UP;
  102157. /**
  102158. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  102159. *
  102160. * @param float32Array The source data.
  102161. * @param inputWidth The width of the input panorama.
  102162. * @param inputHeight The height of the input panorama.
  102163. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  102164. * @return The cubemap data
  102165. */
  102166. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  102167. private static CreateCubemapTexture;
  102168. private static CalcProjectionSpherical;
  102169. }
  102170. }
  102171. declare module BABYLON {
  102172. /**
  102173. * Helper class dealing with the extraction of spherical polynomial dataArray
  102174. * from a cube map.
  102175. */
  102176. export class CubeMapToSphericalPolynomialTools {
  102177. private static FileFaces;
  102178. /**
  102179. * Converts a texture to the according Spherical Polynomial data.
  102180. * This extracts the first 3 orders only as they are the only one used in the lighting.
  102181. *
  102182. * @param texture The texture to extract the information from.
  102183. * @return The Spherical Polynomial data.
  102184. */
  102185. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  102186. /**
  102187. * Converts a cubemap to the according Spherical Polynomial data.
  102188. * This extracts the first 3 orders only as they are the only one used in the lighting.
  102189. *
  102190. * @param cubeInfo The Cube map to extract the information from.
  102191. * @return The Spherical Polynomial data.
  102192. */
  102193. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  102194. }
  102195. }
  102196. declare module BABYLON {
  102197. interface BaseTexture {
  102198. /**
  102199. * Get the polynomial representation of the texture data.
  102200. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  102201. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  102202. */
  102203. sphericalPolynomial: Nullable<SphericalPolynomial>;
  102204. }
  102205. }
  102206. declare module BABYLON {
  102207. /** @hidden */
  102208. export var pbrFragmentDeclaration: {
  102209. name: string;
  102210. shader: string;
  102211. };
  102212. }
  102213. declare module BABYLON {
  102214. /** @hidden */
  102215. export var pbrUboDeclaration: {
  102216. name: string;
  102217. shader: string;
  102218. };
  102219. }
  102220. declare module BABYLON {
  102221. /** @hidden */
  102222. export var pbrFragmentExtraDeclaration: {
  102223. name: string;
  102224. shader: string;
  102225. };
  102226. }
  102227. declare module BABYLON {
  102228. /** @hidden */
  102229. export var pbrFragmentSamplersDeclaration: {
  102230. name: string;
  102231. shader: string;
  102232. };
  102233. }
  102234. declare module BABYLON {
  102235. /** @hidden */
  102236. export var subSurfaceScatteringFunctions: {
  102237. name: string;
  102238. shader: string;
  102239. };
  102240. }
  102241. declare module BABYLON {
  102242. /** @hidden */
  102243. export var importanceSampling: {
  102244. name: string;
  102245. shader: string;
  102246. };
  102247. }
  102248. declare module BABYLON {
  102249. /** @hidden */
  102250. export var pbrHelperFunctions: {
  102251. name: string;
  102252. shader: string;
  102253. };
  102254. }
  102255. declare module BABYLON {
  102256. /** @hidden */
  102257. export var harmonicsFunctions: {
  102258. name: string;
  102259. shader: string;
  102260. };
  102261. }
  102262. declare module BABYLON {
  102263. /** @hidden */
  102264. export var pbrDirectLightingSetupFunctions: {
  102265. name: string;
  102266. shader: string;
  102267. };
  102268. }
  102269. declare module BABYLON {
  102270. /** @hidden */
  102271. export var pbrDirectLightingFalloffFunctions: {
  102272. name: string;
  102273. shader: string;
  102274. };
  102275. }
  102276. declare module BABYLON {
  102277. /** @hidden */
  102278. export var pbrBRDFFunctions: {
  102279. name: string;
  102280. shader: string;
  102281. };
  102282. }
  102283. declare module BABYLON {
  102284. /** @hidden */
  102285. export var hdrFilteringFunctions: {
  102286. name: string;
  102287. shader: string;
  102288. };
  102289. }
  102290. declare module BABYLON {
  102291. /** @hidden */
  102292. export var pbrDirectLightingFunctions: {
  102293. name: string;
  102294. shader: string;
  102295. };
  102296. }
  102297. declare module BABYLON {
  102298. /** @hidden */
  102299. export var pbrIBLFunctions: {
  102300. name: string;
  102301. shader: string;
  102302. };
  102303. }
  102304. declare module BABYLON {
  102305. /** @hidden */
  102306. export var pbrBlockAlbedoOpacity: {
  102307. name: string;
  102308. shader: string;
  102309. };
  102310. }
  102311. declare module BABYLON {
  102312. /** @hidden */
  102313. export var pbrBlockReflectivity: {
  102314. name: string;
  102315. shader: string;
  102316. };
  102317. }
  102318. declare module BABYLON {
  102319. /** @hidden */
  102320. export var pbrBlockAmbientOcclusion: {
  102321. name: string;
  102322. shader: string;
  102323. };
  102324. }
  102325. declare module BABYLON {
  102326. /** @hidden */
  102327. export var pbrBlockAlphaFresnel: {
  102328. name: string;
  102329. shader: string;
  102330. };
  102331. }
  102332. declare module BABYLON {
  102333. /** @hidden */
  102334. export var pbrBlockAnisotropic: {
  102335. name: string;
  102336. shader: string;
  102337. };
  102338. }
  102339. declare module BABYLON {
  102340. /** @hidden */
  102341. export var pbrBlockReflection: {
  102342. name: string;
  102343. shader: string;
  102344. };
  102345. }
  102346. declare module BABYLON {
  102347. /** @hidden */
  102348. export var pbrBlockSheen: {
  102349. name: string;
  102350. shader: string;
  102351. };
  102352. }
  102353. declare module BABYLON {
  102354. /** @hidden */
  102355. export var pbrBlockClearcoat: {
  102356. name: string;
  102357. shader: string;
  102358. };
  102359. }
  102360. declare module BABYLON {
  102361. /** @hidden */
  102362. export var pbrBlockSubSurface: {
  102363. name: string;
  102364. shader: string;
  102365. };
  102366. }
  102367. declare module BABYLON {
  102368. /** @hidden */
  102369. export var pbrBlockNormalGeometric: {
  102370. name: string;
  102371. shader: string;
  102372. };
  102373. }
  102374. declare module BABYLON {
  102375. /** @hidden */
  102376. export var pbrBlockNormalFinal: {
  102377. name: string;
  102378. shader: string;
  102379. };
  102380. }
  102381. declare module BABYLON {
  102382. /** @hidden */
  102383. export var pbrBlockLightmapInit: {
  102384. name: string;
  102385. shader: string;
  102386. };
  102387. }
  102388. declare module BABYLON {
  102389. /** @hidden */
  102390. export var pbrBlockGeometryInfo: {
  102391. name: string;
  102392. shader: string;
  102393. };
  102394. }
  102395. declare module BABYLON {
  102396. /** @hidden */
  102397. export var pbrBlockReflectance0: {
  102398. name: string;
  102399. shader: string;
  102400. };
  102401. }
  102402. declare module BABYLON {
  102403. /** @hidden */
  102404. export var pbrBlockReflectance: {
  102405. name: string;
  102406. shader: string;
  102407. };
  102408. }
  102409. declare module BABYLON {
  102410. /** @hidden */
  102411. export var pbrBlockDirectLighting: {
  102412. name: string;
  102413. shader: string;
  102414. };
  102415. }
  102416. declare module BABYLON {
  102417. /** @hidden */
  102418. export var pbrBlockFinalLitComponents: {
  102419. name: string;
  102420. shader: string;
  102421. };
  102422. }
  102423. declare module BABYLON {
  102424. /** @hidden */
  102425. export var pbrBlockFinalUnlitComponents: {
  102426. name: string;
  102427. shader: string;
  102428. };
  102429. }
  102430. declare module BABYLON {
  102431. /** @hidden */
  102432. export var pbrBlockFinalColorComposition: {
  102433. name: string;
  102434. shader: string;
  102435. };
  102436. }
  102437. declare module BABYLON {
  102438. /** @hidden */
  102439. export var pbrBlockImageProcessing: {
  102440. name: string;
  102441. shader: string;
  102442. };
  102443. }
  102444. declare module BABYLON {
  102445. /** @hidden */
  102446. export var pbrDebug: {
  102447. name: string;
  102448. shader: string;
  102449. };
  102450. }
  102451. declare module BABYLON {
  102452. /** @hidden */
  102453. export var pbrPixelShader: {
  102454. name: string;
  102455. shader: string;
  102456. };
  102457. }
  102458. declare module BABYLON {
  102459. /** @hidden */
  102460. export var pbrVertexDeclaration: {
  102461. name: string;
  102462. shader: string;
  102463. };
  102464. }
  102465. declare module BABYLON {
  102466. /** @hidden */
  102467. export var pbrVertexShader: {
  102468. name: string;
  102469. shader: string;
  102470. };
  102471. }
  102472. declare module BABYLON {
  102473. /**
  102474. * Manages the defines for the PBR Material.
  102475. * @hidden
  102476. */
  102477. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  102478. PBR: boolean;
  102479. NUM_SAMPLES: string;
  102480. REALTIME_FILTERING: boolean;
  102481. MAINUV1: boolean;
  102482. MAINUV2: boolean;
  102483. UV1: boolean;
  102484. UV2: boolean;
  102485. ALBEDO: boolean;
  102486. GAMMAALBEDO: boolean;
  102487. ALBEDODIRECTUV: number;
  102488. VERTEXCOLOR: boolean;
  102489. DETAIL: boolean;
  102490. DETAILDIRECTUV: number;
  102491. DETAIL_NORMALBLENDMETHOD: number;
  102492. AMBIENT: boolean;
  102493. AMBIENTDIRECTUV: number;
  102494. AMBIENTINGRAYSCALE: boolean;
  102495. OPACITY: boolean;
  102496. VERTEXALPHA: boolean;
  102497. OPACITYDIRECTUV: number;
  102498. OPACITYRGB: boolean;
  102499. ALPHATEST: boolean;
  102500. DEPTHPREPASS: boolean;
  102501. ALPHABLEND: boolean;
  102502. ALPHAFROMALBEDO: boolean;
  102503. ALPHATESTVALUE: string;
  102504. SPECULAROVERALPHA: boolean;
  102505. RADIANCEOVERALPHA: boolean;
  102506. ALPHAFRESNEL: boolean;
  102507. LINEARALPHAFRESNEL: boolean;
  102508. PREMULTIPLYALPHA: boolean;
  102509. EMISSIVE: boolean;
  102510. EMISSIVEDIRECTUV: number;
  102511. REFLECTIVITY: boolean;
  102512. REFLECTIVITYDIRECTUV: number;
  102513. SPECULARTERM: boolean;
  102514. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  102515. MICROSURFACEAUTOMATIC: boolean;
  102516. LODBASEDMICROSFURACE: boolean;
  102517. MICROSURFACEMAP: boolean;
  102518. MICROSURFACEMAPDIRECTUV: number;
  102519. METALLICWORKFLOW: boolean;
  102520. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  102521. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  102522. METALLNESSSTOREINMETALMAPBLUE: boolean;
  102523. AOSTOREINMETALMAPRED: boolean;
  102524. METALLIC_REFLECTANCE: boolean;
  102525. METALLIC_REFLECTANCEDIRECTUV: number;
  102526. ENVIRONMENTBRDF: boolean;
  102527. ENVIRONMENTBRDF_RGBD: boolean;
  102528. NORMAL: boolean;
  102529. TANGENT: boolean;
  102530. BUMP: boolean;
  102531. BUMPDIRECTUV: number;
  102532. OBJECTSPACE_NORMALMAP: boolean;
  102533. PARALLAX: boolean;
  102534. PARALLAXOCCLUSION: boolean;
  102535. NORMALXYSCALE: boolean;
  102536. LIGHTMAP: boolean;
  102537. LIGHTMAPDIRECTUV: number;
  102538. USELIGHTMAPASSHADOWMAP: boolean;
  102539. GAMMALIGHTMAP: boolean;
  102540. RGBDLIGHTMAP: boolean;
  102541. REFLECTION: boolean;
  102542. REFLECTIONMAP_3D: boolean;
  102543. REFLECTIONMAP_SPHERICAL: boolean;
  102544. REFLECTIONMAP_PLANAR: boolean;
  102545. REFLECTIONMAP_CUBIC: boolean;
  102546. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102547. REFLECTIONMAP_PROJECTION: boolean;
  102548. REFLECTIONMAP_SKYBOX: boolean;
  102549. REFLECTIONMAP_EXPLICIT: boolean;
  102550. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102551. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102552. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102553. INVERTCUBICMAP: boolean;
  102554. USESPHERICALFROMREFLECTIONMAP: boolean;
  102555. USEIRRADIANCEMAP: boolean;
  102556. SPHERICAL_HARMONICS: boolean;
  102557. USESPHERICALINVERTEX: boolean;
  102558. REFLECTIONMAP_OPPOSITEZ: boolean;
  102559. LODINREFLECTIONALPHA: boolean;
  102560. GAMMAREFLECTION: boolean;
  102561. RGBDREFLECTION: boolean;
  102562. LINEARSPECULARREFLECTION: boolean;
  102563. RADIANCEOCCLUSION: boolean;
  102564. HORIZONOCCLUSION: boolean;
  102565. INSTANCES: boolean;
  102566. THIN_INSTANCES: boolean;
  102567. PREPASS: boolean;
  102568. PREPASS_IRRADIANCE: boolean;
  102569. PREPASS_IRRADIANCE_INDEX: number;
  102570. PREPASS_ALBEDO: boolean;
  102571. PREPASS_ALBEDO_INDEX: number;
  102572. PREPASS_DEPTHNORMAL: boolean;
  102573. PREPASS_DEPTHNORMAL_INDEX: number;
  102574. PREPASS_POSITION: boolean;
  102575. PREPASS_POSITION_INDEX: number;
  102576. PREPASS_VELOCITY: boolean;
  102577. PREPASS_VELOCITY_INDEX: number;
  102578. PREPASS_REFLECTIVITY: boolean;
  102579. PREPASS_REFLECTIVITY_INDEX: number;
  102580. SCENE_MRT_COUNT: number;
  102581. NUM_BONE_INFLUENCERS: number;
  102582. BonesPerMesh: number;
  102583. BONETEXTURE: boolean;
  102584. BONES_VELOCITY_ENABLED: boolean;
  102585. NONUNIFORMSCALING: boolean;
  102586. MORPHTARGETS: boolean;
  102587. MORPHTARGETS_NORMAL: boolean;
  102588. MORPHTARGETS_TANGENT: boolean;
  102589. MORPHTARGETS_UV: boolean;
  102590. NUM_MORPH_INFLUENCERS: number;
  102591. IMAGEPROCESSING: boolean;
  102592. VIGNETTE: boolean;
  102593. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102594. VIGNETTEBLENDMODEOPAQUE: boolean;
  102595. TONEMAPPING: boolean;
  102596. TONEMAPPING_ACES: boolean;
  102597. CONTRAST: boolean;
  102598. COLORCURVES: boolean;
  102599. COLORGRADING: boolean;
  102600. COLORGRADING3D: boolean;
  102601. SAMPLER3DGREENDEPTH: boolean;
  102602. SAMPLER3DBGRMAP: boolean;
  102603. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102604. EXPOSURE: boolean;
  102605. MULTIVIEW: boolean;
  102606. USEPHYSICALLIGHTFALLOFF: boolean;
  102607. USEGLTFLIGHTFALLOFF: boolean;
  102608. TWOSIDEDLIGHTING: boolean;
  102609. SHADOWFLOAT: boolean;
  102610. CLIPPLANE: boolean;
  102611. CLIPPLANE2: boolean;
  102612. CLIPPLANE3: boolean;
  102613. CLIPPLANE4: boolean;
  102614. CLIPPLANE5: boolean;
  102615. CLIPPLANE6: boolean;
  102616. POINTSIZE: boolean;
  102617. FOG: boolean;
  102618. LOGARITHMICDEPTH: boolean;
  102619. FORCENORMALFORWARD: boolean;
  102620. SPECULARAA: boolean;
  102621. CLEARCOAT: boolean;
  102622. CLEARCOAT_DEFAULTIOR: boolean;
  102623. CLEARCOAT_TEXTURE: boolean;
  102624. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  102625. CLEARCOAT_TEXTUREDIRECTUV: number;
  102626. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  102627. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102628. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102629. CLEARCOAT_BUMP: boolean;
  102630. CLEARCOAT_BUMPDIRECTUV: number;
  102631. CLEARCOAT_REMAP_F0: boolean;
  102632. CLEARCOAT_TINT: boolean;
  102633. CLEARCOAT_TINT_TEXTURE: boolean;
  102634. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102635. ANISOTROPIC: boolean;
  102636. ANISOTROPIC_TEXTURE: boolean;
  102637. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102638. BRDF_V_HEIGHT_CORRELATED: boolean;
  102639. MS_BRDF_ENERGY_CONSERVATION: boolean;
  102640. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  102641. SHEEN: boolean;
  102642. SHEEN_TEXTURE: boolean;
  102643. SHEEN_TEXTURE_ROUGHNESS: boolean;
  102644. SHEEN_TEXTUREDIRECTUV: number;
  102645. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  102646. SHEEN_LINKWITHALBEDO: boolean;
  102647. SHEEN_ROUGHNESS: boolean;
  102648. SHEEN_ALBEDOSCALING: boolean;
  102649. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102650. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102651. SUBSURFACE: boolean;
  102652. SS_REFRACTION: boolean;
  102653. SS_TRANSLUCENCY: boolean;
  102654. SS_SCATTERING: boolean;
  102655. SS_THICKNESSANDMASK_TEXTURE: boolean;
  102656. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  102657. SS_REFRACTIONMAP_3D: boolean;
  102658. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  102659. SS_LODINREFRACTIONALPHA: boolean;
  102660. SS_GAMMAREFRACTION: boolean;
  102661. SS_RGBDREFRACTION: boolean;
  102662. SS_LINEARSPECULARREFRACTION: boolean;
  102663. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  102664. SS_ALBEDOFORREFRACTIONTINT: boolean;
  102665. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  102666. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  102667. UNLIT: boolean;
  102668. DEBUGMODE: number;
  102669. /**
  102670. * Initializes the PBR Material defines.
  102671. */
  102672. constructor();
  102673. /**
  102674. * Resets the PBR Material defines.
  102675. */
  102676. reset(): void;
  102677. }
  102678. /**
  102679. * The Physically based material base class of BJS.
  102680. *
  102681. * This offers the main features of a standard PBR material.
  102682. * For more information, please refer to the documentation :
  102683. * https://doc.babylonjs.com/how_to/physically_based_rendering
  102684. */
  102685. export abstract class PBRBaseMaterial extends PushMaterial {
  102686. /**
  102687. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102688. */
  102689. static readonly PBRMATERIAL_OPAQUE: number;
  102690. /**
  102691. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102692. */
  102693. static readonly PBRMATERIAL_ALPHATEST: number;
  102694. /**
  102695. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102696. */
  102697. static readonly PBRMATERIAL_ALPHABLEND: number;
  102698. /**
  102699. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102700. * They are also discarded below the alpha cutoff threshold to improve performances.
  102701. */
  102702. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102703. /**
  102704. * Defines the default value of how much AO map is occluding the analytical lights
  102705. * (point spot...).
  102706. */
  102707. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102708. /**
  102709. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102710. */
  102711. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102712. /**
  102713. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102714. * to enhance interoperability with other engines.
  102715. */
  102716. static readonly LIGHTFALLOFF_GLTF: number;
  102717. /**
  102718. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102719. * to enhance interoperability with other materials.
  102720. */
  102721. static readonly LIGHTFALLOFF_STANDARD: number;
  102722. /**
  102723. * Intensity of the direct lights e.g. the four lights available in your scene.
  102724. * This impacts both the direct diffuse and specular highlights.
  102725. */
  102726. protected _directIntensity: number;
  102727. /**
  102728. * Intensity of the emissive part of the material.
  102729. * This helps controlling the emissive effect without modifying the emissive color.
  102730. */
  102731. protected _emissiveIntensity: number;
  102732. /**
  102733. * Intensity of the environment e.g. how much the environment will light the object
  102734. * either through harmonics for rough material or through the refelction for shiny ones.
  102735. */
  102736. protected _environmentIntensity: number;
  102737. /**
  102738. * This is a special control allowing the reduction of the specular highlights coming from the
  102739. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102740. */
  102741. protected _specularIntensity: number;
  102742. /**
  102743. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102744. */
  102745. private _lightingInfos;
  102746. /**
  102747. * Debug Control allowing disabling the bump map on this material.
  102748. */
  102749. protected _disableBumpMap: boolean;
  102750. /**
  102751. * AKA Diffuse Texture in standard nomenclature.
  102752. */
  102753. protected _albedoTexture: Nullable<BaseTexture>;
  102754. /**
  102755. * AKA Occlusion Texture in other nomenclature.
  102756. */
  102757. protected _ambientTexture: Nullable<BaseTexture>;
  102758. /**
  102759. * AKA Occlusion Texture Intensity in other nomenclature.
  102760. */
  102761. protected _ambientTextureStrength: number;
  102762. /**
  102763. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102764. * 1 means it completely occludes it
  102765. * 0 mean it has no impact
  102766. */
  102767. protected _ambientTextureImpactOnAnalyticalLights: number;
  102768. /**
  102769. * Stores the alpha values in a texture.
  102770. */
  102771. protected _opacityTexture: Nullable<BaseTexture>;
  102772. /**
  102773. * Stores the reflection values in a texture.
  102774. */
  102775. protected _reflectionTexture: Nullable<BaseTexture>;
  102776. /**
  102777. * Stores the emissive values in a texture.
  102778. */
  102779. protected _emissiveTexture: Nullable<BaseTexture>;
  102780. /**
  102781. * AKA Specular texture in other nomenclature.
  102782. */
  102783. protected _reflectivityTexture: Nullable<BaseTexture>;
  102784. /**
  102785. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102786. */
  102787. protected _metallicTexture: Nullable<BaseTexture>;
  102788. /**
  102789. * Specifies the metallic scalar of the metallic/roughness workflow.
  102790. * Can also be used to scale the metalness values of the metallic texture.
  102791. */
  102792. protected _metallic: Nullable<number>;
  102793. /**
  102794. * Specifies the roughness scalar of the metallic/roughness workflow.
  102795. * Can also be used to scale the roughness values of the metallic texture.
  102796. */
  102797. protected _roughness: Nullable<number>;
  102798. /**
  102799. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  102800. * By default the indexOfrefraction is used to compute F0;
  102801. *
  102802. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  102803. *
  102804. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  102805. * F90 = metallicReflectanceColor;
  102806. */
  102807. protected _metallicF0Factor: number;
  102808. /**
  102809. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  102810. * By default the F90 is always 1;
  102811. *
  102812. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  102813. *
  102814. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  102815. * F90 = metallicReflectanceColor;
  102816. */
  102817. protected _metallicReflectanceColor: Color3;
  102818. /**
  102819. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  102820. * This is multiply against the scalar values defined in the material.
  102821. */
  102822. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  102823. /**
  102824. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102825. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102826. */
  102827. protected _microSurfaceTexture: Nullable<BaseTexture>;
  102828. /**
  102829. * Stores surface normal data used to displace a mesh in a texture.
  102830. */
  102831. protected _bumpTexture: Nullable<BaseTexture>;
  102832. /**
  102833. * Stores the pre-calculated light information of a mesh in a texture.
  102834. */
  102835. protected _lightmapTexture: Nullable<BaseTexture>;
  102836. /**
  102837. * The color of a material in ambient lighting.
  102838. */
  102839. protected _ambientColor: Color3;
  102840. /**
  102841. * AKA Diffuse Color in other nomenclature.
  102842. */
  102843. protected _albedoColor: Color3;
  102844. /**
  102845. * AKA Specular Color in other nomenclature.
  102846. */
  102847. protected _reflectivityColor: Color3;
  102848. /**
  102849. * The color applied when light is reflected from a material.
  102850. */
  102851. protected _reflectionColor: Color3;
  102852. /**
  102853. * The color applied when light is emitted from a material.
  102854. */
  102855. protected _emissiveColor: Color3;
  102856. /**
  102857. * AKA Glossiness in other nomenclature.
  102858. */
  102859. protected _microSurface: number;
  102860. /**
  102861. * Specifies that the material will use the light map as a show map.
  102862. */
  102863. protected _useLightmapAsShadowmap: boolean;
  102864. /**
  102865. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102866. * makes the reflect vector face the model (under horizon).
  102867. */
  102868. protected _useHorizonOcclusion: boolean;
  102869. /**
  102870. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102871. * too much the area relying on ambient texture to define their ambient occlusion.
  102872. */
  102873. protected _useRadianceOcclusion: boolean;
  102874. /**
  102875. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102876. */
  102877. protected _useAlphaFromAlbedoTexture: boolean;
  102878. /**
  102879. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102880. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102881. */
  102882. protected _useSpecularOverAlpha: boolean;
  102883. /**
  102884. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102885. */
  102886. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102887. /**
  102888. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102889. */
  102890. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102891. /**
  102892. * Specifies if the metallic texture contains the roughness information in its green channel.
  102893. */
  102894. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102895. /**
  102896. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102897. */
  102898. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102899. /**
  102900. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102901. */
  102902. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102903. /**
  102904. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102905. */
  102906. protected _useAmbientInGrayScale: boolean;
  102907. /**
  102908. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102909. * The material will try to infer what glossiness each pixel should be.
  102910. */
  102911. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102912. /**
  102913. * Defines the falloff type used in this material.
  102914. * It by default is Physical.
  102915. */
  102916. protected _lightFalloff: number;
  102917. /**
  102918. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102919. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102920. */
  102921. protected _useRadianceOverAlpha: boolean;
  102922. /**
  102923. * Allows using an object space normal map (instead of tangent space).
  102924. */
  102925. protected _useObjectSpaceNormalMap: boolean;
  102926. /**
  102927. * Allows using the bump map in parallax mode.
  102928. */
  102929. protected _useParallax: boolean;
  102930. /**
  102931. * Allows using the bump map in parallax occlusion mode.
  102932. */
  102933. protected _useParallaxOcclusion: boolean;
  102934. /**
  102935. * Controls the scale bias of the parallax mode.
  102936. */
  102937. protected _parallaxScaleBias: number;
  102938. /**
  102939. * If sets to true, disables all the lights affecting the material.
  102940. */
  102941. protected _disableLighting: boolean;
  102942. /**
  102943. * Number of Simultaneous lights allowed on the material.
  102944. */
  102945. protected _maxSimultaneousLights: number;
  102946. /**
  102947. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102948. */
  102949. protected _invertNormalMapX: boolean;
  102950. /**
  102951. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102952. */
  102953. protected _invertNormalMapY: boolean;
  102954. /**
  102955. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102956. */
  102957. protected _twoSidedLighting: boolean;
  102958. /**
  102959. * Defines the alpha limits in alpha test mode.
  102960. */
  102961. protected _alphaCutOff: number;
  102962. /**
  102963. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102964. */
  102965. protected _forceAlphaTest: boolean;
  102966. /**
  102967. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102968. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102969. */
  102970. protected _useAlphaFresnel: boolean;
  102971. /**
  102972. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102973. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102974. */
  102975. protected _useLinearAlphaFresnel: boolean;
  102976. /**
  102977. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102978. * from cos thetav and roughness:
  102979. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102980. */
  102981. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102982. /**
  102983. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102984. */
  102985. protected _forceIrradianceInFragment: boolean;
  102986. private _realTimeFiltering;
  102987. /**
  102988. * Enables realtime filtering on the texture.
  102989. */
  102990. get realTimeFiltering(): boolean;
  102991. set realTimeFiltering(b: boolean);
  102992. private _realTimeFilteringQuality;
  102993. /**
  102994. * Quality switch for realtime filtering
  102995. */
  102996. get realTimeFilteringQuality(): number;
  102997. set realTimeFilteringQuality(n: number);
  102998. /**
  102999. * Can this material render to several textures at once
  103000. */
  103001. get canRenderToMRT(): boolean;
  103002. /**
  103003. * Force normal to face away from face.
  103004. */
  103005. protected _forceNormalForward: boolean;
  103006. /**
  103007. * Enables specular anti aliasing in the PBR shader.
  103008. * It will both interacts on the Geometry for analytical and IBL lighting.
  103009. * It also prefilter the roughness map based on the bump values.
  103010. */
  103011. protected _enableSpecularAntiAliasing: boolean;
  103012. /**
  103013. * Default configuration related to image processing available in the PBR Material.
  103014. */
  103015. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103016. /**
  103017. * Keep track of the image processing observer to allow dispose and replace.
  103018. */
  103019. private _imageProcessingObserver;
  103020. /**
  103021. * Attaches a new image processing configuration to the PBR Material.
  103022. * @param configuration
  103023. */
  103024. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103025. /**
  103026. * Stores the available render targets.
  103027. */
  103028. private _renderTargets;
  103029. /**
  103030. * Sets the global ambient color for the material used in lighting calculations.
  103031. */
  103032. private _globalAmbientColor;
  103033. /**
  103034. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  103035. */
  103036. private _useLogarithmicDepth;
  103037. /**
  103038. * If set to true, no lighting calculations will be applied.
  103039. */
  103040. private _unlit;
  103041. private _debugMode;
  103042. /**
  103043. * @hidden
  103044. * This is reserved for the inspector.
  103045. * Defines the material debug mode.
  103046. * It helps seeing only some components of the material while troubleshooting.
  103047. */
  103048. debugMode: number;
  103049. /**
  103050. * @hidden
  103051. * This is reserved for the inspector.
  103052. * Specify from where on screen the debug mode should start.
  103053. * The value goes from -1 (full screen) to 1 (not visible)
  103054. * It helps with side by side comparison against the final render
  103055. * This defaults to -1
  103056. */
  103057. private debugLimit;
  103058. /**
  103059. * @hidden
  103060. * This is reserved for the inspector.
  103061. * As the default viewing range might not be enough (if the ambient is really small for instance)
  103062. * You can use the factor to better multiply the final value.
  103063. */
  103064. private debugFactor;
  103065. /**
  103066. * Defines the clear coat layer parameters for the material.
  103067. */
  103068. readonly clearCoat: PBRClearCoatConfiguration;
  103069. /**
  103070. * Defines the anisotropic parameters for the material.
  103071. */
  103072. readonly anisotropy: PBRAnisotropicConfiguration;
  103073. /**
  103074. * Defines the BRDF parameters for the material.
  103075. */
  103076. readonly brdf: PBRBRDFConfiguration;
  103077. /**
  103078. * Defines the Sheen parameters for the material.
  103079. */
  103080. readonly sheen: PBRSheenConfiguration;
  103081. /**
  103082. * Defines the SubSurface parameters for the material.
  103083. */
  103084. readonly subSurface: PBRSubSurfaceConfiguration;
  103085. /**
  103086. * Defines additionnal PrePass parameters for the material.
  103087. */
  103088. readonly prePassConfiguration: PrePassConfiguration;
  103089. /**
  103090. * Defines the detail map parameters for the material.
  103091. */
  103092. readonly detailMap: DetailMapConfiguration;
  103093. protected _rebuildInParallel: boolean;
  103094. /**
  103095. * Instantiates a new PBRMaterial instance.
  103096. *
  103097. * @param name The material name
  103098. * @param scene The scene the material will be use in.
  103099. */
  103100. constructor(name: string, scene: Scene);
  103101. /**
  103102. * Gets a boolean indicating that current material needs to register RTT
  103103. */
  103104. get hasRenderTargetTextures(): boolean;
  103105. /**
  103106. * Gets the name of the material class.
  103107. */
  103108. getClassName(): string;
  103109. /**
  103110. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103111. */
  103112. get useLogarithmicDepth(): boolean;
  103113. /**
  103114. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103115. */
  103116. set useLogarithmicDepth(value: boolean);
  103117. /**
  103118. * Returns true if alpha blending should be disabled.
  103119. */
  103120. protected get _disableAlphaBlending(): boolean;
  103121. /**
  103122. * Specifies whether or not this material should be rendered in alpha blend mode.
  103123. */
  103124. needAlphaBlending(): boolean;
  103125. /**
  103126. * Specifies whether or not this material should be rendered in alpha test mode.
  103127. */
  103128. needAlphaTesting(): boolean;
  103129. /**
  103130. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  103131. */
  103132. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  103133. /**
  103134. * Specifies whether or not there is a usable alpha channel for transparency.
  103135. */
  103136. protected _hasAlphaChannel(): boolean;
  103137. /**
  103138. * Gets the texture used for the alpha test.
  103139. */
  103140. getAlphaTestTexture(): Nullable<BaseTexture>;
  103141. /**
  103142. * Specifies that the submesh is ready to be used.
  103143. * @param mesh - BJS mesh.
  103144. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  103145. * @param useInstances - Specifies that instances should be used.
  103146. * @returns - boolean indicating that the submesh is ready or not.
  103147. */
  103148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103149. /**
  103150. * Specifies if the material uses metallic roughness workflow.
  103151. * @returns boolean specifiying if the material uses metallic roughness workflow.
  103152. */
  103153. isMetallicWorkflow(): boolean;
  103154. private _prepareEffect;
  103155. private _prepareDefines;
  103156. /**
  103157. * Force shader compilation
  103158. */
  103159. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  103160. /**
  103161. * Initializes the uniform buffer layout for the shader.
  103162. */
  103163. buildUniformLayout(): void;
  103164. /**
  103165. * Unbinds the material from the mesh
  103166. */
  103167. unbind(): void;
  103168. /**
  103169. * Binds the submesh data.
  103170. * @param world - The world matrix.
  103171. * @param mesh - The BJS mesh.
  103172. * @param subMesh - A submesh of the BJS mesh.
  103173. */
  103174. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103175. /**
  103176. * Returns the animatable textures.
  103177. * @returns - Array of animatable textures.
  103178. */
  103179. getAnimatables(): IAnimatable[];
  103180. /**
  103181. * Returns the texture used for reflections.
  103182. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  103183. */
  103184. private _getReflectionTexture;
  103185. /**
  103186. * Returns an array of the actively used textures.
  103187. * @returns - Array of BaseTextures
  103188. */
  103189. getActiveTextures(): BaseTexture[];
  103190. /**
  103191. * Checks to see if a texture is used in the material.
  103192. * @param texture - Base texture to use.
  103193. * @returns - Boolean specifying if a texture is used in the material.
  103194. */
  103195. hasTexture(texture: BaseTexture): boolean;
  103196. /**
  103197. * Sets the required values to the prepass renderer.
  103198. * @param prePassRenderer defines the prepass renderer to setup
  103199. */
  103200. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103201. /**
  103202. * Disposes the resources of the material.
  103203. * @param forceDisposeEffect - Forces the disposal of effects.
  103204. * @param forceDisposeTextures - Forces the disposal of all textures.
  103205. */
  103206. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103207. }
  103208. }
  103209. declare module BABYLON {
  103210. /**
  103211. * The Physically based material of BJS.
  103212. *
  103213. * This offers the main features of a standard PBR material.
  103214. * For more information, please refer to the documentation :
  103215. * https://doc.babylonjs.com/how_to/physically_based_rendering
  103216. */
  103217. export class PBRMaterial extends PBRBaseMaterial {
  103218. /**
  103219. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103220. */
  103221. static readonly PBRMATERIAL_OPAQUE: number;
  103222. /**
  103223. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103224. */
  103225. static readonly PBRMATERIAL_ALPHATEST: number;
  103226. /**
  103227. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103228. */
  103229. static readonly PBRMATERIAL_ALPHABLEND: number;
  103230. /**
  103231. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103232. * They are also discarded below the alpha cutoff threshold to improve performances.
  103233. */
  103234. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  103235. /**
  103236. * Defines the default value of how much AO map is occluding the analytical lights
  103237. * (point spot...).
  103238. */
  103239. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  103240. /**
  103241. * Intensity of the direct lights e.g. the four lights available in your scene.
  103242. * This impacts both the direct diffuse and specular highlights.
  103243. */
  103244. directIntensity: number;
  103245. /**
  103246. * Intensity of the emissive part of the material.
  103247. * This helps controlling the emissive effect without modifying the emissive color.
  103248. */
  103249. emissiveIntensity: number;
  103250. /**
  103251. * Intensity of the environment e.g. how much the environment will light the object
  103252. * either through harmonics for rough material or through the refelction for shiny ones.
  103253. */
  103254. environmentIntensity: number;
  103255. /**
  103256. * This is a special control allowing the reduction of the specular highlights coming from the
  103257. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  103258. */
  103259. specularIntensity: number;
  103260. /**
  103261. * Debug Control allowing disabling the bump map on this material.
  103262. */
  103263. disableBumpMap: boolean;
  103264. /**
  103265. * AKA Diffuse Texture in standard nomenclature.
  103266. */
  103267. albedoTexture: BaseTexture;
  103268. /**
  103269. * AKA Occlusion Texture in other nomenclature.
  103270. */
  103271. ambientTexture: BaseTexture;
  103272. /**
  103273. * AKA Occlusion Texture Intensity in other nomenclature.
  103274. */
  103275. ambientTextureStrength: number;
  103276. /**
  103277. * Defines how much the AO map is occluding the analytical lights (point spot...).
  103278. * 1 means it completely occludes it
  103279. * 0 mean it has no impact
  103280. */
  103281. ambientTextureImpactOnAnalyticalLights: number;
  103282. /**
  103283. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  103284. */
  103285. opacityTexture: BaseTexture;
  103286. /**
  103287. * Stores the reflection values in a texture.
  103288. */
  103289. reflectionTexture: Nullable<BaseTexture>;
  103290. /**
  103291. * Stores the emissive values in a texture.
  103292. */
  103293. emissiveTexture: BaseTexture;
  103294. /**
  103295. * AKA Specular texture in other nomenclature.
  103296. */
  103297. reflectivityTexture: BaseTexture;
  103298. /**
  103299. * Used to switch from specular/glossiness to metallic/roughness workflow.
  103300. */
  103301. metallicTexture: BaseTexture;
  103302. /**
  103303. * Specifies the metallic scalar of the metallic/roughness workflow.
  103304. * Can also be used to scale the metalness values of the metallic texture.
  103305. */
  103306. metallic: Nullable<number>;
  103307. /**
  103308. * Specifies the roughness scalar of the metallic/roughness workflow.
  103309. * Can also be used to scale the roughness values of the metallic texture.
  103310. */
  103311. roughness: Nullable<number>;
  103312. /**
  103313. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  103314. * By default the indexOfrefraction is used to compute F0;
  103315. *
  103316. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  103317. *
  103318. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  103319. * F90 = metallicReflectanceColor;
  103320. */
  103321. metallicF0Factor: number;
  103322. /**
  103323. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  103324. * By default the F90 is always 1;
  103325. *
  103326. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  103327. *
  103328. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  103329. * F90 = metallicReflectanceColor;
  103330. */
  103331. metallicReflectanceColor: Color3;
  103332. /**
  103333. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  103334. * This is multiply against the scalar values defined in the material.
  103335. */
  103336. metallicReflectanceTexture: Nullable<BaseTexture>;
  103337. /**
  103338. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103339. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103340. */
  103341. microSurfaceTexture: BaseTexture;
  103342. /**
  103343. * Stores surface normal data used to displace a mesh in a texture.
  103344. */
  103345. bumpTexture: BaseTexture;
  103346. /**
  103347. * Stores the pre-calculated light information of a mesh in a texture.
  103348. */
  103349. lightmapTexture: BaseTexture;
  103350. /**
  103351. * Stores the refracted light information in a texture.
  103352. */
  103353. get refractionTexture(): Nullable<BaseTexture>;
  103354. set refractionTexture(value: Nullable<BaseTexture>);
  103355. /**
  103356. * The color of a material in ambient lighting.
  103357. */
  103358. ambientColor: Color3;
  103359. /**
  103360. * AKA Diffuse Color in other nomenclature.
  103361. */
  103362. albedoColor: Color3;
  103363. /**
  103364. * AKA Specular Color in other nomenclature.
  103365. */
  103366. reflectivityColor: Color3;
  103367. /**
  103368. * The color reflected from the material.
  103369. */
  103370. reflectionColor: Color3;
  103371. /**
  103372. * The color emitted from the material.
  103373. */
  103374. emissiveColor: Color3;
  103375. /**
  103376. * AKA Glossiness in other nomenclature.
  103377. */
  103378. microSurface: number;
  103379. /**
  103380. * Index of refraction of the material base layer.
  103381. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103382. *
  103383. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  103384. *
  103385. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  103386. */
  103387. get indexOfRefraction(): number;
  103388. set indexOfRefraction(value: number);
  103389. /**
  103390. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103391. */
  103392. get invertRefractionY(): boolean;
  103393. set invertRefractionY(value: boolean);
  103394. /**
  103395. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103396. * Materials half opaque for instance using refraction could benefit from this control.
  103397. */
  103398. get linkRefractionWithTransparency(): boolean;
  103399. set linkRefractionWithTransparency(value: boolean);
  103400. /**
  103401. * If true, the light map contains occlusion information instead of lighting info.
  103402. */
  103403. useLightmapAsShadowmap: boolean;
  103404. /**
  103405. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103406. */
  103407. useAlphaFromAlbedoTexture: boolean;
  103408. /**
  103409. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103410. */
  103411. forceAlphaTest: boolean;
  103412. /**
  103413. * Defines the alpha limits in alpha test mode.
  103414. */
  103415. alphaCutOff: number;
  103416. /**
  103417. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103418. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103419. */
  103420. useSpecularOverAlpha: boolean;
  103421. /**
  103422. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103423. */
  103424. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103425. /**
  103426. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103427. */
  103428. useRoughnessFromMetallicTextureAlpha: boolean;
  103429. /**
  103430. * Specifies if the metallic texture contains the roughness information in its green channel.
  103431. */
  103432. useRoughnessFromMetallicTextureGreen: boolean;
  103433. /**
  103434. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103435. */
  103436. useMetallnessFromMetallicTextureBlue: boolean;
  103437. /**
  103438. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103439. */
  103440. useAmbientOcclusionFromMetallicTextureRed: boolean;
  103441. /**
  103442. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103443. */
  103444. useAmbientInGrayScale: boolean;
  103445. /**
  103446. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103447. * The material will try to infer what glossiness each pixel should be.
  103448. */
  103449. useAutoMicroSurfaceFromReflectivityMap: boolean;
  103450. /**
  103451. * BJS is using an harcoded light falloff based on a manually sets up range.
  103452. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103453. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103454. */
  103455. get usePhysicalLightFalloff(): boolean;
  103456. /**
  103457. * BJS is using an harcoded light falloff based on a manually sets up range.
  103458. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103459. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103460. */
  103461. set usePhysicalLightFalloff(value: boolean);
  103462. /**
  103463. * In order to support the falloff compatibility with gltf, a special mode has been added
  103464. * to reproduce the gltf light falloff.
  103465. */
  103466. get useGLTFLightFalloff(): boolean;
  103467. /**
  103468. * In order to support the falloff compatibility with gltf, a special mode has been added
  103469. * to reproduce the gltf light falloff.
  103470. */
  103471. set useGLTFLightFalloff(value: boolean);
  103472. /**
  103473. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103474. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103475. */
  103476. useRadianceOverAlpha: boolean;
  103477. /**
  103478. * Allows using an object space normal map (instead of tangent space).
  103479. */
  103480. useObjectSpaceNormalMap: boolean;
  103481. /**
  103482. * Allows using the bump map in parallax mode.
  103483. */
  103484. useParallax: boolean;
  103485. /**
  103486. * Allows using the bump map in parallax occlusion mode.
  103487. */
  103488. useParallaxOcclusion: boolean;
  103489. /**
  103490. * Controls the scale bias of the parallax mode.
  103491. */
  103492. parallaxScaleBias: number;
  103493. /**
  103494. * If sets to true, disables all the lights affecting the material.
  103495. */
  103496. disableLighting: boolean;
  103497. /**
  103498. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103499. */
  103500. forceIrradianceInFragment: boolean;
  103501. /**
  103502. * Number of Simultaneous lights allowed on the material.
  103503. */
  103504. maxSimultaneousLights: number;
  103505. /**
  103506. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103507. */
  103508. invertNormalMapX: boolean;
  103509. /**
  103510. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103511. */
  103512. invertNormalMapY: boolean;
  103513. /**
  103514. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103515. */
  103516. twoSidedLighting: boolean;
  103517. /**
  103518. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103519. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103520. */
  103521. useAlphaFresnel: boolean;
  103522. /**
  103523. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103524. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103525. */
  103526. useLinearAlphaFresnel: boolean;
  103527. /**
  103528. * Let user defines the brdf lookup texture used for IBL.
  103529. * A default 8bit version is embedded but you could point at :
  103530. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  103531. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103532. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  103533. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103534. */
  103535. environmentBRDFTexture: Nullable<BaseTexture>;
  103536. /**
  103537. * Force normal to face away from face.
  103538. */
  103539. forceNormalForward: boolean;
  103540. /**
  103541. * Enables specular anti aliasing in the PBR shader.
  103542. * It will both interacts on the Geometry for analytical and IBL lighting.
  103543. * It also prefilter the roughness map based on the bump values.
  103544. */
  103545. enableSpecularAntiAliasing: boolean;
  103546. /**
  103547. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103548. * makes the reflect vector face the model (under horizon).
  103549. */
  103550. useHorizonOcclusion: boolean;
  103551. /**
  103552. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103553. * too much the area relying on ambient texture to define their ambient occlusion.
  103554. */
  103555. useRadianceOcclusion: boolean;
  103556. /**
  103557. * If set to true, no lighting calculations will be applied.
  103558. */
  103559. unlit: boolean;
  103560. /**
  103561. * Gets the image processing configuration used either in this material.
  103562. */
  103563. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103564. /**
  103565. * Sets the Default image processing configuration used either in the this material.
  103566. *
  103567. * If sets to null, the scene one is in use.
  103568. */
  103569. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103570. /**
  103571. * Gets wether the color curves effect is enabled.
  103572. */
  103573. get cameraColorCurvesEnabled(): boolean;
  103574. /**
  103575. * Sets wether the color curves effect is enabled.
  103576. */
  103577. set cameraColorCurvesEnabled(value: boolean);
  103578. /**
  103579. * Gets wether the color grading effect is enabled.
  103580. */
  103581. get cameraColorGradingEnabled(): boolean;
  103582. /**
  103583. * Gets wether the color grading effect is enabled.
  103584. */
  103585. set cameraColorGradingEnabled(value: boolean);
  103586. /**
  103587. * Gets wether tonemapping is enabled or not.
  103588. */
  103589. get cameraToneMappingEnabled(): boolean;
  103590. /**
  103591. * Sets wether tonemapping is enabled or not
  103592. */
  103593. set cameraToneMappingEnabled(value: boolean);
  103594. /**
  103595. * The camera exposure used on this material.
  103596. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103597. * This corresponds to a photographic exposure.
  103598. */
  103599. get cameraExposure(): number;
  103600. /**
  103601. * The camera exposure used on this material.
  103602. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103603. * This corresponds to a photographic exposure.
  103604. */
  103605. set cameraExposure(value: number);
  103606. /**
  103607. * Gets The camera contrast used on this material.
  103608. */
  103609. get cameraContrast(): number;
  103610. /**
  103611. * Sets The camera contrast used on this material.
  103612. */
  103613. set cameraContrast(value: number);
  103614. /**
  103615. * Gets the Color Grading 2D Lookup Texture.
  103616. */
  103617. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  103618. /**
  103619. * Sets the Color Grading 2D Lookup Texture.
  103620. */
  103621. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  103622. /**
  103623. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103624. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103625. * 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;
  103626. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103627. */
  103628. get cameraColorCurves(): Nullable<ColorCurves>;
  103629. /**
  103630. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103631. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103632. * 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;
  103633. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103634. */
  103635. set cameraColorCurves(value: Nullable<ColorCurves>);
  103636. /**
  103637. * Instantiates a new PBRMaterial instance.
  103638. *
  103639. * @param name The material name
  103640. * @param scene The scene the material will be use in.
  103641. */
  103642. constructor(name: string, scene: Scene);
  103643. /**
  103644. * Returns the name of this material class.
  103645. */
  103646. getClassName(): string;
  103647. /**
  103648. * Makes a duplicate of the current material.
  103649. * @param name - name to use for the new material.
  103650. */
  103651. clone(name: string): PBRMaterial;
  103652. /**
  103653. * Serializes this PBR Material.
  103654. * @returns - An object with the serialized material.
  103655. */
  103656. serialize(): any;
  103657. /**
  103658. * Parses a PBR Material from a serialized object.
  103659. * @param source - Serialized object.
  103660. * @param scene - BJS scene instance.
  103661. * @param rootUrl - url for the scene object
  103662. * @returns - PBRMaterial
  103663. */
  103664. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103665. }
  103666. }
  103667. declare module BABYLON {
  103668. /** @hidden */
  103669. export var mrtFragmentDeclaration: {
  103670. name: string;
  103671. shader: string;
  103672. };
  103673. }
  103674. declare module BABYLON {
  103675. /** @hidden */
  103676. export var geometryPixelShader: {
  103677. name: string;
  103678. shader: string;
  103679. };
  103680. }
  103681. declare module BABYLON {
  103682. /** @hidden */
  103683. export var geometryVertexShader: {
  103684. name: string;
  103685. shader: string;
  103686. };
  103687. }
  103688. declare module BABYLON {
  103689. /** @hidden */
  103690. interface ISavedTransformationMatrix {
  103691. world: Matrix;
  103692. viewProjection: Matrix;
  103693. }
  103694. /**
  103695. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  103696. */
  103697. export class GeometryBufferRenderer {
  103698. /**
  103699. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  103700. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  103701. */
  103702. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  103703. /**
  103704. * Constant used to retrieve the position texture index in the G-Buffer textures array
  103705. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  103706. */
  103707. static readonly POSITION_TEXTURE_TYPE: number;
  103708. /**
  103709. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  103710. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  103711. */
  103712. static readonly VELOCITY_TEXTURE_TYPE: number;
  103713. /**
  103714. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  103715. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  103716. */
  103717. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  103718. /**
  103719. * Dictionary used to store the previous transformation matrices of each rendered mesh
  103720. * in order to compute objects velocities when enableVelocity is set to "true"
  103721. * @hidden
  103722. */
  103723. _previousTransformationMatrices: {
  103724. [index: number]: ISavedTransformationMatrix;
  103725. };
  103726. /**
  103727. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  103728. * in order to compute objects velocities when enableVelocity is set to "true"
  103729. * @hidden
  103730. */
  103731. _previousBonesTransformationMatrices: {
  103732. [index: number]: Float32Array;
  103733. };
  103734. /**
  103735. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  103736. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  103737. */
  103738. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  103739. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  103740. renderTransparentMeshes: boolean;
  103741. private _scene;
  103742. private _resizeObserver;
  103743. private _multiRenderTarget;
  103744. private _ratio;
  103745. private _enablePosition;
  103746. private _enableVelocity;
  103747. private _enableReflectivity;
  103748. private _positionIndex;
  103749. private _velocityIndex;
  103750. private _reflectivityIndex;
  103751. private _depthNormalIndex;
  103752. private _linkedWithPrePass;
  103753. private _prePassRenderer;
  103754. private _attachments;
  103755. protected _effect: Effect;
  103756. protected _cachedDefines: string;
  103757. /**
  103758. * @hidden
  103759. * Sets up internal structures to share outputs with PrePassRenderer
  103760. * This method should only be called by the PrePassRenderer itself
  103761. */
  103762. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  103763. /**
  103764. * @hidden
  103765. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  103766. * This method should only be called by the PrePassRenderer itself
  103767. */
  103768. _unlinkPrePassRenderer(): void;
  103769. /**
  103770. * @hidden
  103771. * Resets the geometry buffer layout
  103772. */
  103773. _resetLayout(): void;
  103774. /**
  103775. * @hidden
  103776. * Replaces a texture in the geometry buffer renderer
  103777. * Useful when linking textures of the prepass renderer
  103778. */
  103779. _forceTextureType(geometryBufferType: number, index: number): void;
  103780. /**
  103781. * @hidden
  103782. * Sets texture attachments
  103783. * Useful when linking textures of the prepass renderer
  103784. */
  103785. _setAttachments(attachments: number[]): void;
  103786. /**
  103787. * @hidden
  103788. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  103789. * Useful when linking textures of the prepass renderer
  103790. */
  103791. _linkInternalTexture(internalTexture: InternalTexture): void;
  103792. /**
  103793. * Gets the render list (meshes to be rendered) used in the G buffer.
  103794. */
  103795. get renderList(): Nullable<AbstractMesh[]>;
  103796. /**
  103797. * Set the render list (meshes to be rendered) used in the G buffer.
  103798. */
  103799. set renderList(meshes: Nullable<AbstractMesh[]>);
  103800. /**
  103801. * Gets wether or not G buffer are supported by the running hardware.
  103802. * This requires draw buffer supports
  103803. */
  103804. get isSupported(): boolean;
  103805. /**
  103806. * Returns the index of the given texture type in the G-Buffer textures array
  103807. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  103808. * @returns the index of the given texture type in the G-Buffer textures array
  103809. */
  103810. getTextureIndex(textureType: number): number;
  103811. /**
  103812. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  103813. */
  103814. get enablePosition(): boolean;
  103815. /**
  103816. * Sets whether or not objects positions are enabled for the G buffer.
  103817. */
  103818. set enablePosition(enable: boolean);
  103819. /**
  103820. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  103821. */
  103822. get enableVelocity(): boolean;
  103823. /**
  103824. * Sets wether or not objects velocities are enabled for the G buffer.
  103825. */
  103826. set enableVelocity(enable: boolean);
  103827. /**
  103828. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  103829. */
  103830. get enableReflectivity(): boolean;
  103831. /**
  103832. * Sets wether or not objects roughness are enabled for the G buffer.
  103833. */
  103834. set enableReflectivity(enable: boolean);
  103835. /**
  103836. * Gets the scene associated with the buffer.
  103837. */
  103838. get scene(): Scene;
  103839. /**
  103840. * Gets the ratio used by the buffer during its creation.
  103841. * How big is the buffer related to the main canvas.
  103842. */
  103843. get ratio(): number;
  103844. /** @hidden */
  103845. static _SceneComponentInitialization: (scene: Scene) => void;
  103846. /**
  103847. * Creates a new G Buffer for the scene
  103848. * @param scene The scene the buffer belongs to
  103849. * @param ratio How big is the buffer related to the main canvas.
  103850. */
  103851. constructor(scene: Scene, ratio?: number);
  103852. /**
  103853. * Checks wether everything is ready to render a submesh to the G buffer.
  103854. * @param subMesh the submesh to check readiness for
  103855. * @param useInstances is the mesh drawn using instance or not
  103856. * @returns true if ready otherwise false
  103857. */
  103858. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103859. /**
  103860. * Gets the current underlying G Buffer.
  103861. * @returns the buffer
  103862. */
  103863. getGBuffer(): MultiRenderTarget;
  103864. /**
  103865. * Gets the number of samples used to render the buffer (anti aliasing).
  103866. */
  103867. get samples(): number;
  103868. /**
  103869. * Sets the number of samples used to render the buffer (anti aliasing).
  103870. */
  103871. set samples(value: number);
  103872. /**
  103873. * Disposes the renderer and frees up associated resources.
  103874. */
  103875. dispose(): void;
  103876. private _assignRenderTargetIndices;
  103877. protected _createRenderTargets(): void;
  103878. private _copyBonesTransformationMatrices;
  103879. }
  103880. }
  103881. declare module BABYLON {
  103882. /**
  103883. * Renders a pre pass of the scene
  103884. * This means every mesh in the scene will be rendered to a render target texture
  103885. * And then this texture will be composited to the rendering canvas with post processes
  103886. * It is necessary for effects like subsurface scattering or deferred shading
  103887. */
  103888. export class PrePassRenderer {
  103889. /** @hidden */
  103890. static _SceneComponentInitialization: (scene: Scene) => void;
  103891. private _textureFormats;
  103892. /**
  103893. * To save performance, we can excluded skinned meshes from the prepass
  103894. */
  103895. excludedSkinnedMesh: AbstractMesh[];
  103896. /**
  103897. * Force material to be excluded from the prepass
  103898. * Can be useful when `useGeometryBufferFallback` is set to `true`
  103899. * and you don't want a material to show in the effect.
  103900. */
  103901. excludedMaterials: Material[];
  103902. private _textureIndices;
  103903. private _scene;
  103904. private _engine;
  103905. private _isDirty;
  103906. /**
  103907. * Number of textures in the multi render target texture where the scene is directly rendered
  103908. */
  103909. mrtCount: number;
  103910. /**
  103911. * The render target where the scene is directly rendered
  103912. */
  103913. prePassRT: MultiRenderTarget;
  103914. private _multiRenderAttachments;
  103915. private _defaultAttachments;
  103916. private _clearAttachments;
  103917. private _postProcesses;
  103918. private readonly _clearColor;
  103919. /**
  103920. * Image processing post process for composition
  103921. */
  103922. imageProcessingPostProcess: ImageProcessingPostProcess;
  103923. /**
  103924. * Configuration for prepass effects
  103925. */
  103926. private _effectConfigurations;
  103927. private _mrtFormats;
  103928. private _mrtLayout;
  103929. private _enabled;
  103930. /**
  103931. * Indicates if the prepass is enabled
  103932. */
  103933. get enabled(): boolean;
  103934. /**
  103935. * How many samples are used for MSAA of the scene render target
  103936. */
  103937. get samples(): number;
  103938. set samples(n: number);
  103939. private _geometryBuffer;
  103940. private _useGeometryBufferFallback;
  103941. /**
  103942. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  103943. */
  103944. get useGeometryBufferFallback(): boolean;
  103945. set useGeometryBufferFallback(value: boolean);
  103946. /**
  103947. * Set to true to disable gamma transform in PrePass.
  103948. * Can be useful in case you already proceed to gamma transform on a material level
  103949. * and your post processes don't need to be in linear color space.
  103950. */
  103951. disableGammaTransform: boolean;
  103952. /**
  103953. * Instanciates a prepass renderer
  103954. * @param scene The scene
  103955. */
  103956. constructor(scene: Scene);
  103957. private _initializeAttachments;
  103958. private _createCompositionEffect;
  103959. /**
  103960. * Indicates if rendering a prepass is supported
  103961. */
  103962. get isSupported(): boolean;
  103963. /**
  103964. * Sets the proper output textures to draw in the engine.
  103965. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103966. * @param subMesh Submesh on which the effect is applied
  103967. */
  103968. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  103969. /**
  103970. * Restores attachments for single texture draw.
  103971. */
  103972. restoreAttachments(): void;
  103973. /**
  103974. * @hidden
  103975. */
  103976. _beforeCameraDraw(): void;
  103977. /**
  103978. * @hidden
  103979. */
  103980. _afterCameraDraw(): void;
  103981. private _checkRTSize;
  103982. private _bindFrameBuffer;
  103983. /**
  103984. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103985. */
  103986. clear(): void;
  103987. private _setState;
  103988. private _updateGeometryBufferLayout;
  103989. /**
  103990. * Adds an effect configuration to the prepass.
  103991. * If an effect has already been added, it won't add it twice and will return the configuration
  103992. * already present.
  103993. * @param cfg the effect configuration
  103994. * @return the effect configuration now used by the prepass
  103995. */
  103996. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  103997. /**
  103998. * Returns the index of a texture in the multi render target texture array.
  103999. * @param type Texture type
  104000. * @return The index
  104001. */
  104002. getIndex(type: number): number;
  104003. private _enable;
  104004. private _disable;
  104005. private _resetLayout;
  104006. private _resetPostProcessChain;
  104007. private _bindPostProcessChain;
  104008. /**
  104009. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104010. */
  104011. markAsDirty(): void;
  104012. /**
  104013. * Enables a texture on the MultiRenderTarget for prepass
  104014. */
  104015. private _enableTextures;
  104016. private _update;
  104017. private _markAllMaterialsAsPrePassDirty;
  104018. /**
  104019. * Disposes the prepass renderer.
  104020. */
  104021. dispose(): void;
  104022. }
  104023. }
  104024. declare module BABYLON {
  104025. /**
  104026. * Size options for a post process
  104027. */
  104028. export type PostProcessOptions = {
  104029. width: number;
  104030. height: number;
  104031. };
  104032. /**
  104033. * PostProcess can be used to apply a shader to a texture after it has been rendered
  104034. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  104035. */
  104036. export class PostProcess {
  104037. /**
  104038. * Gets or sets the unique id of the post process
  104039. */
  104040. uniqueId: number;
  104041. /** Name of the PostProcess. */
  104042. name: string;
  104043. /**
  104044. * Width of the texture to apply the post process on
  104045. */
  104046. width: number;
  104047. /**
  104048. * Height of the texture to apply the post process on
  104049. */
  104050. height: number;
  104051. /**
  104052. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  104053. */
  104054. nodeMaterialSource: Nullable<NodeMaterial>;
  104055. /**
  104056. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  104057. * @hidden
  104058. */
  104059. _outputTexture: Nullable<InternalTexture>;
  104060. /**
  104061. * Sampling mode used by the shader
  104062. * See https://doc.babylonjs.com/classes/3.1/texture
  104063. */
  104064. renderTargetSamplingMode: number;
  104065. /**
  104066. * Clear color to use when screen clearing
  104067. */
  104068. clearColor: Color4;
  104069. /**
  104070. * If the buffer needs to be cleared before applying the post process. (default: true)
  104071. * Should be set to false if shader will overwrite all previous pixels.
  104072. */
  104073. autoClear: boolean;
  104074. /**
  104075. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  104076. */
  104077. alphaMode: number;
  104078. /**
  104079. * Sets the setAlphaBlendConstants of the babylon engine
  104080. */
  104081. alphaConstants: Color4;
  104082. /**
  104083. * Animations to be used for the post processing
  104084. */
  104085. animations: Animation[];
  104086. /**
  104087. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  104088. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  104089. */
  104090. enablePixelPerfectMode: boolean;
  104091. /**
  104092. * Force the postprocess to be applied without taking in account viewport
  104093. */
  104094. forceFullscreenViewport: boolean;
  104095. /**
  104096. * List of inspectable custom properties (used by the Inspector)
  104097. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104098. */
  104099. inspectableCustomProperties: IInspectable[];
  104100. /**
  104101. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  104102. *
  104103. * | Value | Type | Description |
  104104. * | ----- | ----------------------------------- | ----------- |
  104105. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  104106. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  104107. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  104108. *
  104109. */
  104110. scaleMode: number;
  104111. /**
  104112. * Force textures to be a power of two (default: false)
  104113. */
  104114. alwaysForcePOT: boolean;
  104115. private _samples;
  104116. /**
  104117. * Number of sample textures (default: 1)
  104118. */
  104119. get samples(): number;
  104120. set samples(n: number);
  104121. /**
  104122. * Modify the scale of the post process to be the same as the viewport (default: false)
  104123. */
  104124. adaptScaleToCurrentViewport: boolean;
  104125. private _camera;
  104126. protected _scene: Scene;
  104127. private _engine;
  104128. private _options;
  104129. private _reusable;
  104130. private _textureType;
  104131. private _textureFormat;
  104132. /**
  104133. * Smart array of input and output textures for the post process.
  104134. * @hidden
  104135. */
  104136. _textures: SmartArray<InternalTexture>;
  104137. /**
  104138. * The index in _textures that corresponds to the output texture.
  104139. * @hidden
  104140. */
  104141. _currentRenderTextureInd: number;
  104142. private _effect;
  104143. private _samplers;
  104144. private _fragmentUrl;
  104145. private _vertexUrl;
  104146. private _parameters;
  104147. private _scaleRatio;
  104148. protected _indexParameters: any;
  104149. private _shareOutputWithPostProcess;
  104150. private _texelSize;
  104151. private _forcedOutputTexture;
  104152. /**
  104153. * Prepass configuration in case this post process needs a texture from prepass
  104154. * @hidden
  104155. */
  104156. _prePassEffectConfiguration: PrePassEffectConfiguration;
  104157. /**
  104158. * Returns the fragment url or shader name used in the post process.
  104159. * @returns the fragment url or name in the shader store.
  104160. */
  104161. getEffectName(): string;
  104162. /**
  104163. * An event triggered when the postprocess is activated.
  104164. */
  104165. onActivateObservable: Observable<Camera>;
  104166. private _onActivateObserver;
  104167. /**
  104168. * A function that is added to the onActivateObservable
  104169. */
  104170. set onActivate(callback: Nullable<(camera: Camera) => void>);
  104171. /**
  104172. * An event triggered when the postprocess changes its size.
  104173. */
  104174. onSizeChangedObservable: Observable<PostProcess>;
  104175. private _onSizeChangedObserver;
  104176. /**
  104177. * A function that is added to the onSizeChangedObservable
  104178. */
  104179. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  104180. /**
  104181. * An event triggered when the postprocess applies its effect.
  104182. */
  104183. onApplyObservable: Observable<Effect>;
  104184. private _onApplyObserver;
  104185. /**
  104186. * A function that is added to the onApplyObservable
  104187. */
  104188. set onApply(callback: (effect: Effect) => void);
  104189. /**
  104190. * An event triggered before rendering the postprocess
  104191. */
  104192. onBeforeRenderObservable: Observable<Effect>;
  104193. private _onBeforeRenderObserver;
  104194. /**
  104195. * A function that is added to the onBeforeRenderObservable
  104196. */
  104197. set onBeforeRender(callback: (effect: Effect) => void);
  104198. /**
  104199. * An event triggered after rendering the postprocess
  104200. */
  104201. onAfterRenderObservable: Observable<Effect>;
  104202. private _onAfterRenderObserver;
  104203. /**
  104204. * A function that is added to the onAfterRenderObservable
  104205. */
  104206. set onAfterRender(callback: (efect: Effect) => void);
  104207. /**
  104208. * 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
  104209. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  104210. */
  104211. get inputTexture(): InternalTexture;
  104212. set inputTexture(value: InternalTexture);
  104213. /**
  104214. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  104215. * the only way to unset it is to use this function to restore its internal state
  104216. */
  104217. restoreDefaultInputTexture(): void;
  104218. /**
  104219. * Gets the camera which post process is applied to.
  104220. * @returns The camera the post process is applied to.
  104221. */
  104222. getCamera(): Camera;
  104223. /**
  104224. * Gets the texel size of the postprocess.
  104225. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  104226. */
  104227. get texelSize(): Vector2;
  104228. /**
  104229. * Creates a new instance PostProcess
  104230. * @param name The name of the PostProcess.
  104231. * @param fragmentUrl The url of the fragment shader to be used.
  104232. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  104233. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  104234. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104235. * @param camera The camera to apply the render pass to.
  104236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104237. * @param engine The engine which the post process will be applied. (default: current engine)
  104238. * @param reusable If the post process can be reused on the same frame. (default: false)
  104239. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  104240. * @param textureType Type of textures used when performing the post process. (default: 0)
  104241. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  104242. * @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
  104243. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  104244. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104245. */
  104246. 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);
  104247. /**
  104248. * Gets a string identifying the name of the class
  104249. * @returns "PostProcess" string
  104250. */
  104251. getClassName(): string;
  104252. /**
  104253. * Gets the engine which this post process belongs to.
  104254. * @returns The engine the post process was enabled with.
  104255. */
  104256. getEngine(): Engine;
  104257. /**
  104258. * The effect that is created when initializing the post process.
  104259. * @returns The created effect corresponding the the postprocess.
  104260. */
  104261. getEffect(): Effect;
  104262. /**
  104263. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  104264. * @param postProcess The post process to share the output with.
  104265. * @returns This post process.
  104266. */
  104267. shareOutputWith(postProcess: PostProcess): PostProcess;
  104268. /**
  104269. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  104270. * This should be called if the post process that shares output with this post process is disabled/disposed.
  104271. */
  104272. useOwnOutput(): void;
  104273. /**
  104274. * Updates the effect with the current post process compile time values and recompiles the shader.
  104275. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104276. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104277. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104278. * @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
  104279. * @param onCompiled Called when the shader has been compiled.
  104280. * @param onError Called if there is an error when compiling a shader.
  104281. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  104282. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  104283. */
  104284. 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;
  104285. /**
  104286. * The post process is reusable if it can be used multiple times within one frame.
  104287. * @returns If the post process is reusable
  104288. */
  104289. isReusable(): boolean;
  104290. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  104291. markTextureDirty(): void;
  104292. /**
  104293. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  104294. * 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.
  104295. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  104296. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  104297. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  104298. * @returns The target texture that was bound to be written to.
  104299. */
  104300. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  104301. /**
  104302. * If the post process is supported.
  104303. */
  104304. get isSupported(): boolean;
  104305. /**
  104306. * The aspect ratio of the output texture.
  104307. */
  104308. get aspectRatio(): number;
  104309. /**
  104310. * Get a value indicating if the post-process is ready to be used
  104311. * @returns true if the post-process is ready (shader is compiled)
  104312. */
  104313. isReady(): boolean;
  104314. /**
  104315. * Binds all textures and uniforms to the shader, this will be run on every pass.
  104316. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  104317. */
  104318. apply(): Nullable<Effect>;
  104319. private _disposeTextures;
  104320. /**
  104321. * Sets the required values to the prepass renderer.
  104322. * @param prePassRenderer defines the prepass renderer to setup.
  104323. * @returns true if the pre pass is needed.
  104324. */
  104325. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104326. /**
  104327. * Disposes the post process.
  104328. * @param camera The camera to dispose the post process on.
  104329. */
  104330. dispose(camera?: Camera): void;
  104331. /**
  104332. * Serializes the particle system to a JSON object
  104333. * @returns the JSON object
  104334. */
  104335. serialize(): any;
  104336. /**
  104337. * Creates a material from parsed material data
  104338. * @param parsedPostProcess defines parsed post process data
  104339. * @param scene defines the hosting scene
  104340. * @param rootUrl defines the root URL to use to load textures
  104341. * @returns a new post process
  104342. */
  104343. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  104344. }
  104345. }
  104346. declare module BABYLON {
  104347. /** @hidden */
  104348. export var kernelBlurVaryingDeclaration: {
  104349. name: string;
  104350. shader: string;
  104351. };
  104352. }
  104353. declare module BABYLON {
  104354. /** @hidden */
  104355. export var packingFunctions: {
  104356. name: string;
  104357. shader: string;
  104358. };
  104359. }
  104360. declare module BABYLON {
  104361. /** @hidden */
  104362. export var kernelBlurFragment: {
  104363. name: string;
  104364. shader: string;
  104365. };
  104366. }
  104367. declare module BABYLON {
  104368. /** @hidden */
  104369. export var kernelBlurFragment2: {
  104370. name: string;
  104371. shader: string;
  104372. };
  104373. }
  104374. declare module BABYLON {
  104375. /** @hidden */
  104376. export var kernelBlurPixelShader: {
  104377. name: string;
  104378. shader: string;
  104379. };
  104380. }
  104381. declare module BABYLON {
  104382. /** @hidden */
  104383. export var kernelBlurVertex: {
  104384. name: string;
  104385. shader: string;
  104386. };
  104387. }
  104388. declare module BABYLON {
  104389. /** @hidden */
  104390. export var kernelBlurVertexShader: {
  104391. name: string;
  104392. shader: string;
  104393. };
  104394. }
  104395. declare module BABYLON {
  104396. /**
  104397. * The Blur Post Process which blurs an image based on a kernel and direction.
  104398. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  104399. */
  104400. export class BlurPostProcess extends PostProcess {
  104401. private blockCompilation;
  104402. protected _kernel: number;
  104403. protected _idealKernel: number;
  104404. protected _packedFloat: boolean;
  104405. private _staticDefines;
  104406. /** The direction in which to blur the image. */
  104407. direction: Vector2;
  104408. /**
  104409. * Sets the length in pixels of the blur sample region
  104410. */
  104411. set kernel(v: number);
  104412. /**
  104413. * Gets the length in pixels of the blur sample region
  104414. */
  104415. get kernel(): number;
  104416. /**
  104417. * Sets wether or not the blur needs to unpack/repack floats
  104418. */
  104419. set packedFloat(v: boolean);
  104420. /**
  104421. * Gets wether or not the blur is unpacking/repacking floats
  104422. */
  104423. get packedFloat(): boolean;
  104424. /**
  104425. * Gets a string identifying the name of the class
  104426. * @returns "BlurPostProcess" string
  104427. */
  104428. getClassName(): string;
  104429. /**
  104430. * Creates a new instance BlurPostProcess
  104431. * @param name The name of the effect.
  104432. * @param direction The direction in which to blur the image.
  104433. * @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.
  104434. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104435. * @param camera The camera to apply the render pass to.
  104436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104437. * @param engine The engine which the post process will be applied. (default: current engine)
  104438. * @param reusable If the post process can be reused on the same frame. (default: false)
  104439. * @param textureType Type of textures used when performing the post process. (default: 0)
  104440. * @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)
  104441. */
  104442. 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);
  104443. /**
  104444. * Updates the effect with the current post process compile time values and recompiles the shader.
  104445. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104446. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104447. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104448. * @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
  104449. * @param onCompiled Called when the shader has been compiled.
  104450. * @param onError Called if there is an error when compiling a shader.
  104451. */
  104452. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104453. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104454. /**
  104455. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  104456. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  104457. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  104458. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  104459. * The gaps between physical kernels are compensated for in the weighting of the samples
  104460. * @param idealKernel Ideal blur kernel.
  104461. * @return Nearest best kernel.
  104462. */
  104463. protected _nearestBestKernel(idealKernel: number): number;
  104464. /**
  104465. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  104466. * @param x The point on the Gaussian distribution to sample.
  104467. * @return the value of the Gaussian function at x.
  104468. */
  104469. protected _gaussianWeight(x: number): number;
  104470. /**
  104471. * Generates a string that can be used as a floating point number in GLSL.
  104472. * @param x Value to print.
  104473. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  104474. * @return GLSL float string.
  104475. */
  104476. protected _glslFloat(x: number, decimalFigures?: number): string;
  104477. /** @hidden */
  104478. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  104479. }
  104480. }
  104481. declare module BABYLON {
  104482. /**
  104483. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104484. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104485. * You can then easily use it as a reflectionTexture on a flat surface.
  104486. * In case the surface is not a plane, please consider relying on reflection probes.
  104487. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104488. */
  104489. export class MirrorTexture extends RenderTargetTexture {
  104490. private scene;
  104491. /**
  104492. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  104493. * 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.
  104494. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104495. */
  104496. mirrorPlane: Plane;
  104497. /**
  104498. * Define the blur ratio used to blur the reflection if needed.
  104499. */
  104500. set blurRatio(value: number);
  104501. get blurRatio(): number;
  104502. /**
  104503. * Define the adaptive blur kernel used to blur the reflection if needed.
  104504. * This will autocompute the closest best match for the `blurKernel`
  104505. */
  104506. set adaptiveBlurKernel(value: number);
  104507. /**
  104508. * Define the blur kernel used to blur the reflection if needed.
  104509. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104510. */
  104511. set blurKernel(value: number);
  104512. /**
  104513. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  104514. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104515. */
  104516. set blurKernelX(value: number);
  104517. get blurKernelX(): number;
  104518. /**
  104519. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  104520. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104521. */
  104522. set blurKernelY(value: number);
  104523. get blurKernelY(): number;
  104524. private _autoComputeBlurKernel;
  104525. protected _onRatioRescale(): void;
  104526. private _updateGammaSpace;
  104527. private _imageProcessingConfigChangeObserver;
  104528. private _transformMatrix;
  104529. private _mirrorMatrix;
  104530. private _savedViewMatrix;
  104531. private _blurX;
  104532. private _blurY;
  104533. private _adaptiveBlurKernel;
  104534. private _blurKernelX;
  104535. private _blurKernelY;
  104536. private _blurRatio;
  104537. /**
  104538. * Instantiates a Mirror Texture.
  104539. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104540. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104541. * You can then easily use it as a reflectionTexture on a flat surface.
  104542. * In case the surface is not a plane, please consider relying on reflection probes.
  104543. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104544. * @param name
  104545. * @param size
  104546. * @param scene
  104547. * @param generateMipMaps
  104548. * @param type
  104549. * @param samplingMode
  104550. * @param generateDepthBuffer
  104551. */
  104552. constructor(name: string, size: number | {
  104553. width: number;
  104554. height: number;
  104555. } | {
  104556. ratio: number;
  104557. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  104558. private _preparePostProcesses;
  104559. /**
  104560. * Clone the mirror texture.
  104561. * @returns the cloned texture
  104562. */
  104563. clone(): MirrorTexture;
  104564. /**
  104565. * Serialize the texture to a JSON representation you could use in Parse later on
  104566. * @returns the serialized JSON representation
  104567. */
  104568. serialize(): any;
  104569. /**
  104570. * Dispose the texture and release its associated resources.
  104571. */
  104572. dispose(): void;
  104573. }
  104574. }
  104575. declare module BABYLON {
  104576. /**
  104577. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104578. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104579. */
  104580. export class Texture extends BaseTexture {
  104581. /**
  104582. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  104583. */
  104584. static SerializeBuffers: boolean;
  104585. /**
  104586. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  104587. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  104588. */
  104589. static ForceSerializeBuffers: boolean;
  104590. /** @hidden */
  104591. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  104592. /** @hidden */
  104593. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  104594. /** @hidden */
  104595. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  104596. /** nearest is mag = nearest and min = nearest and mip = linear */
  104597. static readonly NEAREST_SAMPLINGMODE: number;
  104598. /** nearest is mag = nearest and min = nearest and mip = linear */
  104599. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  104600. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104601. static readonly BILINEAR_SAMPLINGMODE: number;
  104602. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104603. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  104604. /** Trilinear is mag = linear and min = linear and mip = linear */
  104605. static readonly TRILINEAR_SAMPLINGMODE: number;
  104606. /** Trilinear is mag = linear and min = linear and mip = linear */
  104607. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  104608. /** mag = nearest and min = nearest and mip = nearest */
  104609. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  104610. /** mag = nearest and min = linear and mip = nearest */
  104611. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  104612. /** mag = nearest and min = linear and mip = linear */
  104613. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  104614. /** mag = nearest and min = linear and mip = none */
  104615. static readonly NEAREST_LINEAR: number;
  104616. /** mag = nearest and min = nearest and mip = none */
  104617. static readonly NEAREST_NEAREST: number;
  104618. /** mag = linear and min = nearest and mip = nearest */
  104619. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  104620. /** mag = linear and min = nearest and mip = linear */
  104621. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  104622. /** mag = linear and min = linear and mip = none */
  104623. static readonly LINEAR_LINEAR: number;
  104624. /** mag = linear and min = nearest and mip = none */
  104625. static readonly LINEAR_NEAREST: number;
  104626. /** Explicit coordinates mode */
  104627. static readonly EXPLICIT_MODE: number;
  104628. /** Spherical coordinates mode */
  104629. static readonly SPHERICAL_MODE: number;
  104630. /** Planar coordinates mode */
  104631. static readonly PLANAR_MODE: number;
  104632. /** Cubic coordinates mode */
  104633. static readonly CUBIC_MODE: number;
  104634. /** Projection coordinates mode */
  104635. static readonly PROJECTION_MODE: number;
  104636. /** Inverse Cubic coordinates mode */
  104637. static readonly SKYBOX_MODE: number;
  104638. /** Inverse Cubic coordinates mode */
  104639. static readonly INVCUBIC_MODE: number;
  104640. /** Equirectangular coordinates mode */
  104641. static readonly EQUIRECTANGULAR_MODE: number;
  104642. /** Equirectangular Fixed coordinates mode */
  104643. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  104644. /** Equirectangular Fixed Mirrored coordinates mode */
  104645. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104646. /** Texture is not repeating outside of 0..1 UVs */
  104647. static readonly CLAMP_ADDRESSMODE: number;
  104648. /** Texture is repeating outside of 0..1 UVs */
  104649. static readonly WRAP_ADDRESSMODE: number;
  104650. /** Texture is repeating and mirrored */
  104651. static readonly MIRROR_ADDRESSMODE: number;
  104652. /**
  104653. * 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
  104654. */
  104655. static UseSerializedUrlIfAny: boolean;
  104656. /**
  104657. * Define the url of the texture.
  104658. */
  104659. url: Nullable<string>;
  104660. /**
  104661. * Define an offset on the texture to offset the u coordinates of the UVs
  104662. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104663. */
  104664. uOffset: number;
  104665. /**
  104666. * Define an offset on the texture to offset the v coordinates of the UVs
  104667. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104668. */
  104669. vOffset: number;
  104670. /**
  104671. * Define an offset on the texture to scale the u coordinates of the UVs
  104672. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104673. */
  104674. uScale: number;
  104675. /**
  104676. * Define an offset on the texture to scale the v coordinates of the UVs
  104677. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104678. */
  104679. vScale: number;
  104680. /**
  104681. * Define an offset on the texture to rotate around the u coordinates of the UVs
  104682. * @see https://doc.babylonjs.com/how_to/more_materials
  104683. */
  104684. uAng: number;
  104685. /**
  104686. * Define an offset on the texture to rotate around the v coordinates of the UVs
  104687. * @see https://doc.babylonjs.com/how_to/more_materials
  104688. */
  104689. vAng: number;
  104690. /**
  104691. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  104692. * @see https://doc.babylonjs.com/how_to/more_materials
  104693. */
  104694. wAng: number;
  104695. /**
  104696. * Defines the center of rotation (U)
  104697. */
  104698. uRotationCenter: number;
  104699. /**
  104700. * Defines the center of rotation (V)
  104701. */
  104702. vRotationCenter: number;
  104703. /**
  104704. * Defines the center of rotation (W)
  104705. */
  104706. wRotationCenter: number;
  104707. /**
  104708. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  104709. */
  104710. homogeneousRotationInUVTransform: boolean;
  104711. /**
  104712. * Are mip maps generated for this texture or not.
  104713. */
  104714. get noMipmap(): boolean;
  104715. /**
  104716. * List of inspectable custom properties (used by the Inspector)
  104717. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104718. */
  104719. inspectableCustomProperties: Nullable<IInspectable[]>;
  104720. private _noMipmap;
  104721. /** @hidden */
  104722. _invertY: boolean;
  104723. private _rowGenerationMatrix;
  104724. private _cachedTextureMatrix;
  104725. private _projectionModeMatrix;
  104726. private _t0;
  104727. private _t1;
  104728. private _t2;
  104729. private _cachedUOffset;
  104730. private _cachedVOffset;
  104731. private _cachedUScale;
  104732. private _cachedVScale;
  104733. private _cachedUAng;
  104734. private _cachedVAng;
  104735. private _cachedWAng;
  104736. private _cachedProjectionMatrixId;
  104737. private _cachedURotationCenter;
  104738. private _cachedVRotationCenter;
  104739. private _cachedWRotationCenter;
  104740. private _cachedHomogeneousRotationInUVTransform;
  104741. private _cachedCoordinatesMode;
  104742. /** @hidden */
  104743. protected _initialSamplingMode: number;
  104744. /** @hidden */
  104745. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104746. private _deleteBuffer;
  104747. protected _format: Nullable<number>;
  104748. private _delayedOnLoad;
  104749. private _delayedOnError;
  104750. private _mimeType?;
  104751. private _loaderOptions?;
  104752. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  104753. get mimeType(): string | undefined;
  104754. /**
  104755. * Observable triggered once the texture has been loaded.
  104756. */
  104757. onLoadObservable: Observable<Texture>;
  104758. protected _isBlocking: boolean;
  104759. /**
  104760. * Is the texture preventing material to render while loading.
  104761. * If false, a default texture will be used instead of the loading one during the preparation step.
  104762. */
  104763. set isBlocking(value: boolean);
  104764. get isBlocking(): boolean;
  104765. /**
  104766. * Get the current sampling mode associated with the texture.
  104767. */
  104768. get samplingMode(): number;
  104769. /**
  104770. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  104771. */
  104772. get invertY(): boolean;
  104773. /**
  104774. * Instantiates a new texture.
  104775. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104776. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104777. * @param url defines the url of the picture to load as a texture
  104778. * @param sceneOrEngine defines the scene or engine the texture will belong to
  104779. * @param noMipmap defines if the texture will require mip maps or not
  104780. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  104781. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104782. * @param onLoad defines a callback triggered when the texture has been loaded
  104783. * @param onError defines a callback triggered when an error occurred during the loading session
  104784. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  104785. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  104786. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104787. * @param mimeType defines an optional mime type information
  104788. * @param loaderOptions options to be passed to the loader
  104789. */
  104790. 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);
  104791. /**
  104792. * Update the url (and optional buffer) of this texture if url was null during construction.
  104793. * @param url the url of the texture
  104794. * @param buffer the buffer of the texture (defaults to null)
  104795. * @param onLoad callback called when the texture is loaded (defaults to null)
  104796. */
  104797. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  104798. /**
  104799. * Finish the loading sequence of a texture flagged as delayed load.
  104800. * @hidden
  104801. */
  104802. delayLoad(): void;
  104803. private _prepareRowForTextureGeneration;
  104804. /**
  104805. * Checks if the texture has the same transform matrix than another texture
  104806. * @param texture texture to check against
  104807. * @returns true if the transforms are the same, else false
  104808. */
  104809. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  104810. /**
  104811. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  104812. * @returns the transform matrix of the texture.
  104813. */
  104814. getTextureMatrix(uBase?: number): Matrix;
  104815. /**
  104816. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  104817. * @returns The reflection texture transform
  104818. */
  104819. getReflectionTextureMatrix(): Matrix;
  104820. /**
  104821. * Clones the texture.
  104822. * @returns the cloned texture
  104823. */
  104824. clone(): Texture;
  104825. /**
  104826. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104827. * @returns The JSON representation of the texture
  104828. */
  104829. serialize(): any;
  104830. /**
  104831. * Get the current class name of the texture useful for serialization or dynamic coding.
  104832. * @returns "Texture"
  104833. */
  104834. getClassName(): string;
  104835. /**
  104836. * Dispose the texture and release its associated resources.
  104837. */
  104838. dispose(): void;
  104839. /**
  104840. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  104841. * @param parsedTexture Define the JSON representation of the texture
  104842. * @param scene Define the scene the parsed texture should be instantiated in
  104843. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104844. * @returns The parsed texture if successful
  104845. */
  104846. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  104847. /**
  104848. * Creates a texture from its base 64 representation.
  104849. * @param data Define the base64 payload without the data: prefix
  104850. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104851. * @param scene Define the scene the texture should belong to
  104852. * @param noMipmap Forces the texture to not create mip map information if true
  104853. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104854. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104855. * @param onLoad define a callback triggered when the texture has been loaded
  104856. * @param onError define a callback triggered when an error occurred during the loading session
  104857. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104858. * @returns the created texture
  104859. */
  104860. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  104861. /**
  104862. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  104863. * @param data Define the base64 payload without the data: prefix
  104864. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104865. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  104866. * @param scene Define the scene the texture should belong to
  104867. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  104868. * @param noMipmap Forces the texture to not create mip map information if true
  104869. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104870. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104871. * @param onLoad define a callback triggered when the texture has been loaded
  104872. * @param onError define a callback triggered when an error occurred during the loading session
  104873. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104874. * @returns the created texture
  104875. */
  104876. 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;
  104877. }
  104878. }
  104879. declare module BABYLON {
  104880. /**
  104881. * ThinSprite Class used to represent a thin sprite
  104882. * This is the base class for sprites but can also directly be used with ThinEngine
  104883. * @see https://doc.babylonjs.com/babylon101/sprites
  104884. */
  104885. export class ThinSprite {
  104886. /** Gets or sets the cell index in the sprite sheet */
  104887. cellIndex: number;
  104888. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  104889. cellRef: string;
  104890. /** Gets or sets the current world position */
  104891. position: IVector3Like;
  104892. /** Gets or sets the main color */
  104893. color: IColor4Like;
  104894. /** Gets or sets the width */
  104895. width: number;
  104896. /** Gets or sets the height */
  104897. height: number;
  104898. /** Gets or sets rotation angle */
  104899. angle: number;
  104900. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  104901. invertU: boolean;
  104902. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  104903. invertV: boolean;
  104904. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  104905. isVisible: boolean;
  104906. /**
  104907. * Returns a boolean indicating if the animation is started
  104908. */
  104909. get animationStarted(): boolean;
  104910. /** Gets the initial key for the animation (setting it will restart the animation) */
  104911. get fromIndex(): number;
  104912. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  104913. get toIndex(): number;
  104914. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  104915. get loopAnimation(): boolean;
  104916. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  104917. get delay(): number;
  104918. /** @hidden */
  104919. _xOffset: number;
  104920. /** @hidden */
  104921. _yOffset: number;
  104922. /** @hidden */
  104923. _xSize: number;
  104924. /** @hidden */
  104925. _ySize: number;
  104926. private _animationStarted;
  104927. protected _loopAnimation: boolean;
  104928. protected _fromIndex: number;
  104929. protected _toIndex: number;
  104930. protected _delay: number;
  104931. private _direction;
  104932. private _time;
  104933. private _onBaseAnimationEnd;
  104934. /**
  104935. * Creates a new Thin Sprite
  104936. */
  104937. constructor();
  104938. /**
  104939. * Starts an animation
  104940. * @param from defines the initial key
  104941. * @param to defines the end key
  104942. * @param loop defines if the animation must loop
  104943. * @param delay defines the start delay (in ms)
  104944. * @param onAnimationEnd defines a callback for when the animation ends
  104945. */
  104946. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  104947. /** Stops current animation (if any) */
  104948. stopAnimation(): void;
  104949. /** @hidden */
  104950. _animate(deltaTime: number): void;
  104951. }
  104952. }
  104953. declare module BABYLON {
  104954. /** @hidden */
  104955. export var imageProcessingCompatibility: {
  104956. name: string;
  104957. shader: string;
  104958. };
  104959. }
  104960. declare module BABYLON {
  104961. /** @hidden */
  104962. export var spritesPixelShader: {
  104963. name: string;
  104964. shader: string;
  104965. };
  104966. }
  104967. declare module BABYLON {
  104968. /** @hidden */
  104969. export var spritesVertexShader: {
  104970. name: string;
  104971. shader: string;
  104972. };
  104973. }
  104974. declare module BABYLON {
  104975. /**
  104976. * Class used to render sprites.
  104977. *
  104978. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  104979. */
  104980. export class SpriteRenderer {
  104981. /**
  104982. * Defines the texture of the spritesheet
  104983. */
  104984. texture: Nullable<ThinTexture>;
  104985. /**
  104986. * Defines the default width of a cell in the spritesheet
  104987. */
  104988. cellWidth: number;
  104989. /**
  104990. * Defines the default height of a cell in the spritesheet
  104991. */
  104992. cellHeight: number;
  104993. /**
  104994. * Blend mode use to render the particle, it can be any of
  104995. * the static Constants.ALPHA_x properties provided in this class.
  104996. * Default value is Constants.ALPHA_COMBINE
  104997. */
  104998. blendMode: number;
  104999. /**
  105000. * Gets or sets a boolean indicating if alpha mode is automatically
  105001. * reset.
  105002. */
  105003. autoResetAlpha: boolean;
  105004. /**
  105005. * Disables writing to the depth buffer when rendering the sprites.
  105006. * It can be handy to disable depth writing when using textures without alpha channel
  105007. * and setting some specific blend modes.
  105008. */
  105009. disableDepthWrite: boolean;
  105010. /**
  105011. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  105012. */
  105013. fogEnabled: boolean;
  105014. /**
  105015. * Gets the capacity of the manager
  105016. */
  105017. get capacity(): number;
  105018. private readonly _engine;
  105019. private readonly _useVAO;
  105020. private readonly _useInstancing;
  105021. private readonly _scene;
  105022. private readonly _capacity;
  105023. private readonly _epsilon;
  105024. private _vertexBufferSize;
  105025. private _vertexData;
  105026. private _buffer;
  105027. private _vertexBuffers;
  105028. private _spriteBuffer;
  105029. private _indexBuffer;
  105030. private _effectBase;
  105031. private _effectFog;
  105032. private _vertexArrayObject;
  105033. /**
  105034. * Creates a new sprite Renderer
  105035. * @param engine defines the engine the renderer works with
  105036. * @param capacity defines the maximum allowed number of sprites
  105037. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  105038. * @param scene defines the hosting scene
  105039. */
  105040. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  105041. /**
  105042. * Render all child sprites
  105043. * @param sprites defines the list of sprites to render
  105044. * @param deltaTime defines the time since last frame
  105045. * @param viewMatrix defines the viewMatrix to use to render the sprites
  105046. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  105047. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  105048. */
  105049. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  105050. private _appendSpriteVertex;
  105051. /**
  105052. * Release associated resources
  105053. */
  105054. dispose(): void;
  105055. }
  105056. }
  105057. declare module BABYLON {
  105058. /**
  105059. * Defines the minimum interface to fullfil in order to be a sprite manager.
  105060. */
  105061. export interface ISpriteManager extends IDisposable {
  105062. /**
  105063. * Gets manager's name
  105064. */
  105065. name: string;
  105066. /**
  105067. * Restricts the camera to viewing objects with the same layerMask.
  105068. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  105069. */
  105070. layerMask: number;
  105071. /**
  105072. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  105073. */
  105074. isPickable: boolean;
  105075. /**
  105076. * Gets the hosting scene
  105077. */
  105078. scene: Scene;
  105079. /**
  105080. * Specifies the rendering group id for this mesh (0 by default)
  105081. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  105082. */
  105083. renderingGroupId: number;
  105084. /**
  105085. * Defines the list of sprites managed by the manager.
  105086. */
  105087. sprites: Array<Sprite>;
  105088. /**
  105089. * Gets or sets the spritesheet texture
  105090. */
  105091. texture: Texture;
  105092. /** Defines the default width of a cell in the spritesheet */
  105093. cellWidth: number;
  105094. /** Defines the default height of a cell in the spritesheet */
  105095. cellHeight: number;
  105096. /**
  105097. * Tests the intersection of a sprite with a specific ray.
  105098. * @param ray The ray we are sending to test the collision
  105099. * @param camera The camera space we are sending rays in
  105100. * @param predicate A predicate allowing excluding sprites from the list of object to test
  105101. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105102. * @returns picking info or null.
  105103. */
  105104. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  105105. /**
  105106. * Intersects the sprites with a ray
  105107. * @param ray defines the ray to intersect with
  105108. * @param camera defines the current active camera
  105109. * @param predicate defines a predicate used to select candidate sprites
  105110. * @returns null if no hit or a PickingInfo array
  105111. */
  105112. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  105113. /**
  105114. * Renders the list of sprites on screen.
  105115. */
  105116. render(): void;
  105117. }
  105118. /**
  105119. * Class used to manage multiple sprites on the same spritesheet
  105120. * @see https://doc.babylonjs.com/babylon101/sprites
  105121. */
  105122. export class SpriteManager implements ISpriteManager {
  105123. /** defines the manager's name */
  105124. name: string;
  105125. /** Define the Url to load snippets */
  105126. static SnippetUrl: string;
  105127. /** Snippet ID if the manager was created from the snippet server */
  105128. snippetId: string;
  105129. /** Gets the list of sprites */
  105130. sprites: Sprite[];
  105131. /** Gets or sets the rendering group id (0 by default) */
  105132. renderingGroupId: number;
  105133. /** Gets or sets camera layer mask */
  105134. layerMask: number;
  105135. /** Gets or sets a boolean indicating if the sprites are pickable */
  105136. isPickable: boolean;
  105137. /**
  105138. * An event triggered when the manager is disposed.
  105139. */
  105140. onDisposeObservable: Observable<SpriteManager>;
  105141. /**
  105142. * Callback called when the manager is disposed
  105143. */
  105144. set onDispose(callback: () => void);
  105145. /**
  105146. * Gets or sets the unique id of the sprite
  105147. */
  105148. uniqueId: number;
  105149. /**
  105150. * Gets the array of sprites
  105151. */
  105152. get children(): Sprite[];
  105153. /**
  105154. * Gets the hosting scene
  105155. */
  105156. get scene(): Scene;
  105157. /**
  105158. * Gets the capacity of the manager
  105159. */
  105160. get capacity(): number;
  105161. /**
  105162. * Gets or sets the spritesheet texture
  105163. */
  105164. get texture(): Texture;
  105165. set texture(value: Texture);
  105166. /** Defines the default width of a cell in the spritesheet */
  105167. get cellWidth(): number;
  105168. set cellWidth(value: number);
  105169. /** Defines the default height of a cell in the spritesheet */
  105170. get cellHeight(): number;
  105171. set cellHeight(value: number);
  105172. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  105173. get fogEnabled(): boolean;
  105174. set fogEnabled(value: boolean);
  105175. /**
  105176. * Blend mode use to render the particle, it can be any of
  105177. * the static Constants.ALPHA_x properties provided in this class.
  105178. * Default value is Constants.ALPHA_COMBINE
  105179. */
  105180. get blendMode(): number;
  105181. set blendMode(blendMode: number);
  105182. /** Disables writing to the depth buffer when rendering the sprites.
  105183. * It can be handy to disable depth writing when using textures without alpha channel
  105184. * and setting some specific blend modes.
  105185. */
  105186. disableDepthWrite: boolean;
  105187. private _spriteRenderer;
  105188. /** Associative array from JSON sprite data file */
  105189. private _cellData;
  105190. /** Array of sprite names from JSON sprite data file */
  105191. private _spriteMap;
  105192. /** True when packed cell data from JSON file is ready*/
  105193. private _packedAndReady;
  105194. private _textureContent;
  105195. private _onDisposeObserver;
  105196. private _fromPacked;
  105197. private _scene;
  105198. /**
  105199. * Creates a new sprite manager
  105200. * @param name defines the manager's name
  105201. * @param imgUrl defines the sprite sheet url
  105202. * @param capacity defines the maximum allowed number of sprites
  105203. * @param cellSize defines the size of a sprite cell
  105204. * @param scene defines the hosting scene
  105205. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  105206. * @param samplingMode defines the smapling mode to use with spritesheet
  105207. * @param fromPacked set to false; do not alter
  105208. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  105209. */
  105210. constructor(
  105211. /** defines the manager's name */
  105212. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  105213. /**
  105214. * Returns the string "SpriteManager"
  105215. * @returns "SpriteManager"
  105216. */
  105217. getClassName(): string;
  105218. private _makePacked;
  105219. private _checkTextureAlpha;
  105220. /**
  105221. * Intersects the sprites with a ray
  105222. * @param ray defines the ray to intersect with
  105223. * @param camera defines the current active camera
  105224. * @param predicate defines a predicate used to select candidate sprites
  105225. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  105226. * @returns null if no hit or a PickingInfo
  105227. */
  105228. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  105229. /**
  105230. * Intersects the sprites with a ray
  105231. * @param ray defines the ray to intersect with
  105232. * @param camera defines the current active camera
  105233. * @param predicate defines a predicate used to select candidate sprites
  105234. * @returns null if no hit or a PickingInfo array
  105235. */
  105236. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  105237. /**
  105238. * Render all child sprites
  105239. */
  105240. render(): void;
  105241. private _customUpdate;
  105242. /**
  105243. * Release associated resources
  105244. */
  105245. dispose(): void;
  105246. /**
  105247. * Serializes the sprite manager to a JSON object
  105248. * @param serializeTexture defines if the texture must be serialized as well
  105249. * @returns the JSON object
  105250. */
  105251. serialize(serializeTexture?: boolean): any;
  105252. /**
  105253. * Parses a JSON object to create a new sprite manager.
  105254. * @param parsedManager The JSON object to parse
  105255. * @param scene The scene to create the sprite managerin
  105256. * @param rootUrl The root url to use to load external dependencies like texture
  105257. * @returns the new sprite manager
  105258. */
  105259. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  105260. /**
  105261. * Creates a sprite manager from a snippet saved in a remote file
  105262. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  105263. * @param url defines the url to load from
  105264. * @param scene defines the hosting scene
  105265. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105266. * @returns a promise that will resolve to the new sprite manager
  105267. */
  105268. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  105269. /**
  105270. * Creates a sprite manager from a snippet saved by the sprite editor
  105271. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  105272. * @param scene defines the hosting scene
  105273. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105274. * @returns a promise that will resolve to the new sprite manager
  105275. */
  105276. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  105277. }
  105278. }
  105279. declare module BABYLON {
  105280. /**
  105281. * Class used to represent a sprite
  105282. * @see https://doc.babylonjs.com/babylon101/sprites
  105283. */
  105284. export class Sprite extends ThinSprite implements IAnimatable {
  105285. /** defines the name */
  105286. name: string;
  105287. /** Gets or sets the current world position */
  105288. position: Vector3;
  105289. /** Gets or sets the main color */
  105290. color: Color4;
  105291. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  105292. disposeWhenFinishedAnimating: boolean;
  105293. /** Gets the list of attached animations */
  105294. animations: Nullable<Array<Animation>>;
  105295. /** Gets or sets a boolean indicating if the sprite can be picked */
  105296. isPickable: boolean;
  105297. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  105298. useAlphaForPicking: boolean;
  105299. /**
  105300. * Gets or sets the associated action manager
  105301. */
  105302. actionManager: Nullable<ActionManager>;
  105303. /**
  105304. * An event triggered when the control has been disposed
  105305. */
  105306. onDisposeObservable: Observable<Sprite>;
  105307. private _manager;
  105308. private _onAnimationEnd;
  105309. /**
  105310. * Gets or sets the sprite size
  105311. */
  105312. get size(): number;
  105313. set size(value: number);
  105314. /**
  105315. * Gets or sets the unique id of the sprite
  105316. */
  105317. uniqueId: number;
  105318. /**
  105319. * Gets the manager of this sprite
  105320. */
  105321. get manager(): ISpriteManager;
  105322. /**
  105323. * Creates a new Sprite
  105324. * @param name defines the name
  105325. * @param manager defines the manager
  105326. */
  105327. constructor(
  105328. /** defines the name */
  105329. name: string, manager: ISpriteManager);
  105330. /**
  105331. * Returns the string "Sprite"
  105332. * @returns "Sprite"
  105333. */
  105334. getClassName(): string;
  105335. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  105336. get fromIndex(): number;
  105337. set fromIndex(value: number);
  105338. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  105339. get toIndex(): number;
  105340. set toIndex(value: number);
  105341. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  105342. get loopAnimation(): boolean;
  105343. set loopAnimation(value: boolean);
  105344. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  105345. get delay(): number;
  105346. set delay(value: number);
  105347. /**
  105348. * Starts an animation
  105349. * @param from defines the initial key
  105350. * @param to defines the end key
  105351. * @param loop defines if the animation must loop
  105352. * @param delay defines the start delay (in ms)
  105353. * @param onAnimationEnd defines a callback to call when animation ends
  105354. */
  105355. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  105356. private _endAnimation;
  105357. /** Release associated resources */
  105358. dispose(): void;
  105359. /**
  105360. * Serializes the sprite to a JSON object
  105361. * @returns the JSON object
  105362. */
  105363. serialize(): any;
  105364. /**
  105365. * Parses a JSON object to create a new sprite
  105366. * @param parsedSprite The JSON object to parse
  105367. * @param manager defines the hosting manager
  105368. * @returns the new sprite
  105369. */
  105370. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  105371. }
  105372. }
  105373. declare module BABYLON {
  105374. /**
  105375. * Information about the result of picking within a scene
  105376. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  105377. */
  105378. export class PickingInfo {
  105379. /** @hidden */
  105380. _pickingUnavailable: boolean;
  105381. /**
  105382. * If the pick collided with an object
  105383. */
  105384. hit: boolean;
  105385. /**
  105386. * Distance away where the pick collided
  105387. */
  105388. distance: number;
  105389. /**
  105390. * The location of pick collision
  105391. */
  105392. pickedPoint: Nullable<Vector3>;
  105393. /**
  105394. * The mesh corresponding the the pick collision
  105395. */
  105396. pickedMesh: Nullable<AbstractMesh>;
  105397. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  105398. bu: number;
  105399. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  105400. bv: number;
  105401. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105402. faceId: number;
  105403. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105404. subMeshFaceId: number;
  105405. /** Id of the the submesh that was picked */
  105406. subMeshId: number;
  105407. /** If a sprite was picked, this will be the sprite the pick collided with */
  105408. pickedSprite: Nullable<Sprite>;
  105409. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  105410. thinInstanceIndex: number;
  105411. /**
  105412. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  105413. */
  105414. originMesh: Nullable<AbstractMesh>;
  105415. /**
  105416. * The ray that was used to perform the picking.
  105417. */
  105418. ray: Nullable<Ray>;
  105419. /**
  105420. * Gets the normal correspodning to the face the pick collided with
  105421. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  105422. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  105423. * @returns The normal correspodning to the face the pick collided with
  105424. */
  105425. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  105426. /**
  105427. * Gets the texture coordinates of where the pick occured
  105428. * @returns the vector containing the coordnates of the texture
  105429. */
  105430. getTextureCoordinates(): Nullable<Vector2>;
  105431. }
  105432. }
  105433. declare module BABYLON {
  105434. /**
  105435. * Gather the list of pointer event types as constants.
  105436. */
  105437. export class PointerEventTypes {
  105438. /**
  105439. * 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.
  105440. */
  105441. static readonly POINTERDOWN: number;
  105442. /**
  105443. * The pointerup event is fired when a pointer is no longer active.
  105444. */
  105445. static readonly POINTERUP: number;
  105446. /**
  105447. * The pointermove event is fired when a pointer changes coordinates.
  105448. */
  105449. static readonly POINTERMOVE: number;
  105450. /**
  105451. * The pointerwheel event is fired when a mouse wheel has been rotated.
  105452. */
  105453. static readonly POINTERWHEEL: number;
  105454. /**
  105455. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  105456. */
  105457. static readonly POINTERPICK: number;
  105458. /**
  105459. * The pointertap event is fired when a the object has been touched and released without drag.
  105460. */
  105461. static readonly POINTERTAP: number;
  105462. /**
  105463. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  105464. */
  105465. static readonly POINTERDOUBLETAP: number;
  105466. }
  105467. /**
  105468. * Base class of pointer info types.
  105469. */
  105470. export class PointerInfoBase {
  105471. /**
  105472. * Defines the type of event (PointerEventTypes)
  105473. */
  105474. type: number;
  105475. /**
  105476. * Defines the related dom event
  105477. */
  105478. event: PointerEvent | MouseWheelEvent;
  105479. /**
  105480. * Instantiates the base class of pointers info.
  105481. * @param type Defines the type of event (PointerEventTypes)
  105482. * @param event Defines the related dom event
  105483. */
  105484. constructor(
  105485. /**
  105486. * Defines the type of event (PointerEventTypes)
  105487. */
  105488. type: number,
  105489. /**
  105490. * Defines the related dom event
  105491. */
  105492. event: PointerEvent | MouseWheelEvent);
  105493. }
  105494. /**
  105495. * This class is used to store pointer related info for the onPrePointerObservable event.
  105496. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  105497. */
  105498. export class PointerInfoPre extends PointerInfoBase {
  105499. /**
  105500. * Ray from a pointer if availible (eg. 6dof controller)
  105501. */
  105502. ray: Nullable<Ray>;
  105503. /**
  105504. * Defines the local position of the pointer on the canvas.
  105505. */
  105506. localPosition: Vector2;
  105507. /**
  105508. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  105509. */
  105510. skipOnPointerObservable: boolean;
  105511. /**
  105512. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  105513. * @param type Defines the type of event (PointerEventTypes)
  105514. * @param event Defines the related dom event
  105515. * @param localX Defines the local x coordinates of the pointer when the event occured
  105516. * @param localY Defines the local y coordinates of the pointer when the event occured
  105517. */
  105518. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  105519. }
  105520. /**
  105521. * This type contains all the data related to a pointer event in Babylon.js.
  105522. * 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.
  105523. */
  105524. export class PointerInfo extends PointerInfoBase {
  105525. /**
  105526. * Defines the picking info associated to the info (if any)\
  105527. */
  105528. pickInfo: Nullable<PickingInfo>;
  105529. /**
  105530. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  105531. * @param type Defines the type of event (PointerEventTypes)
  105532. * @param event Defines the related dom event
  105533. * @param pickInfo Defines the picking info associated to the info (if any)\
  105534. */
  105535. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  105536. /**
  105537. * Defines the picking info associated to the info (if any)\
  105538. */
  105539. pickInfo: Nullable<PickingInfo>);
  105540. }
  105541. /**
  105542. * Data relating to a touch event on the screen.
  105543. */
  105544. export interface PointerTouch {
  105545. /**
  105546. * X coordinate of touch.
  105547. */
  105548. x: number;
  105549. /**
  105550. * Y coordinate of touch.
  105551. */
  105552. y: number;
  105553. /**
  105554. * Id of touch. Unique for each finger.
  105555. */
  105556. pointerId: number;
  105557. /**
  105558. * Event type passed from DOM.
  105559. */
  105560. type: any;
  105561. }
  105562. }
  105563. declare module BABYLON {
  105564. /**
  105565. * Manage the mouse inputs to control the movement of a free camera.
  105566. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105567. */
  105568. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  105569. /**
  105570. * Define if touch is enabled in the mouse input
  105571. */
  105572. touchEnabled: boolean;
  105573. /**
  105574. * Defines the camera the input is attached to.
  105575. */
  105576. camera: FreeCamera;
  105577. /**
  105578. * Defines the buttons associated with the input to handle camera move.
  105579. */
  105580. buttons: number[];
  105581. /**
  105582. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  105583. */
  105584. angularSensibility: number;
  105585. private _pointerInput;
  105586. private _onMouseMove;
  105587. private _observer;
  105588. private previousPosition;
  105589. /**
  105590. * Observable for when a pointer move event occurs containing the move offset
  105591. */
  105592. onPointerMovedObservable: Observable<{
  105593. offsetX: number;
  105594. offsetY: number;
  105595. }>;
  105596. /**
  105597. * @hidden
  105598. * If the camera should be rotated automatically based on pointer movement
  105599. */
  105600. _allowCameraRotation: boolean;
  105601. /**
  105602. * Manage the mouse inputs to control the movement of a free camera.
  105603. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105604. * @param touchEnabled Defines if touch is enabled or not
  105605. */
  105606. constructor(
  105607. /**
  105608. * Define if touch is enabled in the mouse input
  105609. */
  105610. touchEnabled?: boolean);
  105611. /**
  105612. * Attach the input controls to a specific dom element to get the input from.
  105613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105614. */
  105615. attachControl(noPreventDefault?: boolean): void;
  105616. /**
  105617. * Called on JS contextmenu event.
  105618. * Override this method to provide functionality.
  105619. */
  105620. protected onContextMenu(evt: PointerEvent): void;
  105621. /**
  105622. * Detach the current controls from the specified dom element.
  105623. */
  105624. detachControl(): void;
  105625. /**
  105626. * Gets the class name of the current intput.
  105627. * @returns the class name
  105628. */
  105629. getClassName(): string;
  105630. /**
  105631. * Get the friendly name associated with the input class.
  105632. * @returns the input friendly name
  105633. */
  105634. getSimpleName(): string;
  105635. }
  105636. }
  105637. declare module BABYLON {
  105638. /**
  105639. * Base class for mouse wheel input..
  105640. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  105641. * for example usage.
  105642. */
  105643. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  105644. /**
  105645. * Defines the camera the input is attached to.
  105646. */
  105647. abstract camera: Camera;
  105648. /**
  105649. * How fast is the camera moves in relation to X axis mouseWheel events.
  105650. * Use negative value to reverse direction.
  105651. */
  105652. wheelPrecisionX: number;
  105653. /**
  105654. * How fast is the camera moves in relation to Y axis mouseWheel events.
  105655. * Use negative value to reverse direction.
  105656. */
  105657. wheelPrecisionY: number;
  105658. /**
  105659. * How fast is the camera moves in relation to Z axis mouseWheel events.
  105660. * Use negative value to reverse direction.
  105661. */
  105662. wheelPrecisionZ: number;
  105663. /**
  105664. * Observable for when a mouse wheel move event occurs.
  105665. */
  105666. onChangedObservable: Observable<{
  105667. wheelDeltaX: number;
  105668. wheelDeltaY: number;
  105669. wheelDeltaZ: number;
  105670. }>;
  105671. private _wheel;
  105672. private _observer;
  105673. /**
  105674. * Attach the input controls to a specific dom element to get the input from.
  105675. * @param noPreventDefault Defines whether event caught by the controls
  105676. * should call preventdefault().
  105677. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105678. */
  105679. attachControl(noPreventDefault?: boolean): void;
  105680. /**
  105681. * Detach the current controls from the specified dom element.
  105682. */
  105683. detachControl(): void;
  105684. /**
  105685. * Called for each rendered frame.
  105686. */
  105687. checkInputs(): void;
  105688. /**
  105689. * Gets the class name of the current intput.
  105690. * @returns the class name
  105691. */
  105692. getClassName(): string;
  105693. /**
  105694. * Get the friendly name associated with the input class.
  105695. * @returns the input friendly name
  105696. */
  105697. getSimpleName(): string;
  105698. /**
  105699. * Incremental value of multiple mouse wheel movements of the X axis.
  105700. * Should be zero-ed when read.
  105701. */
  105702. protected _wheelDeltaX: number;
  105703. /**
  105704. * Incremental value of multiple mouse wheel movements of the Y axis.
  105705. * Should be zero-ed when read.
  105706. */
  105707. protected _wheelDeltaY: number;
  105708. /**
  105709. * Incremental value of multiple mouse wheel movements of the Z axis.
  105710. * Should be zero-ed when read.
  105711. */
  105712. protected _wheelDeltaZ: number;
  105713. /**
  105714. * Firefox uses a different scheme to report scroll distances to other
  105715. * browsers. Rather than use complicated methods to calculate the exact
  105716. * multiple we need to apply, let's just cheat and use a constant.
  105717. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  105718. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  105719. */
  105720. private readonly _ffMultiplier;
  105721. /**
  105722. * Different event attributes for wheel data fall into a few set ranges.
  105723. * Some relevant but dated date here:
  105724. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  105725. */
  105726. private readonly _normalize;
  105727. }
  105728. }
  105729. declare module BABYLON {
  105730. /**
  105731. * Manage the mouse wheel inputs to control a free camera.
  105732. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105733. */
  105734. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  105735. /**
  105736. * Defines the camera the input is attached to.
  105737. */
  105738. camera: FreeCamera;
  105739. /**
  105740. * Gets the class name of the current input.
  105741. * @returns the class name
  105742. */
  105743. getClassName(): string;
  105744. /**
  105745. * Set which movement axis (relative to camera's orientation) the mouse
  105746. * wheel's X axis controls.
  105747. * @param axis The axis to be moved. Set null to clear.
  105748. */
  105749. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  105750. /**
  105751. * Get the configured movement axis (relative to camera's orientation) the
  105752. * mouse wheel's X axis controls.
  105753. * @returns The configured axis or null if none.
  105754. */
  105755. get wheelXMoveRelative(): Nullable<Coordinate>;
  105756. /**
  105757. * Set which movement axis (relative to camera's orientation) the mouse
  105758. * wheel's Y axis controls.
  105759. * @param axis The axis to be moved. Set null to clear.
  105760. */
  105761. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  105762. /**
  105763. * Get the configured movement axis (relative to camera's orientation) the
  105764. * mouse wheel's Y axis controls.
  105765. * @returns The configured axis or null if none.
  105766. */
  105767. get wheelYMoveRelative(): Nullable<Coordinate>;
  105768. /**
  105769. * Set which movement axis (relative to camera's orientation) the mouse
  105770. * wheel's Z axis controls.
  105771. * @param axis The axis to be moved. Set null to clear.
  105772. */
  105773. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  105774. /**
  105775. * Get the configured movement axis (relative to camera's orientation) the
  105776. * mouse wheel's Z axis controls.
  105777. * @returns The configured axis or null if none.
  105778. */
  105779. get wheelZMoveRelative(): Nullable<Coordinate>;
  105780. /**
  105781. * Set which rotation axis (relative to camera's orientation) the mouse
  105782. * wheel's X axis controls.
  105783. * @param axis The axis to be moved. Set null to clear.
  105784. */
  105785. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  105786. /**
  105787. * Get the configured rotation axis (relative to camera's orientation) the
  105788. * mouse wheel's X axis controls.
  105789. * @returns The configured axis or null if none.
  105790. */
  105791. get wheelXRotateRelative(): Nullable<Coordinate>;
  105792. /**
  105793. * Set which rotation axis (relative to camera's orientation) the mouse
  105794. * wheel's Y axis controls.
  105795. * @param axis The axis to be moved. Set null to clear.
  105796. */
  105797. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  105798. /**
  105799. * Get the configured rotation axis (relative to camera's orientation) the
  105800. * mouse wheel's Y axis controls.
  105801. * @returns The configured axis or null if none.
  105802. */
  105803. get wheelYRotateRelative(): Nullable<Coordinate>;
  105804. /**
  105805. * Set which rotation axis (relative to camera's orientation) the mouse
  105806. * wheel's Z axis controls.
  105807. * @param axis The axis to be moved. Set null to clear.
  105808. */
  105809. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  105810. /**
  105811. * Get the configured rotation axis (relative to camera's orientation) the
  105812. * mouse wheel's Z axis controls.
  105813. * @returns The configured axis or null if none.
  105814. */
  105815. get wheelZRotateRelative(): Nullable<Coordinate>;
  105816. /**
  105817. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  105818. * controls.
  105819. * @param axis The axis to be moved. Set null to clear.
  105820. */
  105821. set wheelXMoveScene(axis: Nullable<Coordinate>);
  105822. /**
  105823. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105824. * X axis controls.
  105825. * @returns The configured axis or null if none.
  105826. */
  105827. get wheelXMoveScene(): Nullable<Coordinate>;
  105828. /**
  105829. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  105830. * controls.
  105831. * @param axis The axis to be moved. Set null to clear.
  105832. */
  105833. set wheelYMoveScene(axis: Nullable<Coordinate>);
  105834. /**
  105835. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105836. * Y axis controls.
  105837. * @returns The configured axis or null if none.
  105838. */
  105839. get wheelYMoveScene(): Nullable<Coordinate>;
  105840. /**
  105841. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  105842. * controls.
  105843. * @param axis The axis to be moved. Set null to clear.
  105844. */
  105845. set wheelZMoveScene(axis: Nullable<Coordinate>);
  105846. /**
  105847. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105848. * Z axis controls.
  105849. * @returns The configured axis or null if none.
  105850. */
  105851. get wheelZMoveScene(): Nullable<Coordinate>;
  105852. /**
  105853. * Called for each rendered frame.
  105854. */
  105855. checkInputs(): void;
  105856. private _moveRelative;
  105857. private _rotateRelative;
  105858. private _moveScene;
  105859. /**
  105860. * These are set to the desired default behaviour.
  105861. */
  105862. private _wheelXAction;
  105863. private _wheelXActionCoordinate;
  105864. private _wheelYAction;
  105865. private _wheelYActionCoordinate;
  105866. private _wheelZAction;
  105867. private _wheelZActionCoordinate;
  105868. /**
  105869. * Update the camera according to any configured properties for the 3
  105870. * mouse-wheel axis.
  105871. */
  105872. private _updateCamera;
  105873. }
  105874. }
  105875. declare module BABYLON {
  105876. /**
  105877. * Manage the touch inputs to control the movement of a free camera.
  105878. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105879. */
  105880. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  105881. /**
  105882. * Define if mouse events can be treated as touch events
  105883. */
  105884. allowMouse: boolean;
  105885. /**
  105886. * Defines the camera the input is attached to.
  105887. */
  105888. camera: FreeCamera;
  105889. /**
  105890. * Defines the touch sensibility for rotation.
  105891. * The higher the faster.
  105892. */
  105893. touchAngularSensibility: number;
  105894. /**
  105895. * Defines the touch sensibility for move.
  105896. * The higher the faster.
  105897. */
  105898. touchMoveSensibility: number;
  105899. private _offsetX;
  105900. private _offsetY;
  105901. private _pointerPressed;
  105902. private _pointerInput?;
  105903. private _observer;
  105904. private _onLostFocus;
  105905. /**
  105906. * Manage the touch inputs to control the movement of a free camera.
  105907. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105908. * @param allowMouse Defines if mouse events can be treated as touch events
  105909. */
  105910. constructor(
  105911. /**
  105912. * Define if mouse events can be treated as touch events
  105913. */
  105914. allowMouse?: boolean);
  105915. /**
  105916. * Attach the input controls to a specific dom element to get the input from.
  105917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105918. */
  105919. attachControl(noPreventDefault?: boolean): void;
  105920. /**
  105921. * Detach the current controls from the specified dom element.
  105922. */
  105923. detachControl(): void;
  105924. /**
  105925. * Update the current camera state depending on the inputs that have been used this frame.
  105926. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105927. */
  105928. checkInputs(): void;
  105929. /**
  105930. * Gets the class name of the current intput.
  105931. * @returns the class name
  105932. */
  105933. getClassName(): string;
  105934. /**
  105935. * Get the friendly name associated with the input class.
  105936. * @returns the input friendly name
  105937. */
  105938. getSimpleName(): string;
  105939. }
  105940. }
  105941. declare module BABYLON {
  105942. /**
  105943. * Default Inputs manager for the FreeCamera.
  105944. * It groups all the default supported inputs for ease of use.
  105945. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105946. */
  105947. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  105948. /**
  105949. * @hidden
  105950. */
  105951. _mouseInput: Nullable<FreeCameraMouseInput>;
  105952. /**
  105953. * @hidden
  105954. */
  105955. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  105956. /**
  105957. * Instantiates a new FreeCameraInputsManager.
  105958. * @param camera Defines the camera the inputs belong to
  105959. */
  105960. constructor(camera: FreeCamera);
  105961. /**
  105962. * Add keyboard input support to the input manager.
  105963. * @returns the current input manager
  105964. */
  105965. addKeyboard(): FreeCameraInputsManager;
  105966. /**
  105967. * Add mouse input support to the input manager.
  105968. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  105969. * @returns the current input manager
  105970. */
  105971. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  105972. /**
  105973. * Removes the mouse input support from the manager
  105974. * @returns the current input manager
  105975. */
  105976. removeMouse(): FreeCameraInputsManager;
  105977. /**
  105978. * Add mouse wheel input support to the input manager.
  105979. * @returns the current input manager
  105980. */
  105981. addMouseWheel(): FreeCameraInputsManager;
  105982. /**
  105983. * Removes the mouse wheel input support from the manager
  105984. * @returns the current input manager
  105985. */
  105986. removeMouseWheel(): FreeCameraInputsManager;
  105987. /**
  105988. * Add touch input support to the input manager.
  105989. * @returns the current input manager
  105990. */
  105991. addTouch(): FreeCameraInputsManager;
  105992. /**
  105993. * Remove all attached input methods from a camera
  105994. */
  105995. clear(): void;
  105996. }
  105997. }
  105998. declare module BABYLON {
  105999. /**
  106000. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106001. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  106002. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  106003. */
  106004. export class FreeCamera extends TargetCamera {
  106005. /**
  106006. * Define the collision ellipsoid of the camera.
  106007. * This is helpful to simulate a camera body like the player body around the camera
  106008. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106009. */
  106010. ellipsoid: Vector3;
  106011. /**
  106012. * Define an offset for the position of the ellipsoid around the camera.
  106013. * This can be helpful to determine the center of the body near the gravity center of the body
  106014. * instead of its head.
  106015. */
  106016. ellipsoidOffset: Vector3;
  106017. /**
  106018. * Enable or disable collisions of the camera with the rest of the scene objects.
  106019. */
  106020. checkCollisions: boolean;
  106021. /**
  106022. * Enable or disable gravity on the camera.
  106023. */
  106024. applyGravity: boolean;
  106025. /**
  106026. * Define the input manager associated to the camera.
  106027. */
  106028. inputs: FreeCameraInputsManager;
  106029. /**
  106030. * Gets the input sensibility for a mouse input. (default is 2000.0)
  106031. * Higher values reduce sensitivity.
  106032. */
  106033. get angularSensibility(): number;
  106034. /**
  106035. * Sets the input sensibility for a mouse input. (default is 2000.0)
  106036. * Higher values reduce sensitivity.
  106037. */
  106038. set angularSensibility(value: number);
  106039. /**
  106040. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  106041. */
  106042. get keysUp(): number[];
  106043. set keysUp(value: number[]);
  106044. /**
  106045. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  106046. */
  106047. get keysUpward(): number[];
  106048. set keysUpward(value: number[]);
  106049. /**
  106050. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  106051. */
  106052. get keysDown(): number[];
  106053. set keysDown(value: number[]);
  106054. /**
  106055. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  106056. */
  106057. get keysDownward(): number[];
  106058. set keysDownward(value: number[]);
  106059. /**
  106060. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  106061. */
  106062. get keysLeft(): number[];
  106063. set keysLeft(value: number[]);
  106064. /**
  106065. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  106066. */
  106067. get keysRight(): number[];
  106068. set keysRight(value: number[]);
  106069. /**
  106070. * Event raised when the camera collide with a mesh in the scene.
  106071. */
  106072. onCollide: (collidedMesh: AbstractMesh) => void;
  106073. private _collider;
  106074. private _needMoveForGravity;
  106075. private _oldPosition;
  106076. private _diffPosition;
  106077. private _newPosition;
  106078. /** @hidden */
  106079. _localDirection: Vector3;
  106080. /** @hidden */
  106081. _transformedDirection: Vector3;
  106082. /**
  106083. * Instantiates a Free Camera.
  106084. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106085. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  106086. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  106087. * @param name Define the name of the camera in the scene
  106088. * @param position Define the start position of the camera in the scene
  106089. * @param scene Define the scene the camera belongs to
  106090. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  106091. */
  106092. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106093. /**
  106094. * Attach the input controls to a specific dom element to get the input from.
  106095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106096. */
  106097. attachControl(noPreventDefault?: boolean): void;
  106098. /**
  106099. * Attach the input controls to a specific dom element to get the input from.
  106100. * @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
  106101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106102. * BACK COMPAT SIGNATURE ONLY.
  106103. */
  106104. attachControl(ignored: any, noPreventDefault?: boolean): void;
  106105. /**
  106106. * Detach the current controls from the specified dom element.
  106107. */
  106108. detachControl(): void;
  106109. /**
  106110. * Detach the current controls from the specified dom element.
  106111. * @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
  106112. */
  106113. detachControl(ignored: any): void;
  106114. private _collisionMask;
  106115. /**
  106116. * Define a collision mask to limit the list of object the camera can collide with
  106117. */
  106118. get collisionMask(): number;
  106119. set collisionMask(mask: number);
  106120. /** @hidden */
  106121. _collideWithWorld(displacement: Vector3): void;
  106122. private _onCollisionPositionChange;
  106123. /** @hidden */
  106124. _checkInputs(): void;
  106125. /** @hidden */
  106126. _decideIfNeedsToMove(): boolean;
  106127. /** @hidden */
  106128. _updatePosition(): void;
  106129. /**
  106130. * Destroy the camera and release the current resources hold by it.
  106131. */
  106132. dispose(): void;
  106133. /**
  106134. * Gets the current object class name.
  106135. * @return the class name
  106136. */
  106137. getClassName(): string;
  106138. }
  106139. }
  106140. declare module BABYLON {
  106141. /**
  106142. * Represents a gamepad control stick position
  106143. */
  106144. export class StickValues {
  106145. /**
  106146. * The x component of the control stick
  106147. */
  106148. x: number;
  106149. /**
  106150. * The y component of the control stick
  106151. */
  106152. y: number;
  106153. /**
  106154. * Initializes the gamepad x and y control stick values
  106155. * @param x The x component of the gamepad control stick value
  106156. * @param y The y component of the gamepad control stick value
  106157. */
  106158. constructor(
  106159. /**
  106160. * The x component of the control stick
  106161. */
  106162. x: number,
  106163. /**
  106164. * The y component of the control stick
  106165. */
  106166. y: number);
  106167. }
  106168. /**
  106169. * An interface which manages callbacks for gamepad button changes
  106170. */
  106171. export interface GamepadButtonChanges {
  106172. /**
  106173. * Called when a gamepad has been changed
  106174. */
  106175. changed: boolean;
  106176. /**
  106177. * Called when a gamepad press event has been triggered
  106178. */
  106179. pressChanged: boolean;
  106180. /**
  106181. * Called when a touch event has been triggered
  106182. */
  106183. touchChanged: boolean;
  106184. /**
  106185. * Called when a value has changed
  106186. */
  106187. valueChanged: boolean;
  106188. }
  106189. /**
  106190. * Represents a gamepad
  106191. */
  106192. export class Gamepad {
  106193. /**
  106194. * The id of the gamepad
  106195. */
  106196. id: string;
  106197. /**
  106198. * The index of the gamepad
  106199. */
  106200. index: number;
  106201. /**
  106202. * The browser gamepad
  106203. */
  106204. browserGamepad: any;
  106205. /**
  106206. * Specifies what type of gamepad this represents
  106207. */
  106208. type: number;
  106209. private _leftStick;
  106210. private _rightStick;
  106211. /** @hidden */
  106212. _isConnected: boolean;
  106213. private _leftStickAxisX;
  106214. private _leftStickAxisY;
  106215. private _rightStickAxisX;
  106216. private _rightStickAxisY;
  106217. /**
  106218. * Triggered when the left control stick has been changed
  106219. */
  106220. private _onleftstickchanged;
  106221. /**
  106222. * Triggered when the right control stick has been changed
  106223. */
  106224. private _onrightstickchanged;
  106225. /**
  106226. * Represents a gamepad controller
  106227. */
  106228. static GAMEPAD: number;
  106229. /**
  106230. * Represents a generic controller
  106231. */
  106232. static GENERIC: number;
  106233. /**
  106234. * Represents an XBox controller
  106235. */
  106236. static XBOX: number;
  106237. /**
  106238. * Represents a pose-enabled controller
  106239. */
  106240. static POSE_ENABLED: number;
  106241. /**
  106242. * Represents an Dual Shock controller
  106243. */
  106244. static DUALSHOCK: number;
  106245. /**
  106246. * Specifies whether the left control stick should be Y-inverted
  106247. */
  106248. protected _invertLeftStickY: boolean;
  106249. /**
  106250. * Specifies if the gamepad has been connected
  106251. */
  106252. get isConnected(): boolean;
  106253. /**
  106254. * Initializes the gamepad
  106255. * @param id The id of the gamepad
  106256. * @param index The index of the gamepad
  106257. * @param browserGamepad The browser gamepad
  106258. * @param leftStickX The x component of the left joystick
  106259. * @param leftStickY The y component of the left joystick
  106260. * @param rightStickX The x component of the right joystick
  106261. * @param rightStickY The y component of the right joystick
  106262. */
  106263. constructor(
  106264. /**
  106265. * The id of the gamepad
  106266. */
  106267. id: string,
  106268. /**
  106269. * The index of the gamepad
  106270. */
  106271. index: number,
  106272. /**
  106273. * The browser gamepad
  106274. */
  106275. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  106276. /**
  106277. * Callback triggered when the left joystick has changed
  106278. * @param callback
  106279. */
  106280. onleftstickchanged(callback: (values: StickValues) => void): void;
  106281. /**
  106282. * Callback triggered when the right joystick has changed
  106283. * @param callback
  106284. */
  106285. onrightstickchanged(callback: (values: StickValues) => void): void;
  106286. /**
  106287. * Gets the left joystick
  106288. */
  106289. get leftStick(): StickValues;
  106290. /**
  106291. * Sets the left joystick values
  106292. */
  106293. set leftStick(newValues: StickValues);
  106294. /**
  106295. * Gets the right joystick
  106296. */
  106297. get rightStick(): StickValues;
  106298. /**
  106299. * Sets the right joystick value
  106300. */
  106301. set rightStick(newValues: StickValues);
  106302. /**
  106303. * Updates the gamepad joystick positions
  106304. */
  106305. update(): void;
  106306. /**
  106307. * Disposes the gamepad
  106308. */
  106309. dispose(): void;
  106310. }
  106311. /**
  106312. * Represents a generic gamepad
  106313. */
  106314. export class GenericPad extends Gamepad {
  106315. private _buttons;
  106316. private _onbuttondown;
  106317. private _onbuttonup;
  106318. /**
  106319. * Observable triggered when a button has been pressed
  106320. */
  106321. onButtonDownObservable: Observable<number>;
  106322. /**
  106323. * Observable triggered when a button has been released
  106324. */
  106325. onButtonUpObservable: Observable<number>;
  106326. /**
  106327. * Callback triggered when a button has been pressed
  106328. * @param callback Called when a button has been pressed
  106329. */
  106330. onbuttondown(callback: (buttonPressed: number) => void): void;
  106331. /**
  106332. * Callback triggered when a button has been released
  106333. * @param callback Called when a button has been released
  106334. */
  106335. onbuttonup(callback: (buttonReleased: number) => void): void;
  106336. /**
  106337. * Initializes the generic gamepad
  106338. * @param id The id of the generic gamepad
  106339. * @param index The index of the generic gamepad
  106340. * @param browserGamepad The browser gamepad
  106341. */
  106342. constructor(id: string, index: number, browserGamepad: any);
  106343. private _setButtonValue;
  106344. /**
  106345. * Updates the generic gamepad
  106346. */
  106347. update(): void;
  106348. /**
  106349. * Disposes the generic gamepad
  106350. */
  106351. dispose(): void;
  106352. }
  106353. }
  106354. declare module BABYLON {
  106355. /**
  106356. * Defines a runtime animation
  106357. */
  106358. export class RuntimeAnimation {
  106359. private _events;
  106360. /**
  106361. * The current frame of the runtime animation
  106362. */
  106363. private _currentFrame;
  106364. /**
  106365. * The animation used by the runtime animation
  106366. */
  106367. private _animation;
  106368. /**
  106369. * The target of the runtime animation
  106370. */
  106371. private _target;
  106372. /**
  106373. * The initiating animatable
  106374. */
  106375. private _host;
  106376. /**
  106377. * The original value of the runtime animation
  106378. */
  106379. private _originalValue;
  106380. /**
  106381. * The original blend value of the runtime animation
  106382. */
  106383. private _originalBlendValue;
  106384. /**
  106385. * The offsets cache of the runtime animation
  106386. */
  106387. private _offsetsCache;
  106388. /**
  106389. * The high limits cache of the runtime animation
  106390. */
  106391. private _highLimitsCache;
  106392. /**
  106393. * Specifies if the runtime animation has been stopped
  106394. */
  106395. private _stopped;
  106396. /**
  106397. * The blending factor of the runtime animation
  106398. */
  106399. private _blendingFactor;
  106400. /**
  106401. * The BabylonJS scene
  106402. */
  106403. private _scene;
  106404. /**
  106405. * The current value of the runtime animation
  106406. */
  106407. private _currentValue;
  106408. /** @hidden */
  106409. _animationState: _IAnimationState;
  106410. /**
  106411. * The active target of the runtime animation
  106412. */
  106413. private _activeTargets;
  106414. private _currentActiveTarget;
  106415. private _directTarget;
  106416. /**
  106417. * The target path of the runtime animation
  106418. */
  106419. private _targetPath;
  106420. /**
  106421. * The weight of the runtime animation
  106422. */
  106423. private _weight;
  106424. /**
  106425. * The ratio offset of the runtime animation
  106426. */
  106427. private _ratioOffset;
  106428. /**
  106429. * The previous delay of the runtime animation
  106430. */
  106431. private _previousDelay;
  106432. /**
  106433. * The previous ratio of the runtime animation
  106434. */
  106435. private _previousRatio;
  106436. private _enableBlending;
  106437. private _keys;
  106438. private _minFrame;
  106439. private _maxFrame;
  106440. private _minValue;
  106441. private _maxValue;
  106442. private _targetIsArray;
  106443. /**
  106444. * Gets the current frame of the runtime animation
  106445. */
  106446. get currentFrame(): number;
  106447. /**
  106448. * Gets the weight of the runtime animation
  106449. */
  106450. get weight(): number;
  106451. /**
  106452. * Gets the current value of the runtime animation
  106453. */
  106454. get currentValue(): any;
  106455. /**
  106456. * Gets the target path of the runtime animation
  106457. */
  106458. get targetPath(): string;
  106459. /**
  106460. * Gets the actual target of the runtime animation
  106461. */
  106462. get target(): any;
  106463. /**
  106464. * Gets the additive state of the runtime animation
  106465. */
  106466. get isAdditive(): boolean;
  106467. /** @hidden */
  106468. _onLoop: () => void;
  106469. /**
  106470. * Create a new RuntimeAnimation object
  106471. * @param target defines the target of the animation
  106472. * @param animation defines the source animation object
  106473. * @param scene defines the hosting scene
  106474. * @param host defines the initiating Animatable
  106475. */
  106476. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  106477. private _preparePath;
  106478. /**
  106479. * Gets the animation from the runtime animation
  106480. */
  106481. get animation(): Animation;
  106482. /**
  106483. * Resets the runtime animation to the beginning
  106484. * @param restoreOriginal defines whether to restore the target property to the original value
  106485. */
  106486. reset(restoreOriginal?: boolean): void;
  106487. /**
  106488. * Specifies if the runtime animation is stopped
  106489. * @returns Boolean specifying if the runtime animation is stopped
  106490. */
  106491. isStopped(): boolean;
  106492. /**
  106493. * Disposes of the runtime animation
  106494. */
  106495. dispose(): void;
  106496. /**
  106497. * Apply the interpolated value to the target
  106498. * @param currentValue defines the value computed by the animation
  106499. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  106500. */
  106501. setValue(currentValue: any, weight: number): void;
  106502. private _getOriginalValues;
  106503. private _setValue;
  106504. /**
  106505. * Gets the loop pmode of the runtime animation
  106506. * @returns Loop Mode
  106507. */
  106508. private _getCorrectLoopMode;
  106509. /**
  106510. * Move the current animation to a given frame
  106511. * @param frame defines the frame to move to
  106512. */
  106513. goToFrame(frame: number): void;
  106514. /**
  106515. * @hidden Internal use only
  106516. */
  106517. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  106518. /**
  106519. * Execute the current animation
  106520. * @param delay defines the delay to add to the current frame
  106521. * @param from defines the lower bound of the animation range
  106522. * @param to defines the upper bound of the animation range
  106523. * @param loop defines if the current animation must loop
  106524. * @param speedRatio defines the current speed ratio
  106525. * @param weight defines the weight of the animation (default is -1 so no weight)
  106526. * @param onLoop optional callback called when animation loops
  106527. * @returns a boolean indicating if the animation is running
  106528. */
  106529. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  106530. }
  106531. }
  106532. declare module BABYLON {
  106533. /**
  106534. * Class used to store an actual running animation
  106535. */
  106536. export class Animatable {
  106537. /** defines the target object */
  106538. target: any;
  106539. /** defines the starting frame number (default is 0) */
  106540. fromFrame: number;
  106541. /** defines the ending frame number (default is 100) */
  106542. toFrame: number;
  106543. /** defines if the animation must loop (default is false) */
  106544. loopAnimation: boolean;
  106545. /** defines a callback to call when animation ends if it is not looping */
  106546. onAnimationEnd?: (() => void) | null | undefined;
  106547. /** defines a callback to call when animation loops */
  106548. onAnimationLoop?: (() => void) | null | undefined;
  106549. /** defines whether the animation should be evaluated additively */
  106550. isAdditive: boolean;
  106551. private _localDelayOffset;
  106552. private _pausedDelay;
  106553. private _runtimeAnimations;
  106554. private _paused;
  106555. private _scene;
  106556. private _speedRatio;
  106557. private _weight;
  106558. private _syncRoot;
  106559. /**
  106560. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  106561. * This will only apply for non looping animation (default is true)
  106562. */
  106563. disposeOnEnd: boolean;
  106564. /**
  106565. * Gets a boolean indicating if the animation has started
  106566. */
  106567. animationStarted: boolean;
  106568. /**
  106569. * Observer raised when the animation ends
  106570. */
  106571. onAnimationEndObservable: Observable<Animatable>;
  106572. /**
  106573. * Observer raised when the animation loops
  106574. */
  106575. onAnimationLoopObservable: Observable<Animatable>;
  106576. /**
  106577. * Gets the root Animatable used to synchronize and normalize animations
  106578. */
  106579. get syncRoot(): Nullable<Animatable>;
  106580. /**
  106581. * Gets the current frame of the first RuntimeAnimation
  106582. * Used to synchronize Animatables
  106583. */
  106584. get masterFrame(): number;
  106585. /**
  106586. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  106587. */
  106588. get weight(): number;
  106589. set weight(value: number);
  106590. /**
  106591. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  106592. */
  106593. get speedRatio(): number;
  106594. set speedRatio(value: number);
  106595. /**
  106596. * Creates a new Animatable
  106597. * @param scene defines the hosting scene
  106598. * @param target defines the target object
  106599. * @param fromFrame defines the starting frame number (default is 0)
  106600. * @param toFrame defines the ending frame number (default is 100)
  106601. * @param loopAnimation defines if the animation must loop (default is false)
  106602. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  106603. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  106604. * @param animations defines a group of animation to add to the new Animatable
  106605. * @param onAnimationLoop defines a callback to call when animation loops
  106606. * @param isAdditive defines whether the animation should be evaluated additively
  106607. */
  106608. constructor(scene: Scene,
  106609. /** defines the target object */
  106610. target: any,
  106611. /** defines the starting frame number (default is 0) */
  106612. fromFrame?: number,
  106613. /** defines the ending frame number (default is 100) */
  106614. toFrame?: number,
  106615. /** defines if the animation must loop (default is false) */
  106616. loopAnimation?: boolean, speedRatio?: number,
  106617. /** defines a callback to call when animation ends if it is not looping */
  106618. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  106619. /** defines a callback to call when animation loops */
  106620. onAnimationLoop?: (() => void) | null | undefined,
  106621. /** defines whether the animation should be evaluated additively */
  106622. isAdditive?: boolean);
  106623. /**
  106624. * Synchronize and normalize current Animatable with a source Animatable
  106625. * This is useful when using animation weights and when animations are not of the same length
  106626. * @param root defines the root Animatable to synchronize with
  106627. * @returns the current Animatable
  106628. */
  106629. syncWith(root: Animatable): Animatable;
  106630. /**
  106631. * Gets the list of runtime animations
  106632. * @returns an array of RuntimeAnimation
  106633. */
  106634. getAnimations(): RuntimeAnimation[];
  106635. /**
  106636. * Adds more animations to the current animatable
  106637. * @param target defines the target of the animations
  106638. * @param animations defines the new animations to add
  106639. */
  106640. appendAnimations(target: any, animations: Animation[]): void;
  106641. /**
  106642. * Gets the source animation for a specific property
  106643. * @param property defines the propertyu to look for
  106644. * @returns null or the source animation for the given property
  106645. */
  106646. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  106647. /**
  106648. * Gets the runtime animation for a specific property
  106649. * @param property defines the propertyu to look for
  106650. * @returns null or the runtime animation for the given property
  106651. */
  106652. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  106653. /**
  106654. * Resets the animatable to its original state
  106655. */
  106656. reset(): void;
  106657. /**
  106658. * Allows the animatable to blend with current running animations
  106659. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106660. * @param blendingSpeed defines the blending speed to use
  106661. */
  106662. enableBlending(blendingSpeed: number): void;
  106663. /**
  106664. * Disable animation blending
  106665. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106666. */
  106667. disableBlending(): void;
  106668. /**
  106669. * Jump directly to a given frame
  106670. * @param frame defines the frame to jump to
  106671. */
  106672. goToFrame(frame: number): void;
  106673. /**
  106674. * Pause the animation
  106675. */
  106676. pause(): void;
  106677. /**
  106678. * Restart the animation
  106679. */
  106680. restart(): void;
  106681. private _raiseOnAnimationEnd;
  106682. /**
  106683. * Stop and delete the current animation
  106684. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  106685. * @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)
  106686. */
  106687. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  106688. /**
  106689. * Wait asynchronously for the animation to end
  106690. * @returns a promise which will be fullfilled when the animation ends
  106691. */
  106692. waitAsync(): Promise<Animatable>;
  106693. /** @hidden */
  106694. _animate(delay: number): boolean;
  106695. }
  106696. interface Scene {
  106697. /** @hidden */
  106698. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  106699. /** @hidden */
  106700. _processLateAnimationBindingsForMatrices(holder: {
  106701. totalWeight: number;
  106702. totalAdditiveWeight: number;
  106703. animations: RuntimeAnimation[];
  106704. additiveAnimations: RuntimeAnimation[];
  106705. originalValue: Matrix;
  106706. }): any;
  106707. /** @hidden */
  106708. _processLateAnimationBindingsForQuaternions(holder: {
  106709. totalWeight: number;
  106710. totalAdditiveWeight: number;
  106711. animations: RuntimeAnimation[];
  106712. additiveAnimations: RuntimeAnimation[];
  106713. originalValue: Quaternion;
  106714. }, refQuaternion: Quaternion): Quaternion;
  106715. /** @hidden */
  106716. _processLateAnimationBindings(): void;
  106717. /**
  106718. * Will start the animation sequence of a given target
  106719. * @param target defines the target
  106720. * @param from defines from which frame should animation start
  106721. * @param to defines until which frame should animation run.
  106722. * @param weight defines the weight to apply to the animation (1.0 by default)
  106723. * @param loop defines if the animation loops
  106724. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106725. * @param onAnimationEnd defines the function to be executed when the animation ends
  106726. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106727. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106728. * @param onAnimationLoop defines the callback to call when an animation loops
  106729. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106730. * @returns the animatable object created for this animation
  106731. */
  106732. 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;
  106733. /**
  106734. * Will start the animation sequence of a given target
  106735. * @param target defines the target
  106736. * @param from defines from which frame should animation start
  106737. * @param to defines until which frame should animation run.
  106738. * @param loop defines if the animation loops
  106739. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106740. * @param onAnimationEnd defines the function to be executed when the animation ends
  106741. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106742. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106743. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  106744. * @param onAnimationLoop defines the callback to call when an animation loops
  106745. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106746. * @returns the animatable object created for this animation
  106747. */
  106748. 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;
  106749. /**
  106750. * Will start the animation sequence of a given target and its hierarchy
  106751. * @param target defines the target
  106752. * @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.
  106753. * @param from defines from which frame should animation start
  106754. * @param to defines until which frame should animation run.
  106755. * @param loop defines if the animation loops
  106756. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106757. * @param onAnimationEnd defines the function to be executed when the animation ends
  106758. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106759. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106760. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106761. * @param onAnimationLoop defines the callback to call when an animation loops
  106762. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106763. * @returns the list of created animatables
  106764. */
  106765. 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[];
  106766. /**
  106767. * Begin a new animation on a given node
  106768. * @param target defines the target where the animation will take place
  106769. * @param animations defines the list of animations to start
  106770. * @param from defines the initial value
  106771. * @param to defines the final value
  106772. * @param loop defines if you want animation to loop (off by default)
  106773. * @param speedRatio defines the speed ratio to apply to all animations
  106774. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106775. * @param onAnimationLoop defines the callback to call when an animation loops
  106776. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106777. * @returns the list of created animatables
  106778. */
  106779. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  106780. /**
  106781. * Begin a new animation on a given node and its hierarchy
  106782. * @param target defines the root node where the animation will take place
  106783. * @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.
  106784. * @param animations defines the list of animations to start
  106785. * @param from defines the initial value
  106786. * @param to defines the final value
  106787. * @param loop defines if you want animation to loop (off by default)
  106788. * @param speedRatio defines the speed ratio to apply to all animations
  106789. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106790. * @param onAnimationLoop defines the callback to call when an animation loops
  106791. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106792. * @returns the list of animatables created for all nodes
  106793. */
  106794. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  106795. /**
  106796. * Gets the animatable associated with a specific target
  106797. * @param target defines the target of the animatable
  106798. * @returns the required animatable if found
  106799. */
  106800. getAnimatableByTarget(target: any): Nullable<Animatable>;
  106801. /**
  106802. * Gets all animatables associated with a given target
  106803. * @param target defines the target to look animatables for
  106804. * @returns an array of Animatables
  106805. */
  106806. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  106807. /**
  106808. * Stops and removes all animations that have been applied to the scene
  106809. */
  106810. stopAllAnimations(): void;
  106811. /**
  106812. * Gets the current delta time used by animation engine
  106813. */
  106814. deltaTime: number;
  106815. }
  106816. interface Bone {
  106817. /**
  106818. * Copy an animation range from another bone
  106819. * @param source defines the source bone
  106820. * @param rangeName defines the range name to copy
  106821. * @param frameOffset defines the frame offset
  106822. * @param rescaleAsRequired defines if rescaling must be applied if required
  106823. * @param skelDimensionsRatio defines the scaling ratio
  106824. * @returns true if operation was successful
  106825. */
  106826. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  106827. }
  106828. }
  106829. declare module BABYLON {
  106830. /**
  106831. * Class used to override all child animations of a given target
  106832. */
  106833. export class AnimationPropertiesOverride {
  106834. /**
  106835. * Gets or sets a value indicating if animation blending must be used
  106836. */
  106837. enableBlending: boolean;
  106838. /**
  106839. * Gets or sets the blending speed to use when enableBlending is true
  106840. */
  106841. blendingSpeed: number;
  106842. /**
  106843. * Gets or sets the default loop mode to use
  106844. */
  106845. loopMode: number;
  106846. }
  106847. }
  106848. declare module BABYLON {
  106849. /**
  106850. * Class used to handle skinning animations
  106851. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  106852. */
  106853. export class Skeleton implements IAnimatable {
  106854. /** defines the skeleton name */
  106855. name: string;
  106856. /** defines the skeleton Id */
  106857. id: string;
  106858. /**
  106859. * Defines the list of child bones
  106860. */
  106861. bones: Bone[];
  106862. /**
  106863. * Defines an estimate of the dimension of the skeleton at rest
  106864. */
  106865. dimensionsAtRest: Vector3;
  106866. /**
  106867. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  106868. */
  106869. needInitialSkinMatrix: boolean;
  106870. /**
  106871. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  106872. */
  106873. overrideMesh: Nullable<AbstractMesh>;
  106874. /**
  106875. * Gets the list of animations attached to this skeleton
  106876. */
  106877. animations: Array<Animation>;
  106878. private _scene;
  106879. private _isDirty;
  106880. private _transformMatrices;
  106881. private _transformMatrixTexture;
  106882. private _meshesWithPoseMatrix;
  106883. private _animatables;
  106884. private _identity;
  106885. private _synchronizedWithMesh;
  106886. private _ranges;
  106887. private _lastAbsoluteTransformsUpdateId;
  106888. private _canUseTextureForBones;
  106889. private _uniqueId;
  106890. /** @hidden */
  106891. _numBonesWithLinkedTransformNode: number;
  106892. /** @hidden */
  106893. _hasWaitingData: Nullable<boolean>;
  106894. /** @hidden */
  106895. _waitingOverrideMeshId: Nullable<string>;
  106896. /**
  106897. * Specifies if the skeleton should be serialized
  106898. */
  106899. doNotSerialize: boolean;
  106900. private _useTextureToStoreBoneMatrices;
  106901. /**
  106902. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  106903. * Please note that this option is not available if the hardware does not support it
  106904. */
  106905. get useTextureToStoreBoneMatrices(): boolean;
  106906. set useTextureToStoreBoneMatrices(value: boolean);
  106907. private _animationPropertiesOverride;
  106908. /**
  106909. * Gets or sets the animation properties override
  106910. */
  106911. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106912. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106913. /**
  106914. * List of inspectable custom properties (used by the Inspector)
  106915. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  106916. */
  106917. inspectableCustomProperties: IInspectable[];
  106918. /**
  106919. * An observable triggered before computing the skeleton's matrices
  106920. */
  106921. onBeforeComputeObservable: Observable<Skeleton>;
  106922. /**
  106923. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  106924. */
  106925. get isUsingTextureForMatrices(): boolean;
  106926. /**
  106927. * Gets the unique ID of this skeleton
  106928. */
  106929. get uniqueId(): number;
  106930. /**
  106931. * Creates a new skeleton
  106932. * @param name defines the skeleton name
  106933. * @param id defines the skeleton Id
  106934. * @param scene defines the hosting scene
  106935. */
  106936. constructor(
  106937. /** defines the skeleton name */
  106938. name: string,
  106939. /** defines the skeleton Id */
  106940. id: string, scene: Scene);
  106941. /**
  106942. * Gets the current object class name.
  106943. * @return the class name
  106944. */
  106945. getClassName(): string;
  106946. /**
  106947. * Returns an array containing the root bones
  106948. * @returns an array containing the root bones
  106949. */
  106950. getChildren(): Array<Bone>;
  106951. /**
  106952. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  106953. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106954. * @returns a Float32Array containing matrices data
  106955. */
  106956. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  106957. /**
  106958. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  106959. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106960. * @returns a raw texture containing the data
  106961. */
  106962. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  106963. /**
  106964. * Gets the current hosting scene
  106965. * @returns a scene object
  106966. */
  106967. getScene(): Scene;
  106968. /**
  106969. * Gets a string representing the current skeleton data
  106970. * @param fullDetails defines a boolean indicating if we want a verbose version
  106971. * @returns a string representing the current skeleton data
  106972. */
  106973. toString(fullDetails?: boolean): string;
  106974. /**
  106975. * Get bone's index searching by name
  106976. * @param name defines bone's name to search for
  106977. * @return the indice of the bone. Returns -1 if not found
  106978. */
  106979. getBoneIndexByName(name: string): number;
  106980. /**
  106981. * Creater a new animation range
  106982. * @param name defines the name of the range
  106983. * @param from defines the start key
  106984. * @param to defines the end key
  106985. */
  106986. createAnimationRange(name: string, from: number, to: number): void;
  106987. /**
  106988. * Delete a specific animation range
  106989. * @param name defines the name of the range
  106990. * @param deleteFrames defines if frames must be removed as well
  106991. */
  106992. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  106993. /**
  106994. * Gets a specific animation range
  106995. * @param name defines the name of the range to look for
  106996. * @returns the requested animation range or null if not found
  106997. */
  106998. getAnimationRange(name: string): Nullable<AnimationRange>;
  106999. /**
  107000. * Gets the list of all animation ranges defined on this skeleton
  107001. * @returns an array
  107002. */
  107003. getAnimationRanges(): Nullable<AnimationRange>[];
  107004. /**
  107005. * Copy animation range from a source skeleton.
  107006. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  107007. * @param source defines the source skeleton
  107008. * @param name defines the name of the range to copy
  107009. * @param rescaleAsRequired defines if rescaling must be applied if required
  107010. * @returns true if operation was successful
  107011. */
  107012. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  107013. /**
  107014. * Forces the skeleton to go to rest pose
  107015. */
  107016. returnToRest(): void;
  107017. private _getHighestAnimationFrame;
  107018. /**
  107019. * Begin a specific animation range
  107020. * @param name defines the name of the range to start
  107021. * @param loop defines if looping must be turned on (false by default)
  107022. * @param speedRatio defines the speed ratio to apply (1 by default)
  107023. * @param onAnimationEnd defines a callback which will be called when animation will end
  107024. * @returns a new animatable
  107025. */
  107026. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  107027. /**
  107028. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  107029. * @param skeleton defines the Skeleton containing the animation range to convert
  107030. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  107031. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  107032. * @returns the original skeleton
  107033. */
  107034. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  107035. /** @hidden */
  107036. _markAsDirty(): void;
  107037. /** @hidden */
  107038. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  107039. /** @hidden */
  107040. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  107041. private _computeTransformMatrices;
  107042. /**
  107043. * Build all resources required to render a skeleton
  107044. */
  107045. prepare(): void;
  107046. /**
  107047. * Gets the list of animatables currently running for this skeleton
  107048. * @returns an array of animatables
  107049. */
  107050. getAnimatables(): IAnimatable[];
  107051. /**
  107052. * Clone the current skeleton
  107053. * @param name defines the name of the new skeleton
  107054. * @param id defines the id of the new skeleton
  107055. * @returns the new skeleton
  107056. */
  107057. clone(name: string, id?: string): Skeleton;
  107058. /**
  107059. * Enable animation blending for this skeleton
  107060. * @param blendingSpeed defines the blending speed to apply
  107061. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  107062. */
  107063. enableBlending(blendingSpeed?: number): void;
  107064. /**
  107065. * Releases all resources associated with the current skeleton
  107066. */
  107067. dispose(): void;
  107068. /**
  107069. * Serialize the skeleton in a JSON object
  107070. * @returns a JSON object
  107071. */
  107072. serialize(): any;
  107073. /**
  107074. * Creates a new skeleton from serialized data
  107075. * @param parsedSkeleton defines the serialized data
  107076. * @param scene defines the hosting scene
  107077. * @returns a new skeleton
  107078. */
  107079. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  107080. /**
  107081. * Compute all node absolute transforms
  107082. * @param forceUpdate defines if computation must be done even if cache is up to date
  107083. */
  107084. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  107085. /**
  107086. * Gets the root pose matrix
  107087. * @returns a matrix
  107088. */
  107089. getPoseMatrix(): Nullable<Matrix>;
  107090. /**
  107091. * Sorts bones per internal index
  107092. */
  107093. sortBones(): void;
  107094. private _sortBones;
  107095. /**
  107096. * Set the current local matrix as the restPose for all bones in the skeleton.
  107097. */
  107098. setCurrentPoseAsRest(): void;
  107099. }
  107100. }
  107101. declare module BABYLON {
  107102. /**
  107103. * Class used to store bone information
  107104. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107105. */
  107106. export class Bone extends Node {
  107107. /**
  107108. * defines the bone name
  107109. */
  107110. name: string;
  107111. private static _tmpVecs;
  107112. private static _tmpQuat;
  107113. private static _tmpMats;
  107114. /**
  107115. * Gets the list of child bones
  107116. */
  107117. children: Bone[];
  107118. /** Gets the animations associated with this bone */
  107119. animations: Animation[];
  107120. /**
  107121. * Gets or sets bone length
  107122. */
  107123. length: number;
  107124. /**
  107125. * @hidden Internal only
  107126. * Set this value to map this bone to a different index in the transform matrices
  107127. * Set this value to -1 to exclude the bone from the transform matrices
  107128. */
  107129. _index: Nullable<number>;
  107130. private _skeleton;
  107131. private _localMatrix;
  107132. private _restPose;
  107133. private _bindPose;
  107134. private _baseMatrix;
  107135. private _absoluteTransform;
  107136. private _invertedAbsoluteTransform;
  107137. private _parent;
  107138. private _scalingDeterminant;
  107139. private _worldTransform;
  107140. private _localScaling;
  107141. private _localRotation;
  107142. private _localPosition;
  107143. private _needToDecompose;
  107144. private _needToCompose;
  107145. /** @hidden */
  107146. _linkedTransformNode: Nullable<TransformNode>;
  107147. /** @hidden */
  107148. _waitingTransformNodeId: Nullable<string>;
  107149. /** @hidden */
  107150. get _matrix(): Matrix;
  107151. /** @hidden */
  107152. set _matrix(value: Matrix);
  107153. /**
  107154. * Create a new bone
  107155. * @param name defines the bone name
  107156. * @param skeleton defines the parent skeleton
  107157. * @param parentBone defines the parent (can be null if the bone is the root)
  107158. * @param localMatrix defines the local matrix
  107159. * @param restPose defines the rest pose matrix
  107160. * @param baseMatrix defines the base matrix
  107161. * @param index defines index of the bone in the hiearchy
  107162. */
  107163. constructor(
  107164. /**
  107165. * defines the bone name
  107166. */
  107167. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  107168. /**
  107169. * Gets the current object class name.
  107170. * @return the class name
  107171. */
  107172. getClassName(): string;
  107173. /**
  107174. * Gets the parent skeleton
  107175. * @returns a skeleton
  107176. */
  107177. getSkeleton(): Skeleton;
  107178. /**
  107179. * Gets parent bone
  107180. * @returns a bone or null if the bone is the root of the bone hierarchy
  107181. */
  107182. getParent(): Nullable<Bone>;
  107183. /**
  107184. * Returns an array containing the root bones
  107185. * @returns an array containing the root bones
  107186. */
  107187. getChildren(): Array<Bone>;
  107188. /**
  107189. * Gets the node index in matrix array generated for rendering
  107190. * @returns the node index
  107191. */
  107192. getIndex(): number;
  107193. /**
  107194. * Sets the parent bone
  107195. * @param parent defines the parent (can be null if the bone is the root)
  107196. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  107197. */
  107198. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  107199. /**
  107200. * Gets the local matrix
  107201. * @returns a matrix
  107202. */
  107203. getLocalMatrix(): Matrix;
  107204. /**
  107205. * Gets the base matrix (initial matrix which remains unchanged)
  107206. * @returns a matrix
  107207. */
  107208. getBaseMatrix(): Matrix;
  107209. /**
  107210. * Gets the rest pose matrix
  107211. * @returns a matrix
  107212. */
  107213. getRestPose(): Matrix;
  107214. /**
  107215. * Sets the rest pose matrix
  107216. * @param matrix the local-space rest pose to set for this bone
  107217. */
  107218. setRestPose(matrix: Matrix): void;
  107219. /**
  107220. * Gets the bind pose matrix
  107221. * @returns the bind pose matrix
  107222. */
  107223. getBindPose(): Matrix;
  107224. /**
  107225. * Sets the bind pose matrix
  107226. * @param matrix the local-space bind pose to set for this bone
  107227. */
  107228. setBindPose(matrix: Matrix): void;
  107229. /**
  107230. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  107231. */
  107232. getWorldMatrix(): Matrix;
  107233. /**
  107234. * Sets the local matrix to rest pose matrix
  107235. */
  107236. returnToRest(): void;
  107237. /**
  107238. * Gets the inverse of the absolute transform matrix.
  107239. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  107240. * @returns a matrix
  107241. */
  107242. getInvertedAbsoluteTransform(): Matrix;
  107243. /**
  107244. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  107245. * @returns a matrix
  107246. */
  107247. getAbsoluteTransform(): Matrix;
  107248. /**
  107249. * Links with the given transform node.
  107250. * The local matrix of this bone is copied from the transform node every frame.
  107251. * @param transformNode defines the transform node to link to
  107252. */
  107253. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  107254. /**
  107255. * Gets the node used to drive the bone's transformation
  107256. * @returns a transform node or null
  107257. */
  107258. getTransformNode(): Nullable<TransformNode>;
  107259. /** Gets or sets current position (in local space) */
  107260. get position(): Vector3;
  107261. set position(newPosition: Vector3);
  107262. /** Gets or sets current rotation (in local space) */
  107263. get rotation(): Vector3;
  107264. set rotation(newRotation: Vector3);
  107265. /** Gets or sets current rotation quaternion (in local space) */
  107266. get rotationQuaternion(): Quaternion;
  107267. set rotationQuaternion(newRotation: Quaternion);
  107268. /** Gets or sets current scaling (in local space) */
  107269. get scaling(): Vector3;
  107270. set scaling(newScaling: Vector3);
  107271. /**
  107272. * Gets the animation properties override
  107273. */
  107274. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107275. private _decompose;
  107276. private _compose;
  107277. /**
  107278. * Update the base and local matrices
  107279. * @param matrix defines the new base or local matrix
  107280. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  107281. * @param updateLocalMatrix defines if the local matrix should be updated
  107282. */
  107283. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  107284. /** @hidden */
  107285. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  107286. /**
  107287. * Flag the bone as dirty (Forcing it to update everything)
  107288. */
  107289. markAsDirty(): void;
  107290. /** @hidden */
  107291. _markAsDirtyAndCompose(): void;
  107292. private _markAsDirtyAndDecompose;
  107293. /**
  107294. * Translate the bone in local or world space
  107295. * @param vec The amount to translate the bone
  107296. * @param space The space that the translation is in
  107297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107298. */
  107299. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107300. /**
  107301. * Set the postion of the bone in local or world space
  107302. * @param position The position to set the bone
  107303. * @param space The space that the position is in
  107304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107305. */
  107306. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107307. /**
  107308. * Set the absolute position of the bone (world space)
  107309. * @param position The position to set the bone
  107310. * @param mesh The mesh that this bone is attached to
  107311. */
  107312. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  107313. /**
  107314. * Scale the bone on the x, y and z axes (in local space)
  107315. * @param x The amount to scale the bone on the x axis
  107316. * @param y The amount to scale the bone on the y axis
  107317. * @param z The amount to scale the bone on the z axis
  107318. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  107319. */
  107320. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  107321. /**
  107322. * Set the bone scaling in local space
  107323. * @param scale defines the scaling vector
  107324. */
  107325. setScale(scale: Vector3): void;
  107326. /**
  107327. * Gets the current scaling in local space
  107328. * @returns the current scaling vector
  107329. */
  107330. getScale(): Vector3;
  107331. /**
  107332. * Gets the current scaling in local space and stores it in a target vector
  107333. * @param result defines the target vector
  107334. */
  107335. getScaleToRef(result: Vector3): void;
  107336. /**
  107337. * Set the yaw, pitch, and roll of the bone in local or world space
  107338. * @param yaw The rotation of the bone on the y axis
  107339. * @param pitch The rotation of the bone on the x axis
  107340. * @param roll The rotation of the bone on the z axis
  107341. * @param space The space that the axes of rotation are in
  107342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107343. */
  107344. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  107345. /**
  107346. * Add a rotation to the bone on an axis in local or world space
  107347. * @param axis The axis to rotate the bone on
  107348. * @param amount The amount to rotate the bone
  107349. * @param space The space that the axis is in
  107350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107351. */
  107352. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  107353. /**
  107354. * Set the rotation of the bone to a particular axis angle in local or world space
  107355. * @param axis The axis to rotate the bone on
  107356. * @param angle The angle that the bone should be rotated to
  107357. * @param space The space that the axis is in
  107358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107359. */
  107360. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  107361. /**
  107362. * Set the euler rotation of the bone in local or world space
  107363. * @param rotation The euler rotation that the bone should be set to
  107364. * @param space The space that the rotation is in
  107365. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107366. */
  107367. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107368. /**
  107369. * Set the quaternion rotation of the bone in local or world space
  107370. * @param quat The quaternion rotation that the bone should be set to
  107371. * @param space The space that the rotation is in
  107372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107373. */
  107374. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  107375. /**
  107376. * Set the rotation matrix of the bone in local or world space
  107377. * @param rotMat The rotation matrix that the bone should be set to
  107378. * @param space The space that the rotation is in
  107379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107380. */
  107381. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  107382. private _rotateWithMatrix;
  107383. private _getNegativeRotationToRef;
  107384. /**
  107385. * Get the position of the bone in local or world space
  107386. * @param space The space that the returned position is in
  107387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107388. * @returns The position of the bone
  107389. */
  107390. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107391. /**
  107392. * Copy the position of the bone to a vector3 in local or world space
  107393. * @param space The space that the returned position is in
  107394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107395. * @param result The vector3 to copy the position to
  107396. */
  107397. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  107398. /**
  107399. * Get the absolute position of the bone (world space)
  107400. * @param mesh The mesh that this bone is attached to
  107401. * @returns The absolute position of the bone
  107402. */
  107403. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  107404. /**
  107405. * Copy the absolute position of the bone (world space) to the result param
  107406. * @param mesh The mesh that this bone is attached to
  107407. * @param result The vector3 to copy the absolute position to
  107408. */
  107409. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  107410. /**
  107411. * Compute the absolute transforms of this bone and its children
  107412. */
  107413. computeAbsoluteTransforms(): void;
  107414. /**
  107415. * Get the world direction from an axis that is in the local space of the bone
  107416. * @param localAxis The local direction that is used to compute the world direction
  107417. * @param mesh The mesh that this bone is attached to
  107418. * @returns The world direction
  107419. */
  107420. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107421. /**
  107422. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  107423. * @param localAxis The local direction that is used to compute the world direction
  107424. * @param mesh The mesh that this bone is attached to
  107425. * @param result The vector3 that the world direction will be copied to
  107426. */
  107427. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107428. /**
  107429. * Get the euler rotation of the bone in local or world space
  107430. * @param space The space that the rotation should be in
  107431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107432. * @returns The euler rotation
  107433. */
  107434. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107435. /**
  107436. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  107437. * @param space The space that the rotation should be in
  107438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107439. * @param result The vector3 that the rotation should be copied to
  107440. */
  107441. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107442. /**
  107443. * Get the quaternion rotation of the bone in either local or world space
  107444. * @param space The space that the rotation should be in
  107445. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107446. * @returns The quaternion rotation
  107447. */
  107448. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  107449. /**
  107450. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  107451. * @param space The space that the rotation should be in
  107452. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107453. * @param result The quaternion that the rotation should be copied to
  107454. */
  107455. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  107456. /**
  107457. * Get the rotation matrix of the bone in local or world space
  107458. * @param space The space that the rotation should be in
  107459. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107460. * @returns The rotation matrix
  107461. */
  107462. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  107463. /**
  107464. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  107465. * @param space The space that the rotation should be in
  107466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107467. * @param result The quaternion that the rotation should be copied to
  107468. */
  107469. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  107470. /**
  107471. * Get the world position of a point that is in the local space of the bone
  107472. * @param position The local position
  107473. * @param mesh The mesh that this bone is attached to
  107474. * @returns The world position
  107475. */
  107476. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107477. /**
  107478. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  107479. * @param position The local position
  107480. * @param mesh The mesh that this bone is attached to
  107481. * @param result The vector3 that the world position should be copied to
  107482. */
  107483. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107484. /**
  107485. * Get the local position of a point that is in world space
  107486. * @param position The world position
  107487. * @param mesh The mesh that this bone is attached to
  107488. * @returns The local position
  107489. */
  107490. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107491. /**
  107492. * Get the local position of a point that is in world space and copy it to the result param
  107493. * @param position The world position
  107494. * @param mesh The mesh that this bone is attached to
  107495. * @param result The vector3 that the local position should be copied to
  107496. */
  107497. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107498. /**
  107499. * Set the current local matrix as the restPose for this bone.
  107500. */
  107501. setCurrentPoseAsRest(): void;
  107502. }
  107503. }
  107504. declare module BABYLON {
  107505. /**
  107506. * 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.
  107507. * @see https://doc.babylonjs.com/how_to/transformnode
  107508. */
  107509. export class TransformNode extends Node {
  107510. /**
  107511. * Object will not rotate to face the camera
  107512. */
  107513. static BILLBOARDMODE_NONE: number;
  107514. /**
  107515. * Object will rotate to face the camera but only on the x axis
  107516. */
  107517. static BILLBOARDMODE_X: number;
  107518. /**
  107519. * Object will rotate to face the camera but only on the y axis
  107520. */
  107521. static BILLBOARDMODE_Y: number;
  107522. /**
  107523. * Object will rotate to face the camera but only on the z axis
  107524. */
  107525. static BILLBOARDMODE_Z: number;
  107526. /**
  107527. * Object will rotate to face the camera
  107528. */
  107529. static BILLBOARDMODE_ALL: number;
  107530. /**
  107531. * Object will rotate to face the camera's position instead of orientation
  107532. */
  107533. static BILLBOARDMODE_USE_POSITION: number;
  107534. private static _TmpRotation;
  107535. private static _TmpScaling;
  107536. private static _TmpTranslation;
  107537. private _forward;
  107538. private _forwardInverted;
  107539. private _up;
  107540. private _right;
  107541. private _rightInverted;
  107542. private _position;
  107543. private _rotation;
  107544. private _rotationQuaternion;
  107545. protected _scaling: Vector3;
  107546. protected _isDirty: boolean;
  107547. private _transformToBoneReferal;
  107548. private _isAbsoluteSynced;
  107549. private _billboardMode;
  107550. /**
  107551. * Gets or sets the billboard mode. Default is 0.
  107552. *
  107553. * | Value | Type | Description |
  107554. * | --- | --- | --- |
  107555. * | 0 | BILLBOARDMODE_NONE | |
  107556. * | 1 | BILLBOARDMODE_X | |
  107557. * | 2 | BILLBOARDMODE_Y | |
  107558. * | 4 | BILLBOARDMODE_Z | |
  107559. * | 7 | BILLBOARDMODE_ALL | |
  107560. *
  107561. */
  107562. get billboardMode(): number;
  107563. set billboardMode(value: number);
  107564. private _preserveParentRotationForBillboard;
  107565. /**
  107566. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  107567. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  107568. */
  107569. get preserveParentRotationForBillboard(): boolean;
  107570. set preserveParentRotationForBillboard(value: boolean);
  107571. /**
  107572. * 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
  107573. */
  107574. scalingDeterminant: number;
  107575. private _infiniteDistance;
  107576. /**
  107577. * Gets or sets the distance of the object to max, often used by skybox
  107578. */
  107579. get infiniteDistance(): boolean;
  107580. set infiniteDistance(value: boolean);
  107581. /**
  107582. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  107583. * By default the system will update normals to compensate
  107584. */
  107585. ignoreNonUniformScaling: boolean;
  107586. /**
  107587. * 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
  107588. */
  107589. reIntegrateRotationIntoRotationQuaternion: boolean;
  107590. /** @hidden */
  107591. _poseMatrix: Nullable<Matrix>;
  107592. /** @hidden */
  107593. _localMatrix: Matrix;
  107594. private _usePivotMatrix;
  107595. private _absolutePosition;
  107596. private _absoluteScaling;
  107597. private _absoluteRotationQuaternion;
  107598. private _pivotMatrix;
  107599. private _pivotMatrixInverse;
  107600. /** @hidden */
  107601. _postMultiplyPivotMatrix: boolean;
  107602. protected _isWorldMatrixFrozen: boolean;
  107603. /** @hidden */
  107604. _indexInSceneTransformNodesArray: number;
  107605. /**
  107606. * An event triggered after the world matrix is updated
  107607. */
  107608. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  107609. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  107610. /**
  107611. * Gets a string identifying the name of the class
  107612. * @returns "TransformNode" string
  107613. */
  107614. getClassName(): string;
  107615. /**
  107616. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  107617. */
  107618. get position(): Vector3;
  107619. set position(newPosition: Vector3);
  107620. /**
  107621. * 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)).
  107622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  107623. */
  107624. get rotation(): Vector3;
  107625. set rotation(newRotation: Vector3);
  107626. /**
  107627. * 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)).
  107628. */
  107629. get scaling(): Vector3;
  107630. set scaling(newScaling: Vector3);
  107631. /**
  107632. * 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).
  107633. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  107634. */
  107635. get rotationQuaternion(): Nullable<Quaternion>;
  107636. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  107637. /**
  107638. * The forward direction of that transform in world space.
  107639. */
  107640. get forward(): Vector3;
  107641. /**
  107642. * The up direction of that transform in world space.
  107643. */
  107644. get up(): Vector3;
  107645. /**
  107646. * The right direction of that transform in world space.
  107647. */
  107648. get right(): Vector3;
  107649. /**
  107650. * Copies the parameter passed Matrix into the mesh Pose matrix.
  107651. * @param matrix the matrix to copy the pose from
  107652. * @returns this TransformNode.
  107653. */
  107654. updatePoseMatrix(matrix: Matrix): TransformNode;
  107655. /**
  107656. * Returns the mesh Pose matrix.
  107657. * @returns the pose matrix
  107658. */
  107659. getPoseMatrix(): Matrix;
  107660. /** @hidden */
  107661. _isSynchronized(): boolean;
  107662. /** @hidden */
  107663. _initCache(): void;
  107664. /**
  107665. * Flag the transform node as dirty (Forcing it to update everything)
  107666. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  107667. * @returns this transform node
  107668. */
  107669. markAsDirty(property: string): TransformNode;
  107670. /**
  107671. * Returns the current mesh absolute position.
  107672. * Returns a Vector3.
  107673. */
  107674. get absolutePosition(): Vector3;
  107675. /**
  107676. * Returns the current mesh absolute scaling.
  107677. * Returns a Vector3.
  107678. */
  107679. get absoluteScaling(): Vector3;
  107680. /**
  107681. * Returns the current mesh absolute rotation.
  107682. * Returns a Quaternion.
  107683. */
  107684. get absoluteRotationQuaternion(): Quaternion;
  107685. /**
  107686. * Sets a new matrix to apply before all other transformation
  107687. * @param matrix defines the transform matrix
  107688. * @returns the current TransformNode
  107689. */
  107690. setPreTransformMatrix(matrix: Matrix): TransformNode;
  107691. /**
  107692. * Sets a new pivot matrix to the current node
  107693. * @param matrix defines the new pivot matrix to use
  107694. * @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
  107695. * @returns the current TransformNode
  107696. */
  107697. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  107698. /**
  107699. * Returns the mesh pivot matrix.
  107700. * Default : Identity.
  107701. * @returns the matrix
  107702. */
  107703. getPivotMatrix(): Matrix;
  107704. /**
  107705. * Instantiate (when possible) or clone that node with its hierarchy
  107706. * @param newParent defines the new parent to use for the instance (or clone)
  107707. * @param options defines options to configure how copy is done
  107708. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  107709. * @returns an instance (or a clone) of the current node with its hiearchy
  107710. */
  107711. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107712. doNotInstantiate: boolean;
  107713. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107714. /**
  107715. * Prevents the World matrix to be computed any longer
  107716. * @param newWorldMatrix defines an optional matrix to use as world matrix
  107717. * @returns the TransformNode.
  107718. */
  107719. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  107720. /**
  107721. * Allows back the World matrix computation.
  107722. * @returns the TransformNode.
  107723. */
  107724. unfreezeWorldMatrix(): this;
  107725. /**
  107726. * True if the World matrix has been frozen.
  107727. */
  107728. get isWorldMatrixFrozen(): boolean;
  107729. /**
  107730. * Retuns the mesh absolute position in the World.
  107731. * @returns a Vector3.
  107732. */
  107733. getAbsolutePosition(): Vector3;
  107734. /**
  107735. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  107736. * @param absolutePosition the absolute position to set
  107737. * @returns the TransformNode.
  107738. */
  107739. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107740. /**
  107741. * Sets the mesh position in its local space.
  107742. * @param vector3 the position to set in localspace
  107743. * @returns the TransformNode.
  107744. */
  107745. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  107746. /**
  107747. * Returns the mesh position in the local space from the current World matrix values.
  107748. * @returns a new Vector3.
  107749. */
  107750. getPositionExpressedInLocalSpace(): Vector3;
  107751. /**
  107752. * Translates the mesh along the passed Vector3 in its local space.
  107753. * @param vector3 the distance to translate in localspace
  107754. * @returns the TransformNode.
  107755. */
  107756. locallyTranslate(vector3: Vector3): TransformNode;
  107757. private static _lookAtVectorCache;
  107758. /**
  107759. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  107760. * @param targetPoint the position (must be in same space as current mesh) to look at
  107761. * @param yawCor optional yaw (y-axis) correction in radians
  107762. * @param pitchCor optional pitch (x-axis) correction in radians
  107763. * @param rollCor optional roll (z-axis) correction in radians
  107764. * @param space the choosen space of the target
  107765. * @returns the TransformNode.
  107766. */
  107767. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  107768. /**
  107769. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107770. * This Vector3 is expressed in the World space.
  107771. * @param localAxis axis to rotate
  107772. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107773. */
  107774. getDirection(localAxis: Vector3): Vector3;
  107775. /**
  107776. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  107777. * localAxis is expressed in the mesh local space.
  107778. * result is computed in the Wordl space from the mesh World matrix.
  107779. * @param localAxis axis to rotate
  107780. * @param result the resulting transformnode
  107781. * @returns this TransformNode.
  107782. */
  107783. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  107784. /**
  107785. * Sets this transform node rotation to the given local axis.
  107786. * @param localAxis the axis in local space
  107787. * @param yawCor optional yaw (y-axis) correction in radians
  107788. * @param pitchCor optional pitch (x-axis) correction in radians
  107789. * @param rollCor optional roll (z-axis) correction in radians
  107790. * @returns this TransformNode
  107791. */
  107792. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  107793. /**
  107794. * Sets a new pivot point to the current node
  107795. * @param point defines the new pivot point to use
  107796. * @param space defines if the point is in world or local space (local by default)
  107797. * @returns the current TransformNode
  107798. */
  107799. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  107800. /**
  107801. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  107802. * @returns the pivot point
  107803. */
  107804. getPivotPoint(): Vector3;
  107805. /**
  107806. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  107807. * @param result the vector3 to store the result
  107808. * @returns this TransformNode.
  107809. */
  107810. getPivotPointToRef(result: Vector3): TransformNode;
  107811. /**
  107812. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  107813. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  107814. */
  107815. getAbsolutePivotPoint(): Vector3;
  107816. /**
  107817. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  107818. * @param result vector3 to store the result
  107819. * @returns this TransformNode.
  107820. */
  107821. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  107822. /**
  107823. * Defines the passed node as the parent of the current node.
  107824. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  107825. * @see https://doc.babylonjs.com/how_to/parenting
  107826. * @param node the node ot set as the parent
  107827. * @returns this TransformNode.
  107828. */
  107829. setParent(node: Nullable<Node>): TransformNode;
  107830. private _nonUniformScaling;
  107831. /**
  107832. * True if the scaling property of this object is non uniform eg. (1,2,1)
  107833. */
  107834. get nonUniformScaling(): boolean;
  107835. /** @hidden */
  107836. _updateNonUniformScalingState(value: boolean): boolean;
  107837. /**
  107838. * Attach the current TransformNode to another TransformNode associated with a bone
  107839. * @param bone Bone affecting the TransformNode
  107840. * @param affectedTransformNode TransformNode associated with the bone
  107841. * @returns this object
  107842. */
  107843. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  107844. /**
  107845. * Detach the transform node if its associated with a bone
  107846. * @returns this object
  107847. */
  107848. detachFromBone(): TransformNode;
  107849. private static _rotationAxisCache;
  107850. /**
  107851. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  107852. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107853. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107854. * The passed axis is also normalized.
  107855. * @param axis the axis to rotate around
  107856. * @param amount the amount to rotate in radians
  107857. * @param space Space to rotate in (Default: local)
  107858. * @returns the TransformNode.
  107859. */
  107860. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107861. /**
  107862. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  107863. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107864. * The passed axis is also normalized. .
  107865. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  107866. * @param point the point to rotate around
  107867. * @param axis the axis to rotate around
  107868. * @param amount the amount to rotate in radians
  107869. * @returns the TransformNode
  107870. */
  107871. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  107872. /**
  107873. * Translates the mesh along the axis vector for the passed distance in the given space.
  107874. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107875. * @param axis the axis to translate in
  107876. * @param distance the distance to translate
  107877. * @param space Space to rotate in (Default: local)
  107878. * @returns the TransformNode.
  107879. */
  107880. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107881. /**
  107882. * Adds a rotation step to the mesh current rotation.
  107883. * x, y, z are Euler angles expressed in radians.
  107884. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  107885. * This means this rotation is made in the mesh local space only.
  107886. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  107887. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  107888. * ```javascript
  107889. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  107890. * ```
  107891. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  107892. * 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.
  107893. * @param x Rotation to add
  107894. * @param y Rotation to add
  107895. * @param z Rotation to add
  107896. * @returns the TransformNode.
  107897. */
  107898. addRotation(x: number, y: number, z: number): TransformNode;
  107899. /**
  107900. * @hidden
  107901. */
  107902. protected _getEffectiveParent(): Nullable<Node>;
  107903. /**
  107904. * Computes the world matrix of the node
  107905. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  107906. * @returns the world matrix
  107907. */
  107908. computeWorldMatrix(force?: boolean): Matrix;
  107909. /**
  107910. * Resets this nodeTransform's local matrix to Matrix.Identity().
  107911. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  107912. */
  107913. resetLocalMatrix(independentOfChildren?: boolean): void;
  107914. protected _afterComputeWorldMatrix(): void;
  107915. /**
  107916. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  107917. * @param func callback function to add
  107918. *
  107919. * @returns the TransformNode.
  107920. */
  107921. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107922. /**
  107923. * Removes a registered callback function.
  107924. * @param func callback function to remove
  107925. * @returns the TransformNode.
  107926. */
  107927. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107928. /**
  107929. * Gets the position of the current mesh in camera space
  107930. * @param camera defines the camera to use
  107931. * @returns a position
  107932. */
  107933. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  107934. /**
  107935. * Returns the distance from the mesh to the active camera
  107936. * @param camera defines the camera to use
  107937. * @returns the distance
  107938. */
  107939. getDistanceToCamera(camera?: Nullable<Camera>): number;
  107940. /**
  107941. * Clone the current transform node
  107942. * @param name Name of the new clone
  107943. * @param newParent New parent for the clone
  107944. * @param doNotCloneChildren Do not clone children hierarchy
  107945. * @returns the new transform node
  107946. */
  107947. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  107948. /**
  107949. * Serializes the objects information.
  107950. * @param currentSerializationObject defines the object to serialize in
  107951. * @returns the serialized object
  107952. */
  107953. serialize(currentSerializationObject?: any): any;
  107954. /**
  107955. * Returns a new TransformNode object parsed from the source provided.
  107956. * @param parsedTransformNode is the source.
  107957. * @param scene the scne the object belongs to
  107958. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  107959. * @returns a new TransformNode object parsed from the source provided.
  107960. */
  107961. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  107962. /**
  107963. * Get all child-transformNodes of this node
  107964. * @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
  107965. * @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
  107966. * @returns an array of TransformNode
  107967. */
  107968. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  107969. /**
  107970. * Releases resources associated with this transform node.
  107971. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107972. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107973. */
  107974. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107975. /**
  107976. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  107977. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  107978. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  107979. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  107980. * @returns the current mesh
  107981. */
  107982. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  107983. private _syncAbsoluteScalingAndRotation;
  107984. }
  107985. }
  107986. declare module BABYLON {
  107987. /**
  107988. * Defines the types of pose enabled controllers that are supported
  107989. */
  107990. export enum PoseEnabledControllerType {
  107991. /**
  107992. * HTC Vive
  107993. */
  107994. VIVE = 0,
  107995. /**
  107996. * Oculus Rift
  107997. */
  107998. OCULUS = 1,
  107999. /**
  108000. * Windows mixed reality
  108001. */
  108002. WINDOWS = 2,
  108003. /**
  108004. * Samsung gear VR
  108005. */
  108006. GEAR_VR = 3,
  108007. /**
  108008. * Google Daydream
  108009. */
  108010. DAYDREAM = 4,
  108011. /**
  108012. * Generic
  108013. */
  108014. GENERIC = 5
  108015. }
  108016. /**
  108017. * Defines the MutableGamepadButton interface for the state of a gamepad button
  108018. */
  108019. export interface MutableGamepadButton {
  108020. /**
  108021. * Value of the button/trigger
  108022. */
  108023. value: number;
  108024. /**
  108025. * If the button/trigger is currently touched
  108026. */
  108027. touched: boolean;
  108028. /**
  108029. * If the button/trigger is currently pressed
  108030. */
  108031. pressed: boolean;
  108032. }
  108033. /**
  108034. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  108035. * @hidden
  108036. */
  108037. export interface ExtendedGamepadButton extends GamepadButton {
  108038. /**
  108039. * If the button/trigger is currently pressed
  108040. */
  108041. readonly pressed: boolean;
  108042. /**
  108043. * If the button/trigger is currently touched
  108044. */
  108045. readonly touched: boolean;
  108046. /**
  108047. * Value of the button/trigger
  108048. */
  108049. readonly value: number;
  108050. }
  108051. /** @hidden */
  108052. export interface _GamePadFactory {
  108053. /**
  108054. * Returns whether or not the current gamepad can be created for this type of controller.
  108055. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  108056. * @returns true if it can be created, otherwise false
  108057. */
  108058. canCreate(gamepadInfo: any): boolean;
  108059. /**
  108060. * Creates a new instance of the Gamepad.
  108061. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  108062. * @returns the new gamepad instance
  108063. */
  108064. create(gamepadInfo: any): Gamepad;
  108065. }
  108066. /**
  108067. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  108068. */
  108069. export class PoseEnabledControllerHelper {
  108070. /** @hidden */
  108071. static _ControllerFactories: _GamePadFactory[];
  108072. /** @hidden */
  108073. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  108074. /**
  108075. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  108076. * @param vrGamepad the gamepad to initialized
  108077. * @returns a vr controller of the type the gamepad identified as
  108078. */
  108079. static InitiateController(vrGamepad: any): Gamepad;
  108080. }
  108081. /**
  108082. * Defines the PoseEnabledController object that contains state of a vr capable controller
  108083. */
  108084. export class PoseEnabledController extends Gamepad implements PoseControlled {
  108085. /**
  108086. * If the controller is used in a webXR session
  108087. */
  108088. isXR: boolean;
  108089. private _deviceRoomPosition;
  108090. private _deviceRoomRotationQuaternion;
  108091. /**
  108092. * The device position in babylon space
  108093. */
  108094. devicePosition: Vector3;
  108095. /**
  108096. * The device rotation in babylon space
  108097. */
  108098. deviceRotationQuaternion: Quaternion;
  108099. /**
  108100. * The scale factor of the device in babylon space
  108101. */
  108102. deviceScaleFactor: number;
  108103. /**
  108104. * (Likely devicePosition should be used instead) The device position in its room space
  108105. */
  108106. position: Vector3;
  108107. /**
  108108. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  108109. */
  108110. rotationQuaternion: Quaternion;
  108111. /**
  108112. * The type of controller (Eg. Windows mixed reality)
  108113. */
  108114. controllerType: PoseEnabledControllerType;
  108115. protected _calculatedPosition: Vector3;
  108116. private _calculatedRotation;
  108117. /**
  108118. * The raw pose from the device
  108119. */
  108120. rawPose: DevicePose;
  108121. private _trackPosition;
  108122. private _maxRotationDistFromHeadset;
  108123. private _draggedRoomRotation;
  108124. /**
  108125. * @hidden
  108126. */
  108127. _disableTrackPosition(fixedPosition: Vector3): void;
  108128. /**
  108129. * Internal, the mesh attached to the controller
  108130. * @hidden
  108131. */
  108132. _mesh: Nullable<AbstractMesh>;
  108133. private _poseControlledCamera;
  108134. private _leftHandSystemQuaternion;
  108135. /**
  108136. * Internal, matrix used to convert room space to babylon space
  108137. * @hidden
  108138. */
  108139. _deviceToWorld: Matrix;
  108140. /**
  108141. * Node to be used when casting a ray from the controller
  108142. * @hidden
  108143. */
  108144. _pointingPoseNode: Nullable<TransformNode>;
  108145. /**
  108146. * Name of the child mesh that can be used to cast a ray from the controller
  108147. */
  108148. static readonly POINTING_POSE: string;
  108149. /**
  108150. * Creates a new PoseEnabledController from a gamepad
  108151. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  108152. */
  108153. constructor(browserGamepad: any);
  108154. private _workingMatrix;
  108155. /**
  108156. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  108157. */
  108158. update(): void;
  108159. /**
  108160. * Updates only the pose device and mesh without doing any button event checking
  108161. */
  108162. protected _updatePoseAndMesh(): void;
  108163. /**
  108164. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  108165. * @param poseData raw pose fromthe device
  108166. */
  108167. updateFromDevice(poseData: DevicePose): void;
  108168. /**
  108169. * @hidden
  108170. */
  108171. _meshAttachedObservable: Observable<AbstractMesh>;
  108172. /**
  108173. * Attaches a mesh to the controller
  108174. * @param mesh the mesh to be attached
  108175. */
  108176. attachToMesh(mesh: AbstractMesh): void;
  108177. /**
  108178. * Attaches the controllers mesh to a camera
  108179. * @param camera the camera the mesh should be attached to
  108180. */
  108181. attachToPoseControlledCamera(camera: TargetCamera): void;
  108182. /**
  108183. * Disposes of the controller
  108184. */
  108185. dispose(): void;
  108186. /**
  108187. * The mesh that is attached to the controller
  108188. */
  108189. get mesh(): Nullable<AbstractMesh>;
  108190. /**
  108191. * Gets the ray of the controller in the direction the controller is pointing
  108192. * @param length the length the resulting ray should be
  108193. * @returns a ray in the direction the controller is pointing
  108194. */
  108195. getForwardRay(length?: number): Ray;
  108196. }
  108197. }
  108198. declare module BABYLON {
  108199. /**
  108200. * Defines the WebVRController object that represents controllers tracked in 3D space
  108201. */
  108202. export abstract class WebVRController extends PoseEnabledController {
  108203. /**
  108204. * Internal, the default controller model for the controller
  108205. */
  108206. protected _defaultModel: Nullable<AbstractMesh>;
  108207. /**
  108208. * Fired when the trigger state has changed
  108209. */
  108210. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108211. /**
  108212. * Fired when the main button state has changed
  108213. */
  108214. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108215. /**
  108216. * Fired when the secondary button state has changed
  108217. */
  108218. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108219. /**
  108220. * Fired when the pad state has changed
  108221. */
  108222. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  108223. /**
  108224. * Fired when controllers stick values have changed
  108225. */
  108226. onPadValuesChangedObservable: Observable<StickValues>;
  108227. /**
  108228. * Array of button availible on the controller
  108229. */
  108230. protected _buttons: Array<MutableGamepadButton>;
  108231. private _onButtonStateChange;
  108232. /**
  108233. * Fired when a controller button's state has changed
  108234. * @param callback the callback containing the button that was modified
  108235. */
  108236. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  108237. /**
  108238. * X and Y axis corresponding to the controllers joystick
  108239. */
  108240. pad: StickValues;
  108241. /**
  108242. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  108243. */
  108244. hand: string;
  108245. /**
  108246. * The default controller model for the controller
  108247. */
  108248. get defaultModel(): Nullable<AbstractMesh>;
  108249. /**
  108250. * Creates a new WebVRController from a gamepad
  108251. * @param vrGamepad the gamepad that the WebVRController should be created from
  108252. */
  108253. constructor(vrGamepad: any);
  108254. /**
  108255. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  108256. */
  108257. update(): void;
  108258. /**
  108259. * Function to be called when a button is modified
  108260. */
  108261. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108262. /**
  108263. * Loads a mesh and attaches it to the controller
  108264. * @param scene the scene the mesh should be added to
  108265. * @param meshLoaded callback for when the mesh has been loaded
  108266. */
  108267. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108268. private _setButtonValue;
  108269. private _changes;
  108270. private _checkChanges;
  108271. /**
  108272. * Disposes of th webVRCOntroller
  108273. */
  108274. dispose(): void;
  108275. }
  108276. }
  108277. declare module BABYLON {
  108278. /**
  108279. * The HemisphericLight simulates the ambient environment light,
  108280. * so the passed direction is the light reflection direction, not the incoming direction.
  108281. */
  108282. export class HemisphericLight extends Light {
  108283. /**
  108284. * The groundColor is the light in the opposite direction to the one specified during creation.
  108285. * 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.
  108286. */
  108287. groundColor: Color3;
  108288. /**
  108289. * The light reflection direction, not the incoming direction.
  108290. */
  108291. direction: Vector3;
  108292. /**
  108293. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  108294. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  108295. * The HemisphericLight can't cast shadows.
  108296. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108297. * @param name The friendly name of the light
  108298. * @param direction The direction of the light reflection
  108299. * @param scene The scene the light belongs to
  108300. */
  108301. constructor(name: string, direction: Vector3, scene: Scene);
  108302. protected _buildUniformLayout(): void;
  108303. /**
  108304. * Returns the string "HemisphericLight".
  108305. * @return The class name
  108306. */
  108307. getClassName(): string;
  108308. /**
  108309. * Sets the HemisphericLight direction towards the passed target (Vector3).
  108310. * Returns the updated direction.
  108311. * @param target The target the direction should point to
  108312. * @return The computed direction
  108313. */
  108314. setDirectionToTarget(target: Vector3): Vector3;
  108315. /**
  108316. * Returns the shadow generator associated to the light.
  108317. * @returns Always null for hemispheric lights because it does not support shadows.
  108318. */
  108319. getShadowGenerator(): Nullable<IShadowGenerator>;
  108320. /**
  108321. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  108322. * @param effect The effect to update
  108323. * @param lightIndex The index of the light in the effect to update
  108324. * @returns The hemispheric light
  108325. */
  108326. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  108327. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  108328. /**
  108329. * Computes the world matrix of the node
  108330. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  108331. * @param useWasUpdatedFlag defines a reserved property
  108332. * @returns the world matrix
  108333. */
  108334. computeWorldMatrix(): Matrix;
  108335. /**
  108336. * Returns the integer 3.
  108337. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108338. */
  108339. getTypeID(): number;
  108340. /**
  108341. * Prepares the list of defines specific to the light type.
  108342. * @param defines the list of defines
  108343. * @param lightIndex defines the index of the light for the effect
  108344. */
  108345. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108346. }
  108347. }
  108348. declare module BABYLON {
  108349. /** @hidden */
  108350. export var vrMultiviewToSingleviewPixelShader: {
  108351. name: string;
  108352. shader: string;
  108353. };
  108354. }
  108355. declare module BABYLON {
  108356. /**
  108357. * Renders to multiple views with a single draw call
  108358. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  108359. */
  108360. export class MultiviewRenderTarget extends RenderTargetTexture {
  108361. /**
  108362. * Creates a multiview render target
  108363. * @param scene scene used with the render target
  108364. * @param size the size of the render target (used for each view)
  108365. */
  108366. constructor(scene: Scene, size?: number | {
  108367. width: number;
  108368. height: number;
  108369. } | {
  108370. ratio: number;
  108371. });
  108372. /**
  108373. * @hidden
  108374. * @param faceIndex the face index, if its a cube texture
  108375. */
  108376. _bindFrameBuffer(faceIndex?: number): void;
  108377. /**
  108378. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  108379. * @returns the view count
  108380. */
  108381. getViewCount(): number;
  108382. }
  108383. }
  108384. declare module BABYLON {
  108385. interface Engine {
  108386. /**
  108387. * Creates a new multiview render target
  108388. * @param width defines the width of the texture
  108389. * @param height defines the height of the texture
  108390. * @returns the created multiview texture
  108391. */
  108392. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  108393. /**
  108394. * Binds a multiview framebuffer to be drawn to
  108395. * @param multiviewTexture texture to bind
  108396. */
  108397. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  108398. }
  108399. interface Camera {
  108400. /**
  108401. * @hidden
  108402. * 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)
  108403. */
  108404. _useMultiviewToSingleView: boolean;
  108405. /**
  108406. * @hidden
  108407. * 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)
  108408. */
  108409. _multiviewTexture: Nullable<RenderTargetTexture>;
  108410. /**
  108411. * @hidden
  108412. * ensures the multiview texture of the camera exists and has the specified width/height
  108413. * @param width height to set on the multiview texture
  108414. * @param height width to set on the multiview texture
  108415. */
  108416. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  108417. }
  108418. interface Scene {
  108419. /** @hidden */
  108420. _transformMatrixR: Matrix;
  108421. /** @hidden */
  108422. _multiviewSceneUbo: Nullable<UniformBuffer>;
  108423. /** @hidden */
  108424. _createMultiviewUbo(): void;
  108425. /** @hidden */
  108426. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  108427. /** @hidden */
  108428. _renderMultiviewToSingleView(camera: Camera): void;
  108429. }
  108430. }
  108431. declare module BABYLON {
  108432. /**
  108433. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  108434. * This will not be used for webXR as it supports displaying texture arrays directly
  108435. */
  108436. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  108437. /**
  108438. * Gets a string identifying the name of the class
  108439. * @returns "VRMultiviewToSingleviewPostProcess" string
  108440. */
  108441. getClassName(): string;
  108442. /**
  108443. * Initializes a VRMultiviewToSingleview
  108444. * @param name name of the post process
  108445. * @param camera camera to be applied to
  108446. * @param scaleFactor scaling factor to the size of the output texture
  108447. */
  108448. constructor(name: string, camera: Camera, scaleFactor: number);
  108449. }
  108450. }
  108451. declare module BABYLON {
  108452. /**
  108453. * Interface used to define additional presentation attributes
  108454. */
  108455. export interface IVRPresentationAttributes {
  108456. /**
  108457. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  108458. */
  108459. highRefreshRate: boolean;
  108460. /**
  108461. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  108462. */
  108463. foveationLevel: number;
  108464. }
  108465. interface Engine {
  108466. /** @hidden */
  108467. _vrDisplay: any;
  108468. /** @hidden */
  108469. _vrSupported: boolean;
  108470. /** @hidden */
  108471. _oldSize: Size;
  108472. /** @hidden */
  108473. _oldHardwareScaleFactor: number;
  108474. /** @hidden */
  108475. _vrExclusivePointerMode: boolean;
  108476. /** @hidden */
  108477. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  108478. /** @hidden */
  108479. _onVRDisplayPointerRestricted: () => void;
  108480. /** @hidden */
  108481. _onVRDisplayPointerUnrestricted: () => void;
  108482. /** @hidden */
  108483. _onVrDisplayConnect: Nullable<(display: any) => void>;
  108484. /** @hidden */
  108485. _onVrDisplayDisconnect: Nullable<() => void>;
  108486. /** @hidden */
  108487. _onVrDisplayPresentChange: Nullable<() => void>;
  108488. /**
  108489. * Observable signaled when VR display mode changes
  108490. */
  108491. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  108492. /**
  108493. * Observable signaled when VR request present is complete
  108494. */
  108495. onVRRequestPresentComplete: Observable<boolean>;
  108496. /**
  108497. * Observable signaled when VR request present starts
  108498. */
  108499. onVRRequestPresentStart: Observable<Engine>;
  108500. /**
  108501. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  108502. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  108503. */
  108504. isInVRExclusivePointerMode: boolean;
  108505. /**
  108506. * Gets a boolean indicating if a webVR device was detected
  108507. * @returns true if a webVR device was detected
  108508. */
  108509. isVRDevicePresent(): boolean;
  108510. /**
  108511. * Gets the current webVR device
  108512. * @returns the current webVR device (or null)
  108513. */
  108514. getVRDevice(): any;
  108515. /**
  108516. * Initializes a webVR display and starts listening to display change events
  108517. * The onVRDisplayChangedObservable will be notified upon these changes
  108518. * @returns A promise containing a VRDisplay and if vr is supported
  108519. */
  108520. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  108521. /** @hidden */
  108522. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  108523. /**
  108524. * Gets or sets the presentation attributes used to configure VR rendering
  108525. */
  108526. vrPresentationAttributes?: IVRPresentationAttributes;
  108527. /**
  108528. * Call this function to switch to webVR mode
  108529. * Will do nothing if webVR is not supported or if there is no webVR device
  108530. * @param options the webvr options provided to the camera. mainly used for multiview
  108531. * @see https://doc.babylonjs.com/how_to/webvr_camera
  108532. */
  108533. enableVR(options: WebVROptions): void;
  108534. /** @hidden */
  108535. _onVRFullScreenTriggered(): void;
  108536. }
  108537. }
  108538. declare module BABYLON {
  108539. /**
  108540. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  108541. * IMPORTANT!! The data is right-hand data.
  108542. * @export
  108543. * @interface DevicePose
  108544. */
  108545. export interface DevicePose {
  108546. /**
  108547. * The position of the device, values in array are [x,y,z].
  108548. */
  108549. readonly position: Nullable<Float32Array>;
  108550. /**
  108551. * The linearVelocity of the device, values in array are [x,y,z].
  108552. */
  108553. readonly linearVelocity: Nullable<Float32Array>;
  108554. /**
  108555. * The linearAcceleration of the device, values in array are [x,y,z].
  108556. */
  108557. readonly linearAcceleration: Nullable<Float32Array>;
  108558. /**
  108559. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  108560. */
  108561. readonly orientation: Nullable<Float32Array>;
  108562. /**
  108563. * The angularVelocity of the device, values in array are [x,y,z].
  108564. */
  108565. readonly angularVelocity: Nullable<Float32Array>;
  108566. /**
  108567. * The angularAcceleration of the device, values in array are [x,y,z].
  108568. */
  108569. readonly angularAcceleration: Nullable<Float32Array>;
  108570. }
  108571. /**
  108572. * Interface representing a pose controlled object in Babylon.
  108573. * A pose controlled object has both regular pose values as well as pose values
  108574. * from an external device such as a VR head mounted display
  108575. */
  108576. export interface PoseControlled {
  108577. /**
  108578. * The position of the object in babylon space.
  108579. */
  108580. position: Vector3;
  108581. /**
  108582. * The rotation quaternion of the object in babylon space.
  108583. */
  108584. rotationQuaternion: Quaternion;
  108585. /**
  108586. * The position of the device in babylon space.
  108587. */
  108588. devicePosition?: Vector3;
  108589. /**
  108590. * The rotation quaternion of the device in babylon space.
  108591. */
  108592. deviceRotationQuaternion: Quaternion;
  108593. /**
  108594. * The raw pose coming from the device.
  108595. */
  108596. rawPose: Nullable<DevicePose>;
  108597. /**
  108598. * The scale of the device to be used when translating from device space to babylon space.
  108599. */
  108600. deviceScaleFactor: number;
  108601. /**
  108602. * Updates the poseControlled values based on the input device pose.
  108603. * @param poseData the pose data to update the object with
  108604. */
  108605. updateFromDevice(poseData: DevicePose): void;
  108606. }
  108607. /**
  108608. * Set of options to customize the webVRCamera
  108609. */
  108610. export interface WebVROptions {
  108611. /**
  108612. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  108613. */
  108614. trackPosition?: boolean;
  108615. /**
  108616. * Sets the scale of the vrDevice in babylon space. (default: 1)
  108617. */
  108618. positionScale?: number;
  108619. /**
  108620. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  108621. */
  108622. displayName?: string;
  108623. /**
  108624. * Should the native controller meshes be initialized. (default: true)
  108625. */
  108626. controllerMeshes?: boolean;
  108627. /**
  108628. * Creating a default HemiLight only on controllers. (default: true)
  108629. */
  108630. defaultLightingOnControllers?: boolean;
  108631. /**
  108632. * If you don't want to use the default VR button of the helper. (default: false)
  108633. */
  108634. useCustomVRButton?: boolean;
  108635. /**
  108636. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  108637. */
  108638. customVRButton?: HTMLButtonElement;
  108639. /**
  108640. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  108641. */
  108642. rayLength?: number;
  108643. /**
  108644. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  108645. */
  108646. defaultHeight?: number;
  108647. /**
  108648. * If multiview should be used if availible (default: false)
  108649. */
  108650. useMultiview?: boolean;
  108651. }
  108652. /**
  108653. * This represents a WebVR camera.
  108654. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  108655. * @example https://doc.babylonjs.com/how_to/webvr_camera
  108656. */
  108657. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  108658. private webVROptions;
  108659. /**
  108660. * @hidden
  108661. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  108662. */
  108663. _vrDevice: any;
  108664. /**
  108665. * The rawPose of the vrDevice.
  108666. */
  108667. rawPose: Nullable<DevicePose>;
  108668. private _onVREnabled;
  108669. private _specsVersion;
  108670. private _attached;
  108671. private _frameData;
  108672. protected _descendants: Array<Node>;
  108673. private _deviceRoomPosition;
  108674. /** @hidden */
  108675. _deviceRoomRotationQuaternion: Quaternion;
  108676. private _standingMatrix;
  108677. /**
  108678. * Represents device position in babylon space.
  108679. */
  108680. devicePosition: Vector3;
  108681. /**
  108682. * Represents device rotation in babylon space.
  108683. */
  108684. deviceRotationQuaternion: Quaternion;
  108685. /**
  108686. * The scale of the device to be used when translating from device space to babylon space.
  108687. */
  108688. deviceScaleFactor: number;
  108689. private _deviceToWorld;
  108690. private _worldToDevice;
  108691. /**
  108692. * References to the webVR controllers for the vrDevice.
  108693. */
  108694. controllers: Array<WebVRController>;
  108695. /**
  108696. * Emits an event when a controller is attached.
  108697. */
  108698. onControllersAttachedObservable: Observable<WebVRController[]>;
  108699. /**
  108700. * Emits an event when a controller's mesh has been loaded;
  108701. */
  108702. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108703. /**
  108704. * Emits an event when the HMD's pose has been updated.
  108705. */
  108706. onPoseUpdatedFromDeviceObservable: Observable<any>;
  108707. private _poseSet;
  108708. /**
  108709. * If the rig cameras be used as parent instead of this camera.
  108710. */
  108711. rigParenting: boolean;
  108712. private _lightOnControllers;
  108713. private _defaultHeight?;
  108714. /**
  108715. * Instantiates a WebVRFreeCamera.
  108716. * @param name The name of the WebVRFreeCamera
  108717. * @param position The starting anchor position for the camera
  108718. * @param scene The scene the camera belongs to
  108719. * @param webVROptions a set of customizable options for the webVRCamera
  108720. */
  108721. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  108722. /**
  108723. * Gets the device distance from the ground in meters.
  108724. * @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.
  108725. */
  108726. deviceDistanceToRoomGround(): number;
  108727. /**
  108728. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108729. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  108730. */
  108731. useStandingMatrix(callback?: (bool: boolean) => void): void;
  108732. /**
  108733. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108734. * @returns A promise with a boolean set to if the standing matrix is supported.
  108735. */
  108736. useStandingMatrixAsync(): Promise<boolean>;
  108737. /**
  108738. * Disposes the camera
  108739. */
  108740. dispose(): void;
  108741. /**
  108742. * Gets a vrController by name.
  108743. * @param name The name of the controller to retreive
  108744. * @returns the controller matching the name specified or null if not found
  108745. */
  108746. getControllerByName(name: string): Nullable<WebVRController>;
  108747. private _leftController;
  108748. /**
  108749. * The controller corresponding to the users left hand.
  108750. */
  108751. get leftController(): Nullable<WebVRController>;
  108752. private _rightController;
  108753. /**
  108754. * The controller corresponding to the users right hand.
  108755. */
  108756. get rightController(): Nullable<WebVRController>;
  108757. /**
  108758. * Casts a ray forward from the vrCamera's gaze.
  108759. * @param length Length of the ray (default: 100)
  108760. * @returns the ray corresponding to the gaze
  108761. */
  108762. getForwardRay(length?: number): Ray;
  108763. /**
  108764. * @hidden
  108765. * Updates the camera based on device's frame data
  108766. */
  108767. _checkInputs(): void;
  108768. /**
  108769. * Updates the poseControlled values based on the input device pose.
  108770. * @param poseData Pose coming from the device
  108771. */
  108772. updateFromDevice(poseData: DevicePose): void;
  108773. private _detachIfAttached;
  108774. /**
  108775. * WebVR's attach control will start broadcasting frames to the device.
  108776. * Note that in certain browsers (chrome for example) this function must be called
  108777. * within a user-interaction callback. Example:
  108778. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  108779. *
  108780. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  108781. */
  108782. attachControl(noPreventDefault?: boolean): void;
  108783. /**
  108784. * Detach the current controls from the specified dom element.
  108785. */
  108786. detachControl(): void;
  108787. /**
  108788. * @returns the name of this class
  108789. */
  108790. getClassName(): string;
  108791. /**
  108792. * Calls resetPose on the vrDisplay
  108793. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  108794. */
  108795. resetToCurrentRotation(): void;
  108796. /**
  108797. * @hidden
  108798. * Updates the rig cameras (left and right eye)
  108799. */
  108800. _updateRigCameras(): void;
  108801. private _workingVector;
  108802. private _oneVector;
  108803. private _workingMatrix;
  108804. private updateCacheCalled;
  108805. private _correctPositionIfNotTrackPosition;
  108806. /**
  108807. * @hidden
  108808. * Updates the cached values of the camera
  108809. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  108810. */
  108811. _updateCache(ignoreParentClass?: boolean): void;
  108812. /**
  108813. * @hidden
  108814. * Get current device position in babylon world
  108815. */
  108816. _computeDevicePosition(): void;
  108817. /**
  108818. * Updates the current device position and rotation in the babylon world
  108819. */
  108820. update(): void;
  108821. /**
  108822. * @hidden
  108823. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  108824. * @returns an identity matrix
  108825. */
  108826. _getViewMatrix(): Matrix;
  108827. private _tmpMatrix;
  108828. /**
  108829. * This function is called by the two RIG cameras.
  108830. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  108831. * @hidden
  108832. */
  108833. _getWebVRViewMatrix(): Matrix;
  108834. /** @hidden */
  108835. _getWebVRProjectionMatrix(): Matrix;
  108836. private _onGamepadConnectedObserver;
  108837. private _onGamepadDisconnectedObserver;
  108838. private _updateCacheWhenTrackingDisabledObserver;
  108839. /**
  108840. * Initializes the controllers and their meshes
  108841. */
  108842. initControllers(): void;
  108843. }
  108844. }
  108845. declare module BABYLON {
  108846. /**
  108847. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  108848. *
  108849. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  108850. *
  108851. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  108852. */
  108853. export class MaterialHelper {
  108854. /**
  108855. * Bind the current view position to an effect.
  108856. * @param effect The effect to be bound
  108857. * @param scene The scene the eyes position is used from
  108858. * @param variableName name of the shader variable that will hold the eye position
  108859. */
  108860. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  108861. /**
  108862. * Helps preparing the defines values about the UVs in used in the effect.
  108863. * UVs are shared as much as we can accross channels in the shaders.
  108864. * @param texture The texture we are preparing the UVs for
  108865. * @param defines The defines to update
  108866. * @param key The channel key "diffuse", "specular"... used in the shader
  108867. */
  108868. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  108869. /**
  108870. * Binds a texture matrix value to its corrsponding uniform
  108871. * @param texture The texture to bind the matrix for
  108872. * @param uniformBuffer The uniform buffer receivin the data
  108873. * @param key The channel key "diffuse", "specular"... used in the shader
  108874. */
  108875. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  108876. /**
  108877. * Gets the current status of the fog (should it be enabled?)
  108878. * @param mesh defines the mesh to evaluate for fog support
  108879. * @param scene defines the hosting scene
  108880. * @returns true if fog must be enabled
  108881. */
  108882. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  108883. /**
  108884. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  108885. * @param mesh defines the current mesh
  108886. * @param scene defines the current scene
  108887. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  108888. * @param pointsCloud defines if point cloud rendering has to be turned on
  108889. * @param fogEnabled defines if fog has to be turned on
  108890. * @param alphaTest defines if alpha testing has to be turned on
  108891. * @param defines defines the current list of defines
  108892. */
  108893. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  108894. /**
  108895. * Helper used to prepare the list of defines associated with frame values for shader compilation
  108896. * @param scene defines the current scene
  108897. * @param engine defines the current engine
  108898. * @param defines specifies the list of active defines
  108899. * @param useInstances defines if instances have to be turned on
  108900. * @param useClipPlane defines if clip plane have to be turned on
  108901. * @param useInstances defines if instances have to be turned on
  108902. * @param useThinInstances defines if thin instances have to be turned on
  108903. */
  108904. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  108905. /**
  108906. * Prepares the defines for bones
  108907. * @param mesh The mesh containing the geometry data we will draw
  108908. * @param defines The defines to update
  108909. */
  108910. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  108911. /**
  108912. * Prepares the defines for morph targets
  108913. * @param mesh The mesh containing the geometry data we will draw
  108914. * @param defines The defines to update
  108915. */
  108916. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  108917. /**
  108918. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  108919. * @param mesh The mesh containing the geometry data we will draw
  108920. * @param defines The defines to update
  108921. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  108922. * @param useBones Precise whether bones should be used or not (override mesh info)
  108923. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  108924. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  108925. * @returns false if defines are considered not dirty and have not been checked
  108926. */
  108927. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  108928. /**
  108929. * Prepares the defines related to multiview
  108930. * @param scene The scene we are intending to draw
  108931. * @param defines The defines to update
  108932. */
  108933. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  108934. /**
  108935. * Prepares the defines related to the prepass
  108936. * @param scene The scene we are intending to draw
  108937. * @param defines The defines to update
  108938. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  108939. */
  108940. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  108941. /**
  108942. * Prepares the defines related to the light information passed in parameter
  108943. * @param scene The scene we are intending to draw
  108944. * @param mesh The mesh the effect is compiling for
  108945. * @param light The light the effect is compiling for
  108946. * @param lightIndex The index of the light
  108947. * @param defines The defines to update
  108948. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108949. * @param state Defines the current state regarding what is needed (normals, etc...)
  108950. */
  108951. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  108952. needNormals: boolean;
  108953. needRebuild: boolean;
  108954. shadowEnabled: boolean;
  108955. specularEnabled: boolean;
  108956. lightmapMode: boolean;
  108957. }): void;
  108958. /**
  108959. * Prepares the defines related to the light information passed in parameter
  108960. * @param scene The scene we are intending to draw
  108961. * @param mesh The mesh the effect is compiling for
  108962. * @param defines The defines to update
  108963. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108964. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  108965. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  108966. * @returns true if normals will be required for the rest of the effect
  108967. */
  108968. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  108969. /**
  108970. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  108971. * @param lightIndex defines the light index
  108972. * @param uniformsList The uniform list
  108973. * @param samplersList The sampler list
  108974. * @param projectedLightTexture defines if projected texture must be used
  108975. * @param uniformBuffersList defines an optional list of uniform buffers
  108976. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  108977. */
  108978. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  108979. /**
  108980. * Prepares the uniforms and samplers list to be used in the effect
  108981. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  108982. * @param samplersList The sampler list
  108983. * @param defines The defines helping in the list generation
  108984. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  108985. */
  108986. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  108987. /**
  108988. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  108989. * @param defines The defines to update while falling back
  108990. * @param fallbacks The authorized effect fallbacks
  108991. * @param maxSimultaneousLights The maximum number of lights allowed
  108992. * @param rank the current rank of the Effect
  108993. * @returns The newly affected rank
  108994. */
  108995. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  108996. private static _TmpMorphInfluencers;
  108997. /**
  108998. * Prepares the list of attributes required for morph targets according to the effect defines.
  108999. * @param attribs The current list of supported attribs
  109000. * @param mesh The mesh to prepare the morph targets attributes for
  109001. * @param influencers The number of influencers
  109002. */
  109003. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  109004. /**
  109005. * Prepares the list of attributes required for morph targets according to the effect defines.
  109006. * @param attribs The current list of supported attribs
  109007. * @param mesh The mesh to prepare the morph targets attributes for
  109008. * @param defines The current Defines of the effect
  109009. */
  109010. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  109011. /**
  109012. * Prepares the list of attributes required for bones according to the effect defines.
  109013. * @param attribs The current list of supported attribs
  109014. * @param mesh The mesh to prepare the bones attributes for
  109015. * @param defines The current Defines of the effect
  109016. * @param fallbacks The current efffect fallback strategy
  109017. */
  109018. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  109019. /**
  109020. * Check and prepare the list of attributes required for instances according to the effect defines.
  109021. * @param attribs The current list of supported attribs
  109022. * @param defines The current MaterialDefines of the effect
  109023. */
  109024. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  109025. /**
  109026. * Add the list of attributes required for instances to the attribs array.
  109027. * @param attribs The current list of supported attribs
  109028. */
  109029. static PushAttributesForInstances(attribs: string[]): void;
  109030. /**
  109031. * Binds the light information to the effect.
  109032. * @param light The light containing the generator
  109033. * @param effect The effect we are binding the data to
  109034. * @param lightIndex The light index in the effect used to render
  109035. */
  109036. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  109037. /**
  109038. * Binds the lights information from the scene to the effect for the given mesh.
  109039. * @param light Light to bind
  109040. * @param lightIndex Light index
  109041. * @param scene The scene where the light belongs to
  109042. * @param effect The effect we are binding the data to
  109043. * @param useSpecular Defines if specular is supported
  109044. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  109045. */
  109046. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  109047. /**
  109048. * Binds the lights information from the scene to the effect for the given mesh.
  109049. * @param scene The scene the lights belongs to
  109050. * @param mesh The mesh we are binding the information to render
  109051. * @param effect The effect we are binding the data to
  109052. * @param defines The generated defines for the effect
  109053. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  109054. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  109055. */
  109056. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  109057. private static _tempFogColor;
  109058. /**
  109059. * Binds the fog information from the scene to the effect for the given mesh.
  109060. * @param scene The scene the lights belongs to
  109061. * @param mesh The mesh we are binding the information to render
  109062. * @param effect The effect we are binding the data to
  109063. * @param linearSpace Defines if the fog effect is applied in linear space
  109064. */
  109065. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  109066. /**
  109067. * Binds the bones information from the mesh to the effect.
  109068. * @param mesh The mesh we are binding the information to render
  109069. * @param effect The effect we are binding the data to
  109070. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  109071. */
  109072. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  109073. private static _CopyBonesTransformationMatrices;
  109074. /**
  109075. * Binds the morph targets information from the mesh to the effect.
  109076. * @param abstractMesh The mesh we are binding the information to render
  109077. * @param effect The effect we are binding the data to
  109078. */
  109079. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  109080. /**
  109081. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  109082. * @param defines The generated defines used in the effect
  109083. * @param effect The effect we are binding the data to
  109084. * @param scene The scene we are willing to render with logarithmic scale for
  109085. */
  109086. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  109087. /**
  109088. * Binds the clip plane information from the scene to the effect.
  109089. * @param scene The scene the clip plane information are extracted from
  109090. * @param effect The effect we are binding the data to
  109091. */
  109092. static BindClipPlane(effect: Effect, scene: Scene): void;
  109093. }
  109094. }
  109095. declare module BABYLON {
  109096. /** @hidden */
  109097. export var bayerDitherFunctions: {
  109098. name: string;
  109099. shader: string;
  109100. };
  109101. }
  109102. declare module BABYLON {
  109103. /** @hidden */
  109104. export var shadowMapFragmentDeclaration: {
  109105. name: string;
  109106. shader: string;
  109107. };
  109108. }
  109109. declare module BABYLON {
  109110. /** @hidden */
  109111. export var shadowMapFragment: {
  109112. name: string;
  109113. shader: string;
  109114. };
  109115. }
  109116. declare module BABYLON {
  109117. /** @hidden */
  109118. export var shadowMapPixelShader: {
  109119. name: string;
  109120. shader: string;
  109121. };
  109122. }
  109123. declare module BABYLON {
  109124. /** @hidden */
  109125. export var shadowMapVertexDeclaration: {
  109126. name: string;
  109127. shader: string;
  109128. };
  109129. }
  109130. declare module BABYLON {
  109131. /** @hidden */
  109132. export var shadowMapVertexNormalBias: {
  109133. name: string;
  109134. shader: string;
  109135. };
  109136. }
  109137. declare module BABYLON {
  109138. /** @hidden */
  109139. export var shadowMapVertexMetric: {
  109140. name: string;
  109141. shader: string;
  109142. };
  109143. }
  109144. declare module BABYLON {
  109145. /** @hidden */
  109146. export var shadowMapVertexShader: {
  109147. name: string;
  109148. shader: string;
  109149. };
  109150. }
  109151. declare module BABYLON {
  109152. /** @hidden */
  109153. export var depthBoxBlurPixelShader: {
  109154. name: string;
  109155. shader: string;
  109156. };
  109157. }
  109158. declare module BABYLON {
  109159. /** @hidden */
  109160. export var shadowMapFragmentSoftTransparentShadow: {
  109161. name: string;
  109162. shader: string;
  109163. };
  109164. }
  109165. declare module BABYLON {
  109166. /**
  109167. * Creates an instance based on a source mesh.
  109168. */
  109169. export class InstancedMesh extends AbstractMesh {
  109170. private _sourceMesh;
  109171. private _currentLOD;
  109172. /** @hidden */
  109173. _indexInSourceMeshInstanceArray: number;
  109174. constructor(name: string, source: Mesh);
  109175. /**
  109176. * Returns the string "InstancedMesh".
  109177. */
  109178. getClassName(): string;
  109179. /** Gets the list of lights affecting that mesh */
  109180. get lightSources(): Light[];
  109181. _resyncLightSources(): void;
  109182. _resyncLightSource(light: Light): void;
  109183. _removeLightSource(light: Light, dispose: boolean): void;
  109184. /**
  109185. * If the source mesh receives shadows
  109186. */
  109187. get receiveShadows(): boolean;
  109188. /**
  109189. * The material of the source mesh
  109190. */
  109191. get material(): Nullable<Material>;
  109192. /**
  109193. * Visibility of the source mesh
  109194. */
  109195. get visibility(): number;
  109196. /**
  109197. * Skeleton of the source mesh
  109198. */
  109199. get skeleton(): Nullable<Skeleton>;
  109200. /**
  109201. * Rendering ground id of the source mesh
  109202. */
  109203. get renderingGroupId(): number;
  109204. set renderingGroupId(value: number);
  109205. /**
  109206. * Returns the total number of vertices (integer).
  109207. */
  109208. getTotalVertices(): number;
  109209. /**
  109210. * Returns a positive integer : the total number of indices in this mesh geometry.
  109211. * @returns the numner of indices or zero if the mesh has no geometry.
  109212. */
  109213. getTotalIndices(): number;
  109214. /**
  109215. * The source mesh of the instance
  109216. */
  109217. get sourceMesh(): Mesh;
  109218. /**
  109219. * Creates a new InstancedMesh object from the mesh model.
  109220. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109221. * @param name defines the name of the new instance
  109222. * @returns a new InstancedMesh
  109223. */
  109224. createInstance(name: string): InstancedMesh;
  109225. /**
  109226. * Is this node ready to be used/rendered
  109227. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109228. * @return {boolean} is it ready
  109229. */
  109230. isReady(completeCheck?: boolean): boolean;
  109231. /**
  109232. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  109233. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  109234. * @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.
  109235. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  109236. */
  109237. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  109238. /**
  109239. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109240. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109241. * The `data` are either a numeric array either a Float32Array.
  109242. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  109243. * 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).
  109244. * Note that a new underlying VertexBuffer object is created each call.
  109245. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109246. *
  109247. * Possible `kind` values :
  109248. * - VertexBuffer.PositionKind
  109249. * - VertexBuffer.UVKind
  109250. * - VertexBuffer.UV2Kind
  109251. * - VertexBuffer.UV3Kind
  109252. * - VertexBuffer.UV4Kind
  109253. * - VertexBuffer.UV5Kind
  109254. * - VertexBuffer.UV6Kind
  109255. * - VertexBuffer.ColorKind
  109256. * - VertexBuffer.MatricesIndicesKind
  109257. * - VertexBuffer.MatricesIndicesExtraKind
  109258. * - VertexBuffer.MatricesWeightsKind
  109259. * - VertexBuffer.MatricesWeightsExtraKind
  109260. *
  109261. * Returns the Mesh.
  109262. */
  109263. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109264. /**
  109265. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109266. * If the mesh has no geometry, it is simply returned as it is.
  109267. * The `data` are either a numeric array either a Float32Array.
  109268. * No new underlying VertexBuffer object is created.
  109269. * 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.
  109270. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  109271. *
  109272. * Possible `kind` values :
  109273. * - VertexBuffer.PositionKind
  109274. * - VertexBuffer.UVKind
  109275. * - VertexBuffer.UV2Kind
  109276. * - VertexBuffer.UV3Kind
  109277. * - VertexBuffer.UV4Kind
  109278. * - VertexBuffer.UV5Kind
  109279. * - VertexBuffer.UV6Kind
  109280. * - VertexBuffer.ColorKind
  109281. * - VertexBuffer.MatricesIndicesKind
  109282. * - VertexBuffer.MatricesIndicesExtraKind
  109283. * - VertexBuffer.MatricesWeightsKind
  109284. * - VertexBuffer.MatricesWeightsExtraKind
  109285. *
  109286. * Returns the Mesh.
  109287. */
  109288. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  109289. /**
  109290. * Sets the mesh indices.
  109291. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  109292. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109293. * This method creates a new index buffer each call.
  109294. * Returns the Mesh.
  109295. */
  109296. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  109297. /**
  109298. * Boolean : True if the mesh owns the requested kind of data.
  109299. */
  109300. isVerticesDataPresent(kind: string): boolean;
  109301. /**
  109302. * Returns an array of indices (IndicesArray).
  109303. */
  109304. getIndices(): Nullable<IndicesArray>;
  109305. get _positions(): Nullable<Vector3[]>;
  109306. /**
  109307. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109308. * This means the mesh underlying bounding box and sphere are recomputed.
  109309. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109310. * @returns the current mesh
  109311. */
  109312. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  109313. /** @hidden */
  109314. _preActivate(): InstancedMesh;
  109315. /** @hidden */
  109316. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109317. /** @hidden */
  109318. _postActivate(): void;
  109319. getWorldMatrix(): Matrix;
  109320. get isAnInstance(): boolean;
  109321. /**
  109322. * Returns the current associated LOD AbstractMesh.
  109323. */
  109324. getLOD(camera: Camera): AbstractMesh;
  109325. /** @hidden */
  109326. _preActivateForIntermediateRendering(renderId: number): Mesh;
  109327. /** @hidden */
  109328. _syncSubMeshes(): InstancedMesh;
  109329. /** @hidden */
  109330. _generatePointsArray(): boolean;
  109331. /** @hidden */
  109332. _updateBoundingInfo(): AbstractMesh;
  109333. /**
  109334. * Creates a new InstancedMesh from the current mesh.
  109335. * - name (string) : the cloned mesh name
  109336. * - newParent (optional Node) : the optional Node to parent the clone to.
  109337. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  109338. *
  109339. * Returns the clone.
  109340. */
  109341. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  109342. /**
  109343. * Disposes the InstancedMesh.
  109344. * Returns nothing.
  109345. */
  109346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109347. }
  109348. interface Mesh {
  109349. /**
  109350. * Register a custom buffer that will be instanced
  109351. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109352. * @param kind defines the buffer kind
  109353. * @param stride defines the stride in floats
  109354. */
  109355. registerInstancedBuffer(kind: string, stride: number): void;
  109356. /**
  109357. * true to use the edge renderer for all instances of this mesh
  109358. */
  109359. edgesShareWithInstances: boolean;
  109360. /** @hidden */
  109361. _userInstancedBuffersStorage: {
  109362. data: {
  109363. [key: string]: Float32Array;
  109364. };
  109365. sizes: {
  109366. [key: string]: number;
  109367. };
  109368. vertexBuffers: {
  109369. [key: string]: Nullable<VertexBuffer>;
  109370. };
  109371. strides: {
  109372. [key: string]: number;
  109373. };
  109374. };
  109375. }
  109376. interface AbstractMesh {
  109377. /**
  109378. * Object used to store instanced buffers defined by user
  109379. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109380. */
  109381. instancedBuffers: {
  109382. [key: string]: any;
  109383. };
  109384. }
  109385. }
  109386. declare module BABYLON {
  109387. /**
  109388. * Defines the options associated with the creation of a shader material.
  109389. */
  109390. export interface IShaderMaterialOptions {
  109391. /**
  109392. * Does the material work in alpha blend mode
  109393. */
  109394. needAlphaBlending: boolean;
  109395. /**
  109396. * Does the material work in alpha test mode
  109397. */
  109398. needAlphaTesting: boolean;
  109399. /**
  109400. * The list of attribute names used in the shader
  109401. */
  109402. attributes: string[];
  109403. /**
  109404. * The list of unifrom names used in the shader
  109405. */
  109406. uniforms: string[];
  109407. /**
  109408. * The list of UBO names used in the shader
  109409. */
  109410. uniformBuffers: string[];
  109411. /**
  109412. * The list of sampler names used in the shader
  109413. */
  109414. samplers: string[];
  109415. /**
  109416. * The list of defines used in the shader
  109417. */
  109418. defines: string[];
  109419. }
  109420. /**
  109421. * 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.
  109422. *
  109423. * This returned material effects how the mesh will look based on the code in the shaders.
  109424. *
  109425. * @see https://doc.babylonjs.com/how_to/shader_material
  109426. */
  109427. export class ShaderMaterial extends Material {
  109428. private _shaderPath;
  109429. private _options;
  109430. private _textures;
  109431. private _textureArrays;
  109432. private _floats;
  109433. private _ints;
  109434. private _floatsArrays;
  109435. private _colors3;
  109436. private _colors3Arrays;
  109437. private _colors4;
  109438. private _colors4Arrays;
  109439. private _vectors2;
  109440. private _vectors3;
  109441. private _vectors4;
  109442. private _matrices;
  109443. private _matrixArrays;
  109444. private _matrices3x3;
  109445. private _matrices2x2;
  109446. private _vectors2Arrays;
  109447. private _vectors3Arrays;
  109448. private _vectors4Arrays;
  109449. private _cachedWorldViewMatrix;
  109450. private _cachedWorldViewProjectionMatrix;
  109451. private _renderId;
  109452. private _multiview;
  109453. private _cachedDefines;
  109454. /** Define the Url to load snippets */
  109455. static SnippetUrl: string;
  109456. /** Snippet ID if the material was created from the snippet server */
  109457. snippetId: string;
  109458. /**
  109459. * Instantiate a new shader material.
  109460. * 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.
  109461. * This returned material effects how the mesh will look based on the code in the shaders.
  109462. * @see https://doc.babylonjs.com/how_to/shader_material
  109463. * @param name Define the name of the material in the scene
  109464. * @param scene Define the scene the material belongs to
  109465. * @param shaderPath Defines the route to the shader code in one of three ways:
  109466. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  109467. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  109468. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  109469. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  109470. * @param options Define the options used to create the shader
  109471. */
  109472. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  109473. /**
  109474. * Gets the shader path used to define the shader code
  109475. * It can be modified to trigger a new compilation
  109476. */
  109477. get shaderPath(): any;
  109478. /**
  109479. * Sets the shader path used to define the shader code
  109480. * It can be modified to trigger a new compilation
  109481. */
  109482. set shaderPath(shaderPath: any);
  109483. /**
  109484. * Gets the options used to compile the shader.
  109485. * They can be modified to trigger a new compilation
  109486. */
  109487. get options(): IShaderMaterialOptions;
  109488. /**
  109489. * Gets the current class name of the material e.g. "ShaderMaterial"
  109490. * Mainly use in serialization.
  109491. * @returns the class name
  109492. */
  109493. getClassName(): string;
  109494. /**
  109495. * Specifies if the material will require alpha blending
  109496. * @returns a boolean specifying if alpha blending is needed
  109497. */
  109498. needAlphaBlending(): boolean;
  109499. /**
  109500. * Specifies if this material should be rendered in alpha test mode
  109501. * @returns a boolean specifying if an alpha test is needed.
  109502. */
  109503. needAlphaTesting(): boolean;
  109504. private _checkUniform;
  109505. /**
  109506. * Set a texture in the shader.
  109507. * @param name Define the name of the uniform samplers as defined in the shader
  109508. * @param texture Define the texture to bind to this sampler
  109509. * @return the material itself allowing "fluent" like uniform updates
  109510. */
  109511. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  109512. /**
  109513. * Set a texture array in the shader.
  109514. * @param name Define the name of the uniform sampler array as defined in the shader
  109515. * @param textures Define the list of textures to bind to this sampler
  109516. * @return the material itself allowing "fluent" like uniform updates
  109517. */
  109518. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  109519. /**
  109520. * Set a float in the shader.
  109521. * @param name Define the name of the uniform as defined in the shader
  109522. * @param value Define the value to give to the uniform
  109523. * @return the material itself allowing "fluent" like uniform updates
  109524. */
  109525. setFloat(name: string, value: number): ShaderMaterial;
  109526. /**
  109527. * Set a int in the shader.
  109528. * @param name Define the name of the uniform as defined in the shader
  109529. * @param value Define the value to give to the uniform
  109530. * @return the material itself allowing "fluent" like uniform updates
  109531. */
  109532. setInt(name: string, value: number): ShaderMaterial;
  109533. /**
  109534. * Set an array of floats in the shader.
  109535. * @param name Define the name of the uniform as defined in the shader
  109536. * @param value Define the value to give to the uniform
  109537. * @return the material itself allowing "fluent" like uniform updates
  109538. */
  109539. setFloats(name: string, value: number[]): ShaderMaterial;
  109540. /**
  109541. * Set a vec3 in the shader from a Color3.
  109542. * @param name Define the name of the uniform as defined in the shader
  109543. * @param value Define the value to give to the uniform
  109544. * @return the material itself allowing "fluent" like uniform updates
  109545. */
  109546. setColor3(name: string, value: Color3): ShaderMaterial;
  109547. /**
  109548. * Set a vec3 array in the shader from a Color3 array.
  109549. * @param name Define the name of the uniform as defined in the shader
  109550. * @param value Define the value to give to the uniform
  109551. * @return the material itself allowing "fluent" like uniform updates
  109552. */
  109553. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  109554. /**
  109555. * Set a vec4 in the shader from a Color4.
  109556. * @param name Define the name of the uniform as defined in the shader
  109557. * @param value Define the value to give to the uniform
  109558. * @return the material itself allowing "fluent" like uniform updates
  109559. */
  109560. setColor4(name: string, value: Color4): ShaderMaterial;
  109561. /**
  109562. * Set a vec4 array in the shader from a Color4 array.
  109563. * @param name Define the name of the uniform as defined in the shader
  109564. * @param value Define the value to give to the uniform
  109565. * @return the material itself allowing "fluent" like uniform updates
  109566. */
  109567. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  109568. /**
  109569. * Set a vec2 in the shader from a Vector2.
  109570. * @param name Define the name of the uniform as defined in the shader
  109571. * @param value Define the value to give to the uniform
  109572. * @return the material itself allowing "fluent" like uniform updates
  109573. */
  109574. setVector2(name: string, value: Vector2): ShaderMaterial;
  109575. /**
  109576. * Set a vec3 in the shader from a Vector3.
  109577. * @param name Define the name of the uniform as defined in the shader
  109578. * @param value Define the value to give to the uniform
  109579. * @return the material itself allowing "fluent" like uniform updates
  109580. */
  109581. setVector3(name: string, value: Vector3): ShaderMaterial;
  109582. /**
  109583. * Set a vec4 in the shader from a Vector4.
  109584. * @param name Define the name of the uniform as defined in the shader
  109585. * @param value Define the value to give to the uniform
  109586. * @return the material itself allowing "fluent" like uniform updates
  109587. */
  109588. setVector4(name: string, value: Vector4): ShaderMaterial;
  109589. /**
  109590. * Set a mat4 in the shader from a Matrix.
  109591. * @param name Define the name of the uniform as defined in the shader
  109592. * @param value Define the value to give to the uniform
  109593. * @return the material itself allowing "fluent" like uniform updates
  109594. */
  109595. setMatrix(name: string, value: Matrix): ShaderMaterial;
  109596. /**
  109597. * Set a float32Array in the shader from a matrix array.
  109598. * @param name Define the name of the uniform as defined in the shader
  109599. * @param value Define the value to give to the uniform
  109600. * @return the material itself allowing "fluent" like uniform updates
  109601. */
  109602. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  109603. /**
  109604. * Set a mat3 in the shader from a Float32Array.
  109605. * @param name Define the name of the uniform as defined in the shader
  109606. * @param value Define the value to give to the uniform
  109607. * @return the material itself allowing "fluent" like uniform updates
  109608. */
  109609. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109610. /**
  109611. * Set a mat2 in the shader from a Float32Array.
  109612. * @param name Define the name of the uniform as defined in the shader
  109613. * @param value Define the value to give to the uniform
  109614. * @return the material itself allowing "fluent" like uniform updates
  109615. */
  109616. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109617. /**
  109618. * Set a vec2 array in the shader from a number array.
  109619. * @param name Define the name of the uniform as defined in the shader
  109620. * @param value Define the value to give to the uniform
  109621. * @return the material itself allowing "fluent" like uniform updates
  109622. */
  109623. setArray2(name: string, value: number[]): ShaderMaterial;
  109624. /**
  109625. * Set a vec3 array in the shader from a number array.
  109626. * @param name Define the name of the uniform as defined in the shader
  109627. * @param value Define the value to give to the uniform
  109628. * @return the material itself allowing "fluent" like uniform updates
  109629. */
  109630. setArray3(name: string, value: number[]): ShaderMaterial;
  109631. /**
  109632. * Set a vec4 array in the shader from a number array.
  109633. * @param name Define the name of the uniform as defined in the shader
  109634. * @param value Define the value to give to the uniform
  109635. * @return the material itself allowing "fluent" like uniform updates
  109636. */
  109637. setArray4(name: string, value: number[]): ShaderMaterial;
  109638. private _checkCache;
  109639. /**
  109640. * Specifies that the submesh is ready to be used
  109641. * @param mesh defines the mesh to check
  109642. * @param subMesh defines which submesh to check
  109643. * @param useInstances specifies that instances should be used
  109644. * @returns a boolean indicating that the submesh is ready or not
  109645. */
  109646. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109647. /**
  109648. * Checks if the material is ready to render the requested mesh
  109649. * @param mesh Define the mesh to render
  109650. * @param useInstances Define whether or not the material is used with instances
  109651. * @returns true if ready, otherwise false
  109652. */
  109653. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109654. /**
  109655. * Binds the world matrix to the material
  109656. * @param world defines the world transformation matrix
  109657. * @param effectOverride - If provided, use this effect instead of internal effect
  109658. */
  109659. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  109660. /**
  109661. * Binds the submesh to this material by preparing the effect and shader to draw
  109662. * @param world defines the world transformation matrix
  109663. * @param mesh defines the mesh containing the submesh
  109664. * @param subMesh defines the submesh to bind the material to
  109665. */
  109666. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109667. /**
  109668. * Binds the material to the mesh
  109669. * @param world defines the world transformation matrix
  109670. * @param mesh defines the mesh to bind the material to
  109671. * @param effectOverride - If provided, use this effect instead of internal effect
  109672. */
  109673. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  109674. protected _afterBind(mesh?: Mesh): void;
  109675. /**
  109676. * Gets the active textures from the material
  109677. * @returns an array of textures
  109678. */
  109679. getActiveTextures(): BaseTexture[];
  109680. /**
  109681. * Specifies if the material uses a texture
  109682. * @param texture defines the texture to check against the material
  109683. * @returns a boolean specifying if the material uses the texture
  109684. */
  109685. hasTexture(texture: BaseTexture): boolean;
  109686. /**
  109687. * Makes a duplicate of the material, and gives it a new name
  109688. * @param name defines the new name for the duplicated material
  109689. * @returns the cloned material
  109690. */
  109691. clone(name: string): ShaderMaterial;
  109692. /**
  109693. * Disposes the material
  109694. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109695. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109696. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  109697. */
  109698. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  109699. /**
  109700. * Serializes this material in a JSON representation
  109701. * @returns the serialized material object
  109702. */
  109703. serialize(): any;
  109704. /**
  109705. * Creates a shader material from parsed shader material data
  109706. * @param source defines the JSON represnetation of the material
  109707. * @param scene defines the hosting scene
  109708. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109709. * @returns a new material
  109710. */
  109711. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  109712. /**
  109713. * Creates a new ShaderMaterial from a snippet saved in a remote file
  109714. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  109715. * @param url defines the url to load from
  109716. * @param scene defines the hosting scene
  109717. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109718. * @returns a promise that will resolve to the new ShaderMaterial
  109719. */
  109720. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109721. /**
  109722. * Creates a ShaderMaterial from a snippet saved by the Inspector
  109723. * @param snippetId defines the snippet to load
  109724. * @param scene defines the hosting scene
  109725. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109726. * @returns a promise that will resolve to the new ShaderMaterial
  109727. */
  109728. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109729. }
  109730. }
  109731. declare module BABYLON {
  109732. /** @hidden */
  109733. export var colorPixelShader: {
  109734. name: string;
  109735. shader: string;
  109736. };
  109737. }
  109738. declare module BABYLON {
  109739. /** @hidden */
  109740. export var colorVertexShader: {
  109741. name: string;
  109742. shader: string;
  109743. };
  109744. }
  109745. declare module BABYLON {
  109746. /**
  109747. * Line mesh
  109748. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  109749. */
  109750. export class LinesMesh extends Mesh {
  109751. /**
  109752. * If vertex color should be applied to the mesh
  109753. */
  109754. readonly useVertexColor?: boolean | undefined;
  109755. /**
  109756. * If vertex alpha should be applied to the mesh
  109757. */
  109758. readonly useVertexAlpha?: boolean | undefined;
  109759. /**
  109760. * Color of the line (Default: White)
  109761. */
  109762. color: Color3;
  109763. /**
  109764. * Alpha of the line (Default: 1)
  109765. */
  109766. alpha: number;
  109767. /**
  109768. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109769. * This margin is expressed in world space coordinates, so its value may vary.
  109770. * Default value is 0.1
  109771. */
  109772. intersectionThreshold: number;
  109773. private _colorShader;
  109774. private color4;
  109775. /**
  109776. * Creates a new LinesMesh
  109777. * @param name defines the name
  109778. * @param scene defines the hosting scene
  109779. * @param parent defines the parent mesh if any
  109780. * @param source defines the optional source LinesMesh used to clone data from
  109781. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  109782. * When false, achieved by calling a clone(), also passing False.
  109783. * This will make creation of children, recursive.
  109784. * @param useVertexColor defines if this LinesMesh supports vertex color
  109785. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  109786. */
  109787. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  109788. /**
  109789. * If vertex color should be applied to the mesh
  109790. */
  109791. useVertexColor?: boolean | undefined,
  109792. /**
  109793. * If vertex alpha should be applied to the mesh
  109794. */
  109795. useVertexAlpha?: boolean | undefined);
  109796. private _addClipPlaneDefine;
  109797. private _removeClipPlaneDefine;
  109798. isReady(): boolean;
  109799. /**
  109800. * Returns the string "LineMesh"
  109801. */
  109802. getClassName(): string;
  109803. /**
  109804. * @hidden
  109805. */
  109806. get material(): Material;
  109807. /**
  109808. * @hidden
  109809. */
  109810. set material(value: Material);
  109811. /**
  109812. * @hidden
  109813. */
  109814. get checkCollisions(): boolean;
  109815. /** @hidden */
  109816. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109817. /** @hidden */
  109818. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109819. /**
  109820. * Disposes of the line mesh
  109821. * @param doNotRecurse If children should be disposed
  109822. */
  109823. dispose(doNotRecurse?: boolean): void;
  109824. /**
  109825. * Returns a new LineMesh object cloned from the current one.
  109826. */
  109827. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  109828. /**
  109829. * Creates a new InstancedLinesMesh object from the mesh model.
  109830. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109831. * @param name defines the name of the new instance
  109832. * @returns a new InstancedLinesMesh
  109833. */
  109834. createInstance(name: string): InstancedLinesMesh;
  109835. }
  109836. /**
  109837. * Creates an instance based on a source LinesMesh
  109838. */
  109839. export class InstancedLinesMesh extends InstancedMesh {
  109840. /**
  109841. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109842. * This margin is expressed in world space coordinates, so its value may vary.
  109843. * Initilized with the intersectionThreshold value of the source LinesMesh
  109844. */
  109845. intersectionThreshold: number;
  109846. constructor(name: string, source: LinesMesh);
  109847. /**
  109848. * Returns the string "InstancedLinesMesh".
  109849. */
  109850. getClassName(): string;
  109851. }
  109852. }
  109853. declare module BABYLON {
  109854. /** @hidden */
  109855. export var linePixelShader: {
  109856. name: string;
  109857. shader: string;
  109858. };
  109859. }
  109860. declare module BABYLON {
  109861. /** @hidden */
  109862. export var lineVertexShader: {
  109863. name: string;
  109864. shader: string;
  109865. };
  109866. }
  109867. declare module BABYLON {
  109868. interface Scene {
  109869. /** @hidden */
  109870. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  109871. }
  109872. interface AbstractMesh {
  109873. /**
  109874. * Gets the edgesRenderer associated with the mesh
  109875. */
  109876. edgesRenderer: Nullable<EdgesRenderer>;
  109877. }
  109878. interface LinesMesh {
  109879. /**
  109880. * Enables the edge rendering mode on the mesh.
  109881. * This mode makes the mesh edges visible
  109882. * @param epsilon defines the maximal distance between two angles to detect a face
  109883. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109884. * @returns the currentAbstractMesh
  109885. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109886. */
  109887. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109888. }
  109889. interface InstancedLinesMesh {
  109890. /**
  109891. * Enables the edge rendering mode on the mesh.
  109892. * This mode makes the mesh edges visible
  109893. * @param epsilon defines the maximal distance between two angles to detect a face
  109894. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109895. * @returns the current InstancedLinesMesh
  109896. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109897. */
  109898. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  109899. }
  109900. /**
  109901. * Defines the minimum contract an Edges renderer should follow.
  109902. */
  109903. export interface IEdgesRenderer extends IDisposable {
  109904. /**
  109905. * Gets or sets a boolean indicating if the edgesRenderer is active
  109906. */
  109907. isEnabled: boolean;
  109908. /**
  109909. * Renders the edges of the attached mesh,
  109910. */
  109911. render(): void;
  109912. /**
  109913. * Checks wether or not the edges renderer is ready to render.
  109914. * @return true if ready, otherwise false.
  109915. */
  109916. isReady(): boolean;
  109917. /**
  109918. * List of instances to render in case the source mesh has instances
  109919. */
  109920. customInstances: SmartArray<Matrix>;
  109921. }
  109922. /**
  109923. * Defines the additional options of the edges renderer
  109924. */
  109925. export interface IEdgesRendererOptions {
  109926. /**
  109927. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  109928. * If not defined, the default value is true
  109929. */
  109930. useAlternateEdgeFinder?: boolean;
  109931. /**
  109932. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  109933. * If not defined, the default value is true.
  109934. * 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)
  109935. * This option is used only if useAlternateEdgeFinder = true
  109936. */
  109937. useFastVertexMerger?: boolean;
  109938. /**
  109939. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  109940. * The default value is 1e-6
  109941. * This option is used only if useAlternateEdgeFinder = true
  109942. */
  109943. epsilonVertexMerge?: number;
  109944. /**
  109945. * 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
  109946. * 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.
  109947. * This option is used only if useAlternateEdgeFinder = true
  109948. */
  109949. applyTessellation?: boolean;
  109950. /**
  109951. * 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
  109952. * The default value is 1e-6
  109953. * This option is used only if useAlternateEdgeFinder = true
  109954. */
  109955. epsilonVertexAligned?: number;
  109956. }
  109957. /**
  109958. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  109959. */
  109960. export class EdgesRenderer implements IEdgesRenderer {
  109961. /**
  109962. * Define the size of the edges with an orthographic camera
  109963. */
  109964. edgesWidthScalerForOrthographic: number;
  109965. /**
  109966. * Define the size of the edges with a perspective camera
  109967. */
  109968. edgesWidthScalerForPerspective: number;
  109969. protected _source: AbstractMesh;
  109970. protected _linesPositions: number[];
  109971. protected _linesNormals: number[];
  109972. protected _linesIndices: number[];
  109973. protected _epsilon: number;
  109974. protected _indicesCount: number;
  109975. protected _lineShader: ShaderMaterial;
  109976. protected _ib: DataBuffer;
  109977. protected _buffers: {
  109978. [key: string]: Nullable<VertexBuffer>;
  109979. };
  109980. protected _buffersForInstances: {
  109981. [key: string]: Nullable<VertexBuffer>;
  109982. };
  109983. protected _checkVerticesInsteadOfIndices: boolean;
  109984. protected _options: Nullable<IEdgesRendererOptions>;
  109985. private _meshRebuildObserver;
  109986. private _meshDisposeObserver;
  109987. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  109988. isEnabled: boolean;
  109989. /** Gets the vertices generated by the edge renderer */
  109990. get linesPositions(): Immutable<Array<number>>;
  109991. /** Gets the normals generated by the edge renderer */
  109992. get linesNormals(): Immutable<Array<number>>;
  109993. /** Gets the indices generated by the edge renderer */
  109994. get linesIndices(): Immutable<Array<number>>;
  109995. /**
  109996. * List of instances to render in case the source mesh has instances
  109997. */
  109998. customInstances: SmartArray<Matrix>;
  109999. private static GetShader;
  110000. /**
  110001. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  110002. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  110003. * @param source Mesh used to create edges
  110004. * @param epsilon sum of angles in adjacency to check for edge
  110005. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  110006. * @param generateEdgesLines - should generate Lines or only prepare resources.
  110007. * @param options The options to apply when generating the edges
  110008. */
  110009. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  110010. protected _prepareRessources(): void;
  110011. /** @hidden */
  110012. _rebuild(): void;
  110013. /**
  110014. * Releases the required resources for the edges renderer
  110015. */
  110016. dispose(): void;
  110017. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  110018. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  110019. /**
  110020. * Checks if the pair of p0 and p1 is en edge
  110021. * @param faceIndex
  110022. * @param edge
  110023. * @param faceNormals
  110024. * @param p0
  110025. * @param p1
  110026. * @private
  110027. */
  110028. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  110029. /**
  110030. * push line into the position, normal and index buffer
  110031. * @protected
  110032. */
  110033. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  110034. /**
  110035. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  110036. */
  110037. private _tessellateTriangle;
  110038. private _generateEdgesLinesAlternate;
  110039. /**
  110040. * Generates lines edges from adjacencjes
  110041. * @private
  110042. */
  110043. _generateEdgesLines(): void;
  110044. /**
  110045. * Checks wether or not the edges renderer is ready to render.
  110046. * @return true if ready, otherwise false.
  110047. */
  110048. isReady(): boolean;
  110049. /**
  110050. * Renders the edges of the attached mesh,
  110051. */
  110052. render(): void;
  110053. }
  110054. /**
  110055. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  110056. */
  110057. export class LineEdgesRenderer extends EdgesRenderer {
  110058. /**
  110059. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  110060. * @param source LineMesh used to generate edges
  110061. * @param epsilon not important (specified angle for edge detection)
  110062. * @param checkVerticesInsteadOfIndices not important for LineMesh
  110063. */
  110064. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  110065. /**
  110066. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  110067. */
  110068. _generateEdgesLines(): void;
  110069. }
  110070. }
  110071. declare module BABYLON {
  110072. /**
  110073. * This represents the object necessary to create a rendering group.
  110074. * This is exclusively used and created by the rendering manager.
  110075. * To modify the behavior, you use the available helpers in your scene or meshes.
  110076. * @hidden
  110077. */
  110078. export class RenderingGroup {
  110079. index: number;
  110080. private static _zeroVector;
  110081. private _scene;
  110082. private _opaqueSubMeshes;
  110083. private _transparentSubMeshes;
  110084. private _alphaTestSubMeshes;
  110085. private _depthOnlySubMeshes;
  110086. private _particleSystems;
  110087. private _spriteManagers;
  110088. private _opaqueSortCompareFn;
  110089. private _alphaTestSortCompareFn;
  110090. private _transparentSortCompareFn;
  110091. private _renderOpaque;
  110092. private _renderAlphaTest;
  110093. private _renderTransparent;
  110094. /** @hidden */
  110095. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  110096. onBeforeTransparentRendering: () => void;
  110097. /**
  110098. * Set the opaque sort comparison function.
  110099. * If null the sub meshes will be render in the order they were created
  110100. */
  110101. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  110102. /**
  110103. * Set the alpha test sort comparison function.
  110104. * If null the sub meshes will be render in the order they were created
  110105. */
  110106. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  110107. /**
  110108. * Set the transparent sort comparison function.
  110109. * If null the sub meshes will be render in the order they were created
  110110. */
  110111. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  110112. /**
  110113. * Creates a new rendering group.
  110114. * @param index The rendering group index
  110115. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  110116. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  110117. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  110118. */
  110119. 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>);
  110120. /**
  110121. * Render all the sub meshes contained in the group.
  110122. * @param customRenderFunction Used to override the default render behaviour of the group.
  110123. * @returns true if rendered some submeshes.
  110124. */
  110125. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  110126. /**
  110127. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  110128. * @param subMeshes The submeshes to render
  110129. */
  110130. private renderOpaqueSorted;
  110131. /**
  110132. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  110133. * @param subMeshes The submeshes to render
  110134. */
  110135. private renderAlphaTestSorted;
  110136. /**
  110137. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  110138. * @param subMeshes The submeshes to render
  110139. */
  110140. private renderTransparentSorted;
  110141. /**
  110142. * Renders the submeshes in a specified order.
  110143. * @param subMeshes The submeshes to sort before render
  110144. * @param sortCompareFn The comparison function use to sort
  110145. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  110146. * @param transparent Specifies to activate blending if true
  110147. */
  110148. private static renderSorted;
  110149. /**
  110150. * Renders the submeshes in the order they were dispatched (no sort applied).
  110151. * @param subMeshes The submeshes to render
  110152. */
  110153. private static renderUnsorted;
  110154. /**
  110155. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  110156. * are rendered back to front if in the same alpha index.
  110157. *
  110158. * @param a The first submesh
  110159. * @param b The second submesh
  110160. * @returns The result of the comparison
  110161. */
  110162. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  110163. /**
  110164. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  110165. * are rendered back to front.
  110166. *
  110167. * @param a The first submesh
  110168. * @param b The second submesh
  110169. * @returns The result of the comparison
  110170. */
  110171. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  110172. /**
  110173. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  110174. * are rendered front to back (prevent overdraw).
  110175. *
  110176. * @param a The first submesh
  110177. * @param b The second submesh
  110178. * @returns The result of the comparison
  110179. */
  110180. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  110181. /**
  110182. * Resets the different lists of submeshes to prepare a new frame.
  110183. */
  110184. prepare(): void;
  110185. dispose(): void;
  110186. /**
  110187. * Inserts the submesh in its correct queue depending on its material.
  110188. * @param subMesh The submesh to dispatch
  110189. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  110190. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  110191. */
  110192. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  110193. dispatchSprites(spriteManager: ISpriteManager): void;
  110194. dispatchParticles(particleSystem: IParticleSystem): void;
  110195. private _renderParticles;
  110196. private _renderSprites;
  110197. }
  110198. }
  110199. declare module BABYLON {
  110200. /**
  110201. * Interface describing the different options available in the rendering manager
  110202. * regarding Auto Clear between groups.
  110203. */
  110204. export interface IRenderingManagerAutoClearSetup {
  110205. /**
  110206. * Defines whether or not autoclear is enable.
  110207. */
  110208. autoClear: boolean;
  110209. /**
  110210. * Defines whether or not to autoclear the depth buffer.
  110211. */
  110212. depth: boolean;
  110213. /**
  110214. * Defines whether or not to autoclear the stencil buffer.
  110215. */
  110216. stencil: boolean;
  110217. }
  110218. /**
  110219. * This class is used by the onRenderingGroupObservable
  110220. */
  110221. export class RenderingGroupInfo {
  110222. /**
  110223. * The Scene that being rendered
  110224. */
  110225. scene: Scene;
  110226. /**
  110227. * The camera currently used for the rendering pass
  110228. */
  110229. camera: Nullable<Camera>;
  110230. /**
  110231. * The ID of the renderingGroup being processed
  110232. */
  110233. renderingGroupId: number;
  110234. }
  110235. /**
  110236. * This is the manager responsible of all the rendering for meshes sprites and particles.
  110237. * It is enable to manage the different groups as well as the different necessary sort functions.
  110238. * This should not be used directly aside of the few static configurations
  110239. */
  110240. export class RenderingManager {
  110241. /**
  110242. * The max id used for rendering groups (not included)
  110243. */
  110244. static MAX_RENDERINGGROUPS: number;
  110245. /**
  110246. * The min id used for rendering groups (included)
  110247. */
  110248. static MIN_RENDERINGGROUPS: number;
  110249. /**
  110250. * Used to globally prevent autoclearing scenes.
  110251. */
  110252. static AUTOCLEAR: boolean;
  110253. /**
  110254. * @hidden
  110255. */
  110256. _useSceneAutoClearSetup: boolean;
  110257. private _scene;
  110258. private _renderingGroups;
  110259. private _depthStencilBufferAlreadyCleaned;
  110260. private _autoClearDepthStencil;
  110261. private _customOpaqueSortCompareFn;
  110262. private _customAlphaTestSortCompareFn;
  110263. private _customTransparentSortCompareFn;
  110264. private _renderingGroupInfo;
  110265. /**
  110266. * Instantiates a new rendering group for a particular scene
  110267. * @param scene Defines the scene the groups belongs to
  110268. */
  110269. constructor(scene: Scene);
  110270. private _clearDepthStencilBuffer;
  110271. /**
  110272. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  110273. * @hidden
  110274. */
  110275. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  110276. /**
  110277. * Resets the different information of the group to prepare a new frame
  110278. * @hidden
  110279. */
  110280. reset(): void;
  110281. /**
  110282. * Dispose and release the group and its associated resources.
  110283. * @hidden
  110284. */
  110285. dispose(): void;
  110286. /**
  110287. * Clear the info related to rendering groups preventing retention points during dispose.
  110288. */
  110289. freeRenderingGroups(): void;
  110290. private _prepareRenderingGroup;
  110291. /**
  110292. * Add a sprite manager to the rendering manager in order to render it this frame.
  110293. * @param spriteManager Define the sprite manager to render
  110294. */
  110295. dispatchSprites(spriteManager: ISpriteManager): void;
  110296. /**
  110297. * Add a particle system to the rendering manager in order to render it this frame.
  110298. * @param particleSystem Define the particle system to render
  110299. */
  110300. dispatchParticles(particleSystem: IParticleSystem): void;
  110301. /**
  110302. * Add a submesh to the manager in order to render it this frame
  110303. * @param subMesh The submesh to dispatch
  110304. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  110305. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  110306. */
  110307. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  110308. /**
  110309. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110310. * This allowed control for front to back rendering or reversly depending of the special needs.
  110311. *
  110312. * @param renderingGroupId The rendering group id corresponding to its index
  110313. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110314. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110315. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110316. */
  110317. 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;
  110318. /**
  110319. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110320. *
  110321. * @param renderingGroupId The rendering group id corresponding to its index
  110322. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110323. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110324. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110325. */
  110326. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110327. /**
  110328. * Gets the current auto clear configuration for one rendering group of the rendering
  110329. * manager.
  110330. * @param index the rendering group index to get the information for
  110331. * @returns The auto clear setup for the requested rendering group
  110332. */
  110333. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110334. }
  110335. }
  110336. declare module BABYLON {
  110337. /**
  110338. * Defines the options associated with the creation of a custom shader for a shadow generator.
  110339. */
  110340. export interface ICustomShaderOptions {
  110341. /**
  110342. * Gets or sets the custom shader name to use
  110343. */
  110344. shaderName: string;
  110345. /**
  110346. * The list of attribute names used in the shader
  110347. */
  110348. attributes?: string[];
  110349. /**
  110350. * The list of unifrom names used in the shader
  110351. */
  110352. uniforms?: string[];
  110353. /**
  110354. * The list of sampler names used in the shader
  110355. */
  110356. samplers?: string[];
  110357. /**
  110358. * The list of defines used in the shader
  110359. */
  110360. defines?: string[];
  110361. }
  110362. /**
  110363. * Interface to implement to create a shadow generator compatible with BJS.
  110364. */
  110365. export interface IShadowGenerator {
  110366. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110367. id: string;
  110368. /**
  110369. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110370. * @returns The render target texture if present otherwise, null
  110371. */
  110372. getShadowMap(): Nullable<RenderTargetTexture>;
  110373. /**
  110374. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110375. * @param subMesh The submesh we want to render in the shadow map
  110376. * @param useInstances Defines wether will draw in the map using instances
  110377. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110378. * @returns true if ready otherwise, false
  110379. */
  110380. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110381. /**
  110382. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110383. * @param defines Defines of the material we want to update
  110384. * @param lightIndex Index of the light in the enabled light list of the material
  110385. */
  110386. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  110387. /**
  110388. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110389. * defined in the generator but impacting the effect).
  110390. * It implies the unifroms available on the materials are the standard BJS ones.
  110391. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110392. * @param effect The effect we are binfing the information for
  110393. */
  110394. bindShadowLight(lightIndex: string, effect: Effect): void;
  110395. /**
  110396. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110397. * (eq to shadow prjection matrix * light transform matrix)
  110398. * @returns The transform matrix used to create the shadow map
  110399. */
  110400. getTransformMatrix(): Matrix;
  110401. /**
  110402. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110403. * Cube and 2D textures for instance.
  110404. */
  110405. recreateShadowMap(): void;
  110406. /**
  110407. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110408. * @param onCompiled Callback triggered at the and of the effects compilation
  110409. * @param options Sets of optional options forcing the compilation with different modes
  110410. */
  110411. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110412. useInstances: boolean;
  110413. }>): void;
  110414. /**
  110415. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110416. * @param options Sets of optional options forcing the compilation with different modes
  110417. * @returns A promise that resolves when the compilation completes
  110418. */
  110419. forceCompilationAsync(options?: Partial<{
  110420. useInstances: boolean;
  110421. }>): Promise<void>;
  110422. /**
  110423. * Serializes the shadow generator setup to a json object.
  110424. * @returns The serialized JSON object
  110425. */
  110426. serialize(): any;
  110427. /**
  110428. * Disposes the Shadow map and related Textures and effects.
  110429. */
  110430. dispose(): void;
  110431. }
  110432. /**
  110433. * Default implementation IShadowGenerator.
  110434. * This is the main object responsible of generating shadows in the framework.
  110435. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  110436. */
  110437. export class ShadowGenerator implements IShadowGenerator {
  110438. /**
  110439. * Name of the shadow generator class
  110440. */
  110441. static CLASSNAME: string;
  110442. /**
  110443. * Shadow generator mode None: no filtering applied.
  110444. */
  110445. static readonly FILTER_NONE: number;
  110446. /**
  110447. * Shadow generator mode ESM: Exponential Shadow Mapping.
  110448. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110449. */
  110450. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  110451. /**
  110452. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  110453. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  110454. */
  110455. static readonly FILTER_POISSONSAMPLING: number;
  110456. /**
  110457. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  110458. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110459. */
  110460. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  110461. /**
  110462. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  110463. * edge artifacts on steep falloff.
  110464. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110465. */
  110466. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  110467. /**
  110468. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  110469. * edge artifacts on steep falloff.
  110470. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110471. */
  110472. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  110473. /**
  110474. * Shadow generator mode PCF: Percentage Closer Filtering
  110475. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110476. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  110477. */
  110478. static readonly FILTER_PCF: number;
  110479. /**
  110480. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  110481. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110482. * Contact Hardening
  110483. */
  110484. static readonly FILTER_PCSS: number;
  110485. /**
  110486. * Reserved for PCF and PCSS
  110487. * Highest Quality.
  110488. *
  110489. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  110490. *
  110491. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  110492. */
  110493. static readonly QUALITY_HIGH: number;
  110494. /**
  110495. * Reserved for PCF and PCSS
  110496. * Good tradeoff for quality/perf cross devices
  110497. *
  110498. * Execute PCF on a 3*3 kernel.
  110499. *
  110500. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  110501. */
  110502. static readonly QUALITY_MEDIUM: number;
  110503. /**
  110504. * Reserved for PCF and PCSS
  110505. * The lowest quality but the fastest.
  110506. *
  110507. * Execute PCF on a 1*1 kernel.
  110508. *
  110509. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  110510. */
  110511. static readonly QUALITY_LOW: number;
  110512. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110513. id: string;
  110514. /** Gets or sets the custom shader name to use */
  110515. customShaderOptions: ICustomShaderOptions;
  110516. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  110517. customAllowRendering: (subMesh: SubMesh) => boolean;
  110518. /**
  110519. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  110520. */
  110521. onBeforeShadowMapRenderObservable: Observable<Effect>;
  110522. /**
  110523. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  110524. */
  110525. onAfterShadowMapRenderObservable: Observable<Effect>;
  110526. /**
  110527. * Observable triggered before a mesh is rendered in the shadow map.
  110528. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  110529. */
  110530. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  110531. /**
  110532. * Observable triggered after a mesh is rendered in the shadow map.
  110533. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  110534. */
  110535. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  110536. protected _bias: number;
  110537. /**
  110538. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  110539. */
  110540. get bias(): number;
  110541. /**
  110542. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  110543. */
  110544. set bias(bias: number);
  110545. protected _normalBias: number;
  110546. /**
  110547. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110548. */
  110549. get normalBias(): number;
  110550. /**
  110551. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110552. */
  110553. set normalBias(normalBias: number);
  110554. protected _blurBoxOffset: number;
  110555. /**
  110556. * Gets the blur box offset: offset applied during the blur pass.
  110557. * Only useful if useKernelBlur = false
  110558. */
  110559. get blurBoxOffset(): number;
  110560. /**
  110561. * Sets the blur box offset: offset applied during the blur pass.
  110562. * Only useful if useKernelBlur = false
  110563. */
  110564. set blurBoxOffset(value: number);
  110565. protected _blurScale: number;
  110566. /**
  110567. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  110568. * 2 means half of the size.
  110569. */
  110570. get blurScale(): number;
  110571. /**
  110572. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  110573. * 2 means half of the size.
  110574. */
  110575. set blurScale(value: number);
  110576. protected _blurKernel: number;
  110577. /**
  110578. * Gets the blur kernel: kernel size of the blur pass.
  110579. * Only useful if useKernelBlur = true
  110580. */
  110581. get blurKernel(): number;
  110582. /**
  110583. * Sets the blur kernel: kernel size of the blur pass.
  110584. * Only useful if useKernelBlur = true
  110585. */
  110586. set blurKernel(value: number);
  110587. protected _useKernelBlur: boolean;
  110588. /**
  110589. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  110590. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110591. */
  110592. get useKernelBlur(): boolean;
  110593. /**
  110594. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  110595. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110596. */
  110597. set useKernelBlur(value: boolean);
  110598. protected _depthScale: number;
  110599. /**
  110600. * Gets the depth scale used in ESM mode.
  110601. */
  110602. get depthScale(): number;
  110603. /**
  110604. * Sets the depth scale used in ESM mode.
  110605. * This can override the scale stored on the light.
  110606. */
  110607. set depthScale(value: number);
  110608. protected _validateFilter(filter: number): number;
  110609. protected _filter: number;
  110610. /**
  110611. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  110612. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110613. */
  110614. get filter(): number;
  110615. /**
  110616. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  110617. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110618. */
  110619. set filter(value: number);
  110620. /**
  110621. * Gets if the current filter is set to Poisson Sampling.
  110622. */
  110623. get usePoissonSampling(): boolean;
  110624. /**
  110625. * Sets the current filter to Poisson Sampling.
  110626. */
  110627. set usePoissonSampling(value: boolean);
  110628. /**
  110629. * Gets if the current filter is set to ESM.
  110630. */
  110631. get useExponentialShadowMap(): boolean;
  110632. /**
  110633. * Sets the current filter is to ESM.
  110634. */
  110635. set useExponentialShadowMap(value: boolean);
  110636. /**
  110637. * Gets if the current filter is set to filtered ESM.
  110638. */
  110639. get useBlurExponentialShadowMap(): boolean;
  110640. /**
  110641. * Gets if the current filter is set to filtered ESM.
  110642. */
  110643. set useBlurExponentialShadowMap(value: boolean);
  110644. /**
  110645. * Gets if the current filter is set to "close ESM" (using the inverse of the
  110646. * exponential to prevent steep falloff artifacts).
  110647. */
  110648. get useCloseExponentialShadowMap(): boolean;
  110649. /**
  110650. * Sets the current filter to "close ESM" (using the inverse of the
  110651. * exponential to prevent steep falloff artifacts).
  110652. */
  110653. set useCloseExponentialShadowMap(value: boolean);
  110654. /**
  110655. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  110656. * exponential to prevent steep falloff artifacts).
  110657. */
  110658. get useBlurCloseExponentialShadowMap(): boolean;
  110659. /**
  110660. * Sets the current filter to filtered "close ESM" (using the inverse of the
  110661. * exponential to prevent steep falloff artifacts).
  110662. */
  110663. set useBlurCloseExponentialShadowMap(value: boolean);
  110664. /**
  110665. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  110666. */
  110667. get usePercentageCloserFiltering(): boolean;
  110668. /**
  110669. * Sets the current filter to "PCF" (percentage closer filtering).
  110670. */
  110671. set usePercentageCloserFiltering(value: boolean);
  110672. protected _filteringQuality: number;
  110673. /**
  110674. * Gets the PCF or PCSS Quality.
  110675. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110676. */
  110677. get filteringQuality(): number;
  110678. /**
  110679. * Sets the PCF or PCSS Quality.
  110680. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110681. */
  110682. set filteringQuality(filteringQuality: number);
  110683. /**
  110684. * Gets if the current filter is set to "PCSS" (contact hardening).
  110685. */
  110686. get useContactHardeningShadow(): boolean;
  110687. /**
  110688. * Sets the current filter to "PCSS" (contact hardening).
  110689. */
  110690. set useContactHardeningShadow(value: boolean);
  110691. protected _contactHardeningLightSizeUVRatio: number;
  110692. /**
  110693. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110694. * Using a ratio helps keeping shape stability independently of the map size.
  110695. *
  110696. * It does not account for the light projection as it was having too much
  110697. * instability during the light setup or during light position changes.
  110698. *
  110699. * Only valid if useContactHardeningShadow is true.
  110700. */
  110701. get contactHardeningLightSizeUVRatio(): number;
  110702. /**
  110703. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110704. * Using a ratio helps keeping shape stability independently of the map size.
  110705. *
  110706. * It does not account for the light projection as it was having too much
  110707. * instability during the light setup or during light position changes.
  110708. *
  110709. * Only valid if useContactHardeningShadow is true.
  110710. */
  110711. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  110712. protected _darkness: number;
  110713. /** Gets or sets the actual darkness of a shadow */
  110714. get darkness(): number;
  110715. set darkness(value: number);
  110716. /**
  110717. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  110718. * 0 means strongest and 1 would means no shadow.
  110719. * @returns the darkness.
  110720. */
  110721. getDarkness(): number;
  110722. /**
  110723. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  110724. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  110725. * @returns the shadow generator allowing fluent coding.
  110726. */
  110727. setDarkness(darkness: number): ShadowGenerator;
  110728. protected _transparencyShadow: boolean;
  110729. /** Gets or sets the ability to have transparent shadow */
  110730. get transparencyShadow(): boolean;
  110731. set transparencyShadow(value: boolean);
  110732. /**
  110733. * Sets the ability to have transparent shadow (boolean).
  110734. * @param transparent True if transparent else False
  110735. * @returns the shadow generator allowing fluent coding
  110736. */
  110737. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  110738. /**
  110739. * Enables or disables shadows with varying strength based on the transparency
  110740. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  110741. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  110742. * mesh.visibility * alphaTexture.a
  110743. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  110744. */
  110745. enableSoftTransparentShadow: boolean;
  110746. protected _shadowMap: Nullable<RenderTargetTexture>;
  110747. protected _shadowMap2: Nullable<RenderTargetTexture>;
  110748. /**
  110749. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110750. * @returns The render target texture if present otherwise, null
  110751. */
  110752. getShadowMap(): Nullable<RenderTargetTexture>;
  110753. /**
  110754. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  110755. * @returns The render target texture if the shadow map is present otherwise, null
  110756. */
  110757. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  110758. /**
  110759. * Gets the class name of that object
  110760. * @returns "ShadowGenerator"
  110761. */
  110762. getClassName(): string;
  110763. /**
  110764. * Helper function to add a mesh and its descendants to the list of shadow casters.
  110765. * @param mesh Mesh to add
  110766. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  110767. * @returns the Shadow Generator itself
  110768. */
  110769. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110770. /**
  110771. * Helper function to remove a mesh and its descendants from the list of shadow casters
  110772. * @param mesh Mesh to remove
  110773. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  110774. * @returns the Shadow Generator itself
  110775. */
  110776. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110777. /**
  110778. * Controls the extent to which the shadows fade out at the edge of the frustum
  110779. */
  110780. frustumEdgeFalloff: number;
  110781. protected _light: IShadowLight;
  110782. /**
  110783. * Returns the associated light object.
  110784. * @returns the light generating the shadow
  110785. */
  110786. getLight(): IShadowLight;
  110787. /**
  110788. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  110789. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  110790. * It might on the other hand introduce peter panning.
  110791. */
  110792. forceBackFacesOnly: boolean;
  110793. protected _scene: Scene;
  110794. protected _lightDirection: Vector3;
  110795. protected _effect: Effect;
  110796. protected _viewMatrix: Matrix;
  110797. protected _projectionMatrix: Matrix;
  110798. protected _transformMatrix: Matrix;
  110799. protected _cachedPosition: Vector3;
  110800. protected _cachedDirection: Vector3;
  110801. protected _cachedDefines: string;
  110802. protected _currentRenderID: number;
  110803. protected _boxBlurPostprocess: Nullable<PostProcess>;
  110804. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  110805. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  110806. protected _blurPostProcesses: PostProcess[];
  110807. protected _mapSize: number;
  110808. protected _currentFaceIndex: number;
  110809. protected _currentFaceIndexCache: number;
  110810. protected _textureType: number;
  110811. protected _defaultTextureMatrix: Matrix;
  110812. protected _storedUniqueId: Nullable<number>;
  110813. /** @hidden */
  110814. static _SceneComponentInitialization: (scene: Scene) => void;
  110815. /**
  110816. * Gets or sets the size of the texture what stores the shadows
  110817. */
  110818. get mapSize(): number;
  110819. set mapSize(size: number);
  110820. /**
  110821. * Creates a ShadowGenerator object.
  110822. * A ShadowGenerator is the required tool to use the shadows.
  110823. * Each light casting shadows needs to use its own ShadowGenerator.
  110824. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  110825. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  110826. * @param light The light object generating the shadows.
  110827. * @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.
  110828. */
  110829. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  110830. protected _initializeGenerator(): void;
  110831. protected _createTargetRenderTexture(): void;
  110832. protected _initializeShadowMap(): void;
  110833. protected _initializeBlurRTTAndPostProcesses(): void;
  110834. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  110835. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  110836. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  110837. protected _applyFilterValues(): void;
  110838. /**
  110839. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110840. * @param onCompiled Callback triggered at the and of the effects compilation
  110841. * @param options Sets of optional options forcing the compilation with different modes
  110842. */
  110843. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110844. useInstances: boolean;
  110845. }>): void;
  110846. /**
  110847. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110848. * @param options Sets of optional options forcing the compilation with different modes
  110849. * @returns A promise that resolves when the compilation completes
  110850. */
  110851. forceCompilationAsync(options?: Partial<{
  110852. useInstances: boolean;
  110853. }>): Promise<void>;
  110854. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  110855. private _prepareShadowDefines;
  110856. /**
  110857. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110858. * @param subMesh The submesh we want to render in the shadow map
  110859. * @param useInstances Defines wether will draw in the map using instances
  110860. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110861. * @returns true if ready otherwise, false
  110862. */
  110863. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110864. /**
  110865. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110866. * @param defines Defines of the material we want to update
  110867. * @param lightIndex Index of the light in the enabled light list of the material
  110868. */
  110869. prepareDefines(defines: any, lightIndex: number): void;
  110870. /**
  110871. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110872. * defined in the generator but impacting the effect).
  110873. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110874. * @param effect The effect we are binfing the information for
  110875. */
  110876. bindShadowLight(lightIndex: string, effect: Effect): void;
  110877. /**
  110878. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110879. * (eq to shadow prjection matrix * light transform matrix)
  110880. * @returns The transform matrix used to create the shadow map
  110881. */
  110882. getTransformMatrix(): Matrix;
  110883. /**
  110884. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110885. * Cube and 2D textures for instance.
  110886. */
  110887. recreateShadowMap(): void;
  110888. protected _disposeBlurPostProcesses(): void;
  110889. protected _disposeRTTandPostProcesses(): void;
  110890. /**
  110891. * Disposes the ShadowGenerator.
  110892. * Returns nothing.
  110893. */
  110894. dispose(): void;
  110895. /**
  110896. * Serializes the shadow generator setup to a json object.
  110897. * @returns The serialized JSON object
  110898. */
  110899. serialize(): any;
  110900. /**
  110901. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  110902. * @param parsedShadowGenerator The JSON object to parse
  110903. * @param scene The scene to create the shadow map for
  110904. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  110905. * @returns The parsed shadow generator
  110906. */
  110907. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  110908. }
  110909. }
  110910. declare module BABYLON {
  110911. /**
  110912. * Options to be used when creating a shadow depth material
  110913. */
  110914. export interface IIOptionShadowDepthMaterial {
  110915. /** Variables in the vertex shader code that need to have their names remapped.
  110916. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  110917. * "var_name" should be either: worldPos or vNormalW
  110918. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  110919. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  110920. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  110921. */
  110922. remappedVariables?: string[];
  110923. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  110924. standalone?: boolean;
  110925. }
  110926. /**
  110927. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  110928. */
  110929. export class ShadowDepthWrapper {
  110930. private _scene;
  110931. private _options?;
  110932. private _baseMaterial;
  110933. private _onEffectCreatedObserver;
  110934. private _subMeshToEffect;
  110935. private _subMeshToDepthEffect;
  110936. private _meshes;
  110937. /** @hidden */
  110938. _matriceNames: any;
  110939. /** Gets the standalone status of the wrapper */
  110940. get standalone(): boolean;
  110941. /** Gets the base material the wrapper is built upon */
  110942. get baseMaterial(): Material;
  110943. /**
  110944. * Instantiate a new shadow depth wrapper.
  110945. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  110946. * generate the shadow depth map. For more information, please refer to the documentation:
  110947. * https://doc.babylonjs.com/babylon101/shadows
  110948. * @param baseMaterial Material to wrap
  110949. * @param scene Define the scene the material belongs to
  110950. * @param options Options used to create the wrapper
  110951. */
  110952. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  110953. /**
  110954. * Gets the effect to use to generate the depth map
  110955. * @param subMesh subMesh to get the effect for
  110956. * @param shadowGenerator shadow generator to get the effect for
  110957. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  110958. */
  110959. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  110960. /**
  110961. * Specifies that the submesh is ready to be used for depth rendering
  110962. * @param subMesh submesh to check
  110963. * @param defines the list of defines to take into account when checking the effect
  110964. * @param shadowGenerator combined with subMesh, it defines the effect to check
  110965. * @param useInstances specifies that instances should be used
  110966. * @returns a boolean indicating that the submesh is ready or not
  110967. */
  110968. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  110969. /**
  110970. * Disposes the resources
  110971. */
  110972. dispose(): void;
  110973. private _makeEffect;
  110974. }
  110975. }
  110976. declare module BABYLON {
  110977. /**
  110978. * Options for compiling materials.
  110979. */
  110980. export interface IMaterialCompilationOptions {
  110981. /**
  110982. * Defines whether clip planes are enabled.
  110983. */
  110984. clipPlane: boolean;
  110985. /**
  110986. * Defines whether instances are enabled.
  110987. */
  110988. useInstances: boolean;
  110989. }
  110990. /**
  110991. * Options passed when calling customShaderNameResolve
  110992. */
  110993. export interface ICustomShaderNameResolveOptions {
  110994. /**
  110995. * 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
  110996. */
  110997. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110998. }
  110999. /**
  111000. * Base class for the main features of a material in Babylon.js
  111001. */
  111002. export class Material implements IAnimatable {
  111003. /**
  111004. * Returns the triangle fill mode
  111005. */
  111006. static readonly TriangleFillMode: number;
  111007. /**
  111008. * Returns the wireframe mode
  111009. */
  111010. static readonly WireFrameFillMode: number;
  111011. /**
  111012. * Returns the point fill mode
  111013. */
  111014. static readonly PointFillMode: number;
  111015. /**
  111016. * Returns the point list draw mode
  111017. */
  111018. static readonly PointListDrawMode: number;
  111019. /**
  111020. * Returns the line list draw mode
  111021. */
  111022. static readonly LineListDrawMode: number;
  111023. /**
  111024. * Returns the line loop draw mode
  111025. */
  111026. static readonly LineLoopDrawMode: number;
  111027. /**
  111028. * Returns the line strip draw mode
  111029. */
  111030. static readonly LineStripDrawMode: number;
  111031. /**
  111032. * Returns the triangle strip draw mode
  111033. */
  111034. static readonly TriangleStripDrawMode: number;
  111035. /**
  111036. * Returns the triangle fan draw mode
  111037. */
  111038. static readonly TriangleFanDrawMode: number;
  111039. /**
  111040. * Stores the clock-wise side orientation
  111041. */
  111042. static readonly ClockWiseSideOrientation: number;
  111043. /**
  111044. * Stores the counter clock-wise side orientation
  111045. */
  111046. static readonly CounterClockWiseSideOrientation: number;
  111047. /**
  111048. * The dirty texture flag value
  111049. */
  111050. static readonly TextureDirtyFlag: number;
  111051. /**
  111052. * The dirty light flag value
  111053. */
  111054. static readonly LightDirtyFlag: number;
  111055. /**
  111056. * The dirty fresnel flag value
  111057. */
  111058. static readonly FresnelDirtyFlag: number;
  111059. /**
  111060. * The dirty attribute flag value
  111061. */
  111062. static readonly AttributesDirtyFlag: number;
  111063. /**
  111064. * The dirty misc flag value
  111065. */
  111066. static readonly MiscDirtyFlag: number;
  111067. /**
  111068. * The dirty prepass flag value
  111069. */
  111070. static readonly PrePassDirtyFlag: number;
  111071. /**
  111072. * The all dirty flag value
  111073. */
  111074. static readonly AllDirtyFlag: number;
  111075. /**
  111076. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  111077. */
  111078. static readonly MATERIAL_OPAQUE: number;
  111079. /**
  111080. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  111081. */
  111082. static readonly MATERIAL_ALPHATEST: number;
  111083. /**
  111084. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111085. */
  111086. static readonly MATERIAL_ALPHABLEND: number;
  111087. /**
  111088. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111089. * They are also discarded below the alpha cutoff threshold to improve performances.
  111090. */
  111091. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  111092. /**
  111093. * The Whiteout method is used to blend normals.
  111094. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  111095. */
  111096. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  111097. /**
  111098. * The Reoriented Normal Mapping method is used to blend normals.
  111099. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  111100. */
  111101. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  111102. /**
  111103. * Custom callback helping to override the default shader used in the material.
  111104. */
  111105. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  111106. /**
  111107. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  111108. */
  111109. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  111110. /**
  111111. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  111112. * This means that the material can keep using a previous shader while a new one is being compiled.
  111113. * This is mostly used when shader parallel compilation is supported (true by default)
  111114. */
  111115. allowShaderHotSwapping: boolean;
  111116. /**
  111117. * The ID of the material
  111118. */
  111119. id: string;
  111120. /**
  111121. * Gets or sets the unique id of the material
  111122. */
  111123. uniqueId: number;
  111124. /**
  111125. * The name of the material
  111126. */
  111127. name: string;
  111128. /**
  111129. * Gets or sets user defined metadata
  111130. */
  111131. metadata: any;
  111132. /**
  111133. * For internal use only. Please do not use.
  111134. */
  111135. reservedDataStore: any;
  111136. /**
  111137. * Specifies if the ready state should be checked on each call
  111138. */
  111139. checkReadyOnEveryCall: boolean;
  111140. /**
  111141. * Specifies if the ready state should be checked once
  111142. */
  111143. checkReadyOnlyOnce: boolean;
  111144. /**
  111145. * The state of the material
  111146. */
  111147. state: string;
  111148. /**
  111149. * If the material can be rendered to several textures with MRT extension
  111150. */
  111151. get canRenderToMRT(): boolean;
  111152. /**
  111153. * The alpha value of the material
  111154. */
  111155. protected _alpha: number;
  111156. /**
  111157. * List of inspectable custom properties (used by the Inspector)
  111158. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111159. */
  111160. inspectableCustomProperties: IInspectable[];
  111161. /**
  111162. * Sets the alpha value of the material
  111163. */
  111164. set alpha(value: number);
  111165. /**
  111166. * Gets the alpha value of the material
  111167. */
  111168. get alpha(): number;
  111169. /**
  111170. * Specifies if back face culling is enabled
  111171. */
  111172. protected _backFaceCulling: boolean;
  111173. /**
  111174. * Sets the back-face culling state
  111175. */
  111176. set backFaceCulling(value: boolean);
  111177. /**
  111178. * Gets the back-face culling state
  111179. */
  111180. get backFaceCulling(): boolean;
  111181. /**
  111182. * Stores the value for side orientation
  111183. */
  111184. sideOrientation: number;
  111185. /**
  111186. * Callback triggered when the material is compiled
  111187. */
  111188. onCompiled: Nullable<(effect: Effect) => void>;
  111189. /**
  111190. * Callback triggered when an error occurs
  111191. */
  111192. onError: Nullable<(effect: Effect, errors: string) => void>;
  111193. /**
  111194. * Callback triggered to get the render target textures
  111195. */
  111196. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  111197. /**
  111198. * Gets a boolean indicating that current material needs to register RTT
  111199. */
  111200. get hasRenderTargetTextures(): boolean;
  111201. /**
  111202. * Specifies if the material should be serialized
  111203. */
  111204. doNotSerialize: boolean;
  111205. /**
  111206. * @hidden
  111207. */
  111208. _storeEffectOnSubMeshes: boolean;
  111209. /**
  111210. * Stores the animations for the material
  111211. */
  111212. animations: Nullable<Array<Animation>>;
  111213. /**
  111214. * An event triggered when the material is disposed
  111215. */
  111216. onDisposeObservable: Observable<Material>;
  111217. /**
  111218. * An observer which watches for dispose events
  111219. */
  111220. private _onDisposeObserver;
  111221. private _onUnBindObservable;
  111222. /**
  111223. * Called during a dispose event
  111224. */
  111225. set onDispose(callback: () => void);
  111226. private _onBindObservable;
  111227. /**
  111228. * An event triggered when the material is bound
  111229. */
  111230. get onBindObservable(): Observable<AbstractMesh>;
  111231. /**
  111232. * An observer which watches for bind events
  111233. */
  111234. private _onBindObserver;
  111235. /**
  111236. * Called during a bind event
  111237. */
  111238. set onBind(callback: (Mesh: AbstractMesh) => void);
  111239. /**
  111240. * An event triggered when the material is unbound
  111241. */
  111242. get onUnBindObservable(): Observable<Material>;
  111243. protected _onEffectCreatedObservable: Nullable<Observable<{
  111244. effect: Effect;
  111245. subMesh: Nullable<SubMesh>;
  111246. }>>;
  111247. /**
  111248. * An event triggered when the effect is (re)created
  111249. */
  111250. get onEffectCreatedObservable(): Observable<{
  111251. effect: Effect;
  111252. subMesh: Nullable<SubMesh>;
  111253. }>;
  111254. /**
  111255. * Stores the value of the alpha mode
  111256. */
  111257. private _alphaMode;
  111258. /**
  111259. * Sets the value of the alpha mode.
  111260. *
  111261. * | Value | Type | Description |
  111262. * | --- | --- | --- |
  111263. * | 0 | ALPHA_DISABLE | |
  111264. * | 1 | ALPHA_ADD | |
  111265. * | 2 | ALPHA_COMBINE | |
  111266. * | 3 | ALPHA_SUBTRACT | |
  111267. * | 4 | ALPHA_MULTIPLY | |
  111268. * | 5 | ALPHA_MAXIMIZED | |
  111269. * | 6 | ALPHA_ONEONE | |
  111270. * | 7 | ALPHA_PREMULTIPLIED | |
  111271. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  111272. * | 9 | ALPHA_INTERPOLATE | |
  111273. * | 10 | ALPHA_SCREENMODE | |
  111274. *
  111275. */
  111276. set alphaMode(value: number);
  111277. /**
  111278. * Gets the value of the alpha mode
  111279. */
  111280. get alphaMode(): number;
  111281. /**
  111282. * Stores the state of the need depth pre-pass value
  111283. */
  111284. private _needDepthPrePass;
  111285. /**
  111286. * Sets the need depth pre-pass value
  111287. */
  111288. set needDepthPrePass(value: boolean);
  111289. /**
  111290. * Gets the depth pre-pass value
  111291. */
  111292. get needDepthPrePass(): boolean;
  111293. /**
  111294. * Specifies if depth writing should be disabled
  111295. */
  111296. disableDepthWrite: boolean;
  111297. /**
  111298. * Specifies if color writing should be disabled
  111299. */
  111300. disableColorWrite: boolean;
  111301. /**
  111302. * Specifies if depth writing should be forced
  111303. */
  111304. forceDepthWrite: boolean;
  111305. /**
  111306. * Specifies the depth function that should be used. 0 means the default engine function
  111307. */
  111308. depthFunction: number;
  111309. /**
  111310. * Specifies if there should be a separate pass for culling
  111311. */
  111312. separateCullingPass: boolean;
  111313. /**
  111314. * Stores the state specifing if fog should be enabled
  111315. */
  111316. private _fogEnabled;
  111317. /**
  111318. * Sets the state for enabling fog
  111319. */
  111320. set fogEnabled(value: boolean);
  111321. /**
  111322. * Gets the value of the fog enabled state
  111323. */
  111324. get fogEnabled(): boolean;
  111325. /**
  111326. * Stores the size of points
  111327. */
  111328. pointSize: number;
  111329. /**
  111330. * Stores the z offset value
  111331. */
  111332. zOffset: number;
  111333. get wireframe(): boolean;
  111334. /**
  111335. * Sets the state of wireframe mode
  111336. */
  111337. set wireframe(value: boolean);
  111338. /**
  111339. * Gets the value specifying if point clouds are enabled
  111340. */
  111341. get pointsCloud(): boolean;
  111342. /**
  111343. * Sets the state of point cloud mode
  111344. */
  111345. set pointsCloud(value: boolean);
  111346. /**
  111347. * Gets the material fill mode
  111348. */
  111349. get fillMode(): number;
  111350. /**
  111351. * Sets the material fill mode
  111352. */
  111353. set fillMode(value: number);
  111354. /**
  111355. * @hidden
  111356. * Stores the effects for the material
  111357. */
  111358. _effect: Nullable<Effect>;
  111359. /**
  111360. * Specifies if uniform buffers should be used
  111361. */
  111362. private _useUBO;
  111363. /**
  111364. * Stores a reference to the scene
  111365. */
  111366. private _scene;
  111367. /**
  111368. * Stores the fill mode state
  111369. */
  111370. private _fillMode;
  111371. /**
  111372. * Specifies if the depth write state should be cached
  111373. */
  111374. private _cachedDepthWriteState;
  111375. /**
  111376. * Specifies if the color write state should be cached
  111377. */
  111378. private _cachedColorWriteState;
  111379. /**
  111380. * Specifies if the depth function state should be cached
  111381. */
  111382. private _cachedDepthFunctionState;
  111383. /**
  111384. * Stores the uniform buffer
  111385. */
  111386. protected _uniformBuffer: UniformBuffer;
  111387. /** @hidden */
  111388. _indexInSceneMaterialArray: number;
  111389. /** @hidden */
  111390. meshMap: Nullable<{
  111391. [id: string]: AbstractMesh | undefined;
  111392. }>;
  111393. /**
  111394. * Creates a material instance
  111395. * @param name defines the name of the material
  111396. * @param scene defines the scene to reference
  111397. * @param doNotAdd specifies if the material should be added to the scene
  111398. */
  111399. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  111400. /**
  111401. * Returns a string representation of the current material
  111402. * @param fullDetails defines a boolean indicating which levels of logging is desired
  111403. * @returns a string with material information
  111404. */
  111405. toString(fullDetails?: boolean): string;
  111406. /**
  111407. * Gets the class name of the material
  111408. * @returns a string with the class name of the material
  111409. */
  111410. getClassName(): string;
  111411. /**
  111412. * Specifies if updates for the material been locked
  111413. */
  111414. get isFrozen(): boolean;
  111415. /**
  111416. * Locks updates for the material
  111417. */
  111418. freeze(): void;
  111419. /**
  111420. * Unlocks updates for the material
  111421. */
  111422. unfreeze(): void;
  111423. /**
  111424. * Specifies if the material is ready to be used
  111425. * @param mesh defines the mesh to check
  111426. * @param useInstances specifies if instances should be used
  111427. * @returns a boolean indicating if the material is ready to be used
  111428. */
  111429. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  111430. /**
  111431. * Specifies that the submesh is ready to be used
  111432. * @param mesh defines the mesh to check
  111433. * @param subMesh defines which submesh to check
  111434. * @param useInstances specifies that instances should be used
  111435. * @returns a boolean indicating that the submesh is ready or not
  111436. */
  111437. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111438. /**
  111439. * Returns the material effect
  111440. * @returns the effect associated with the material
  111441. */
  111442. getEffect(): Nullable<Effect>;
  111443. /**
  111444. * Returns the current scene
  111445. * @returns a Scene
  111446. */
  111447. getScene(): Scene;
  111448. /**
  111449. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111450. */
  111451. protected _forceAlphaTest: boolean;
  111452. /**
  111453. * The transparency mode of the material.
  111454. */
  111455. protected _transparencyMode: Nullable<number>;
  111456. /**
  111457. * Gets the current transparency mode.
  111458. */
  111459. get transparencyMode(): Nullable<number>;
  111460. /**
  111461. * Sets the transparency mode of the material.
  111462. *
  111463. * | Value | Type | Description |
  111464. * | ----- | ----------------------------------- | ----------- |
  111465. * | 0 | OPAQUE | |
  111466. * | 1 | ALPHATEST | |
  111467. * | 2 | ALPHABLEND | |
  111468. * | 3 | ALPHATESTANDBLEND | |
  111469. *
  111470. */
  111471. set transparencyMode(value: Nullable<number>);
  111472. /**
  111473. * Returns true if alpha blending should be disabled.
  111474. */
  111475. protected get _disableAlphaBlending(): boolean;
  111476. /**
  111477. * Specifies whether or not this material should be rendered in alpha blend mode.
  111478. * @returns a boolean specifying if alpha blending is needed
  111479. */
  111480. needAlphaBlending(): boolean;
  111481. /**
  111482. * Specifies if the mesh will require alpha blending
  111483. * @param mesh defines the mesh to check
  111484. * @returns a boolean specifying if alpha blending is needed for the mesh
  111485. */
  111486. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111487. /**
  111488. * Specifies whether or not this material should be rendered in alpha test mode.
  111489. * @returns a boolean specifying if an alpha test is needed.
  111490. */
  111491. needAlphaTesting(): boolean;
  111492. /**
  111493. * Specifies if material alpha testing should be turned on for the mesh
  111494. * @param mesh defines the mesh to check
  111495. */
  111496. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  111497. /**
  111498. * Gets the texture used for the alpha test
  111499. * @returns the texture to use for alpha testing
  111500. */
  111501. getAlphaTestTexture(): Nullable<BaseTexture>;
  111502. /**
  111503. * Marks the material to indicate that it needs to be re-calculated
  111504. */
  111505. markDirty(): void;
  111506. /** @hidden */
  111507. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  111508. /**
  111509. * Binds the material to the mesh
  111510. * @param world defines the world transformation matrix
  111511. * @param mesh defines the mesh to bind the material to
  111512. */
  111513. bind(world: Matrix, mesh?: Mesh): void;
  111514. /**
  111515. * Binds the submesh to the material
  111516. * @param world defines the world transformation matrix
  111517. * @param mesh defines the mesh containing the submesh
  111518. * @param subMesh defines the submesh to bind the material to
  111519. */
  111520. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111521. /**
  111522. * Binds the world matrix to the material
  111523. * @param world defines the world transformation matrix
  111524. */
  111525. bindOnlyWorldMatrix(world: Matrix): void;
  111526. /**
  111527. * Binds the scene's uniform buffer to the effect.
  111528. * @param effect defines the effect to bind to the scene uniform buffer
  111529. * @param sceneUbo defines the uniform buffer storing scene data
  111530. */
  111531. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  111532. /**
  111533. * Binds the view matrix to the effect
  111534. * @param effect defines the effect to bind the view matrix to
  111535. */
  111536. bindView(effect: Effect): void;
  111537. /**
  111538. * Binds the view projection matrix to the effect
  111539. * @param effect defines the effect to bind the view projection matrix to
  111540. */
  111541. bindViewProjection(effect: Effect): void;
  111542. /**
  111543. * Processes to execute after binding the material to a mesh
  111544. * @param mesh defines the rendered mesh
  111545. */
  111546. protected _afterBind(mesh?: Mesh): void;
  111547. /**
  111548. * Unbinds the material from the mesh
  111549. */
  111550. unbind(): void;
  111551. /**
  111552. * Gets the active textures from the material
  111553. * @returns an array of textures
  111554. */
  111555. getActiveTextures(): BaseTexture[];
  111556. /**
  111557. * Specifies if the material uses a texture
  111558. * @param texture defines the texture to check against the material
  111559. * @returns a boolean specifying if the material uses the texture
  111560. */
  111561. hasTexture(texture: BaseTexture): boolean;
  111562. /**
  111563. * Makes a duplicate of the material, and gives it a new name
  111564. * @param name defines the new name for the duplicated material
  111565. * @returns the cloned material
  111566. */
  111567. clone(name: string): Nullable<Material>;
  111568. /**
  111569. * Gets the meshes bound to the material
  111570. * @returns an array of meshes bound to the material
  111571. */
  111572. getBindedMeshes(): AbstractMesh[];
  111573. /**
  111574. * Force shader compilation
  111575. * @param mesh defines the mesh associated with this material
  111576. * @param onCompiled defines a function to execute once the material is compiled
  111577. * @param options defines the options to configure the compilation
  111578. * @param onError defines a function to execute if the material fails compiling
  111579. */
  111580. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  111581. /**
  111582. * Force shader compilation
  111583. * @param mesh defines the mesh that will use this material
  111584. * @param options defines additional options for compiling the shaders
  111585. * @returns a promise that resolves when the compilation completes
  111586. */
  111587. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  111588. private static readonly _AllDirtyCallBack;
  111589. private static readonly _ImageProcessingDirtyCallBack;
  111590. private static readonly _TextureDirtyCallBack;
  111591. private static readonly _FresnelDirtyCallBack;
  111592. private static readonly _MiscDirtyCallBack;
  111593. private static readonly _PrePassDirtyCallBack;
  111594. private static readonly _LightsDirtyCallBack;
  111595. private static readonly _AttributeDirtyCallBack;
  111596. private static _FresnelAndMiscDirtyCallBack;
  111597. private static _TextureAndMiscDirtyCallBack;
  111598. private static readonly _DirtyCallbackArray;
  111599. private static readonly _RunDirtyCallBacks;
  111600. /**
  111601. * Marks a define in the material to indicate that it needs to be re-computed
  111602. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  111603. */
  111604. markAsDirty(flag: number): void;
  111605. /**
  111606. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  111607. * @param func defines a function which checks material defines against the submeshes
  111608. */
  111609. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  111610. /**
  111611. * Indicates that the scene should check if the rendering now needs a prepass
  111612. */
  111613. protected _markScenePrePassDirty(): void;
  111614. /**
  111615. * Indicates that we need to re-calculated for all submeshes
  111616. */
  111617. protected _markAllSubMeshesAsAllDirty(): void;
  111618. /**
  111619. * Indicates that image processing needs to be re-calculated for all submeshes
  111620. */
  111621. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  111622. /**
  111623. * Indicates that textures need to be re-calculated for all submeshes
  111624. */
  111625. protected _markAllSubMeshesAsTexturesDirty(): void;
  111626. /**
  111627. * Indicates that fresnel needs to be re-calculated for all submeshes
  111628. */
  111629. protected _markAllSubMeshesAsFresnelDirty(): void;
  111630. /**
  111631. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  111632. */
  111633. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  111634. /**
  111635. * Indicates that lights need to be re-calculated for all submeshes
  111636. */
  111637. protected _markAllSubMeshesAsLightsDirty(): void;
  111638. /**
  111639. * Indicates that attributes need to be re-calculated for all submeshes
  111640. */
  111641. protected _markAllSubMeshesAsAttributesDirty(): void;
  111642. /**
  111643. * Indicates that misc needs to be re-calculated for all submeshes
  111644. */
  111645. protected _markAllSubMeshesAsMiscDirty(): void;
  111646. /**
  111647. * Indicates that prepass needs to be re-calculated for all submeshes
  111648. */
  111649. protected _markAllSubMeshesAsPrePassDirty(): void;
  111650. /**
  111651. * Indicates that textures and misc need to be re-calculated for all submeshes
  111652. */
  111653. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  111654. /**
  111655. * Sets the required values to the prepass renderer.
  111656. * @param prePassRenderer defines the prepass renderer to setup.
  111657. * @returns true if the pre pass is needed.
  111658. */
  111659. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  111660. /**
  111661. * Disposes the material
  111662. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111663. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111664. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  111665. */
  111666. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  111667. /** @hidden */
  111668. private releaseVertexArrayObject;
  111669. /**
  111670. * Serializes this material
  111671. * @returns the serialized material object
  111672. */
  111673. serialize(): any;
  111674. /**
  111675. * Creates a material from parsed material data
  111676. * @param parsedMaterial defines parsed material data
  111677. * @param scene defines the hosting scene
  111678. * @param rootUrl defines the root URL to use to load textures
  111679. * @returns a new material
  111680. */
  111681. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  111682. }
  111683. }
  111684. declare module BABYLON {
  111685. /**
  111686. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111687. * separate meshes. This can be use to improve performances.
  111688. * @see https://doc.babylonjs.com/how_to/multi_materials
  111689. */
  111690. export class MultiMaterial extends Material {
  111691. private _subMaterials;
  111692. /**
  111693. * Gets or Sets the list of Materials used within the multi material.
  111694. * They need to be ordered according to the submeshes order in the associated mesh
  111695. */
  111696. get subMaterials(): Nullable<Material>[];
  111697. set subMaterials(value: Nullable<Material>[]);
  111698. /**
  111699. * Function used to align with Node.getChildren()
  111700. * @returns the list of Materials used within the multi material
  111701. */
  111702. getChildren(): Nullable<Material>[];
  111703. /**
  111704. * Instantiates a new Multi Material
  111705. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111706. * separate meshes. This can be use to improve performances.
  111707. * @see https://doc.babylonjs.com/how_to/multi_materials
  111708. * @param name Define the name in the scene
  111709. * @param scene Define the scene the material belongs to
  111710. */
  111711. constructor(name: string, scene: Scene);
  111712. private _hookArray;
  111713. /**
  111714. * Get one of the submaterial by its index in the submaterials array
  111715. * @param index The index to look the sub material at
  111716. * @returns The Material if the index has been defined
  111717. */
  111718. getSubMaterial(index: number): Nullable<Material>;
  111719. /**
  111720. * Get the list of active textures for the whole sub materials list.
  111721. * @returns All the textures that will be used during the rendering
  111722. */
  111723. getActiveTextures(): BaseTexture[];
  111724. /**
  111725. * Specifies if any sub-materials of this multi-material use a given texture.
  111726. * @param texture Defines the texture to check against this multi-material's sub-materials.
  111727. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  111728. */
  111729. hasTexture(texture: BaseTexture): boolean;
  111730. /**
  111731. * Gets the current class name of the material e.g. "MultiMaterial"
  111732. * Mainly use in serialization.
  111733. * @returns the class name
  111734. */
  111735. getClassName(): string;
  111736. /**
  111737. * Checks if the material is ready to render the requested sub mesh
  111738. * @param mesh Define the mesh the submesh belongs to
  111739. * @param subMesh Define the sub mesh to look readyness for
  111740. * @param useInstances Define whether or not the material is used with instances
  111741. * @returns true if ready, otherwise false
  111742. */
  111743. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111744. /**
  111745. * Clones the current material and its related sub materials
  111746. * @param name Define the name of the newly cloned material
  111747. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  111748. * @returns the cloned material
  111749. */
  111750. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  111751. /**
  111752. * Serializes the materials into a JSON representation.
  111753. * @returns the JSON representation
  111754. */
  111755. serialize(): any;
  111756. /**
  111757. * Dispose the material and release its associated resources
  111758. * @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)
  111759. * @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)
  111760. * @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)
  111761. */
  111762. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  111763. /**
  111764. * Creates a MultiMaterial from parsed MultiMaterial data.
  111765. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  111766. * @param scene defines the hosting scene
  111767. * @returns a new MultiMaterial
  111768. */
  111769. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  111770. }
  111771. }
  111772. declare module BABYLON {
  111773. /**
  111774. * Defines a subdivision inside a mesh
  111775. */
  111776. export class SubMesh implements ICullable {
  111777. /** the material index to use */
  111778. materialIndex: number;
  111779. /** vertex index start */
  111780. verticesStart: number;
  111781. /** vertices count */
  111782. verticesCount: number;
  111783. /** index start */
  111784. indexStart: number;
  111785. /** indices count */
  111786. indexCount: number;
  111787. /** @hidden */
  111788. _materialDefines: Nullable<MaterialDefines>;
  111789. /** @hidden */
  111790. _materialEffect: Nullable<Effect>;
  111791. /** @hidden */
  111792. _effectOverride: Nullable<Effect>;
  111793. /**
  111794. * Gets material defines used by the effect associated to the sub mesh
  111795. */
  111796. get materialDefines(): Nullable<MaterialDefines>;
  111797. /**
  111798. * Sets material defines used by the effect associated to the sub mesh
  111799. */
  111800. set materialDefines(defines: Nullable<MaterialDefines>);
  111801. /**
  111802. * Gets associated effect
  111803. */
  111804. get effect(): Nullable<Effect>;
  111805. /**
  111806. * Sets associated effect (effect used to render this submesh)
  111807. * @param effect defines the effect to associate with
  111808. * @param defines defines the set of defines used to compile this effect
  111809. */
  111810. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  111811. /** @hidden */
  111812. _linesIndexCount: number;
  111813. private _mesh;
  111814. private _renderingMesh;
  111815. private _boundingInfo;
  111816. private _linesIndexBuffer;
  111817. /** @hidden */
  111818. _lastColliderWorldVertices: Nullable<Vector3[]>;
  111819. /** @hidden */
  111820. _trianglePlanes: Plane[];
  111821. /** @hidden */
  111822. _lastColliderTransformMatrix: Nullable<Matrix>;
  111823. /** @hidden */
  111824. _renderId: number;
  111825. /** @hidden */
  111826. _alphaIndex: number;
  111827. /** @hidden */
  111828. _distanceToCamera: number;
  111829. /** @hidden */
  111830. _id: number;
  111831. private _currentMaterial;
  111832. /**
  111833. * Add a new submesh to a mesh
  111834. * @param materialIndex defines the material index to use
  111835. * @param verticesStart defines vertex index start
  111836. * @param verticesCount defines vertices count
  111837. * @param indexStart defines index start
  111838. * @param indexCount defines indices count
  111839. * @param mesh defines the parent mesh
  111840. * @param renderingMesh defines an optional rendering mesh
  111841. * @param createBoundingBox defines if bounding box should be created for this submesh
  111842. * @returns the new submesh
  111843. */
  111844. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  111845. /**
  111846. * Creates a new submesh
  111847. * @param materialIndex defines the material index to use
  111848. * @param verticesStart defines vertex index start
  111849. * @param verticesCount defines vertices count
  111850. * @param indexStart defines index start
  111851. * @param indexCount defines indices count
  111852. * @param mesh defines the parent mesh
  111853. * @param renderingMesh defines an optional rendering mesh
  111854. * @param createBoundingBox defines if bounding box should be created for this submesh
  111855. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  111856. */
  111857. constructor(
  111858. /** the material index to use */
  111859. materialIndex: number,
  111860. /** vertex index start */
  111861. verticesStart: number,
  111862. /** vertices count */
  111863. verticesCount: number,
  111864. /** index start */
  111865. indexStart: number,
  111866. /** indices count */
  111867. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  111868. /**
  111869. * Returns true if this submesh covers the entire parent mesh
  111870. * @ignorenaming
  111871. */
  111872. get IsGlobal(): boolean;
  111873. /**
  111874. * Returns the submesh BoudingInfo object
  111875. * @returns current bounding info (or mesh's one if the submesh is global)
  111876. */
  111877. getBoundingInfo(): BoundingInfo;
  111878. /**
  111879. * Sets the submesh BoundingInfo
  111880. * @param boundingInfo defines the new bounding info to use
  111881. * @returns the SubMesh
  111882. */
  111883. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  111884. /**
  111885. * Returns the mesh of the current submesh
  111886. * @return the parent mesh
  111887. */
  111888. getMesh(): AbstractMesh;
  111889. /**
  111890. * Returns the rendering mesh of the submesh
  111891. * @returns the rendering mesh (could be different from parent mesh)
  111892. */
  111893. getRenderingMesh(): Mesh;
  111894. /**
  111895. * Returns the replacement mesh of the submesh
  111896. * @returns the replacement mesh (could be different from parent mesh)
  111897. */
  111898. getReplacementMesh(): Nullable<AbstractMesh>;
  111899. /**
  111900. * Returns the effective mesh of the submesh
  111901. * @returns the effective mesh (could be different from parent mesh)
  111902. */
  111903. getEffectiveMesh(): AbstractMesh;
  111904. /**
  111905. * Returns the submesh material
  111906. * @returns null or the current material
  111907. */
  111908. getMaterial(): Nullable<Material>;
  111909. private _IsMultiMaterial;
  111910. /**
  111911. * Sets a new updated BoundingInfo object to the submesh
  111912. * @param data defines an optional position array to use to determine the bounding info
  111913. * @returns the SubMesh
  111914. */
  111915. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  111916. /** @hidden */
  111917. _checkCollision(collider: Collider): boolean;
  111918. /**
  111919. * Updates the submesh BoundingInfo
  111920. * @param world defines the world matrix to use to update the bounding info
  111921. * @returns the submesh
  111922. */
  111923. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  111924. /**
  111925. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  111926. * @param frustumPlanes defines the frustum planes
  111927. * @returns true if the submesh is intersecting with the frustum
  111928. */
  111929. isInFrustum(frustumPlanes: Plane[]): boolean;
  111930. /**
  111931. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  111932. * @param frustumPlanes defines the frustum planes
  111933. * @returns true if the submesh is inside the frustum
  111934. */
  111935. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111936. /**
  111937. * Renders the submesh
  111938. * @param enableAlphaMode defines if alpha needs to be used
  111939. * @returns the submesh
  111940. */
  111941. render(enableAlphaMode: boolean): SubMesh;
  111942. /**
  111943. * @hidden
  111944. */
  111945. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  111946. /**
  111947. * Checks if the submesh intersects with a ray
  111948. * @param ray defines the ray to test
  111949. * @returns true is the passed ray intersects the submesh bounding box
  111950. */
  111951. canIntersects(ray: Ray): boolean;
  111952. /**
  111953. * Intersects current submesh with a ray
  111954. * @param ray defines the ray to test
  111955. * @param positions defines mesh's positions array
  111956. * @param indices defines mesh's indices array
  111957. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111958. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111959. * @returns intersection info or null if no intersection
  111960. */
  111961. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  111962. /** @hidden */
  111963. private _intersectLines;
  111964. /** @hidden */
  111965. private _intersectUnIndexedLines;
  111966. /** @hidden */
  111967. private _intersectTriangles;
  111968. /** @hidden */
  111969. private _intersectUnIndexedTriangles;
  111970. /** @hidden */
  111971. _rebuild(): void;
  111972. /**
  111973. * Creates a new submesh from the passed mesh
  111974. * @param newMesh defines the new hosting mesh
  111975. * @param newRenderingMesh defines an optional rendering mesh
  111976. * @returns the new submesh
  111977. */
  111978. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  111979. /**
  111980. * Release associated resources
  111981. */
  111982. dispose(): void;
  111983. /**
  111984. * Gets the class name
  111985. * @returns the string "SubMesh".
  111986. */
  111987. getClassName(): string;
  111988. /**
  111989. * Creates a new submesh from indices data
  111990. * @param materialIndex the index of the main mesh material
  111991. * @param startIndex the index where to start the copy in the mesh indices array
  111992. * @param indexCount the number of indices to copy then from the startIndex
  111993. * @param mesh the main mesh to create the submesh from
  111994. * @param renderingMesh the optional rendering mesh
  111995. * @returns a new submesh
  111996. */
  111997. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  111998. }
  111999. }
  112000. declare module BABYLON {
  112001. /**
  112002. * Class used to represent data loading progression
  112003. */
  112004. export class SceneLoaderFlags {
  112005. private static _ForceFullSceneLoadingForIncremental;
  112006. private static _ShowLoadingScreen;
  112007. private static _CleanBoneMatrixWeights;
  112008. private static _loggingLevel;
  112009. /**
  112010. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  112011. */
  112012. static get ForceFullSceneLoadingForIncremental(): boolean;
  112013. static set ForceFullSceneLoadingForIncremental(value: boolean);
  112014. /**
  112015. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  112016. */
  112017. static get ShowLoadingScreen(): boolean;
  112018. static set ShowLoadingScreen(value: boolean);
  112019. /**
  112020. * Defines the current logging level (while loading the scene)
  112021. * @ignorenaming
  112022. */
  112023. static get loggingLevel(): number;
  112024. static set loggingLevel(value: number);
  112025. /**
  112026. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  112027. */
  112028. static get CleanBoneMatrixWeights(): boolean;
  112029. static set CleanBoneMatrixWeights(value: boolean);
  112030. }
  112031. }
  112032. declare module BABYLON {
  112033. /**
  112034. * Class used to store geometry data (vertex buffers + index buffer)
  112035. */
  112036. export class Geometry implements IGetSetVerticesData {
  112037. /**
  112038. * Gets or sets the ID of the geometry
  112039. */
  112040. id: string;
  112041. /**
  112042. * Gets or sets the unique ID of the geometry
  112043. */
  112044. uniqueId: number;
  112045. /**
  112046. * Gets the delay loading state of the geometry (none by default which means not delayed)
  112047. */
  112048. delayLoadState: number;
  112049. /**
  112050. * Gets the file containing the data to load when running in delay load state
  112051. */
  112052. delayLoadingFile: Nullable<string>;
  112053. /**
  112054. * Callback called when the geometry is updated
  112055. */
  112056. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  112057. private _scene;
  112058. private _engine;
  112059. private _meshes;
  112060. private _totalVertices;
  112061. /** @hidden */
  112062. _indices: IndicesArray;
  112063. /** @hidden */
  112064. _vertexBuffers: {
  112065. [key: string]: VertexBuffer;
  112066. };
  112067. private _isDisposed;
  112068. private _extend;
  112069. private _boundingBias;
  112070. /** @hidden */
  112071. _delayInfo: Array<string>;
  112072. private _indexBuffer;
  112073. private _indexBufferIsUpdatable;
  112074. /** @hidden */
  112075. _boundingInfo: Nullable<BoundingInfo>;
  112076. /** @hidden */
  112077. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  112078. /** @hidden */
  112079. _softwareSkinningFrameId: number;
  112080. private _vertexArrayObjects;
  112081. private _updatable;
  112082. /** @hidden */
  112083. _positions: Nullable<Vector3[]>;
  112084. private _positionsCache;
  112085. /**
  112086. * 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
  112087. */
  112088. get boundingBias(): Vector2;
  112089. /**
  112090. * 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
  112091. */
  112092. set boundingBias(value: Vector2);
  112093. /**
  112094. * Static function used to attach a new empty geometry to a mesh
  112095. * @param mesh defines the mesh to attach the geometry to
  112096. * @returns the new Geometry
  112097. */
  112098. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  112099. /** Get the list of meshes using this geometry */
  112100. get meshes(): Mesh[];
  112101. /**
  112102. * 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
  112103. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  112104. */
  112105. useBoundingInfoFromGeometry: boolean;
  112106. /**
  112107. * Creates a new geometry
  112108. * @param id defines the unique ID
  112109. * @param scene defines the hosting scene
  112110. * @param vertexData defines the VertexData used to get geometry data
  112111. * @param updatable defines if geometry must be updatable (false by default)
  112112. * @param mesh defines the mesh that will be associated with the geometry
  112113. */
  112114. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  112115. /**
  112116. * Gets the current extend of the geometry
  112117. */
  112118. get extend(): {
  112119. minimum: Vector3;
  112120. maximum: Vector3;
  112121. };
  112122. /**
  112123. * Gets the hosting scene
  112124. * @returns the hosting Scene
  112125. */
  112126. getScene(): Scene;
  112127. /**
  112128. * Gets the hosting engine
  112129. * @returns the hosting Engine
  112130. */
  112131. getEngine(): Engine;
  112132. /**
  112133. * Defines if the geometry is ready to use
  112134. * @returns true if the geometry is ready to be used
  112135. */
  112136. isReady(): boolean;
  112137. /**
  112138. * Gets a value indicating that the geometry should not be serialized
  112139. */
  112140. get doNotSerialize(): boolean;
  112141. /** @hidden */
  112142. _rebuild(): void;
  112143. /**
  112144. * Affects all geometry data in one call
  112145. * @param vertexData defines the geometry data
  112146. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  112147. */
  112148. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  112149. /**
  112150. * Set specific vertex data
  112151. * @param kind defines the data kind (Position, normal, etc...)
  112152. * @param data defines the vertex data to use
  112153. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  112154. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  112155. */
  112156. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  112157. /**
  112158. * Removes a specific vertex data
  112159. * @param kind defines the data kind (Position, normal, etc...)
  112160. */
  112161. removeVerticesData(kind: string): void;
  112162. /**
  112163. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  112164. * @param buffer defines the vertex buffer to use
  112165. * @param totalVertices defines the total number of vertices for position kind (could be null)
  112166. */
  112167. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  112168. /**
  112169. * Update a specific vertex buffer
  112170. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  112171. * It will do nothing if the buffer is not updatable
  112172. * @param kind defines the data kind (Position, normal, etc...)
  112173. * @param data defines the data to use
  112174. * @param offset defines the offset in the target buffer where to store the data
  112175. * @param useBytes set to true if the offset is in bytes
  112176. */
  112177. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  112178. /**
  112179. * Update a specific vertex buffer
  112180. * This function will create a new buffer if the current one is not updatable
  112181. * @param kind defines the data kind (Position, normal, etc...)
  112182. * @param data defines the data to use
  112183. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  112184. */
  112185. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  112186. private _updateBoundingInfo;
  112187. /** @hidden */
  112188. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  112189. /**
  112190. * Gets total number of vertices
  112191. * @returns the total number of vertices
  112192. */
  112193. getTotalVertices(): number;
  112194. /**
  112195. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  112196. * @param kind defines the data kind (Position, normal, etc...)
  112197. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  112198. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  112199. * @returns a float array containing vertex data
  112200. */
  112201. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  112202. /**
  112203. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  112204. * @param kind defines the data kind (Position, normal, etc...)
  112205. * @returns true if the vertex buffer with the specified kind is updatable
  112206. */
  112207. isVertexBufferUpdatable(kind: string): boolean;
  112208. /**
  112209. * Gets a specific vertex buffer
  112210. * @param kind defines the data kind (Position, normal, etc...)
  112211. * @returns a VertexBuffer
  112212. */
  112213. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  112214. /**
  112215. * Returns all vertex buffers
  112216. * @return an object holding all vertex buffers indexed by kind
  112217. */
  112218. getVertexBuffers(): Nullable<{
  112219. [key: string]: VertexBuffer;
  112220. }>;
  112221. /**
  112222. * Gets a boolean indicating if specific vertex buffer is present
  112223. * @param kind defines the data kind (Position, normal, etc...)
  112224. * @returns true if data is present
  112225. */
  112226. isVerticesDataPresent(kind: string): boolean;
  112227. /**
  112228. * Gets a list of all attached data kinds (Position, normal, etc...)
  112229. * @returns a list of string containing all kinds
  112230. */
  112231. getVerticesDataKinds(): string[];
  112232. /**
  112233. * Update index buffer
  112234. * @param indices defines the indices to store in the index buffer
  112235. * @param offset defines the offset in the target buffer where to store the data
  112236. * @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)
  112237. */
  112238. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  112239. /**
  112240. * Creates a new index buffer
  112241. * @param indices defines the indices to store in the index buffer
  112242. * @param totalVertices defines the total number of vertices (could be null)
  112243. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  112244. */
  112245. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  112246. /**
  112247. * Return the total number of indices
  112248. * @returns the total number of indices
  112249. */
  112250. getTotalIndices(): number;
  112251. /**
  112252. * Gets the index buffer array
  112253. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  112254. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  112255. * @returns the index buffer array
  112256. */
  112257. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  112258. /**
  112259. * Gets the index buffer
  112260. * @return the index buffer
  112261. */
  112262. getIndexBuffer(): Nullable<DataBuffer>;
  112263. /** @hidden */
  112264. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  112265. /**
  112266. * Release the associated resources for a specific mesh
  112267. * @param mesh defines the source mesh
  112268. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  112269. */
  112270. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  112271. /**
  112272. * Apply current geometry to a given mesh
  112273. * @param mesh defines the mesh to apply geometry to
  112274. */
  112275. applyToMesh(mesh: Mesh): void;
  112276. private _updateExtend;
  112277. private _applyToMesh;
  112278. private notifyUpdate;
  112279. /**
  112280. * Load the geometry if it was flagged as delay loaded
  112281. * @param scene defines the hosting scene
  112282. * @param onLoaded defines a callback called when the geometry is loaded
  112283. */
  112284. load(scene: Scene, onLoaded?: () => void): void;
  112285. private _queueLoad;
  112286. /**
  112287. * Invert the geometry to move from a right handed system to a left handed one.
  112288. */
  112289. toLeftHanded(): void;
  112290. /** @hidden */
  112291. _resetPointsArrayCache(): void;
  112292. /** @hidden */
  112293. _generatePointsArray(): boolean;
  112294. /**
  112295. * Gets a value indicating if the geometry is disposed
  112296. * @returns true if the geometry was disposed
  112297. */
  112298. isDisposed(): boolean;
  112299. private _disposeVertexArrayObjects;
  112300. /**
  112301. * Free all associated resources
  112302. */
  112303. dispose(): void;
  112304. /**
  112305. * Clone the current geometry into a new geometry
  112306. * @param id defines the unique ID of the new geometry
  112307. * @returns a new geometry object
  112308. */
  112309. copy(id: string): Geometry;
  112310. /**
  112311. * Serialize the current geometry info (and not the vertices data) into a JSON object
  112312. * @return a JSON representation of the current geometry data (without the vertices data)
  112313. */
  112314. serialize(): any;
  112315. private toNumberArray;
  112316. /**
  112317. * Serialize all vertices data into a JSON oject
  112318. * @returns a JSON representation of the current geometry data
  112319. */
  112320. serializeVerticeData(): any;
  112321. /**
  112322. * Extracts a clone of a mesh geometry
  112323. * @param mesh defines the source mesh
  112324. * @param id defines the unique ID of the new geometry object
  112325. * @returns the new geometry object
  112326. */
  112327. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  112328. /**
  112329. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  112330. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  112331. * Be aware Math.random() could cause collisions, but:
  112332. * "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"
  112333. * @returns a string containing a new GUID
  112334. */
  112335. static RandomId(): string;
  112336. /** @hidden */
  112337. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  112338. private static _CleanMatricesWeights;
  112339. /**
  112340. * Create a new geometry from persisted data (Using .babylon file format)
  112341. * @param parsedVertexData defines the persisted data
  112342. * @param scene defines the hosting scene
  112343. * @param rootUrl defines the root url to use to load assets (like delayed data)
  112344. * @returns the new geometry object
  112345. */
  112346. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  112347. }
  112348. }
  112349. declare module BABYLON {
  112350. /**
  112351. * Defines a target to use with MorphTargetManager
  112352. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112353. */
  112354. export class MorphTarget implements IAnimatable {
  112355. /** defines the name of the target */
  112356. name: string;
  112357. /**
  112358. * Gets or sets the list of animations
  112359. */
  112360. animations: Animation[];
  112361. private _scene;
  112362. private _positions;
  112363. private _normals;
  112364. private _tangents;
  112365. private _uvs;
  112366. private _influence;
  112367. private _uniqueId;
  112368. /**
  112369. * Observable raised when the influence changes
  112370. */
  112371. onInfluenceChanged: Observable<boolean>;
  112372. /** @hidden */
  112373. _onDataLayoutChanged: Observable<void>;
  112374. /**
  112375. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  112376. */
  112377. get influence(): number;
  112378. set influence(influence: number);
  112379. /**
  112380. * Gets or sets the id of the morph Target
  112381. */
  112382. id: string;
  112383. private _animationPropertiesOverride;
  112384. /**
  112385. * Gets or sets the animation properties override
  112386. */
  112387. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112388. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112389. /**
  112390. * Creates a new MorphTarget
  112391. * @param name defines the name of the target
  112392. * @param influence defines the influence to use
  112393. * @param scene defines the scene the morphtarget belongs to
  112394. */
  112395. constructor(
  112396. /** defines the name of the target */
  112397. name: string, influence?: number, scene?: Nullable<Scene>);
  112398. /**
  112399. * Gets the unique ID of this manager
  112400. */
  112401. get uniqueId(): number;
  112402. /**
  112403. * Gets a boolean defining if the target contains position data
  112404. */
  112405. get hasPositions(): boolean;
  112406. /**
  112407. * Gets a boolean defining if the target contains normal data
  112408. */
  112409. get hasNormals(): boolean;
  112410. /**
  112411. * Gets a boolean defining if the target contains tangent data
  112412. */
  112413. get hasTangents(): boolean;
  112414. /**
  112415. * Gets a boolean defining if the target contains texture coordinates data
  112416. */
  112417. get hasUVs(): boolean;
  112418. /**
  112419. * Affects position data to this target
  112420. * @param data defines the position data to use
  112421. */
  112422. setPositions(data: Nullable<FloatArray>): void;
  112423. /**
  112424. * Gets the position data stored in this target
  112425. * @returns a FloatArray containing the position data (or null if not present)
  112426. */
  112427. getPositions(): Nullable<FloatArray>;
  112428. /**
  112429. * Affects normal data to this target
  112430. * @param data defines the normal data to use
  112431. */
  112432. setNormals(data: Nullable<FloatArray>): void;
  112433. /**
  112434. * Gets the normal data stored in this target
  112435. * @returns a FloatArray containing the normal data (or null if not present)
  112436. */
  112437. getNormals(): Nullable<FloatArray>;
  112438. /**
  112439. * Affects tangent data to this target
  112440. * @param data defines the tangent data to use
  112441. */
  112442. setTangents(data: Nullable<FloatArray>): void;
  112443. /**
  112444. * Gets the tangent data stored in this target
  112445. * @returns a FloatArray containing the tangent data (or null if not present)
  112446. */
  112447. getTangents(): Nullable<FloatArray>;
  112448. /**
  112449. * Affects texture coordinates data to this target
  112450. * @param data defines the texture coordinates data to use
  112451. */
  112452. setUVs(data: Nullable<FloatArray>): void;
  112453. /**
  112454. * Gets the texture coordinates data stored in this target
  112455. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  112456. */
  112457. getUVs(): Nullable<FloatArray>;
  112458. /**
  112459. * Clone the current target
  112460. * @returns a new MorphTarget
  112461. */
  112462. clone(): MorphTarget;
  112463. /**
  112464. * Serializes the current target into a Serialization object
  112465. * @returns the serialized object
  112466. */
  112467. serialize(): any;
  112468. /**
  112469. * Returns the string "MorphTarget"
  112470. * @returns "MorphTarget"
  112471. */
  112472. getClassName(): string;
  112473. /**
  112474. * Creates a new target from serialized data
  112475. * @param serializationObject defines the serialized data to use
  112476. * @returns a new MorphTarget
  112477. */
  112478. static Parse(serializationObject: any): MorphTarget;
  112479. /**
  112480. * Creates a MorphTarget from mesh data
  112481. * @param mesh defines the source mesh
  112482. * @param name defines the name to use for the new target
  112483. * @param influence defines the influence to attach to the target
  112484. * @returns a new MorphTarget
  112485. */
  112486. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  112487. }
  112488. }
  112489. declare module BABYLON {
  112490. /**
  112491. * This class is used to deform meshes using morphing between different targets
  112492. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112493. */
  112494. export class MorphTargetManager {
  112495. private _targets;
  112496. private _targetInfluenceChangedObservers;
  112497. private _targetDataLayoutChangedObservers;
  112498. private _activeTargets;
  112499. private _scene;
  112500. private _influences;
  112501. private _supportsNormals;
  112502. private _supportsTangents;
  112503. private _supportsUVs;
  112504. private _vertexCount;
  112505. private _uniqueId;
  112506. private _tempInfluences;
  112507. /**
  112508. * Gets or sets a boolean indicating if normals must be morphed
  112509. */
  112510. enableNormalMorphing: boolean;
  112511. /**
  112512. * Gets or sets a boolean indicating if tangents must be morphed
  112513. */
  112514. enableTangentMorphing: boolean;
  112515. /**
  112516. * Gets or sets a boolean indicating if UV must be morphed
  112517. */
  112518. enableUVMorphing: boolean;
  112519. /**
  112520. * Creates a new MorphTargetManager
  112521. * @param scene defines the current scene
  112522. */
  112523. constructor(scene?: Nullable<Scene>);
  112524. /**
  112525. * Gets the unique ID of this manager
  112526. */
  112527. get uniqueId(): number;
  112528. /**
  112529. * Gets the number of vertices handled by this manager
  112530. */
  112531. get vertexCount(): number;
  112532. /**
  112533. * Gets a boolean indicating if this manager supports morphing of normals
  112534. */
  112535. get supportsNormals(): boolean;
  112536. /**
  112537. * Gets a boolean indicating if this manager supports morphing of tangents
  112538. */
  112539. get supportsTangents(): boolean;
  112540. /**
  112541. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  112542. */
  112543. get supportsUVs(): boolean;
  112544. /**
  112545. * Gets the number of targets stored in this manager
  112546. */
  112547. get numTargets(): number;
  112548. /**
  112549. * Gets the number of influencers (ie. the number of targets with influences > 0)
  112550. */
  112551. get numInfluencers(): number;
  112552. /**
  112553. * Gets the list of influences (one per target)
  112554. */
  112555. get influences(): Float32Array;
  112556. /**
  112557. * Gets the active target at specified index. An active target is a target with an influence > 0
  112558. * @param index defines the index to check
  112559. * @returns the requested target
  112560. */
  112561. getActiveTarget(index: number): MorphTarget;
  112562. /**
  112563. * Gets the target at specified index
  112564. * @param index defines the index to check
  112565. * @returns the requested target
  112566. */
  112567. getTarget(index: number): MorphTarget;
  112568. /**
  112569. * Add a new target to this manager
  112570. * @param target defines the target to add
  112571. */
  112572. addTarget(target: MorphTarget): void;
  112573. /**
  112574. * Removes a target from the manager
  112575. * @param target defines the target to remove
  112576. */
  112577. removeTarget(target: MorphTarget): void;
  112578. /**
  112579. * Clone the current manager
  112580. * @returns a new MorphTargetManager
  112581. */
  112582. clone(): MorphTargetManager;
  112583. /**
  112584. * Serializes the current manager into a Serialization object
  112585. * @returns the serialized object
  112586. */
  112587. serialize(): any;
  112588. private _syncActiveTargets;
  112589. /**
  112590. * Syncrhonize the targets with all the meshes using this morph target manager
  112591. */
  112592. synchronize(): void;
  112593. /**
  112594. * Creates a new MorphTargetManager from serialized data
  112595. * @param serializationObject defines the serialized data
  112596. * @param scene defines the hosting scene
  112597. * @returns the new MorphTargetManager
  112598. */
  112599. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  112600. }
  112601. }
  112602. declare module BABYLON {
  112603. /**
  112604. * Class used to represent a specific level of detail of a mesh
  112605. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  112606. */
  112607. export class MeshLODLevel {
  112608. /** Defines the distance where this level should start being displayed */
  112609. distance: number;
  112610. /** Defines the mesh to use to render this level */
  112611. mesh: Nullable<Mesh>;
  112612. /**
  112613. * Creates a new LOD level
  112614. * @param distance defines the distance where this level should star being displayed
  112615. * @param mesh defines the mesh to use to render this level
  112616. */
  112617. constructor(
  112618. /** Defines the distance where this level should start being displayed */
  112619. distance: number,
  112620. /** Defines the mesh to use to render this level */
  112621. mesh: Nullable<Mesh>);
  112622. }
  112623. }
  112624. declare module BABYLON {
  112625. /**
  112626. * Helper class used to generate a canvas to manipulate images
  112627. */
  112628. export class CanvasGenerator {
  112629. /**
  112630. * Create a new canvas (or offscreen canvas depending on the context)
  112631. * @param width defines the expected width
  112632. * @param height defines the expected height
  112633. * @return a new canvas or offscreen canvas
  112634. */
  112635. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  112636. }
  112637. }
  112638. declare module BABYLON {
  112639. /**
  112640. * Mesh representing the gorund
  112641. */
  112642. export class GroundMesh extends Mesh {
  112643. /** If octree should be generated */
  112644. generateOctree: boolean;
  112645. private _heightQuads;
  112646. /** @hidden */
  112647. _subdivisionsX: number;
  112648. /** @hidden */
  112649. _subdivisionsY: number;
  112650. /** @hidden */
  112651. _width: number;
  112652. /** @hidden */
  112653. _height: number;
  112654. /** @hidden */
  112655. _minX: number;
  112656. /** @hidden */
  112657. _maxX: number;
  112658. /** @hidden */
  112659. _minZ: number;
  112660. /** @hidden */
  112661. _maxZ: number;
  112662. constructor(name: string, scene: Scene);
  112663. /**
  112664. * "GroundMesh"
  112665. * @returns "GroundMesh"
  112666. */
  112667. getClassName(): string;
  112668. /**
  112669. * The minimum of x and y subdivisions
  112670. */
  112671. get subdivisions(): number;
  112672. /**
  112673. * X subdivisions
  112674. */
  112675. get subdivisionsX(): number;
  112676. /**
  112677. * Y subdivisions
  112678. */
  112679. get subdivisionsY(): number;
  112680. /**
  112681. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112682. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112683. * @param chunksCount the number of subdivisions for x and y
  112684. * @param octreeBlocksSize (Default: 32)
  112685. */
  112686. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112687. /**
  112688. * Returns a height (y) value in the Worl system :
  112689. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112690. * @param x x coordinate
  112691. * @param z z coordinate
  112692. * @returns the ground y position if (x, z) are outside the ground surface.
  112693. */
  112694. getHeightAtCoordinates(x: number, z: number): number;
  112695. /**
  112696. * Returns a normalized vector (Vector3) orthogonal to the ground
  112697. * at the ground coordinates (x, z) expressed in the World system.
  112698. * @param x x coordinate
  112699. * @param z z coordinate
  112700. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112701. */
  112702. getNormalAtCoordinates(x: number, z: number): Vector3;
  112703. /**
  112704. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112705. * at the ground coordinates (x, z) expressed in the World system.
  112706. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112707. * @param x x coordinate
  112708. * @param z z coordinate
  112709. * @param ref vector to store the result
  112710. * @returns the GroundMesh.
  112711. */
  112712. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112713. /**
  112714. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112715. * if the ground has been updated.
  112716. * This can be used in the render loop.
  112717. * @returns the GroundMesh.
  112718. */
  112719. updateCoordinateHeights(): GroundMesh;
  112720. private _getFacetAt;
  112721. private _initHeightQuads;
  112722. private _computeHeightQuads;
  112723. /**
  112724. * Serializes this ground mesh
  112725. * @param serializationObject object to write serialization to
  112726. */
  112727. serialize(serializationObject: any): void;
  112728. /**
  112729. * Parses a serialized ground mesh
  112730. * @param parsedMesh the serialized mesh
  112731. * @param scene the scene to create the ground mesh in
  112732. * @returns the created ground mesh
  112733. */
  112734. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112735. }
  112736. }
  112737. declare module BABYLON {
  112738. /**
  112739. * Interface for Physics-Joint data
  112740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112741. */
  112742. export interface PhysicsJointData {
  112743. /**
  112744. * The main pivot of the joint
  112745. */
  112746. mainPivot?: Vector3;
  112747. /**
  112748. * The connected pivot of the joint
  112749. */
  112750. connectedPivot?: Vector3;
  112751. /**
  112752. * The main axis of the joint
  112753. */
  112754. mainAxis?: Vector3;
  112755. /**
  112756. * The connected axis of the joint
  112757. */
  112758. connectedAxis?: Vector3;
  112759. /**
  112760. * The collision of the joint
  112761. */
  112762. collision?: boolean;
  112763. /**
  112764. * Native Oimo/Cannon/Energy data
  112765. */
  112766. nativeParams?: any;
  112767. }
  112768. /**
  112769. * This is a holder class for the physics joint created by the physics plugin
  112770. * It holds a set of functions to control the underlying joint
  112771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112772. */
  112773. export class PhysicsJoint {
  112774. /**
  112775. * The type of the physics joint
  112776. */
  112777. type: number;
  112778. /**
  112779. * The data for the physics joint
  112780. */
  112781. jointData: PhysicsJointData;
  112782. private _physicsJoint;
  112783. protected _physicsPlugin: IPhysicsEnginePlugin;
  112784. /**
  112785. * Initializes the physics joint
  112786. * @param type The type of the physics joint
  112787. * @param jointData The data for the physics joint
  112788. */
  112789. constructor(
  112790. /**
  112791. * The type of the physics joint
  112792. */
  112793. type: number,
  112794. /**
  112795. * The data for the physics joint
  112796. */
  112797. jointData: PhysicsJointData);
  112798. /**
  112799. * Gets the physics joint
  112800. */
  112801. get physicsJoint(): any;
  112802. /**
  112803. * Sets the physics joint
  112804. */
  112805. set physicsJoint(newJoint: any);
  112806. /**
  112807. * Sets the physics plugin
  112808. */
  112809. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112810. /**
  112811. * Execute a function that is physics-plugin specific.
  112812. * @param {Function} func the function that will be executed.
  112813. * It accepts two parameters: the physics world and the physics joint
  112814. */
  112815. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112816. /**
  112817. * Distance-Joint type
  112818. */
  112819. static DistanceJoint: number;
  112820. /**
  112821. * Hinge-Joint type
  112822. */
  112823. static HingeJoint: number;
  112824. /**
  112825. * Ball-and-Socket joint type
  112826. */
  112827. static BallAndSocketJoint: number;
  112828. /**
  112829. * Wheel-Joint type
  112830. */
  112831. static WheelJoint: number;
  112832. /**
  112833. * Slider-Joint type
  112834. */
  112835. static SliderJoint: number;
  112836. /**
  112837. * Prismatic-Joint type
  112838. */
  112839. static PrismaticJoint: number;
  112840. /**
  112841. * Universal-Joint type
  112842. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112843. */
  112844. static UniversalJoint: number;
  112845. /**
  112846. * Hinge-Joint 2 type
  112847. */
  112848. static Hinge2Joint: number;
  112849. /**
  112850. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112851. */
  112852. static PointToPointJoint: number;
  112853. /**
  112854. * Spring-Joint type
  112855. */
  112856. static SpringJoint: number;
  112857. /**
  112858. * Lock-Joint type
  112859. */
  112860. static LockJoint: number;
  112861. }
  112862. /**
  112863. * A class representing a physics distance joint
  112864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112865. */
  112866. export class DistanceJoint extends PhysicsJoint {
  112867. /**
  112868. *
  112869. * @param jointData The data for the Distance-Joint
  112870. */
  112871. constructor(jointData: DistanceJointData);
  112872. /**
  112873. * Update the predefined distance.
  112874. * @param maxDistance The maximum preferred distance
  112875. * @param minDistance The minimum preferred distance
  112876. */
  112877. updateDistance(maxDistance: number, minDistance?: number): void;
  112878. }
  112879. /**
  112880. * Represents a Motor-Enabled Joint
  112881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112882. */
  112883. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112884. /**
  112885. * Initializes the Motor-Enabled Joint
  112886. * @param type The type of the joint
  112887. * @param jointData The physica joint data for the joint
  112888. */
  112889. constructor(type: number, jointData: PhysicsJointData);
  112890. /**
  112891. * Set the motor values.
  112892. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112893. * @param force the force to apply
  112894. * @param maxForce max force for this motor.
  112895. */
  112896. setMotor(force?: number, maxForce?: number): void;
  112897. /**
  112898. * Set the motor's limits.
  112899. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112900. * @param upperLimit The upper limit of the motor
  112901. * @param lowerLimit The lower limit of the motor
  112902. */
  112903. setLimit(upperLimit: number, lowerLimit?: number): void;
  112904. }
  112905. /**
  112906. * This class represents a single physics Hinge-Joint
  112907. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112908. */
  112909. export class HingeJoint extends MotorEnabledJoint {
  112910. /**
  112911. * Initializes the Hinge-Joint
  112912. * @param jointData The joint data for the Hinge-Joint
  112913. */
  112914. constructor(jointData: PhysicsJointData);
  112915. /**
  112916. * Set the motor values.
  112917. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112918. * @param {number} force the force to apply
  112919. * @param {number} maxForce max force for this motor.
  112920. */
  112921. setMotor(force?: number, maxForce?: number): void;
  112922. /**
  112923. * Set the motor's limits.
  112924. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112925. * @param upperLimit The upper limit of the motor
  112926. * @param lowerLimit The lower limit of the motor
  112927. */
  112928. setLimit(upperLimit: number, lowerLimit?: number): void;
  112929. }
  112930. /**
  112931. * This class represents a dual hinge physics joint (same as wheel joint)
  112932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112933. */
  112934. export class Hinge2Joint extends MotorEnabledJoint {
  112935. /**
  112936. * Initializes the Hinge2-Joint
  112937. * @param jointData The joint data for the Hinge2-Joint
  112938. */
  112939. constructor(jointData: PhysicsJointData);
  112940. /**
  112941. * Set the motor values.
  112942. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112943. * @param {number} targetSpeed the speed the motor is to reach
  112944. * @param {number} maxForce max force for this motor.
  112945. * @param {motorIndex} the motor's index, 0 or 1.
  112946. */
  112947. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112948. /**
  112949. * Set the motor limits.
  112950. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112951. * @param {number} upperLimit the upper limit
  112952. * @param {number} lowerLimit lower limit
  112953. * @param {motorIndex} the motor's index, 0 or 1.
  112954. */
  112955. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112956. }
  112957. /**
  112958. * Interface for a motor enabled joint
  112959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112960. */
  112961. export interface IMotorEnabledJoint {
  112962. /**
  112963. * Physics joint
  112964. */
  112965. physicsJoint: any;
  112966. /**
  112967. * Sets the motor of the motor-enabled joint
  112968. * @param force The force of the motor
  112969. * @param maxForce The maximum force of the motor
  112970. * @param motorIndex The index of the motor
  112971. */
  112972. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112973. /**
  112974. * Sets the limit of the motor
  112975. * @param upperLimit The upper limit of the motor
  112976. * @param lowerLimit The lower limit of the motor
  112977. * @param motorIndex The index of the motor
  112978. */
  112979. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112980. }
  112981. /**
  112982. * Joint data for a Distance-Joint
  112983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112984. */
  112985. export interface DistanceJointData extends PhysicsJointData {
  112986. /**
  112987. * Max distance the 2 joint objects can be apart
  112988. */
  112989. maxDistance: number;
  112990. }
  112991. /**
  112992. * Joint data from a spring joint
  112993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112994. */
  112995. export interface SpringJointData extends PhysicsJointData {
  112996. /**
  112997. * Length of the spring
  112998. */
  112999. length: number;
  113000. /**
  113001. * Stiffness of the spring
  113002. */
  113003. stiffness: number;
  113004. /**
  113005. * Damping of the spring
  113006. */
  113007. damping: number;
  113008. /** this callback will be called when applying the force to the impostors. */
  113009. forceApplicationCallback: () => void;
  113010. }
  113011. }
  113012. declare module BABYLON {
  113013. /**
  113014. * Holds the data for the raycast result
  113015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113016. */
  113017. export class PhysicsRaycastResult {
  113018. private _hasHit;
  113019. private _hitDistance;
  113020. private _hitNormalWorld;
  113021. private _hitPointWorld;
  113022. private _rayFromWorld;
  113023. private _rayToWorld;
  113024. /**
  113025. * Gets if there was a hit
  113026. */
  113027. get hasHit(): boolean;
  113028. /**
  113029. * Gets the distance from the hit
  113030. */
  113031. get hitDistance(): number;
  113032. /**
  113033. * Gets the hit normal/direction in the world
  113034. */
  113035. get hitNormalWorld(): Vector3;
  113036. /**
  113037. * Gets the hit point in the world
  113038. */
  113039. get hitPointWorld(): Vector3;
  113040. /**
  113041. * Gets the ray "start point" of the ray in the world
  113042. */
  113043. get rayFromWorld(): Vector3;
  113044. /**
  113045. * Gets the ray "end point" of the ray in the world
  113046. */
  113047. get rayToWorld(): Vector3;
  113048. /**
  113049. * Sets the hit data (normal & point in world space)
  113050. * @param hitNormalWorld defines the normal in world space
  113051. * @param hitPointWorld defines the point in world space
  113052. */
  113053. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  113054. /**
  113055. * Sets the distance from the start point to the hit point
  113056. * @param distance
  113057. */
  113058. setHitDistance(distance: number): void;
  113059. /**
  113060. * Calculates the distance manually
  113061. */
  113062. calculateHitDistance(): void;
  113063. /**
  113064. * Resets all the values to default
  113065. * @param from The from point on world space
  113066. * @param to The to point on world space
  113067. */
  113068. reset(from?: Vector3, to?: Vector3): void;
  113069. }
  113070. /**
  113071. * Interface for the size containing width and height
  113072. */
  113073. interface IXYZ {
  113074. /**
  113075. * X
  113076. */
  113077. x: number;
  113078. /**
  113079. * Y
  113080. */
  113081. y: number;
  113082. /**
  113083. * Z
  113084. */
  113085. z: number;
  113086. }
  113087. }
  113088. declare module BABYLON {
  113089. /**
  113090. * Interface used to describe a physics joint
  113091. */
  113092. export interface PhysicsImpostorJoint {
  113093. /** Defines the main impostor to which the joint is linked */
  113094. mainImpostor: PhysicsImpostor;
  113095. /** Defines the impostor that is connected to the main impostor using this joint */
  113096. connectedImpostor: PhysicsImpostor;
  113097. /** Defines the joint itself */
  113098. joint: PhysicsJoint;
  113099. }
  113100. /** @hidden */
  113101. export interface IPhysicsEnginePlugin {
  113102. world: any;
  113103. name: string;
  113104. setGravity(gravity: Vector3): void;
  113105. setTimeStep(timeStep: number): void;
  113106. getTimeStep(): number;
  113107. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113108. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113109. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113110. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113111. removePhysicsBody(impostor: PhysicsImpostor): void;
  113112. generateJoint(joint: PhysicsImpostorJoint): void;
  113113. removeJoint(joint: PhysicsImpostorJoint): void;
  113114. isSupported(): boolean;
  113115. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113116. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113117. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113118. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113119. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113120. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113121. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113122. getBodyMass(impostor: PhysicsImpostor): number;
  113123. getBodyFriction(impostor: PhysicsImpostor): number;
  113124. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113125. getBodyRestitution(impostor: PhysicsImpostor): number;
  113126. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113127. getBodyPressure?(impostor: PhysicsImpostor): number;
  113128. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  113129. getBodyStiffness?(impostor: PhysicsImpostor): number;
  113130. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  113131. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  113132. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  113133. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  113134. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  113135. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113136. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113137. sleepBody(impostor: PhysicsImpostor): void;
  113138. wakeUpBody(impostor: PhysicsImpostor): void;
  113139. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113140. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113141. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  113142. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113143. getRadius(impostor: PhysicsImpostor): number;
  113144. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113145. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113146. dispose(): void;
  113147. }
  113148. /**
  113149. * Interface used to define a physics engine
  113150. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113151. */
  113152. export interface IPhysicsEngine {
  113153. /**
  113154. * Gets the gravity vector used by the simulation
  113155. */
  113156. gravity: Vector3;
  113157. /**
  113158. * Sets the gravity vector used by the simulation
  113159. * @param gravity defines the gravity vector to use
  113160. */
  113161. setGravity(gravity: Vector3): void;
  113162. /**
  113163. * Set the time step of the physics engine.
  113164. * Default is 1/60.
  113165. * To slow it down, enter 1/600 for example.
  113166. * To speed it up, 1/30
  113167. * @param newTimeStep the new timestep to apply to this world.
  113168. */
  113169. setTimeStep(newTimeStep: number): void;
  113170. /**
  113171. * Get the time step of the physics engine.
  113172. * @returns the current time step
  113173. */
  113174. getTimeStep(): number;
  113175. /**
  113176. * Set the sub time step of the physics engine.
  113177. * Default is 0 meaning there is no sub steps
  113178. * To increase physics resolution precision, set a small value (like 1 ms)
  113179. * @param subTimeStep defines the new sub timestep used for physics resolution.
  113180. */
  113181. setSubTimeStep(subTimeStep: number): void;
  113182. /**
  113183. * Get the sub time step of the physics engine.
  113184. * @returns the current sub time step
  113185. */
  113186. getSubTimeStep(): number;
  113187. /**
  113188. * Release all resources
  113189. */
  113190. dispose(): void;
  113191. /**
  113192. * Gets the name of the current physics plugin
  113193. * @returns the name of the plugin
  113194. */
  113195. getPhysicsPluginName(): string;
  113196. /**
  113197. * Adding a new impostor for the impostor tracking.
  113198. * This will be done by the impostor itself.
  113199. * @param impostor the impostor to add
  113200. */
  113201. addImpostor(impostor: PhysicsImpostor): void;
  113202. /**
  113203. * Remove an impostor from the engine.
  113204. * This impostor and its mesh will not longer be updated by the physics engine.
  113205. * @param impostor the impostor to remove
  113206. */
  113207. removeImpostor(impostor: PhysicsImpostor): void;
  113208. /**
  113209. * Add a joint to the physics engine
  113210. * @param mainImpostor defines the main impostor to which the joint is added.
  113211. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113212. * @param joint defines the joint that will connect both impostors.
  113213. */
  113214. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113215. /**
  113216. * Removes a joint from the simulation
  113217. * @param mainImpostor defines the impostor used with the joint
  113218. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113219. * @param joint defines the joint to remove
  113220. */
  113221. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113222. /**
  113223. * Gets the current plugin used to run the simulation
  113224. * @returns current plugin
  113225. */
  113226. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113227. /**
  113228. * Gets the list of physic impostors
  113229. * @returns an array of PhysicsImpostor
  113230. */
  113231. getImpostors(): Array<PhysicsImpostor>;
  113232. /**
  113233. * Gets the impostor for a physics enabled object
  113234. * @param object defines the object impersonated by the impostor
  113235. * @returns the PhysicsImpostor or null if not found
  113236. */
  113237. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113238. /**
  113239. * Gets the impostor for a physics body object
  113240. * @param body defines physics body used by the impostor
  113241. * @returns the PhysicsImpostor or null if not found
  113242. */
  113243. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113244. /**
  113245. * Does a raycast in the physics world
  113246. * @param from when should the ray start?
  113247. * @param to when should the ray end?
  113248. * @returns PhysicsRaycastResult
  113249. */
  113250. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113251. /**
  113252. * Called by the scene. No need to call it.
  113253. * @param delta defines the timespam between frames
  113254. */
  113255. _step(delta: number): void;
  113256. }
  113257. }
  113258. declare module BABYLON {
  113259. /**
  113260. * The interface for the physics imposter parameters
  113261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113262. */
  113263. export interface PhysicsImpostorParameters {
  113264. /**
  113265. * The mass of the physics imposter
  113266. */
  113267. mass: number;
  113268. /**
  113269. * The friction of the physics imposter
  113270. */
  113271. friction?: number;
  113272. /**
  113273. * The coefficient of restitution of the physics imposter
  113274. */
  113275. restitution?: number;
  113276. /**
  113277. * The native options of the physics imposter
  113278. */
  113279. nativeOptions?: any;
  113280. /**
  113281. * Specifies if the parent should be ignored
  113282. */
  113283. ignoreParent?: boolean;
  113284. /**
  113285. * Specifies if bi-directional transformations should be disabled
  113286. */
  113287. disableBidirectionalTransformation?: boolean;
  113288. /**
  113289. * The pressure inside the physics imposter, soft object only
  113290. */
  113291. pressure?: number;
  113292. /**
  113293. * The stiffness the physics imposter, soft object only
  113294. */
  113295. stiffness?: number;
  113296. /**
  113297. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  113298. */
  113299. velocityIterations?: number;
  113300. /**
  113301. * The number of iterations used in maintaining consistent vertex positions, soft object only
  113302. */
  113303. positionIterations?: number;
  113304. /**
  113305. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  113306. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  113307. * Add to fix multiple points
  113308. */
  113309. fixedPoints?: number;
  113310. /**
  113311. * The collision margin around a soft object
  113312. */
  113313. margin?: number;
  113314. /**
  113315. * The collision margin around a soft object
  113316. */
  113317. damping?: number;
  113318. /**
  113319. * The path for a rope based on an extrusion
  113320. */
  113321. path?: any;
  113322. /**
  113323. * The shape of an extrusion used for a rope based on an extrusion
  113324. */
  113325. shape?: any;
  113326. }
  113327. /**
  113328. * Interface for a physics-enabled object
  113329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113330. */
  113331. export interface IPhysicsEnabledObject {
  113332. /**
  113333. * The position of the physics-enabled object
  113334. */
  113335. position: Vector3;
  113336. /**
  113337. * The rotation of the physics-enabled object
  113338. */
  113339. rotationQuaternion: Nullable<Quaternion>;
  113340. /**
  113341. * The scale of the physics-enabled object
  113342. */
  113343. scaling: Vector3;
  113344. /**
  113345. * The rotation of the physics-enabled object
  113346. */
  113347. rotation?: Vector3;
  113348. /**
  113349. * The parent of the physics-enabled object
  113350. */
  113351. parent?: any;
  113352. /**
  113353. * The bounding info of the physics-enabled object
  113354. * @returns The bounding info of the physics-enabled object
  113355. */
  113356. getBoundingInfo(): BoundingInfo;
  113357. /**
  113358. * Computes the world matrix
  113359. * @param force Specifies if the world matrix should be computed by force
  113360. * @returns A world matrix
  113361. */
  113362. computeWorldMatrix(force: boolean): Matrix;
  113363. /**
  113364. * Gets the world matrix
  113365. * @returns A world matrix
  113366. */
  113367. getWorldMatrix?(): Matrix;
  113368. /**
  113369. * Gets the child meshes
  113370. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  113371. * @returns An array of abstract meshes
  113372. */
  113373. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  113374. /**
  113375. * Gets the vertex data
  113376. * @param kind The type of vertex data
  113377. * @returns A nullable array of numbers, or a float32 array
  113378. */
  113379. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  113380. /**
  113381. * Gets the indices from the mesh
  113382. * @returns A nullable array of index arrays
  113383. */
  113384. getIndices?(): Nullable<IndicesArray>;
  113385. /**
  113386. * Gets the scene from the mesh
  113387. * @returns the indices array or null
  113388. */
  113389. getScene?(): Scene;
  113390. /**
  113391. * Gets the absolute position from the mesh
  113392. * @returns the absolute position
  113393. */
  113394. getAbsolutePosition(): Vector3;
  113395. /**
  113396. * Gets the absolute pivot point from the mesh
  113397. * @returns the absolute pivot point
  113398. */
  113399. getAbsolutePivotPoint(): Vector3;
  113400. /**
  113401. * Rotates the mesh
  113402. * @param axis The axis of rotation
  113403. * @param amount The amount of rotation
  113404. * @param space The space of the rotation
  113405. * @returns The rotation transform node
  113406. */
  113407. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  113408. /**
  113409. * Translates the mesh
  113410. * @param axis The axis of translation
  113411. * @param distance The distance of translation
  113412. * @param space The space of the translation
  113413. * @returns The transform node
  113414. */
  113415. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  113416. /**
  113417. * Sets the absolute position of the mesh
  113418. * @param absolutePosition The absolute position of the mesh
  113419. * @returns The transform node
  113420. */
  113421. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  113422. /**
  113423. * Gets the class name of the mesh
  113424. * @returns The class name
  113425. */
  113426. getClassName(): string;
  113427. }
  113428. /**
  113429. * Represents a physics imposter
  113430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113431. */
  113432. export class PhysicsImpostor {
  113433. /**
  113434. * The physics-enabled object used as the physics imposter
  113435. */
  113436. object: IPhysicsEnabledObject;
  113437. /**
  113438. * The type of the physics imposter
  113439. */
  113440. type: number;
  113441. private _options;
  113442. private _scene?;
  113443. /**
  113444. * The default object size of the imposter
  113445. */
  113446. static DEFAULT_OBJECT_SIZE: Vector3;
  113447. /**
  113448. * The identity quaternion of the imposter
  113449. */
  113450. static IDENTITY_QUATERNION: Quaternion;
  113451. /** @hidden */
  113452. _pluginData: any;
  113453. private _physicsEngine;
  113454. private _physicsBody;
  113455. private _bodyUpdateRequired;
  113456. private _onBeforePhysicsStepCallbacks;
  113457. private _onAfterPhysicsStepCallbacks;
  113458. /** @hidden */
  113459. _onPhysicsCollideCallbacks: Array<{
  113460. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  113461. otherImpostors: Array<PhysicsImpostor>;
  113462. }>;
  113463. private _deltaPosition;
  113464. private _deltaRotation;
  113465. private _deltaRotationConjugated;
  113466. /** @hidden */
  113467. _isFromLine: boolean;
  113468. private _parent;
  113469. private _isDisposed;
  113470. private static _tmpVecs;
  113471. private static _tmpQuat;
  113472. /**
  113473. * Specifies if the physics imposter is disposed
  113474. */
  113475. get isDisposed(): boolean;
  113476. /**
  113477. * Gets the mass of the physics imposter
  113478. */
  113479. get mass(): number;
  113480. set mass(value: number);
  113481. /**
  113482. * Gets the coefficient of friction
  113483. */
  113484. get friction(): number;
  113485. /**
  113486. * Sets the coefficient of friction
  113487. */
  113488. set friction(value: number);
  113489. /**
  113490. * Gets the coefficient of restitution
  113491. */
  113492. get restitution(): number;
  113493. /**
  113494. * Sets the coefficient of restitution
  113495. */
  113496. set restitution(value: number);
  113497. /**
  113498. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  113499. */
  113500. get pressure(): number;
  113501. /**
  113502. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  113503. */
  113504. set pressure(value: number);
  113505. /**
  113506. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113507. */
  113508. get stiffness(): number;
  113509. /**
  113510. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113511. */
  113512. set stiffness(value: number);
  113513. /**
  113514. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113515. */
  113516. get velocityIterations(): number;
  113517. /**
  113518. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113519. */
  113520. set velocityIterations(value: number);
  113521. /**
  113522. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113523. */
  113524. get positionIterations(): number;
  113525. /**
  113526. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113527. */
  113528. set positionIterations(value: number);
  113529. /**
  113530. * The unique id of the physics imposter
  113531. * set by the physics engine when adding this impostor to the array
  113532. */
  113533. uniqueId: number;
  113534. /**
  113535. * @hidden
  113536. */
  113537. soft: boolean;
  113538. /**
  113539. * @hidden
  113540. */
  113541. segments: number;
  113542. private _joints;
  113543. /**
  113544. * Initializes the physics imposter
  113545. * @param object The physics-enabled object used as the physics imposter
  113546. * @param type The type of the physics imposter
  113547. * @param _options The options for the physics imposter
  113548. * @param _scene The Babylon scene
  113549. */
  113550. constructor(
  113551. /**
  113552. * The physics-enabled object used as the physics imposter
  113553. */
  113554. object: IPhysicsEnabledObject,
  113555. /**
  113556. * The type of the physics imposter
  113557. */
  113558. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  113559. /**
  113560. * This function will completly initialize this impostor.
  113561. * It will create a new body - but only if this mesh has no parent.
  113562. * If it has, this impostor will not be used other than to define the impostor
  113563. * of the child mesh.
  113564. * @hidden
  113565. */
  113566. _init(): void;
  113567. private _getPhysicsParent;
  113568. /**
  113569. * Should a new body be generated.
  113570. * @returns boolean specifying if body initialization is required
  113571. */
  113572. isBodyInitRequired(): boolean;
  113573. /**
  113574. * Sets the updated scaling
  113575. * @param updated Specifies if the scaling is updated
  113576. */
  113577. setScalingUpdated(): void;
  113578. /**
  113579. * Force a regeneration of this or the parent's impostor's body.
  113580. * Use under cautious - This will remove all joints already implemented.
  113581. */
  113582. forceUpdate(): void;
  113583. /**
  113584. * Gets the body that holds this impostor. Either its own, or its parent.
  113585. */
  113586. get physicsBody(): any;
  113587. /**
  113588. * Get the parent of the physics imposter
  113589. * @returns Physics imposter or null
  113590. */
  113591. get parent(): Nullable<PhysicsImpostor>;
  113592. /**
  113593. * Sets the parent of the physics imposter
  113594. */
  113595. set parent(value: Nullable<PhysicsImpostor>);
  113596. /**
  113597. * Set the physics body. Used mainly by the physics engine/plugin
  113598. */
  113599. set physicsBody(physicsBody: any);
  113600. /**
  113601. * Resets the update flags
  113602. */
  113603. resetUpdateFlags(): void;
  113604. /**
  113605. * Gets the object extend size
  113606. * @returns the object extend size
  113607. */
  113608. getObjectExtendSize(): Vector3;
  113609. /**
  113610. * Gets the object center
  113611. * @returns The object center
  113612. */
  113613. getObjectCenter(): Vector3;
  113614. /**
  113615. * Get a specific parameter from the options parameters
  113616. * @param paramName The object parameter name
  113617. * @returns The object parameter
  113618. */
  113619. getParam(paramName: string): any;
  113620. /**
  113621. * Sets a specific parameter in the options given to the physics plugin
  113622. * @param paramName The parameter name
  113623. * @param value The value of the parameter
  113624. */
  113625. setParam(paramName: string, value: number): void;
  113626. /**
  113627. * Specifically change the body's mass option. Won't recreate the physics body object
  113628. * @param mass The mass of the physics imposter
  113629. */
  113630. setMass(mass: number): void;
  113631. /**
  113632. * Gets the linear velocity
  113633. * @returns linear velocity or null
  113634. */
  113635. getLinearVelocity(): Nullable<Vector3>;
  113636. /**
  113637. * Sets the linear velocity
  113638. * @param velocity linear velocity or null
  113639. */
  113640. setLinearVelocity(velocity: Nullable<Vector3>): void;
  113641. /**
  113642. * Gets the angular velocity
  113643. * @returns angular velocity or null
  113644. */
  113645. getAngularVelocity(): Nullable<Vector3>;
  113646. /**
  113647. * Sets the angular velocity
  113648. * @param velocity The velocity or null
  113649. */
  113650. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113651. /**
  113652. * Execute a function with the physics plugin native code
  113653. * Provide a function the will have two variables - the world object and the physics body object
  113654. * @param func The function to execute with the physics plugin native code
  113655. */
  113656. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113657. /**
  113658. * Register a function that will be executed before the physics world is stepping forward
  113659. * @param func The function to execute before the physics world is stepped forward
  113660. */
  113661. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113662. /**
  113663. * Unregister a function that will be executed before the physics world is stepping forward
  113664. * @param func The function to execute before the physics world is stepped forward
  113665. */
  113666. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113667. /**
  113668. * Register a function that will be executed after the physics step
  113669. * @param func The function to execute after physics step
  113670. */
  113671. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113672. /**
  113673. * Unregisters a function that will be executed after the physics step
  113674. * @param func The function to execute after physics step
  113675. */
  113676. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113677. /**
  113678. * register a function that will be executed when this impostor collides against a different body
  113679. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113680. * @param func Callback that is executed on collision
  113681. */
  113682. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113683. /**
  113684. * Unregisters the physics imposter on contact
  113685. * @param collideAgainst The physics object to collide against
  113686. * @param func Callback to execute on collision
  113687. */
  113688. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113689. private _tmpQuat;
  113690. private _tmpQuat2;
  113691. /**
  113692. * Get the parent rotation
  113693. * @returns The parent rotation
  113694. */
  113695. getParentsRotation(): Quaternion;
  113696. /**
  113697. * this function is executed by the physics engine.
  113698. */
  113699. beforeStep: () => void;
  113700. /**
  113701. * this function is executed by the physics engine
  113702. */
  113703. afterStep: () => void;
  113704. /**
  113705. * Legacy collision detection event support
  113706. */
  113707. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113708. /**
  113709. * event and body object due to cannon's event-based architecture.
  113710. */
  113711. onCollide: (e: {
  113712. body: any;
  113713. point: Nullable<Vector3>;
  113714. }) => void;
  113715. /**
  113716. * Apply a force
  113717. * @param force The force to apply
  113718. * @param contactPoint The contact point for the force
  113719. * @returns The physics imposter
  113720. */
  113721. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113722. /**
  113723. * Apply an impulse
  113724. * @param force The impulse force
  113725. * @param contactPoint The contact point for the impulse force
  113726. * @returns The physics imposter
  113727. */
  113728. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113729. /**
  113730. * A help function to create a joint
  113731. * @param otherImpostor A physics imposter used to create a joint
  113732. * @param jointType The type of joint
  113733. * @param jointData The data for the joint
  113734. * @returns The physics imposter
  113735. */
  113736. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113737. /**
  113738. * Add a joint to this impostor with a different impostor
  113739. * @param otherImpostor A physics imposter used to add a joint
  113740. * @param joint The joint to add
  113741. * @returns The physics imposter
  113742. */
  113743. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113744. /**
  113745. * Add an anchor to a cloth impostor
  113746. * @param otherImpostor rigid impostor to anchor to
  113747. * @param width ratio across width from 0 to 1
  113748. * @param height ratio up height from 0 to 1
  113749. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113750. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113751. * @returns impostor the soft imposter
  113752. */
  113753. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113754. /**
  113755. * Add a hook to a rope impostor
  113756. * @param otherImpostor rigid impostor to anchor to
  113757. * @param length ratio across rope from 0 to 1
  113758. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113759. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113760. * @returns impostor the rope imposter
  113761. */
  113762. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113763. /**
  113764. * Will keep this body still, in a sleep mode.
  113765. * @returns the physics imposter
  113766. */
  113767. sleep(): PhysicsImpostor;
  113768. /**
  113769. * Wake the body up.
  113770. * @returns The physics imposter
  113771. */
  113772. wakeUp(): PhysicsImpostor;
  113773. /**
  113774. * Clones the physics imposter
  113775. * @param newObject The physics imposter clones to this physics-enabled object
  113776. * @returns A nullable physics imposter
  113777. */
  113778. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113779. /**
  113780. * Disposes the physics imposter
  113781. */
  113782. dispose(): void;
  113783. /**
  113784. * Sets the delta position
  113785. * @param position The delta position amount
  113786. */
  113787. setDeltaPosition(position: Vector3): void;
  113788. /**
  113789. * Sets the delta rotation
  113790. * @param rotation The delta rotation amount
  113791. */
  113792. setDeltaRotation(rotation: Quaternion): void;
  113793. /**
  113794. * Gets the box size of the physics imposter and stores the result in the input parameter
  113795. * @param result Stores the box size
  113796. * @returns The physics imposter
  113797. */
  113798. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113799. /**
  113800. * Gets the radius of the physics imposter
  113801. * @returns Radius of the physics imposter
  113802. */
  113803. getRadius(): number;
  113804. /**
  113805. * Sync a bone with this impostor
  113806. * @param bone The bone to sync to the impostor.
  113807. * @param boneMesh The mesh that the bone is influencing.
  113808. * @param jointPivot The pivot of the joint / bone in local space.
  113809. * @param distToJoint Optional distance from the impostor to the joint.
  113810. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113811. */
  113812. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113813. /**
  113814. * Sync impostor to a bone
  113815. * @param bone The bone that the impostor will be synced to.
  113816. * @param boneMesh The mesh that the bone is influencing.
  113817. * @param jointPivot The pivot of the joint / bone in local space.
  113818. * @param distToJoint Optional distance from the impostor to the joint.
  113819. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113820. * @param boneAxis Optional vector3 axis the bone is aligned with
  113821. */
  113822. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113823. /**
  113824. * No-Imposter type
  113825. */
  113826. static NoImpostor: number;
  113827. /**
  113828. * Sphere-Imposter type
  113829. */
  113830. static SphereImpostor: number;
  113831. /**
  113832. * Box-Imposter type
  113833. */
  113834. static BoxImpostor: number;
  113835. /**
  113836. * Plane-Imposter type
  113837. */
  113838. static PlaneImpostor: number;
  113839. /**
  113840. * Mesh-imposter type
  113841. */
  113842. static MeshImpostor: number;
  113843. /**
  113844. * Capsule-Impostor type (Ammo.js plugin only)
  113845. */
  113846. static CapsuleImpostor: number;
  113847. /**
  113848. * Cylinder-Imposter type
  113849. */
  113850. static CylinderImpostor: number;
  113851. /**
  113852. * Particle-Imposter type
  113853. */
  113854. static ParticleImpostor: number;
  113855. /**
  113856. * Heightmap-Imposter type
  113857. */
  113858. static HeightmapImpostor: number;
  113859. /**
  113860. * ConvexHull-Impostor type (Ammo.js plugin only)
  113861. */
  113862. static ConvexHullImpostor: number;
  113863. /**
  113864. * Custom-Imposter type (Ammo.js plugin only)
  113865. */
  113866. static CustomImpostor: number;
  113867. /**
  113868. * Rope-Imposter type
  113869. */
  113870. static RopeImpostor: number;
  113871. /**
  113872. * Cloth-Imposter type
  113873. */
  113874. static ClothImpostor: number;
  113875. /**
  113876. * Softbody-Imposter type
  113877. */
  113878. static SoftbodyImpostor: number;
  113879. }
  113880. }
  113881. declare module BABYLON {
  113882. /**
  113883. * @hidden
  113884. **/
  113885. export class _CreationDataStorage {
  113886. closePath?: boolean;
  113887. closeArray?: boolean;
  113888. idx: number[];
  113889. dashSize: number;
  113890. gapSize: number;
  113891. path3D: Path3D;
  113892. pathArray: Vector3[][];
  113893. arc: number;
  113894. radius: number;
  113895. cap: number;
  113896. tessellation: number;
  113897. }
  113898. /**
  113899. * @hidden
  113900. **/
  113901. class _InstanceDataStorage {
  113902. visibleInstances: any;
  113903. batchCache: _InstancesBatch;
  113904. instancesBufferSize: number;
  113905. instancesBuffer: Nullable<Buffer>;
  113906. instancesData: Float32Array;
  113907. overridenInstanceCount: number;
  113908. isFrozen: boolean;
  113909. previousBatch: Nullable<_InstancesBatch>;
  113910. hardwareInstancedRendering: boolean;
  113911. sideOrientation: number;
  113912. manualUpdate: boolean;
  113913. previousRenderId: number;
  113914. }
  113915. /**
  113916. * @hidden
  113917. **/
  113918. export class _InstancesBatch {
  113919. mustReturn: boolean;
  113920. visibleInstances: Nullable<InstancedMesh[]>[];
  113921. renderSelf: boolean[];
  113922. hardwareInstancedRendering: boolean[];
  113923. }
  113924. /**
  113925. * @hidden
  113926. **/
  113927. class _ThinInstanceDataStorage {
  113928. instancesCount: number;
  113929. matrixBuffer: Nullable<Buffer>;
  113930. matrixBufferSize: number;
  113931. matrixData: Nullable<Float32Array>;
  113932. boundingVectors: Array<Vector3>;
  113933. worldMatrices: Nullable<Matrix[]>;
  113934. }
  113935. /**
  113936. * Class used to represent renderable models
  113937. */
  113938. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113939. /**
  113940. * Mesh side orientation : usually the external or front surface
  113941. */
  113942. static readonly FRONTSIDE: number;
  113943. /**
  113944. * Mesh side orientation : usually the internal or back surface
  113945. */
  113946. static readonly BACKSIDE: number;
  113947. /**
  113948. * Mesh side orientation : both internal and external or front and back surfaces
  113949. */
  113950. static readonly DOUBLESIDE: number;
  113951. /**
  113952. * Mesh side orientation : by default, `FRONTSIDE`
  113953. */
  113954. static readonly DEFAULTSIDE: number;
  113955. /**
  113956. * Mesh cap setting : no cap
  113957. */
  113958. static readonly NO_CAP: number;
  113959. /**
  113960. * Mesh cap setting : one cap at the beginning of the mesh
  113961. */
  113962. static readonly CAP_START: number;
  113963. /**
  113964. * Mesh cap setting : one cap at the end of the mesh
  113965. */
  113966. static readonly CAP_END: number;
  113967. /**
  113968. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113969. */
  113970. static readonly CAP_ALL: number;
  113971. /**
  113972. * Mesh pattern setting : no flip or rotate
  113973. */
  113974. static readonly NO_FLIP: number;
  113975. /**
  113976. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113977. */
  113978. static readonly FLIP_TILE: number;
  113979. /**
  113980. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113981. */
  113982. static readonly ROTATE_TILE: number;
  113983. /**
  113984. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113985. */
  113986. static readonly FLIP_ROW: number;
  113987. /**
  113988. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113989. */
  113990. static readonly ROTATE_ROW: number;
  113991. /**
  113992. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113993. */
  113994. static readonly FLIP_N_ROTATE_TILE: number;
  113995. /**
  113996. * Mesh pattern setting : rotate pattern and rotate
  113997. */
  113998. static readonly FLIP_N_ROTATE_ROW: number;
  113999. /**
  114000. * Mesh tile positioning : part tiles same on left/right or top/bottom
  114001. */
  114002. static readonly CENTER: number;
  114003. /**
  114004. * Mesh tile positioning : part tiles on left
  114005. */
  114006. static readonly LEFT: number;
  114007. /**
  114008. * Mesh tile positioning : part tiles on right
  114009. */
  114010. static readonly RIGHT: number;
  114011. /**
  114012. * Mesh tile positioning : part tiles on top
  114013. */
  114014. static readonly TOP: number;
  114015. /**
  114016. * Mesh tile positioning : part tiles on bottom
  114017. */
  114018. static readonly BOTTOM: number;
  114019. /**
  114020. * Gets the default side orientation.
  114021. * @param orientation the orientation to value to attempt to get
  114022. * @returns the default orientation
  114023. * @hidden
  114024. */
  114025. static _GetDefaultSideOrientation(orientation?: number): number;
  114026. private _internalMeshDataInfo;
  114027. get computeBonesUsingShaders(): boolean;
  114028. set computeBonesUsingShaders(value: boolean);
  114029. /**
  114030. * An event triggered before rendering the mesh
  114031. */
  114032. get onBeforeRenderObservable(): Observable<Mesh>;
  114033. /**
  114034. * An event triggered before binding the mesh
  114035. */
  114036. get onBeforeBindObservable(): Observable<Mesh>;
  114037. /**
  114038. * An event triggered after rendering the mesh
  114039. */
  114040. get onAfterRenderObservable(): Observable<Mesh>;
  114041. /**
  114042. * An event triggered before drawing the mesh
  114043. */
  114044. get onBeforeDrawObservable(): Observable<Mesh>;
  114045. private _onBeforeDrawObserver;
  114046. /**
  114047. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  114048. */
  114049. set onBeforeDraw(callback: () => void);
  114050. get hasInstances(): boolean;
  114051. get hasThinInstances(): boolean;
  114052. /**
  114053. * Gets the delay loading state of the mesh (when delay loading is turned on)
  114054. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  114055. */
  114056. delayLoadState: number;
  114057. /**
  114058. * Gets the list of instances created from this mesh
  114059. * it is not supposed to be modified manually.
  114060. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  114061. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114062. */
  114063. instances: InstancedMesh[];
  114064. /**
  114065. * Gets the file containing delay loading data for this mesh
  114066. */
  114067. delayLoadingFile: string;
  114068. /** @hidden */
  114069. _binaryInfo: any;
  114070. /**
  114071. * User defined function used to change how LOD level selection is done
  114072. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114073. */
  114074. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  114075. /**
  114076. * Gets or sets the morph target manager
  114077. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  114078. */
  114079. get morphTargetManager(): Nullable<MorphTargetManager>;
  114080. set morphTargetManager(value: Nullable<MorphTargetManager>);
  114081. /** @hidden */
  114082. _creationDataStorage: Nullable<_CreationDataStorage>;
  114083. /** @hidden */
  114084. _geometry: Nullable<Geometry>;
  114085. /** @hidden */
  114086. _delayInfo: Array<string>;
  114087. /** @hidden */
  114088. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  114089. /** @hidden */
  114090. _instanceDataStorage: _InstanceDataStorage;
  114091. /** @hidden */
  114092. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  114093. private _effectiveMaterial;
  114094. /** @hidden */
  114095. _shouldGenerateFlatShading: boolean;
  114096. /** @hidden */
  114097. _originalBuilderSideOrientation: number;
  114098. /**
  114099. * Use this property to change the original side orientation defined at construction time
  114100. */
  114101. overrideMaterialSideOrientation: Nullable<number>;
  114102. /**
  114103. * Gets the source mesh (the one used to clone this one from)
  114104. */
  114105. get source(): Nullable<Mesh>;
  114106. /**
  114107. * Gets the list of clones of this mesh
  114108. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  114109. * Note that useClonedMeshMap=true is the default setting
  114110. */
  114111. get cloneMeshMap(): Nullable<{
  114112. [id: string]: Mesh | undefined;
  114113. }>;
  114114. /**
  114115. * Gets or sets a boolean indicating that this mesh does not use index buffer
  114116. */
  114117. get isUnIndexed(): boolean;
  114118. set isUnIndexed(value: boolean);
  114119. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  114120. get worldMatrixInstancedBuffer(): Float32Array;
  114121. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  114122. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  114123. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  114124. /**
  114125. * @constructor
  114126. * @param name The value used by scene.getMeshByName() to do a lookup.
  114127. * @param scene The scene to add this mesh to.
  114128. * @param parent The parent of this mesh, if it has one
  114129. * @param source An optional Mesh from which geometry is shared, cloned.
  114130. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  114131. * When false, achieved by calling a clone(), also passing False.
  114132. * This will make creation of children, recursive.
  114133. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  114134. */
  114135. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  114136. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  114137. doNotInstantiate: boolean;
  114138. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  114139. /**
  114140. * Gets the class name
  114141. * @returns the string "Mesh".
  114142. */
  114143. getClassName(): string;
  114144. /** @hidden */
  114145. get _isMesh(): boolean;
  114146. /**
  114147. * Returns a description of this mesh
  114148. * @param fullDetails define if full details about this mesh must be used
  114149. * @returns a descriptive string representing this mesh
  114150. */
  114151. toString(fullDetails?: boolean): string;
  114152. /** @hidden */
  114153. _unBindEffect(): void;
  114154. /**
  114155. * Gets a boolean indicating if this mesh has LOD
  114156. */
  114157. get hasLODLevels(): boolean;
  114158. /**
  114159. * Gets the list of MeshLODLevel associated with the current mesh
  114160. * @returns an array of MeshLODLevel
  114161. */
  114162. getLODLevels(): MeshLODLevel[];
  114163. private _sortLODLevels;
  114164. /**
  114165. * Add a mesh as LOD level triggered at the given distance.
  114166. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114167. * @param distance The distance from the center of the object to show this level
  114168. * @param mesh The mesh to be added as LOD level (can be null)
  114169. * @return This mesh (for chaining)
  114170. */
  114171. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  114172. /**
  114173. * Returns the LOD level mesh at the passed distance or null if not found.
  114174. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114175. * @param distance The distance from the center of the object to show this level
  114176. * @returns a Mesh or `null`
  114177. */
  114178. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  114179. /**
  114180. * Remove a mesh from the LOD array
  114181. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114182. * @param mesh defines the mesh to be removed
  114183. * @return This mesh (for chaining)
  114184. */
  114185. removeLODLevel(mesh: Mesh): Mesh;
  114186. /**
  114187. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  114188. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114189. * @param camera defines the camera to use to compute distance
  114190. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  114191. * @return This mesh (for chaining)
  114192. */
  114193. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  114194. /**
  114195. * Gets the mesh internal Geometry object
  114196. */
  114197. get geometry(): Nullable<Geometry>;
  114198. /**
  114199. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  114200. * @returns the total number of vertices
  114201. */
  114202. getTotalVertices(): number;
  114203. /**
  114204. * Returns the content of an associated vertex buffer
  114205. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114206. * - VertexBuffer.PositionKind
  114207. * - VertexBuffer.UVKind
  114208. * - VertexBuffer.UV2Kind
  114209. * - VertexBuffer.UV3Kind
  114210. * - VertexBuffer.UV4Kind
  114211. * - VertexBuffer.UV5Kind
  114212. * - VertexBuffer.UV6Kind
  114213. * - VertexBuffer.ColorKind
  114214. * - VertexBuffer.MatricesIndicesKind
  114215. * - VertexBuffer.MatricesIndicesExtraKind
  114216. * - VertexBuffer.MatricesWeightsKind
  114217. * - VertexBuffer.MatricesWeightsExtraKind
  114218. * @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
  114219. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  114220. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  114221. */
  114222. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114223. /**
  114224. * Returns the mesh VertexBuffer object from the requested `kind`
  114225. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114226. * - VertexBuffer.PositionKind
  114227. * - VertexBuffer.NormalKind
  114228. * - VertexBuffer.UVKind
  114229. * - VertexBuffer.UV2Kind
  114230. * - VertexBuffer.UV3Kind
  114231. * - VertexBuffer.UV4Kind
  114232. * - VertexBuffer.UV5Kind
  114233. * - VertexBuffer.UV6Kind
  114234. * - VertexBuffer.ColorKind
  114235. * - VertexBuffer.MatricesIndicesKind
  114236. * - VertexBuffer.MatricesIndicesExtraKind
  114237. * - VertexBuffer.MatricesWeightsKind
  114238. * - VertexBuffer.MatricesWeightsExtraKind
  114239. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  114240. */
  114241. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  114242. /**
  114243. * Tests if a specific vertex buffer is associated with this mesh
  114244. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114245. * - VertexBuffer.PositionKind
  114246. * - VertexBuffer.NormalKind
  114247. * - VertexBuffer.UVKind
  114248. * - VertexBuffer.UV2Kind
  114249. * - VertexBuffer.UV3Kind
  114250. * - VertexBuffer.UV4Kind
  114251. * - VertexBuffer.UV5Kind
  114252. * - VertexBuffer.UV6Kind
  114253. * - VertexBuffer.ColorKind
  114254. * - VertexBuffer.MatricesIndicesKind
  114255. * - VertexBuffer.MatricesIndicesExtraKind
  114256. * - VertexBuffer.MatricesWeightsKind
  114257. * - VertexBuffer.MatricesWeightsExtraKind
  114258. * @returns a boolean
  114259. */
  114260. isVerticesDataPresent(kind: string): boolean;
  114261. /**
  114262. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  114263. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114264. * - VertexBuffer.PositionKind
  114265. * - VertexBuffer.UVKind
  114266. * - VertexBuffer.UV2Kind
  114267. * - VertexBuffer.UV3Kind
  114268. * - VertexBuffer.UV4Kind
  114269. * - VertexBuffer.UV5Kind
  114270. * - VertexBuffer.UV6Kind
  114271. * - VertexBuffer.ColorKind
  114272. * - VertexBuffer.MatricesIndicesKind
  114273. * - VertexBuffer.MatricesIndicesExtraKind
  114274. * - VertexBuffer.MatricesWeightsKind
  114275. * - VertexBuffer.MatricesWeightsExtraKind
  114276. * @returns a boolean
  114277. */
  114278. isVertexBufferUpdatable(kind: string): boolean;
  114279. /**
  114280. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  114281. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114282. * - VertexBuffer.PositionKind
  114283. * - VertexBuffer.NormalKind
  114284. * - VertexBuffer.UVKind
  114285. * - VertexBuffer.UV2Kind
  114286. * - VertexBuffer.UV3Kind
  114287. * - VertexBuffer.UV4Kind
  114288. * - VertexBuffer.UV5Kind
  114289. * - VertexBuffer.UV6Kind
  114290. * - VertexBuffer.ColorKind
  114291. * - VertexBuffer.MatricesIndicesKind
  114292. * - VertexBuffer.MatricesIndicesExtraKind
  114293. * - VertexBuffer.MatricesWeightsKind
  114294. * - VertexBuffer.MatricesWeightsExtraKind
  114295. * @returns an array of strings
  114296. */
  114297. getVerticesDataKinds(): string[];
  114298. /**
  114299. * Returns a positive integer : the total number of indices in this mesh geometry.
  114300. * @returns the numner of indices or zero if the mesh has no geometry.
  114301. */
  114302. getTotalIndices(): number;
  114303. /**
  114304. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114305. * @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.
  114306. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114307. * @returns the indices array or an empty array if the mesh has no geometry
  114308. */
  114309. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114310. get isBlocked(): boolean;
  114311. /**
  114312. * Determine if the current mesh is ready to be rendered
  114313. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  114314. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  114315. * @returns true if all associated assets are ready (material, textures, shaders)
  114316. */
  114317. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  114318. /**
  114319. * 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.
  114320. */
  114321. get areNormalsFrozen(): boolean;
  114322. /**
  114323. * 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.
  114324. * @returns the current mesh
  114325. */
  114326. freezeNormals(): Mesh;
  114327. /**
  114328. * 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
  114329. * @returns the current mesh
  114330. */
  114331. unfreezeNormals(): Mesh;
  114332. /**
  114333. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  114334. */
  114335. set overridenInstanceCount(count: number);
  114336. /** @hidden */
  114337. _preActivate(): Mesh;
  114338. /** @hidden */
  114339. _preActivateForIntermediateRendering(renderId: number): Mesh;
  114340. /** @hidden */
  114341. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  114342. protected _afterComputeWorldMatrix(): void;
  114343. /** @hidden */
  114344. _postActivate(): void;
  114345. /**
  114346. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114347. * This means the mesh underlying bounding box and sphere are recomputed.
  114348. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114349. * @returns the current mesh
  114350. */
  114351. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  114352. /** @hidden */
  114353. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  114354. /**
  114355. * This function will subdivide the mesh into multiple submeshes
  114356. * @param count defines the expected number of submeshes
  114357. */
  114358. subdivide(count: number): void;
  114359. /**
  114360. * Copy a FloatArray into a specific associated vertex buffer
  114361. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114362. * - VertexBuffer.PositionKind
  114363. * - VertexBuffer.UVKind
  114364. * - VertexBuffer.UV2Kind
  114365. * - VertexBuffer.UV3Kind
  114366. * - VertexBuffer.UV4Kind
  114367. * - VertexBuffer.UV5Kind
  114368. * - VertexBuffer.UV6Kind
  114369. * - VertexBuffer.ColorKind
  114370. * - VertexBuffer.MatricesIndicesKind
  114371. * - VertexBuffer.MatricesIndicesExtraKind
  114372. * - VertexBuffer.MatricesWeightsKind
  114373. * - VertexBuffer.MatricesWeightsExtraKind
  114374. * @param data defines the data source
  114375. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114376. * @param stride defines the data stride size (can be null)
  114377. * @returns the current mesh
  114378. */
  114379. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114380. /**
  114381. * Delete a vertex buffer associated with this mesh
  114382. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  114383. * - VertexBuffer.PositionKind
  114384. * - VertexBuffer.UVKind
  114385. * - VertexBuffer.UV2Kind
  114386. * - VertexBuffer.UV3Kind
  114387. * - VertexBuffer.UV4Kind
  114388. * - VertexBuffer.UV5Kind
  114389. * - VertexBuffer.UV6Kind
  114390. * - VertexBuffer.ColorKind
  114391. * - VertexBuffer.MatricesIndicesKind
  114392. * - VertexBuffer.MatricesIndicesExtraKind
  114393. * - VertexBuffer.MatricesWeightsKind
  114394. * - VertexBuffer.MatricesWeightsExtraKind
  114395. */
  114396. removeVerticesData(kind: string): void;
  114397. /**
  114398. * Flags an associated vertex buffer as updatable
  114399. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  114400. * - VertexBuffer.PositionKind
  114401. * - VertexBuffer.UVKind
  114402. * - VertexBuffer.UV2Kind
  114403. * - VertexBuffer.UV3Kind
  114404. * - VertexBuffer.UV4Kind
  114405. * - VertexBuffer.UV5Kind
  114406. * - VertexBuffer.UV6Kind
  114407. * - VertexBuffer.ColorKind
  114408. * - VertexBuffer.MatricesIndicesKind
  114409. * - VertexBuffer.MatricesIndicesExtraKind
  114410. * - VertexBuffer.MatricesWeightsKind
  114411. * - VertexBuffer.MatricesWeightsExtraKind
  114412. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114413. */
  114414. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  114415. /**
  114416. * Sets the mesh global Vertex Buffer
  114417. * @param buffer defines the buffer to use
  114418. * @returns the current mesh
  114419. */
  114420. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  114421. /**
  114422. * Update a specific associated vertex buffer
  114423. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114424. * - VertexBuffer.PositionKind
  114425. * - VertexBuffer.UVKind
  114426. * - VertexBuffer.UV2Kind
  114427. * - VertexBuffer.UV3Kind
  114428. * - VertexBuffer.UV4Kind
  114429. * - VertexBuffer.UV5Kind
  114430. * - VertexBuffer.UV6Kind
  114431. * - VertexBuffer.ColorKind
  114432. * - VertexBuffer.MatricesIndicesKind
  114433. * - VertexBuffer.MatricesIndicesExtraKind
  114434. * - VertexBuffer.MatricesWeightsKind
  114435. * - VertexBuffer.MatricesWeightsExtraKind
  114436. * @param data defines the data source
  114437. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114438. * @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)
  114439. * @returns the current mesh
  114440. */
  114441. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  114442. /**
  114443. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  114444. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  114445. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  114446. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  114447. * @returns the current mesh
  114448. */
  114449. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  114450. /**
  114451. * Creates a un-shared specific occurence of the geometry for the mesh.
  114452. * @returns the current mesh
  114453. */
  114454. makeGeometryUnique(): Mesh;
  114455. /**
  114456. * Set the index buffer of this mesh
  114457. * @param indices defines the source data
  114458. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  114459. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  114460. * @returns the current mesh
  114461. */
  114462. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  114463. /**
  114464. * Update the current index buffer
  114465. * @param indices defines the source data
  114466. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  114467. * @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)
  114468. * @returns the current mesh
  114469. */
  114470. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  114471. /**
  114472. * Invert the geometry to move from a right handed system to a left handed one.
  114473. * @returns the current mesh
  114474. */
  114475. toLeftHanded(): Mesh;
  114476. /** @hidden */
  114477. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114478. /** @hidden */
  114479. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114480. /**
  114481. * Registers for this mesh a javascript function called just before the rendering process
  114482. * @param func defines the function to call before rendering this mesh
  114483. * @returns the current mesh
  114484. */
  114485. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114486. /**
  114487. * Disposes a previously registered javascript function called before the rendering
  114488. * @param func defines the function to remove
  114489. * @returns the current mesh
  114490. */
  114491. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114492. /**
  114493. * Registers for this mesh a javascript function called just after the rendering is complete
  114494. * @param func defines the function to call after rendering this mesh
  114495. * @returns the current mesh
  114496. */
  114497. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114498. /**
  114499. * Disposes a previously registered javascript function called after the rendering.
  114500. * @param func defines the function to remove
  114501. * @returns the current mesh
  114502. */
  114503. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114504. /** @hidden */
  114505. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  114506. /** @hidden */
  114507. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  114508. /** @hidden */
  114509. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  114510. /** @hidden */
  114511. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  114512. /** @hidden */
  114513. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  114514. /** @hidden */
  114515. _rebuild(): void;
  114516. /** @hidden */
  114517. _freeze(): void;
  114518. /** @hidden */
  114519. _unFreeze(): void;
  114520. /**
  114521. * 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
  114522. * @param subMesh defines the subMesh to render
  114523. * @param enableAlphaMode defines if alpha mode can be changed
  114524. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  114525. * @returns the current mesh
  114526. */
  114527. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  114528. private _onBeforeDraw;
  114529. /**
  114530. * Renormalize the mesh and patch it up if there are no weights
  114531. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  114532. * However in the case of zero weights then we set just a single influence to 1.
  114533. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  114534. */
  114535. cleanMatrixWeights(): void;
  114536. private normalizeSkinFourWeights;
  114537. private normalizeSkinWeightsAndExtra;
  114538. /**
  114539. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  114540. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  114541. * the user know there was an issue with importing the mesh
  114542. * @returns a validation object with skinned, valid and report string
  114543. */
  114544. validateSkinning(): {
  114545. skinned: boolean;
  114546. valid: boolean;
  114547. report: string;
  114548. };
  114549. /** @hidden */
  114550. _checkDelayState(): Mesh;
  114551. private _queueLoad;
  114552. /**
  114553. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  114554. * A mesh is in the frustum if its bounding box intersects the frustum
  114555. * @param frustumPlanes defines the frustum to test
  114556. * @returns true if the mesh is in the frustum planes
  114557. */
  114558. isInFrustum(frustumPlanes: Plane[]): boolean;
  114559. /**
  114560. * Sets the mesh material by the material or multiMaterial `id` property
  114561. * @param id is a string identifying the material or the multiMaterial
  114562. * @returns the current mesh
  114563. */
  114564. setMaterialByID(id: string): Mesh;
  114565. /**
  114566. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  114567. * @returns an array of IAnimatable
  114568. */
  114569. getAnimatables(): IAnimatable[];
  114570. /**
  114571. * Modifies the mesh geometry according to the passed transformation matrix.
  114572. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  114573. * The mesh normals are modified using the same transformation.
  114574. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114575. * @param transform defines the transform matrix to use
  114576. * @see https://doc.babylonjs.com/resources/baking_transformations
  114577. * @returns the current mesh
  114578. */
  114579. bakeTransformIntoVertices(transform: Matrix): Mesh;
  114580. /**
  114581. * Modifies the mesh geometry according to its own current World Matrix.
  114582. * The mesh World Matrix is then reset.
  114583. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  114584. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114585. * @see https://doc.babylonjs.com/resources/baking_transformations
  114586. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  114587. * @returns the current mesh
  114588. */
  114589. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  114590. /** @hidden */
  114591. get _positions(): Nullable<Vector3[]>;
  114592. /** @hidden */
  114593. _resetPointsArrayCache(): Mesh;
  114594. /** @hidden */
  114595. _generatePointsArray(): boolean;
  114596. /**
  114597. * Returns a new Mesh object generated from the current mesh properties.
  114598. * This method must not get confused with createInstance()
  114599. * @param name is a string, the name given to the new mesh
  114600. * @param newParent can be any Node object (default `null`)
  114601. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  114602. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  114603. * @returns a new mesh
  114604. */
  114605. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  114606. /**
  114607. * Releases resources associated with this mesh.
  114608. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114609. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114610. */
  114611. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114612. /** @hidden */
  114613. _disposeInstanceSpecificData(): void;
  114614. /** @hidden */
  114615. _disposeThinInstanceSpecificData(): void;
  114616. /**
  114617. * Modifies the mesh geometry according to a displacement map.
  114618. * 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.
  114619. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114620. * @param url is a string, the URL from the image file is to be downloaded.
  114621. * @param minHeight is the lower limit of the displacement.
  114622. * @param maxHeight is the upper limit of the displacement.
  114623. * @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.
  114624. * @param uvOffset is an optional vector2 used to offset UV.
  114625. * @param uvScale is an optional vector2 used to scale UV.
  114626. * @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.
  114627. * @returns the Mesh.
  114628. */
  114629. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114630. /**
  114631. * Modifies the mesh geometry according to a displacementMap buffer.
  114632. * 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.
  114633. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114634. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  114635. * @param heightMapWidth is the width of the buffer image.
  114636. * @param heightMapHeight is the height of the buffer image.
  114637. * @param minHeight is the lower limit of the displacement.
  114638. * @param maxHeight is the upper limit of the displacement.
  114639. * @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.
  114640. * @param uvOffset is an optional vector2 used to offset UV.
  114641. * @param uvScale is an optional vector2 used to scale UV.
  114642. * @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.
  114643. * @returns the Mesh.
  114644. */
  114645. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114646. /**
  114647. * Modify the mesh to get a flat shading rendering.
  114648. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  114649. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114650. * @returns current mesh
  114651. */
  114652. convertToFlatShadedMesh(): Mesh;
  114653. /**
  114654. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114655. * In other words, more vertices, no more indices and a single bigger VBO.
  114656. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114657. * @returns current mesh
  114658. */
  114659. convertToUnIndexedMesh(): Mesh;
  114660. /**
  114661. * Inverses facet orientations.
  114662. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114663. * @param flipNormals will also inverts the normals
  114664. * @returns current mesh
  114665. */
  114666. flipFaces(flipNormals?: boolean): Mesh;
  114667. /**
  114668. * Increase the number of facets and hence vertices in a mesh
  114669. * Vertex normals are interpolated from existing vertex normals
  114670. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114671. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114672. */
  114673. increaseVertices(numberPerEdge: number): void;
  114674. /**
  114675. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114676. * This will undo any application of covertToFlatShadedMesh
  114677. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114678. */
  114679. forceSharedVertices(): void;
  114680. /** @hidden */
  114681. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114682. /** @hidden */
  114683. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114684. /**
  114685. * Creates a new InstancedMesh object from the mesh model.
  114686. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114687. * @param name defines the name of the new instance
  114688. * @returns a new InstancedMesh
  114689. */
  114690. createInstance(name: string): InstancedMesh;
  114691. /**
  114692. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114693. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114694. * @returns the current mesh
  114695. */
  114696. synchronizeInstances(): Mesh;
  114697. /**
  114698. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114699. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114700. * This should be used together with the simplification to avoid disappearing triangles.
  114701. * @param successCallback an optional success callback to be called after the optimization finished.
  114702. * @returns the current mesh
  114703. */
  114704. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114705. /**
  114706. * Serialize current mesh
  114707. * @param serializationObject defines the object which will receive the serialization data
  114708. */
  114709. serialize(serializationObject: any): void;
  114710. /** @hidden */
  114711. _syncGeometryWithMorphTargetManager(): void;
  114712. /** @hidden */
  114713. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114714. /**
  114715. * Returns a new Mesh object parsed from the source provided.
  114716. * @param parsedMesh is the source
  114717. * @param scene defines the hosting scene
  114718. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114719. * @returns a new Mesh
  114720. */
  114721. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114722. /**
  114723. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114725. * @param name defines the name of the mesh to create
  114726. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114727. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114728. * @param closePath creates a seam between the first and the last points of each path of the path array
  114729. * @param offset is taken in account only if the `pathArray` is containing a single path
  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 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)
  114734. * @returns a new Mesh
  114735. */
  114736. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114737. /**
  114738. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114739. * @param name defines the name of the mesh to create
  114740. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114741. * @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
  114742. * @param scene defines the hosting scene
  114743. * @param updatable defines if the mesh must be flagged as updatable
  114744. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114745. * @returns a new Mesh
  114746. */
  114747. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114748. /**
  114749. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114750. * @param name defines the name of the mesh to create
  114751. * @param size sets the size (float) of each box side (default 1)
  114752. * @param scene defines the hosting scene
  114753. * @param updatable defines if the mesh must be flagged as updatable
  114754. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114755. * @returns a new Mesh
  114756. */
  114757. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114758. /**
  114759. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114760. * @param name defines the name of the mesh to create
  114761. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114762. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114763. * @param scene defines the hosting scene
  114764. * @param updatable defines if the mesh must be flagged as updatable
  114765. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114766. * @returns a new Mesh
  114767. */
  114768. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114769. /**
  114770. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114771. * @param name defines the name of the mesh to create
  114772. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114773. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114774. * @param scene defines the hosting scene
  114775. * @returns a new Mesh
  114776. */
  114777. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114778. /**
  114779. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114780. * @param name defines the name of the mesh to create
  114781. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114782. * @param diameterTop set the top cap diameter (floats, default 1)
  114783. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114784. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114785. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114786. * @param scene defines the hosting scene
  114787. * @param updatable defines if the mesh must be flagged as updatable
  114788. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114789. * @returns a new Mesh
  114790. */
  114791. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114792. /**
  114793. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114794. * @param name defines the name of the mesh to create
  114795. * @param diameter sets the diameter size (float) of the torus (default 1)
  114796. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114797. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114798. * @param scene defines the hosting scene
  114799. * @param updatable defines if the mesh must be flagged as updatable
  114800. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114801. * @returns a new Mesh
  114802. */
  114803. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114804. /**
  114805. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114806. * @param name defines the name of the mesh to create
  114807. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114808. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114809. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114810. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114811. * @param p the number of windings on X axis (positive integers, default 2)
  114812. * @param q the number of windings on Y axis (positive integers, default 3)
  114813. * @param scene defines the hosting scene
  114814. * @param updatable defines if the mesh must be flagged as updatable
  114815. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114816. * @returns a new Mesh
  114817. */
  114818. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114819. /**
  114820. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114821. * @param name defines the name of the mesh to create
  114822. * @param points is an array successive Vector3
  114823. * @param scene defines the hosting scene
  114824. * @param updatable defines if the mesh must be flagged as updatable
  114825. * @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).
  114826. * @returns a new Mesh
  114827. */
  114828. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114829. /**
  114830. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114831. * @param name defines the name of the mesh to create
  114832. * @param points is an array successive Vector3
  114833. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114834. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114835. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114836. * @param scene defines the hosting scene
  114837. * @param updatable defines if the mesh must be flagged as updatable
  114838. * @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)
  114839. * @returns a new Mesh
  114840. */
  114841. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114842. /**
  114843. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114844. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114845. * 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.
  114846. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114847. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114848. * Remember you can only change the shape positions, not their number when updating a polygon.
  114849. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114850. * @param name defines the name of the mesh to create
  114851. * @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
  114852. * @param scene defines the hosting scene
  114853. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114854. * @param updatable defines if the mesh must be flagged as updatable
  114855. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114856. * @param earcutInjection can be used to inject your own earcut reference
  114857. * @returns a new Mesh
  114858. */
  114859. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114860. /**
  114861. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114862. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114863. * @param name defines the name of the mesh to create
  114864. * @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
  114865. * @param depth defines the height of extrusion
  114866. * @param scene defines the hosting scene
  114867. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114868. * @param updatable defines if the mesh must be flagged as updatable
  114869. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114870. * @param earcutInjection can be used to inject your own earcut reference
  114871. * @returns a new Mesh
  114872. */
  114873. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114874. /**
  114875. * Creates an extruded shape mesh.
  114876. * 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
  114877. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114879. * @param name defines the name of the mesh to create
  114880. * @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
  114881. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114882. * @param scale is the value to scale the shape
  114883. * @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
  114884. * @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
  114885. * @param scene defines the hosting scene
  114886. * @param updatable defines if the mesh must be flagged as updatable
  114887. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114888. * @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)
  114889. * @returns a new Mesh
  114890. */
  114891. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114892. /**
  114893. * Creates an custom extruded shape mesh.
  114894. * The custom extrusion is a parametric shape.
  114895. * It has no predefined shape. Its final shape will depend on the input parameters.
  114896. * Please consider using the same method from the MeshBuilder class instead
  114897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114898. * @param name defines the name of the mesh to create
  114899. * @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
  114900. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114901. * @param scaleFunction is a custom Javascript function called on each path point
  114902. * @param rotationFunction is a custom Javascript function called on each path point
  114903. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114904. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114905. * @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
  114906. * @param scene defines the hosting scene
  114907. * @param updatable defines if the mesh must be flagged as updatable
  114908. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114909. * @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)
  114910. * @returns a new Mesh
  114911. */
  114912. 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;
  114913. /**
  114914. * Creates lathe mesh.
  114915. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114916. * Please consider using the same method from the MeshBuilder class instead
  114917. * @param name defines the name of the mesh to create
  114918. * @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
  114919. * @param radius is the radius value of the lathe
  114920. * @param tessellation is the side number of the lathe.
  114921. * @param scene defines the hosting scene
  114922. * @param updatable defines if the mesh must be flagged as updatable
  114923. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114924. * @returns a new Mesh
  114925. */
  114926. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114927. /**
  114928. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114929. * @param name defines the name of the mesh to create
  114930. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114931. * @param scene defines the hosting scene
  114932. * @param updatable defines if the mesh must be flagged as updatable
  114933. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114934. * @returns a new Mesh
  114935. */
  114936. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114937. /**
  114938. * Creates a ground mesh.
  114939. * Please consider using the same method from the MeshBuilder class instead
  114940. * @param name defines the name of the mesh to create
  114941. * @param width set the width of the ground
  114942. * @param height set the height of the ground
  114943. * @param subdivisions sets the number of subdivisions per side
  114944. * @param scene defines the hosting scene
  114945. * @param updatable defines if the mesh must be flagged as updatable
  114946. * @returns a new Mesh
  114947. */
  114948. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114949. /**
  114950. * Creates a tiled ground mesh.
  114951. * Please consider using the same method from the MeshBuilder class instead
  114952. * @param name defines the name of the mesh to create
  114953. * @param xmin set the ground minimum X coordinate
  114954. * @param zmin set the ground minimum Y coordinate
  114955. * @param xmax set the ground maximum X coordinate
  114956. * @param zmax set the ground maximum Z coordinate
  114957. * @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
  114958. * @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
  114959. * @param scene defines the hosting scene
  114960. * @param updatable defines if the mesh must be flagged as updatable
  114961. * @returns a new Mesh
  114962. */
  114963. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114964. w: number;
  114965. h: number;
  114966. }, precision: {
  114967. w: number;
  114968. h: number;
  114969. }, scene: Scene, updatable?: boolean): Mesh;
  114970. /**
  114971. * Creates a ground mesh from a height map.
  114972. * Please consider using the same method from the MeshBuilder class instead
  114973. * @see https://doc.babylonjs.com/babylon101/height_map
  114974. * @param name defines the name of the mesh to create
  114975. * @param url sets the URL of the height map image resource
  114976. * @param width set the ground width size
  114977. * @param height set the ground height size
  114978. * @param subdivisions sets the number of subdivision per side
  114979. * @param minHeight is the minimum altitude on the ground
  114980. * @param maxHeight is the maximum altitude on the ground
  114981. * @param scene defines the hosting scene
  114982. * @param updatable defines if the mesh must be flagged as updatable
  114983. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114984. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114985. * @returns a new Mesh
  114986. */
  114987. 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;
  114988. /**
  114989. * Creates a tube mesh.
  114990. * The tube is a parametric shape.
  114991. * It has no predefined shape. Its final shape will depend on the input parameters.
  114992. * Please consider using the same method from the MeshBuilder class instead
  114993. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114994. * @param name defines the name of the mesh to create
  114995. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114996. * @param radius sets the tube radius size
  114997. * @param tessellation is the number of sides on the tubular surface
  114998. * @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
  114999. * @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
  115000. * @param scene defines the hosting scene
  115001. * @param updatable defines if the mesh must be flagged as updatable
  115002. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  115003. * @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)
  115004. * @returns a new Mesh
  115005. */
  115006. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  115007. (i: number, distance: number): number;
  115008. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  115009. /**
  115010. * Creates a polyhedron mesh.
  115011. * Please consider using the same method from the MeshBuilder class instead.
  115012. * * 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
  115013. * * The parameter `size` (positive float, default 1) sets the polygon size
  115014. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115015. * * 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`
  115016. * * 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
  115017. * * 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)`)
  115018. * * 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
  115019. * * 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
  115020. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115023. * @param name defines the name of the mesh to create
  115024. * @param options defines the options used to create the mesh
  115025. * @param scene defines the hosting scene
  115026. * @returns a new Mesh
  115027. */
  115028. static CreatePolyhedron(name: string, options: {
  115029. type?: number;
  115030. size?: number;
  115031. sizeX?: number;
  115032. sizeY?: number;
  115033. sizeZ?: number;
  115034. custom?: any;
  115035. faceUV?: Vector4[];
  115036. faceColors?: Color4[];
  115037. updatable?: boolean;
  115038. sideOrientation?: number;
  115039. }, scene: Scene): Mesh;
  115040. /**
  115041. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115042. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115043. * * 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`)
  115044. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115045. * * 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
  115046. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115049. * @param name defines the name of the mesh
  115050. * @param options defines the options used to create the mesh
  115051. * @param scene defines the hosting scene
  115052. * @returns a new Mesh
  115053. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115054. */
  115055. static CreateIcoSphere(name: string, options: {
  115056. radius?: number;
  115057. flat?: boolean;
  115058. subdivisions?: number;
  115059. sideOrientation?: number;
  115060. updatable?: boolean;
  115061. }, scene: Scene): Mesh;
  115062. /**
  115063. * Creates a decal mesh.
  115064. * Please consider using the same method from the MeshBuilder class instead.
  115065. * A decal is a mesh usually applied as a model onto the surface of another mesh
  115066. * @param name defines the name of the mesh
  115067. * @param sourceMesh defines the mesh receiving the decal
  115068. * @param position sets the position of the decal in world coordinates
  115069. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  115070. * @param size sets the decal scaling
  115071. * @param angle sets the angle to rotate the decal
  115072. * @returns a new Mesh
  115073. */
  115074. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  115075. /** Creates a Capsule Mesh
  115076. * @param name defines the name of the mesh.
  115077. * @param options the constructors options used to shape the mesh.
  115078. * @param scene defines the scene the mesh is scoped to.
  115079. * @returns the capsule mesh
  115080. * @see https://doc.babylonjs.com/how_to/capsule_shape
  115081. */
  115082. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  115083. /**
  115084. * Prepare internal position array for software CPU skinning
  115085. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  115086. */
  115087. setPositionsForCPUSkinning(): Float32Array;
  115088. /**
  115089. * Prepare internal normal array for software CPU skinning
  115090. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  115091. */
  115092. setNormalsForCPUSkinning(): Float32Array;
  115093. /**
  115094. * Updates the vertex buffer by applying transformation from the bones
  115095. * @param skeleton defines the skeleton to apply to current mesh
  115096. * @returns the current mesh
  115097. */
  115098. applySkeleton(skeleton: Skeleton): Mesh;
  115099. /**
  115100. * 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
  115101. * @param meshes defines the list of meshes to scan
  115102. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  115103. */
  115104. static MinMax(meshes: AbstractMesh[]): {
  115105. min: Vector3;
  115106. max: Vector3;
  115107. };
  115108. /**
  115109. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  115110. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  115111. * @returns a vector3
  115112. */
  115113. static Center(meshesOrMinMaxVector: {
  115114. min: Vector3;
  115115. max: Vector3;
  115116. } | AbstractMesh[]): Vector3;
  115117. /**
  115118. * Merge the array of meshes into a single mesh for performance reasons.
  115119. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  115120. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  115121. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  115122. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  115123. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  115124. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  115125. * @returns a new mesh
  115126. */
  115127. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  115128. /** @hidden */
  115129. addInstance(instance: InstancedMesh): void;
  115130. /** @hidden */
  115131. removeInstance(instance: InstancedMesh): void;
  115132. }
  115133. }
  115134. declare module BABYLON {
  115135. /**
  115136. * The options Interface for creating a Capsule Mesh
  115137. */
  115138. export interface ICreateCapsuleOptions {
  115139. /** The Orientation of the capsule. Default : Vector3.Up() */
  115140. orientation?: Vector3;
  115141. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  115142. subdivisions: number;
  115143. /** Number of cylindrical segments on the capsule. */
  115144. tessellation: number;
  115145. /** Height or Length of the capsule. */
  115146. height: number;
  115147. /** Radius of the capsule. */
  115148. radius: number;
  115149. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  115150. capSubdivisions: number;
  115151. /** Overwrite for the top radius. */
  115152. radiusTop?: number;
  115153. /** Overwrite for the bottom radius. */
  115154. radiusBottom?: number;
  115155. /** Overwrite for the top capSubdivisions. */
  115156. topCapSubdivisions?: number;
  115157. /** Overwrite for the bottom capSubdivisions. */
  115158. bottomCapSubdivisions?: number;
  115159. }
  115160. /**
  115161. * Class containing static functions to help procedurally build meshes
  115162. */
  115163. export class CapsuleBuilder {
  115164. /**
  115165. * Creates a capsule or a pill mesh
  115166. * @param name defines the name of the mesh
  115167. * @param options The constructors options.
  115168. * @param scene The scene the mesh is scoped to.
  115169. * @returns Capsule Mesh
  115170. */
  115171. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  115172. }
  115173. }
  115174. declare module BABYLON {
  115175. /**
  115176. * Define an interface for all classes that will get and set the data on vertices
  115177. */
  115178. export interface IGetSetVerticesData {
  115179. /**
  115180. * Gets a boolean indicating if specific vertex data is present
  115181. * @param kind defines the vertex data kind to use
  115182. * @returns true is data kind is present
  115183. */
  115184. isVerticesDataPresent(kind: string): boolean;
  115185. /**
  115186. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  115187. * @param kind defines the data kind (Position, normal, etc...)
  115188. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  115189. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  115190. * @returns a float array containing vertex data
  115191. */
  115192. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  115193. /**
  115194. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  115195. * @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.
  115196. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  115197. * @returns the indices array or an empty array if the mesh has no geometry
  115198. */
  115199. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  115200. /**
  115201. * Set specific vertex data
  115202. * @param kind defines the data kind (Position, normal, etc...)
  115203. * @param data defines the vertex data to use
  115204. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  115205. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  115206. */
  115207. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  115208. /**
  115209. * Update a specific associated vertex buffer
  115210. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  115211. * - VertexBuffer.PositionKind
  115212. * - VertexBuffer.UVKind
  115213. * - VertexBuffer.UV2Kind
  115214. * - VertexBuffer.UV3Kind
  115215. * - VertexBuffer.UV4Kind
  115216. * - VertexBuffer.UV5Kind
  115217. * - VertexBuffer.UV6Kind
  115218. * - VertexBuffer.ColorKind
  115219. * - VertexBuffer.MatricesIndicesKind
  115220. * - VertexBuffer.MatricesIndicesExtraKind
  115221. * - VertexBuffer.MatricesWeightsKind
  115222. * - VertexBuffer.MatricesWeightsExtraKind
  115223. * @param data defines the data source
  115224. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  115225. * @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)
  115226. */
  115227. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  115228. /**
  115229. * Creates a new index buffer
  115230. * @param indices defines the indices to store in the index buffer
  115231. * @param totalVertices defines the total number of vertices (could be null)
  115232. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  115233. */
  115234. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  115235. }
  115236. /**
  115237. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  115238. */
  115239. export class VertexData {
  115240. /**
  115241. * Mesh side orientation : usually the external or front surface
  115242. */
  115243. static readonly FRONTSIDE: number;
  115244. /**
  115245. * Mesh side orientation : usually the internal or back surface
  115246. */
  115247. static readonly BACKSIDE: number;
  115248. /**
  115249. * Mesh side orientation : both internal and external or front and back surfaces
  115250. */
  115251. static readonly DOUBLESIDE: number;
  115252. /**
  115253. * Mesh side orientation : by default, `FRONTSIDE`
  115254. */
  115255. static readonly DEFAULTSIDE: number;
  115256. /**
  115257. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  115258. */
  115259. positions: Nullable<FloatArray>;
  115260. /**
  115261. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  115262. */
  115263. normals: Nullable<FloatArray>;
  115264. /**
  115265. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  115266. */
  115267. tangents: Nullable<FloatArray>;
  115268. /**
  115269. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115270. */
  115271. uvs: Nullable<FloatArray>;
  115272. /**
  115273. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115274. */
  115275. uvs2: Nullable<FloatArray>;
  115276. /**
  115277. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115278. */
  115279. uvs3: Nullable<FloatArray>;
  115280. /**
  115281. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115282. */
  115283. uvs4: Nullable<FloatArray>;
  115284. /**
  115285. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115286. */
  115287. uvs5: Nullable<FloatArray>;
  115288. /**
  115289. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115290. */
  115291. uvs6: Nullable<FloatArray>;
  115292. /**
  115293. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  115294. */
  115295. colors: Nullable<FloatArray>;
  115296. /**
  115297. * 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).
  115298. */
  115299. matricesIndices: Nullable<FloatArray>;
  115300. /**
  115301. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  115302. */
  115303. matricesWeights: Nullable<FloatArray>;
  115304. /**
  115305. * An array extending the number of possible indices
  115306. */
  115307. matricesIndicesExtra: Nullable<FloatArray>;
  115308. /**
  115309. * An array extending the number of possible weights when the number of indices is extended
  115310. */
  115311. matricesWeightsExtra: Nullable<FloatArray>;
  115312. /**
  115313. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  115314. */
  115315. indices: Nullable<IndicesArray>;
  115316. /**
  115317. * Uses the passed data array to set the set the values for the specified kind of data
  115318. * @param data a linear array of floating numbers
  115319. * @param kind the type of data that is being set, eg positions, colors etc
  115320. */
  115321. set(data: FloatArray, kind: string): void;
  115322. /**
  115323. * Associates the vertexData to the passed Mesh.
  115324. * Sets it as updatable or not (default `false`)
  115325. * @param mesh the mesh the vertexData is applied to
  115326. * @param updatable when used and having the value true allows new data to update the vertexData
  115327. * @returns the VertexData
  115328. */
  115329. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  115330. /**
  115331. * Associates the vertexData to the passed Geometry.
  115332. * Sets it as updatable or not (default `false`)
  115333. * @param geometry the geometry the vertexData is applied to
  115334. * @param updatable when used and having the value true allows new data to update the vertexData
  115335. * @returns VertexData
  115336. */
  115337. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  115338. /**
  115339. * Updates the associated mesh
  115340. * @param mesh the mesh to be updated
  115341. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115342. * @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
  115343. * @returns VertexData
  115344. */
  115345. updateMesh(mesh: Mesh): VertexData;
  115346. /**
  115347. * Updates the associated geometry
  115348. * @param geometry the geometry to be updated
  115349. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115350. * @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
  115351. * @returns VertexData.
  115352. */
  115353. updateGeometry(geometry: Geometry): VertexData;
  115354. private _applyTo;
  115355. private _update;
  115356. /**
  115357. * Transforms each position and each normal of the vertexData according to the passed Matrix
  115358. * @param matrix the transforming matrix
  115359. * @returns the VertexData
  115360. */
  115361. transform(matrix: Matrix): VertexData;
  115362. /**
  115363. * Merges the passed VertexData into the current one
  115364. * @param other the VertexData to be merged into the current one
  115365. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  115366. * @returns the modified VertexData
  115367. */
  115368. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  115369. private _mergeElement;
  115370. private _validate;
  115371. /**
  115372. * Serializes the VertexData
  115373. * @returns a serialized object
  115374. */
  115375. serialize(): any;
  115376. /**
  115377. * Extracts the vertexData from a mesh
  115378. * @param mesh the mesh from which to extract the VertexData
  115379. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  115380. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115381. * @returns the object VertexData associated to the passed mesh
  115382. */
  115383. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115384. /**
  115385. * Extracts the vertexData from the geometry
  115386. * @param geometry the geometry from which to extract the VertexData
  115387. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  115388. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115389. * @returns the object VertexData associated to the passed mesh
  115390. */
  115391. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115392. private static _ExtractFrom;
  115393. /**
  115394. * Creates the VertexData for a Ribbon
  115395. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  115396. * * pathArray array of paths, each of which an array of successive Vector3
  115397. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  115398. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  115399. * * 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
  115400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115401. * * 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)
  115402. * * 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)
  115403. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  115404. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  115405. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  115406. * @returns the VertexData of the ribbon
  115407. */
  115408. static CreateRibbon(options: {
  115409. pathArray: Vector3[][];
  115410. closeArray?: boolean;
  115411. closePath?: boolean;
  115412. offset?: number;
  115413. sideOrientation?: number;
  115414. frontUVs?: Vector4;
  115415. backUVs?: Vector4;
  115416. invertUV?: boolean;
  115417. uvs?: Vector2[];
  115418. colors?: Color4[];
  115419. }): VertexData;
  115420. /**
  115421. * Creates the VertexData for a box
  115422. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115423. * * size sets the width, height and depth of the box to the value of size, optional default 1
  115424. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  115425. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  115426. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  115427. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115428. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115430. * * 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)
  115431. * * 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)
  115432. * @returns the VertexData of the box
  115433. */
  115434. static CreateBox(options: {
  115435. size?: number;
  115436. width?: number;
  115437. height?: number;
  115438. depth?: number;
  115439. faceUV?: Vector4[];
  115440. faceColors?: Color4[];
  115441. sideOrientation?: number;
  115442. frontUVs?: Vector4;
  115443. backUVs?: Vector4;
  115444. }): VertexData;
  115445. /**
  115446. * Creates the VertexData for a tiled box
  115447. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115448. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115449. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115450. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115452. * @returns the VertexData of the box
  115453. */
  115454. static CreateTiledBox(options: {
  115455. pattern?: number;
  115456. width?: number;
  115457. height?: number;
  115458. depth?: number;
  115459. tileSize?: number;
  115460. tileWidth?: number;
  115461. tileHeight?: number;
  115462. alignHorizontal?: number;
  115463. alignVertical?: number;
  115464. faceUV?: Vector4[];
  115465. faceColors?: Color4[];
  115466. sideOrientation?: number;
  115467. }): VertexData;
  115468. /**
  115469. * Creates the VertexData for a tiled plane
  115470. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115471. * * pattern a limited pattern arrangement depending on the number
  115472. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  115473. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  115474. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  115475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115476. * * 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)
  115477. * * 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)
  115478. * @returns the VertexData of the tiled plane
  115479. */
  115480. static CreateTiledPlane(options: {
  115481. pattern?: number;
  115482. tileSize?: number;
  115483. tileWidth?: number;
  115484. tileHeight?: number;
  115485. size?: number;
  115486. width?: number;
  115487. height?: number;
  115488. alignHorizontal?: number;
  115489. alignVertical?: number;
  115490. sideOrientation?: number;
  115491. frontUVs?: Vector4;
  115492. backUVs?: Vector4;
  115493. }): VertexData;
  115494. /**
  115495. * Creates the VertexData for an ellipsoid, defaults to a sphere
  115496. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115497. * * segments sets the number of horizontal strips optional, default 32
  115498. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  115499. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  115500. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  115501. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  115502. * * 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
  115503. * * 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
  115504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115505. * * 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)
  115506. * * 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)
  115507. * @returns the VertexData of the ellipsoid
  115508. */
  115509. static CreateSphere(options: {
  115510. segments?: number;
  115511. diameter?: number;
  115512. diameterX?: number;
  115513. diameterY?: number;
  115514. diameterZ?: number;
  115515. arc?: number;
  115516. slice?: number;
  115517. sideOrientation?: number;
  115518. frontUVs?: Vector4;
  115519. backUVs?: Vector4;
  115520. }): VertexData;
  115521. /**
  115522. * Creates the VertexData for a cylinder, cone or prism
  115523. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115524. * * height sets the height (y direction) of the cylinder, optional, default 2
  115525. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  115526. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  115527. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  115528. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115529. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  115530. * * 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
  115531. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115532. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115533. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  115534. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  115535. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115536. * * 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)
  115537. * * 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)
  115538. * @returns the VertexData of the cylinder, cone or prism
  115539. */
  115540. static CreateCylinder(options: {
  115541. height?: number;
  115542. diameterTop?: number;
  115543. diameterBottom?: number;
  115544. diameter?: number;
  115545. tessellation?: number;
  115546. subdivisions?: number;
  115547. arc?: number;
  115548. faceColors?: Color4[];
  115549. faceUV?: Vector4[];
  115550. hasRings?: boolean;
  115551. enclose?: boolean;
  115552. sideOrientation?: number;
  115553. frontUVs?: Vector4;
  115554. backUVs?: Vector4;
  115555. }): VertexData;
  115556. /**
  115557. * Creates the VertexData for a torus
  115558. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115559. * * diameter the diameter of the torus, optional default 1
  115560. * * thickness the diameter of the tube forming the torus, optional default 0.5
  115561. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115562. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115563. * * 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)
  115564. * * 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)
  115565. * @returns the VertexData of the torus
  115566. */
  115567. static CreateTorus(options: {
  115568. diameter?: number;
  115569. thickness?: number;
  115570. tessellation?: number;
  115571. sideOrientation?: number;
  115572. frontUVs?: Vector4;
  115573. backUVs?: Vector4;
  115574. }): VertexData;
  115575. /**
  115576. * Creates the VertexData of the LineSystem
  115577. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  115578. * - lines an array of lines, each line being an array of successive Vector3
  115579. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  115580. * @returns the VertexData of the LineSystem
  115581. */
  115582. static CreateLineSystem(options: {
  115583. lines: Vector3[][];
  115584. colors?: Nullable<Color4[][]>;
  115585. }): VertexData;
  115586. /**
  115587. * Create the VertexData for a DashedLines
  115588. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  115589. * - points an array successive Vector3
  115590. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  115591. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  115592. * - dashNb the intended total number of dashes, optional, default 200
  115593. * @returns the VertexData for the DashedLines
  115594. */
  115595. static CreateDashedLines(options: {
  115596. points: Vector3[];
  115597. dashSize?: number;
  115598. gapSize?: number;
  115599. dashNb?: number;
  115600. }): VertexData;
  115601. /**
  115602. * Creates the VertexData for a Ground
  115603. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115604. * - width the width (x direction) of the ground, optional, default 1
  115605. * - height the height (z direction) of the ground, optional, default 1
  115606. * - subdivisions the number of subdivisions per side, optional, default 1
  115607. * @returns the VertexData of the Ground
  115608. */
  115609. static CreateGround(options: {
  115610. width?: number;
  115611. height?: number;
  115612. subdivisions?: number;
  115613. subdivisionsX?: number;
  115614. subdivisionsY?: number;
  115615. }): VertexData;
  115616. /**
  115617. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  115618. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115619. * * xmin the ground minimum X coordinate, optional, default -1
  115620. * * zmin the ground minimum Z coordinate, optional, default -1
  115621. * * xmax the ground maximum X coordinate, optional, default 1
  115622. * * zmax the ground maximum Z coordinate, optional, default 1
  115623. * * 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}
  115624. * * 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}
  115625. * @returns the VertexData of the TiledGround
  115626. */
  115627. static CreateTiledGround(options: {
  115628. xmin: number;
  115629. zmin: number;
  115630. xmax: number;
  115631. zmax: number;
  115632. subdivisions?: {
  115633. w: number;
  115634. h: number;
  115635. };
  115636. precision?: {
  115637. w: number;
  115638. h: number;
  115639. };
  115640. }): VertexData;
  115641. /**
  115642. * Creates the VertexData of the Ground designed from a heightmap
  115643. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  115644. * * width the width (x direction) of the ground
  115645. * * height the height (z direction) of the ground
  115646. * * subdivisions the number of subdivisions per side
  115647. * * minHeight the minimum altitude on the ground, optional, default 0
  115648. * * maxHeight the maximum altitude on the ground, optional default 1
  115649. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  115650. * * buffer the array holding the image color data
  115651. * * bufferWidth the width of image
  115652. * * bufferHeight the height of image
  115653. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  115654. * @returns the VertexData of the Ground designed from a heightmap
  115655. */
  115656. static CreateGroundFromHeightMap(options: {
  115657. width: number;
  115658. height: number;
  115659. subdivisions: number;
  115660. minHeight: number;
  115661. maxHeight: number;
  115662. colorFilter: Color3;
  115663. buffer: Uint8Array;
  115664. bufferWidth: number;
  115665. bufferHeight: number;
  115666. alphaFilter: number;
  115667. }): VertexData;
  115668. /**
  115669. * Creates the VertexData for a Plane
  115670. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  115671. * * size sets the width and height of the plane to the value of size, optional default 1
  115672. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  115673. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  115674. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115675. * * 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)
  115676. * * 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)
  115677. * @returns the VertexData of the box
  115678. */
  115679. static CreatePlane(options: {
  115680. size?: number;
  115681. width?: number;
  115682. height?: number;
  115683. sideOrientation?: number;
  115684. frontUVs?: Vector4;
  115685. backUVs?: Vector4;
  115686. }): VertexData;
  115687. /**
  115688. * Creates the VertexData of the Disc or regular Polygon
  115689. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  115690. * * radius the radius of the disc, optional default 0.5
  115691. * * tessellation the number of polygon sides, optional, default 64
  115692. * * 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
  115693. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115694. * * 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)
  115695. * * 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)
  115696. * @returns the VertexData of the box
  115697. */
  115698. static CreateDisc(options: {
  115699. radius?: number;
  115700. tessellation?: number;
  115701. arc?: number;
  115702. sideOrientation?: number;
  115703. frontUVs?: Vector4;
  115704. backUVs?: Vector4;
  115705. }): VertexData;
  115706. /**
  115707. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  115708. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  115709. * @param polygon a mesh built from polygonTriangulation.build()
  115710. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115711. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115712. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115713. * @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)
  115714. * @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)
  115715. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  115716. * @returns the VertexData of the Polygon
  115717. */
  115718. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  115719. /**
  115720. * Creates the VertexData of the IcoSphere
  115721. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  115722. * * radius the radius of the IcoSphere, optional default 1
  115723. * * radiusX allows stretching in the x direction, optional, default radius
  115724. * * radiusY allows stretching in the y direction, optional, default radius
  115725. * * radiusZ allows stretching in the z direction, optional, default radius
  115726. * * flat when true creates a flat shaded mesh, optional, default true
  115727. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115728. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115729. * * 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)
  115730. * * 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)
  115731. * @returns the VertexData of the IcoSphere
  115732. */
  115733. static CreateIcoSphere(options: {
  115734. radius?: number;
  115735. radiusX?: number;
  115736. radiusY?: number;
  115737. radiusZ?: number;
  115738. flat?: boolean;
  115739. subdivisions?: number;
  115740. sideOrientation?: number;
  115741. frontUVs?: Vector4;
  115742. backUVs?: Vector4;
  115743. }): VertexData;
  115744. /**
  115745. * Creates the VertexData for a Polyhedron
  115746. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  115747. * * type provided types are:
  115748. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  115749. * * 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)
  115750. * * size the size of the IcoSphere, optional default 1
  115751. * * sizeX allows stretching in the x direction, optional, default size
  115752. * * sizeY allows stretching in the y direction, optional, default size
  115753. * * sizeZ allows stretching in the z direction, optional, default size
  115754. * * 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
  115755. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115756. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115757. * * flat when true creates a flat shaded mesh, optional, default true
  115758. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115759. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115760. * * 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)
  115761. * * 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)
  115762. * @returns the VertexData of the Polyhedron
  115763. */
  115764. static CreatePolyhedron(options: {
  115765. type?: number;
  115766. size?: number;
  115767. sizeX?: number;
  115768. sizeY?: number;
  115769. sizeZ?: number;
  115770. custom?: any;
  115771. faceUV?: Vector4[];
  115772. faceColors?: Color4[];
  115773. flat?: boolean;
  115774. sideOrientation?: number;
  115775. frontUVs?: Vector4;
  115776. backUVs?: Vector4;
  115777. }): VertexData;
  115778. /**
  115779. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  115780. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  115781. * @returns the VertexData of the Capsule
  115782. */
  115783. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  115784. /**
  115785. * Creates the VertexData for a TorusKnot
  115786. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  115787. * * radius the radius of the torus knot, optional, default 2
  115788. * * tube the thickness of the tube, optional, default 0.5
  115789. * * radialSegments the number of sides on each tube segments, optional, default 32
  115790. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  115791. * * p the number of windings around the z axis, optional, default 2
  115792. * * q the number of windings around the x axis, optional, default 3
  115793. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115794. * * 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)
  115795. * * 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)
  115796. * @returns the VertexData of the Torus Knot
  115797. */
  115798. static CreateTorusKnot(options: {
  115799. radius?: number;
  115800. tube?: number;
  115801. radialSegments?: number;
  115802. tubularSegments?: number;
  115803. p?: number;
  115804. q?: number;
  115805. sideOrientation?: number;
  115806. frontUVs?: Vector4;
  115807. backUVs?: Vector4;
  115808. }): VertexData;
  115809. /**
  115810. * Compute normals for given positions and indices
  115811. * @param positions an array of vertex positions, [...., x, y, z, ......]
  115812. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  115813. * @param normals an array of vertex normals, [...., x, y, z, ......]
  115814. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  115815. * * facetNormals : optional array of facet normals (vector3)
  115816. * * facetPositions : optional array of facet positions (vector3)
  115817. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  115818. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  115819. * * bInfo : optional bounding info, required for facetPartitioning computation
  115820. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  115821. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  115822. * * useRightHandedSystem: optional boolean to for right handed system computation
  115823. * * depthSort : optional boolean to enable the facet depth sort computation
  115824. * * distanceTo : optional Vector3 to compute the facet depth from this location
  115825. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  115826. */
  115827. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  115828. facetNormals?: any;
  115829. facetPositions?: any;
  115830. facetPartitioning?: any;
  115831. ratio?: number;
  115832. bInfo?: any;
  115833. bbSize?: Vector3;
  115834. subDiv?: any;
  115835. useRightHandedSystem?: boolean;
  115836. depthSort?: boolean;
  115837. distanceTo?: Vector3;
  115838. depthSortedFacets?: any;
  115839. }): void;
  115840. /** @hidden */
  115841. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  115842. /**
  115843. * Applies VertexData created from the imported parameters to the geometry
  115844. * @param parsedVertexData the parsed data from an imported file
  115845. * @param geometry the geometry to apply the VertexData to
  115846. */
  115847. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  115848. }
  115849. }
  115850. declare module BABYLON {
  115851. /**
  115852. * Class containing static functions to help procedurally build meshes
  115853. */
  115854. export class DiscBuilder {
  115855. /**
  115856. * Creates a plane polygonal mesh. By default, this is a disc
  115857. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115858. * * 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
  115859. * * 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
  115860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115863. * @param name defines the name of the mesh
  115864. * @param options defines the options used to create the mesh
  115865. * @param scene defines the hosting scene
  115866. * @returns the plane polygonal mesh
  115867. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115868. */
  115869. static CreateDisc(name: string, options: {
  115870. radius?: number;
  115871. tessellation?: number;
  115872. arc?: number;
  115873. updatable?: boolean;
  115874. sideOrientation?: number;
  115875. frontUVs?: Vector4;
  115876. backUVs?: Vector4;
  115877. }, scene?: Nullable<Scene>): Mesh;
  115878. }
  115879. }
  115880. declare module BABYLON {
  115881. /**
  115882. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115883. *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.
  115884. * The SPS is also a particle system. It provides some methods to manage the particles.
  115885. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115886. *
  115887. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115888. */
  115889. export class SolidParticleSystem implements IDisposable {
  115890. /**
  115891. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115892. * Example : var p = SPS.particles[i];
  115893. */
  115894. particles: SolidParticle[];
  115895. /**
  115896. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115897. */
  115898. nbParticles: number;
  115899. /**
  115900. * If the particles must ever face the camera (default false). Useful for planar particles.
  115901. */
  115902. billboard: boolean;
  115903. /**
  115904. * Recompute normals when adding a shape
  115905. */
  115906. recomputeNormals: boolean;
  115907. /**
  115908. * This a counter ofr your own usage. It's not set by any SPS functions.
  115909. */
  115910. counter: number;
  115911. /**
  115912. * The SPS name. This name is also given to the underlying mesh.
  115913. */
  115914. name: string;
  115915. /**
  115916. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115917. */
  115918. mesh: Mesh;
  115919. /**
  115920. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115921. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115922. */
  115923. vars: any;
  115924. /**
  115925. * This array is populated when the SPS is set as 'pickable'.
  115926. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115927. * Each element of this array is an object `{idx: int, faceId: int}`.
  115928. * `idx` is the picked particle index in the `SPS.particles` array
  115929. * `faceId` is the picked face index counted within this particle.
  115930. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115931. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115932. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115933. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115934. */
  115935. pickedParticles: {
  115936. idx: number;
  115937. faceId: number;
  115938. }[];
  115939. /**
  115940. * This array is populated when the SPS is set as 'pickable'
  115941. * Each key of this array is a submesh index.
  115942. * Each element of this array is a second array defined like this :
  115943. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115944. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115945. * `idx` is the picked particle index in the `SPS.particles` array
  115946. * `faceId` is the picked face index counted within this particle.
  115947. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115948. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115949. */
  115950. pickedBySubMesh: {
  115951. idx: number;
  115952. faceId: number;
  115953. }[][];
  115954. /**
  115955. * This array is populated when `enableDepthSort` is set to true.
  115956. * Each element of this array is an instance of the class DepthSortedParticle.
  115957. */
  115958. depthSortedParticles: DepthSortedParticle[];
  115959. /**
  115960. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115961. * @hidden
  115962. */
  115963. _bSphereOnly: boolean;
  115964. /**
  115965. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115966. * @hidden
  115967. */
  115968. _bSphereRadiusFactor: number;
  115969. private _scene;
  115970. private _positions;
  115971. private _indices;
  115972. private _normals;
  115973. private _colors;
  115974. private _uvs;
  115975. private _indices32;
  115976. private _positions32;
  115977. private _normals32;
  115978. private _fixedNormal32;
  115979. private _colors32;
  115980. private _uvs32;
  115981. private _index;
  115982. private _updatable;
  115983. private _pickable;
  115984. private _isVisibilityBoxLocked;
  115985. private _alwaysVisible;
  115986. private _depthSort;
  115987. private _expandable;
  115988. private _shapeCounter;
  115989. private _copy;
  115990. private _color;
  115991. private _computeParticleColor;
  115992. private _computeParticleTexture;
  115993. private _computeParticleRotation;
  115994. private _computeParticleVertex;
  115995. private _computeBoundingBox;
  115996. private _depthSortParticles;
  115997. private _camera;
  115998. private _mustUnrotateFixedNormals;
  115999. private _particlesIntersect;
  116000. private _needs32Bits;
  116001. private _isNotBuilt;
  116002. private _lastParticleId;
  116003. private _idxOfId;
  116004. private _multimaterialEnabled;
  116005. private _useModelMaterial;
  116006. private _indicesByMaterial;
  116007. private _materialIndexes;
  116008. private _depthSortFunction;
  116009. private _materialSortFunction;
  116010. private _materials;
  116011. private _multimaterial;
  116012. private _materialIndexesById;
  116013. private _defaultMaterial;
  116014. private _autoUpdateSubMeshes;
  116015. private _tmpVertex;
  116016. /**
  116017. * Creates a SPS (Solid Particle System) object.
  116018. * @param name (String) is the SPS name, this will be the underlying mesh name.
  116019. * @param scene (Scene) is the scene in which the SPS is added.
  116020. * @param options defines the options of the sps e.g.
  116021. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  116022. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  116023. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  116024. * * 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.
  116025. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  116026. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  116027. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  116028. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  116029. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  116030. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  116031. */
  116032. constructor(name: string, scene: Scene, options?: {
  116033. updatable?: boolean;
  116034. isPickable?: boolean;
  116035. enableDepthSort?: boolean;
  116036. particleIntersection?: boolean;
  116037. boundingSphereOnly?: boolean;
  116038. bSphereRadiusFactor?: number;
  116039. expandable?: boolean;
  116040. useModelMaterial?: boolean;
  116041. enableMultiMaterial?: boolean;
  116042. });
  116043. /**
  116044. * Builds the SPS underlying mesh. Returns a standard Mesh.
  116045. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  116046. * @returns the created mesh
  116047. */
  116048. buildMesh(): Mesh;
  116049. /**
  116050. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  116051. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  116052. * Thus the particles generated from `digest()` have their property `position` set yet.
  116053. * @param mesh ( Mesh ) is the mesh to be digested
  116054. * @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
  116055. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  116056. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  116057. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  116058. * @returns the current SPS
  116059. */
  116060. digest(mesh: Mesh, options?: {
  116061. facetNb?: number;
  116062. number?: number;
  116063. delta?: number;
  116064. storage?: [];
  116065. }): SolidParticleSystem;
  116066. /**
  116067. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  116068. * @hidden
  116069. */
  116070. private _unrotateFixedNormals;
  116071. /**
  116072. * Resets the temporary working copy particle
  116073. * @hidden
  116074. */
  116075. private _resetCopy;
  116076. /**
  116077. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  116078. * @param p the current index in the positions array to be updated
  116079. * @param ind the current index in the indices array
  116080. * @param shape a Vector3 array, the shape geometry
  116081. * @param positions the positions array to be updated
  116082. * @param meshInd the shape indices array
  116083. * @param indices the indices array to be updated
  116084. * @param meshUV the shape uv array
  116085. * @param uvs the uv array to be updated
  116086. * @param meshCol the shape color array
  116087. * @param colors the color array to be updated
  116088. * @param meshNor the shape normals array
  116089. * @param normals the normals array to be updated
  116090. * @param idx the particle index
  116091. * @param idxInShape the particle index in its shape
  116092. * @param options the addShape() method passed options
  116093. * @model the particle model
  116094. * @hidden
  116095. */
  116096. private _meshBuilder;
  116097. /**
  116098. * Returns a shape Vector3 array from positions float array
  116099. * @param positions float array
  116100. * @returns a vector3 array
  116101. * @hidden
  116102. */
  116103. private _posToShape;
  116104. /**
  116105. * Returns a shapeUV array from a float uvs (array deep copy)
  116106. * @param uvs as a float array
  116107. * @returns a shapeUV array
  116108. * @hidden
  116109. */
  116110. private _uvsToShapeUV;
  116111. /**
  116112. * Adds a new particle object in the particles array
  116113. * @param idx particle index in particles array
  116114. * @param id particle id
  116115. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  116116. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  116117. * @param model particle ModelShape object
  116118. * @param shapeId model shape identifier
  116119. * @param idxInShape index of the particle in the current model
  116120. * @param bInfo model bounding info object
  116121. * @param storage target storage array, if any
  116122. * @hidden
  116123. */
  116124. private _addParticle;
  116125. /**
  116126. * Adds some particles to the SPS from the model shape. Returns the shape id.
  116127. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  116128. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  116129. * @param nb (positive integer) the number of particles to be created from this model
  116130. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  116131. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  116132. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  116133. * @returns the number of shapes in the system
  116134. */
  116135. addShape(mesh: Mesh, nb: number, options?: {
  116136. positionFunction?: any;
  116137. vertexFunction?: any;
  116138. storage?: [];
  116139. }): number;
  116140. /**
  116141. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  116142. * @hidden
  116143. */
  116144. private _rebuildParticle;
  116145. /**
  116146. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  116147. * @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.
  116148. * @returns the SPS.
  116149. */
  116150. rebuildMesh(reset?: boolean): SolidParticleSystem;
  116151. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  116152. * Returns an array with the removed particles.
  116153. * 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.
  116154. * The SPS can't be empty so at least one particle needs to remain in place.
  116155. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  116156. * @param start index of the first particle to remove
  116157. * @param end index of the last particle to remove (included)
  116158. * @returns an array populated with the removed particles
  116159. */
  116160. removeParticles(start: number, end: number): SolidParticle[];
  116161. /**
  116162. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  116163. * @param solidParticleArray an array populated with Solid Particles objects
  116164. * @returns the SPS
  116165. */
  116166. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  116167. /**
  116168. * Creates a new particle and modifies the SPS mesh geometry :
  116169. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  116170. * - calls _addParticle() to populate the particle array
  116171. * factorized code from addShape() and insertParticlesFromArray()
  116172. * @param idx particle index in the particles array
  116173. * @param i particle index in its shape
  116174. * @param modelShape particle ModelShape object
  116175. * @param shape shape vertex array
  116176. * @param meshInd shape indices array
  116177. * @param meshUV shape uv array
  116178. * @param meshCol shape color array
  116179. * @param meshNor shape normals array
  116180. * @param bbInfo shape bounding info
  116181. * @param storage target particle storage
  116182. * @options addShape() passed options
  116183. * @hidden
  116184. */
  116185. private _insertNewParticle;
  116186. /**
  116187. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  116188. * This method calls `updateParticle()` for each particle of the SPS.
  116189. * For an animated SPS, it is usually called within the render loop.
  116190. * 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.
  116191. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  116192. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  116193. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  116194. * @returns the SPS.
  116195. */
  116196. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  116197. /**
  116198. * Disposes the SPS.
  116199. */
  116200. dispose(): void;
  116201. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  116202. * idx is the particle index in the SPS
  116203. * faceId is the picked face index counted within this particle.
  116204. * Returns null if the pickInfo can't identify a picked particle.
  116205. * @param pickingInfo (PickingInfo object)
  116206. * @returns {idx: number, faceId: number} or null
  116207. */
  116208. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  116209. idx: number;
  116210. faceId: number;
  116211. }>;
  116212. /**
  116213. * Returns a SolidParticle object from its identifier : particle.id
  116214. * @param id (integer) the particle Id
  116215. * @returns the searched particle or null if not found in the SPS.
  116216. */
  116217. getParticleById(id: number): Nullable<SolidParticle>;
  116218. /**
  116219. * Returns a new array populated with the particles having the passed shapeId.
  116220. * @param shapeId (integer) the shape identifier
  116221. * @returns a new solid particle array
  116222. */
  116223. getParticlesByShapeId(shapeId: number): SolidParticle[];
  116224. /**
  116225. * Populates the passed array "ref" with the particles having the passed shapeId.
  116226. * @param shapeId the shape identifier
  116227. * @returns the SPS
  116228. * @param ref
  116229. */
  116230. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  116231. /**
  116232. * Computes the required SubMeshes according the materials assigned to the particles.
  116233. * @returns the solid particle system.
  116234. * Does nothing if called before the SPS mesh is built.
  116235. */
  116236. computeSubMeshes(): SolidParticleSystem;
  116237. /**
  116238. * Sorts the solid particles by material when MultiMaterial is enabled.
  116239. * Updates the indices32 array.
  116240. * Updates the indicesByMaterial array.
  116241. * Updates the mesh indices array.
  116242. * @returns the SPS
  116243. * @hidden
  116244. */
  116245. private _sortParticlesByMaterial;
  116246. /**
  116247. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  116248. * @hidden
  116249. */
  116250. private _setMaterialIndexesById;
  116251. /**
  116252. * Returns an array with unique values of Materials from the passed array
  116253. * @param array the material array to be checked and filtered
  116254. * @hidden
  116255. */
  116256. private _filterUniqueMaterialId;
  116257. /**
  116258. * Sets a new Standard Material as _defaultMaterial if not already set.
  116259. * @hidden
  116260. */
  116261. private _setDefaultMaterial;
  116262. /**
  116263. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  116264. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116265. * @returns the SPS.
  116266. */
  116267. refreshVisibleSize(): SolidParticleSystem;
  116268. /**
  116269. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  116270. * @param size the size (float) of the visibility box
  116271. * note : this doesn't lock the SPS mesh bounding box.
  116272. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116273. */
  116274. setVisibilityBox(size: number): void;
  116275. /**
  116276. * Gets whether the SPS as always visible or not
  116277. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116278. */
  116279. get isAlwaysVisible(): boolean;
  116280. /**
  116281. * Sets the SPS as always visible or not
  116282. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116283. */
  116284. set isAlwaysVisible(val: boolean);
  116285. /**
  116286. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116287. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116288. */
  116289. set isVisibilityBoxLocked(val: boolean);
  116290. /**
  116291. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116292. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116293. */
  116294. get isVisibilityBoxLocked(): boolean;
  116295. /**
  116296. * Tells to `setParticles()` to compute the particle rotations or not.
  116297. * Default value : true. The SPS is faster when it's set to false.
  116298. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116299. */
  116300. set computeParticleRotation(val: boolean);
  116301. /**
  116302. * Tells to `setParticles()` to compute the particle colors or not.
  116303. * Default value : true. The SPS is faster when it's set to false.
  116304. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116305. */
  116306. set computeParticleColor(val: boolean);
  116307. set computeParticleTexture(val: boolean);
  116308. /**
  116309. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  116310. * Default value : false. The SPS is faster when it's set to false.
  116311. * Note : the particle custom vertex positions aren't stored values.
  116312. */
  116313. set computeParticleVertex(val: boolean);
  116314. /**
  116315. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  116316. */
  116317. set computeBoundingBox(val: boolean);
  116318. /**
  116319. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  116320. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116321. * Default : `true`
  116322. */
  116323. set depthSortParticles(val: boolean);
  116324. /**
  116325. * Gets if `setParticles()` computes the particle rotations or not.
  116326. * Default value : true. The SPS is faster when it's set to false.
  116327. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116328. */
  116329. get computeParticleRotation(): boolean;
  116330. /**
  116331. * Gets if `setParticles()` computes the particle colors or not.
  116332. * Default value : true. The SPS is faster when it's set to false.
  116333. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116334. */
  116335. get computeParticleColor(): boolean;
  116336. /**
  116337. * Gets if `setParticles()` computes the particle textures or not.
  116338. * Default value : true. The SPS is faster when it's set to false.
  116339. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  116340. */
  116341. get computeParticleTexture(): boolean;
  116342. /**
  116343. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  116344. * Default value : false. The SPS is faster when it's set to false.
  116345. * Note : the particle custom vertex positions aren't stored values.
  116346. */
  116347. get computeParticleVertex(): boolean;
  116348. /**
  116349. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  116350. */
  116351. get computeBoundingBox(): boolean;
  116352. /**
  116353. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  116354. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116355. * Default : `true`
  116356. */
  116357. get depthSortParticles(): boolean;
  116358. /**
  116359. * Gets if the SPS is created as expandable at construction time.
  116360. * Default : `false`
  116361. */
  116362. get expandable(): boolean;
  116363. /**
  116364. * Gets if the SPS supports the Multi Materials
  116365. */
  116366. get multimaterialEnabled(): boolean;
  116367. /**
  116368. * Gets if the SPS uses the model materials for its own multimaterial.
  116369. */
  116370. get useModelMaterial(): boolean;
  116371. /**
  116372. * The SPS used material array.
  116373. */
  116374. get materials(): Material[];
  116375. /**
  116376. * Sets the SPS MultiMaterial from the passed materials.
  116377. * Note : the passed array is internally copied and not used then by reference.
  116378. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  116379. */
  116380. setMultiMaterial(materials: Material[]): void;
  116381. /**
  116382. * The SPS computed multimaterial object
  116383. */
  116384. get multimaterial(): MultiMaterial;
  116385. set multimaterial(mm: MultiMaterial);
  116386. /**
  116387. * If the subMeshes must be updated on the next call to setParticles()
  116388. */
  116389. get autoUpdateSubMeshes(): boolean;
  116390. set autoUpdateSubMeshes(val: boolean);
  116391. /**
  116392. * This function does nothing. It may be overwritten to set all the particle first values.
  116393. * The SPS doesn't call this function, you may have to call it by your own.
  116394. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116395. */
  116396. initParticles(): void;
  116397. /**
  116398. * This function does nothing. It may be overwritten to recycle a particle.
  116399. * The SPS doesn't call this function, you may have to call it by your own.
  116400. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116401. * @param particle The particle to recycle
  116402. * @returns the recycled particle
  116403. */
  116404. recycleParticle(particle: SolidParticle): SolidParticle;
  116405. /**
  116406. * Updates a particle : this function should be overwritten by the user.
  116407. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  116408. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116409. * @example : just set a particle position or velocity and recycle conditions
  116410. * @param particle The particle to update
  116411. * @returns the updated particle
  116412. */
  116413. updateParticle(particle: SolidParticle): SolidParticle;
  116414. /**
  116415. * Updates a vertex of a particle : it can be overwritten by the user.
  116416. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  116417. * @param particle the current particle
  116418. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  116419. * @param pt the index of the current vertex in the particle shape
  116420. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  116421. * @example : just set a vertex particle position or color
  116422. * @returns the sps
  116423. */
  116424. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  116425. /**
  116426. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  116427. * This does nothing and may be overwritten by the user.
  116428. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116429. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116430. * @param update the boolean update value actually passed to setParticles()
  116431. */
  116432. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116433. /**
  116434. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  116435. * This will be passed three parameters.
  116436. * This does nothing and may be overwritten by the user.
  116437. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116438. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116439. * @param update the boolean update value actually passed to setParticles()
  116440. */
  116441. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116442. }
  116443. }
  116444. declare module BABYLON {
  116445. /**
  116446. * Represents one particle of a solid particle system.
  116447. */
  116448. export class SolidParticle {
  116449. /**
  116450. * particle global index
  116451. */
  116452. idx: number;
  116453. /**
  116454. * particle identifier
  116455. */
  116456. id: number;
  116457. /**
  116458. * The color of the particle
  116459. */
  116460. color: Nullable<Color4>;
  116461. /**
  116462. * The world space position of the particle.
  116463. */
  116464. position: Vector3;
  116465. /**
  116466. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  116467. */
  116468. rotation: Vector3;
  116469. /**
  116470. * The world space rotation quaternion of the particle.
  116471. */
  116472. rotationQuaternion: Nullable<Quaternion>;
  116473. /**
  116474. * The scaling of the particle.
  116475. */
  116476. scaling: Vector3;
  116477. /**
  116478. * The uvs of the particle.
  116479. */
  116480. uvs: Vector4;
  116481. /**
  116482. * The current speed of the particle.
  116483. */
  116484. velocity: Vector3;
  116485. /**
  116486. * The pivot point in the particle local space.
  116487. */
  116488. pivot: Vector3;
  116489. /**
  116490. * Must the particle be translated from its pivot point in its local space ?
  116491. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  116492. * Default : false
  116493. */
  116494. translateFromPivot: boolean;
  116495. /**
  116496. * Is the particle active or not ?
  116497. */
  116498. alive: boolean;
  116499. /**
  116500. * Is the particle visible or not ?
  116501. */
  116502. isVisible: boolean;
  116503. /**
  116504. * Index of this particle in the global "positions" array (Internal use)
  116505. * @hidden
  116506. */
  116507. _pos: number;
  116508. /**
  116509. * @hidden Index of this particle in the global "indices" array (Internal use)
  116510. */
  116511. _ind: number;
  116512. /**
  116513. * @hidden ModelShape of this particle (Internal use)
  116514. */
  116515. _model: ModelShape;
  116516. /**
  116517. * ModelShape id of this particle
  116518. */
  116519. shapeId: number;
  116520. /**
  116521. * Index of the particle in its shape id
  116522. */
  116523. idxInShape: number;
  116524. /**
  116525. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  116526. */
  116527. _modelBoundingInfo: BoundingInfo;
  116528. /**
  116529. * @hidden Particle BoundingInfo object (Internal use)
  116530. */
  116531. _boundingInfo: BoundingInfo;
  116532. /**
  116533. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  116534. */
  116535. _sps: SolidParticleSystem;
  116536. /**
  116537. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  116538. */
  116539. _stillInvisible: boolean;
  116540. /**
  116541. * @hidden Last computed particle rotation matrix
  116542. */
  116543. _rotationMatrix: number[];
  116544. /**
  116545. * Parent particle Id, if any.
  116546. * Default null.
  116547. */
  116548. parentId: Nullable<number>;
  116549. /**
  116550. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  116551. */
  116552. materialIndex: Nullable<number>;
  116553. /**
  116554. * Custom object or properties.
  116555. */
  116556. props: Nullable<any>;
  116557. /**
  116558. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  116559. * The possible values are :
  116560. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116561. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116562. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116563. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116564. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116565. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  116566. * */
  116567. cullingStrategy: number;
  116568. /**
  116569. * @hidden Internal global position in the SPS.
  116570. */
  116571. _globalPosition: Vector3;
  116572. /**
  116573. * Creates a Solid Particle object.
  116574. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  116575. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  116576. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  116577. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  116578. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  116579. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  116580. * @param shapeId (integer) is the model shape identifier in the SPS.
  116581. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  116582. * @param sps defines the sps it is associated to
  116583. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  116584. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  116585. */
  116586. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  116587. /**
  116588. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  116589. * @param target the particle target
  116590. * @returns the current particle
  116591. */
  116592. copyToRef(target: SolidParticle): SolidParticle;
  116593. /**
  116594. * Legacy support, changed scale to scaling
  116595. */
  116596. get scale(): Vector3;
  116597. /**
  116598. * Legacy support, changed scale to scaling
  116599. */
  116600. set scale(scale: Vector3);
  116601. /**
  116602. * Legacy support, changed quaternion to rotationQuaternion
  116603. */
  116604. get quaternion(): Nullable<Quaternion>;
  116605. /**
  116606. * Legacy support, changed quaternion to rotationQuaternion
  116607. */
  116608. set quaternion(q: Nullable<Quaternion>);
  116609. /**
  116610. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  116611. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  116612. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  116613. * @returns true if it intersects
  116614. */
  116615. intersectsMesh(target: Mesh | SolidParticle): boolean;
  116616. /**
  116617. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  116618. * A particle is in the frustum if its bounding box intersects the frustum
  116619. * @param frustumPlanes defines the frustum to test
  116620. * @returns true if the particle is in the frustum planes
  116621. */
  116622. isInFrustum(frustumPlanes: Plane[]): boolean;
  116623. /**
  116624. * get the rotation matrix of the particle
  116625. * @hidden
  116626. */
  116627. getRotationMatrix(m: Matrix): void;
  116628. }
  116629. /**
  116630. * Represents the shape of the model used by one particle of a solid particle system.
  116631. * SPS internal tool, don't use it manually.
  116632. */
  116633. export class ModelShape {
  116634. /**
  116635. * The shape id
  116636. * @hidden
  116637. */
  116638. shapeID: number;
  116639. /**
  116640. * flat array of model positions (internal use)
  116641. * @hidden
  116642. */
  116643. _shape: Vector3[];
  116644. /**
  116645. * flat array of model UVs (internal use)
  116646. * @hidden
  116647. */
  116648. _shapeUV: number[];
  116649. /**
  116650. * color array of the model
  116651. * @hidden
  116652. */
  116653. _shapeColors: number[];
  116654. /**
  116655. * indices array of the model
  116656. * @hidden
  116657. */
  116658. _indices: number[];
  116659. /**
  116660. * normals array of the model
  116661. * @hidden
  116662. */
  116663. _normals: number[];
  116664. /**
  116665. * length of the shape in the model indices array (internal use)
  116666. * @hidden
  116667. */
  116668. _indicesLength: number;
  116669. /**
  116670. * Custom position function (internal use)
  116671. * @hidden
  116672. */
  116673. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  116674. /**
  116675. * Custom vertex function (internal use)
  116676. * @hidden
  116677. */
  116678. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  116679. /**
  116680. * Model material (internal use)
  116681. * @hidden
  116682. */
  116683. _material: Nullable<Material>;
  116684. /**
  116685. * 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.
  116686. * SPS internal tool, don't use it manually.
  116687. * @hidden
  116688. */
  116689. 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>);
  116690. }
  116691. /**
  116692. * Represents a Depth Sorted Particle in the solid particle system.
  116693. * @hidden
  116694. */
  116695. export class DepthSortedParticle {
  116696. /**
  116697. * Particle index
  116698. */
  116699. idx: number;
  116700. /**
  116701. * Index of the particle in the "indices" array
  116702. */
  116703. ind: number;
  116704. /**
  116705. * Length of the particle shape in the "indices" array
  116706. */
  116707. indicesLength: number;
  116708. /**
  116709. * Squared distance from the particle to the camera
  116710. */
  116711. sqDistance: number;
  116712. /**
  116713. * Material index when used with MultiMaterials
  116714. */
  116715. materialIndex: number;
  116716. /**
  116717. * Creates a new sorted particle
  116718. * @param materialIndex
  116719. */
  116720. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  116721. }
  116722. /**
  116723. * Represents a solid particle vertex
  116724. */
  116725. export class SolidParticleVertex {
  116726. /**
  116727. * Vertex position
  116728. */
  116729. position: Vector3;
  116730. /**
  116731. * Vertex color
  116732. */
  116733. color: Color4;
  116734. /**
  116735. * Vertex UV
  116736. */
  116737. uv: Vector2;
  116738. /**
  116739. * Creates a new solid particle vertex
  116740. */
  116741. constructor();
  116742. /** Vertex x coordinate */
  116743. get x(): number;
  116744. set x(val: number);
  116745. /** Vertex y coordinate */
  116746. get y(): number;
  116747. set y(val: number);
  116748. /** Vertex z coordinate */
  116749. get z(): number;
  116750. set z(val: number);
  116751. }
  116752. }
  116753. declare module BABYLON {
  116754. /**
  116755. * @hidden
  116756. */
  116757. export class _MeshCollisionData {
  116758. _checkCollisions: boolean;
  116759. _collisionMask: number;
  116760. _collisionGroup: number;
  116761. _surroundingMeshes: Nullable<AbstractMesh[]>;
  116762. _collider: Nullable<Collider>;
  116763. _oldPositionForCollisions: Vector3;
  116764. _diffPositionForCollisions: Vector3;
  116765. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  116766. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  116767. _collisionResponse: boolean;
  116768. }
  116769. }
  116770. declare module BABYLON {
  116771. /** @hidden */
  116772. class _FacetDataStorage {
  116773. facetPositions: Vector3[];
  116774. facetNormals: Vector3[];
  116775. facetPartitioning: number[][];
  116776. facetNb: number;
  116777. partitioningSubdivisions: number;
  116778. partitioningBBoxRatio: number;
  116779. facetDataEnabled: boolean;
  116780. facetParameters: any;
  116781. bbSize: Vector3;
  116782. subDiv: {
  116783. max: number;
  116784. X: number;
  116785. Y: number;
  116786. Z: number;
  116787. };
  116788. facetDepthSort: boolean;
  116789. facetDepthSortEnabled: boolean;
  116790. depthSortedIndices: IndicesArray;
  116791. depthSortedFacets: {
  116792. ind: number;
  116793. sqDistance: number;
  116794. }[];
  116795. facetDepthSortFunction: (f1: {
  116796. ind: number;
  116797. sqDistance: number;
  116798. }, f2: {
  116799. ind: number;
  116800. sqDistance: number;
  116801. }) => number;
  116802. facetDepthSortFrom: Vector3;
  116803. facetDepthSortOrigin: Vector3;
  116804. invertedMatrix: Matrix;
  116805. }
  116806. /**
  116807. * @hidden
  116808. **/
  116809. class _InternalAbstractMeshDataInfo {
  116810. _hasVertexAlpha: boolean;
  116811. _useVertexColors: boolean;
  116812. _numBoneInfluencers: number;
  116813. _applyFog: boolean;
  116814. _receiveShadows: boolean;
  116815. _facetData: _FacetDataStorage;
  116816. _visibility: number;
  116817. _skeleton: Nullable<Skeleton>;
  116818. _layerMask: number;
  116819. _computeBonesUsingShaders: boolean;
  116820. _isActive: boolean;
  116821. _onlyForInstances: boolean;
  116822. _isActiveIntermediate: boolean;
  116823. _onlyForInstancesIntermediate: boolean;
  116824. _actAsRegularMesh: boolean;
  116825. _currentLOD: Nullable<AbstractMesh>;
  116826. _currentLODIsUpToDate: boolean;
  116827. }
  116828. /**
  116829. * Class used to store all common mesh properties
  116830. */
  116831. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116832. /** No occlusion */
  116833. static OCCLUSION_TYPE_NONE: number;
  116834. /** Occlusion set to optimisitic */
  116835. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116836. /** Occlusion set to strict */
  116837. static OCCLUSION_TYPE_STRICT: number;
  116838. /** Use an accurante occlusion algorithm */
  116839. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116840. /** Use a conservative occlusion algorithm */
  116841. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116842. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116843. * Test order :
  116844. * Is the bounding sphere outside the frustum ?
  116845. * If not, are the bounding box vertices outside the frustum ?
  116846. * It not, then the cullable object is in the frustum.
  116847. */
  116848. static readonly CULLINGSTRATEGY_STANDARD: number;
  116849. /** Culling strategy : Bounding Sphere Only.
  116850. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116851. * It's also less accurate than the standard because some not visible objects can still be selected.
  116852. * Test : is the bounding sphere outside the frustum ?
  116853. * If not, then the cullable object is in the frustum.
  116854. */
  116855. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116856. /** Culling strategy : Optimistic Inclusion.
  116857. * This in an inclusion test first, then the standard exclusion test.
  116858. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116859. * 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.
  116860. * Anyway, it's as accurate as the standard strategy.
  116861. * Test :
  116862. * Is the cullable object bounding sphere center in the frustum ?
  116863. * If not, apply the default culling strategy.
  116864. */
  116865. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116866. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116867. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116868. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116869. * 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.
  116870. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116871. * Test :
  116872. * Is the cullable object bounding sphere center in the frustum ?
  116873. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116874. */
  116875. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116876. /**
  116877. * No billboard
  116878. */
  116879. static get BILLBOARDMODE_NONE(): number;
  116880. /** Billboard on X axis */
  116881. static get BILLBOARDMODE_X(): number;
  116882. /** Billboard on Y axis */
  116883. static get BILLBOARDMODE_Y(): number;
  116884. /** Billboard on Z axis */
  116885. static get BILLBOARDMODE_Z(): number;
  116886. /** Billboard on all axes */
  116887. static get BILLBOARDMODE_ALL(): number;
  116888. /** Billboard on using position instead of orientation */
  116889. static get BILLBOARDMODE_USE_POSITION(): number;
  116890. /** @hidden */
  116891. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116892. /**
  116893. * The culling strategy to use to check whether the mesh must be rendered or not.
  116894. * This value can be changed at any time and will be used on the next render mesh selection.
  116895. * The possible values are :
  116896. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116897. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116898. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116899. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116900. * Please read each static variable documentation to get details about the culling process.
  116901. * */
  116902. cullingStrategy: number;
  116903. /**
  116904. * Gets the number of facets in the mesh
  116905. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116906. */
  116907. get facetNb(): number;
  116908. /**
  116909. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116910. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116911. */
  116912. get partitioningSubdivisions(): number;
  116913. set partitioningSubdivisions(nb: number);
  116914. /**
  116915. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116916. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116917. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116918. */
  116919. get partitioningBBoxRatio(): number;
  116920. set partitioningBBoxRatio(ratio: number);
  116921. /**
  116922. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116923. * Works only for updatable meshes.
  116924. * Doesn't work with multi-materials
  116925. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116926. */
  116927. get mustDepthSortFacets(): boolean;
  116928. set mustDepthSortFacets(sort: boolean);
  116929. /**
  116930. * The location (Vector3) where the facet depth sort must be computed from.
  116931. * By default, the active camera position.
  116932. * Used only when facet depth sort is enabled
  116933. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116934. */
  116935. get facetDepthSortFrom(): Vector3;
  116936. set facetDepthSortFrom(location: Vector3);
  116937. /**
  116938. * gets a boolean indicating if facetData is enabled
  116939. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116940. */
  116941. get isFacetDataEnabled(): boolean;
  116942. /** @hidden */
  116943. _updateNonUniformScalingState(value: boolean): boolean;
  116944. /**
  116945. * An event triggered when this mesh collides with another one
  116946. */
  116947. onCollideObservable: Observable<AbstractMesh>;
  116948. /** Set a function to call when this mesh collides with another one */
  116949. set onCollide(callback: () => void);
  116950. /**
  116951. * An event triggered when the collision's position changes
  116952. */
  116953. onCollisionPositionChangeObservable: Observable<Vector3>;
  116954. /** Set a function to call when the collision's position changes */
  116955. set onCollisionPositionChange(callback: () => void);
  116956. /**
  116957. * An event triggered when material is changed
  116958. */
  116959. onMaterialChangedObservable: Observable<AbstractMesh>;
  116960. /**
  116961. * Gets or sets the orientation for POV movement & rotation
  116962. */
  116963. definedFacingForward: boolean;
  116964. /** @hidden */
  116965. _occlusionQuery: Nullable<WebGLQuery>;
  116966. /** @hidden */
  116967. _renderingGroup: Nullable<RenderingGroup>;
  116968. /**
  116969. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116970. */
  116971. get visibility(): number;
  116972. /**
  116973. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116974. */
  116975. set visibility(value: number);
  116976. /** Gets or sets the alpha index used to sort transparent meshes
  116977. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116978. */
  116979. alphaIndex: number;
  116980. /**
  116981. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116982. */
  116983. isVisible: boolean;
  116984. /**
  116985. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116986. */
  116987. isPickable: boolean;
  116988. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116989. showSubMeshesBoundingBox: boolean;
  116990. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116991. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116992. */
  116993. isBlocker: boolean;
  116994. /**
  116995. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116996. */
  116997. enablePointerMoveEvents: boolean;
  116998. private _renderingGroupId;
  116999. /**
  117000. * Specifies the rendering group id for this mesh (0 by default)
  117001. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  117002. */
  117003. get renderingGroupId(): number;
  117004. set renderingGroupId(value: number);
  117005. private _material;
  117006. /** Gets or sets current material */
  117007. get material(): Nullable<Material>;
  117008. set material(value: Nullable<Material>);
  117009. /**
  117010. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  117011. * @see https://doc.babylonjs.com/babylon101/shadows
  117012. */
  117013. get receiveShadows(): boolean;
  117014. set receiveShadows(value: boolean);
  117015. /** Defines color to use when rendering outline */
  117016. outlineColor: Color3;
  117017. /** Define width to use when rendering outline */
  117018. outlineWidth: number;
  117019. /** Defines color to use when rendering overlay */
  117020. overlayColor: Color3;
  117021. /** Defines alpha to use when rendering overlay */
  117022. overlayAlpha: number;
  117023. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  117024. get hasVertexAlpha(): boolean;
  117025. set hasVertexAlpha(value: boolean);
  117026. /** 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) */
  117027. get useVertexColors(): boolean;
  117028. set useVertexColors(value: boolean);
  117029. /**
  117030. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  117031. */
  117032. get computeBonesUsingShaders(): boolean;
  117033. set computeBonesUsingShaders(value: boolean);
  117034. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  117035. get numBoneInfluencers(): number;
  117036. set numBoneInfluencers(value: number);
  117037. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  117038. get applyFog(): boolean;
  117039. set applyFog(value: boolean);
  117040. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  117041. useOctreeForRenderingSelection: boolean;
  117042. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  117043. useOctreeForPicking: boolean;
  117044. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  117045. useOctreeForCollisions: boolean;
  117046. /**
  117047. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  117048. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  117049. */
  117050. get layerMask(): number;
  117051. set layerMask(value: number);
  117052. /**
  117053. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  117054. */
  117055. alwaysSelectAsActiveMesh: boolean;
  117056. /**
  117057. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  117058. */
  117059. doNotSyncBoundingInfo: boolean;
  117060. /**
  117061. * Gets or sets the current action manager
  117062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117063. */
  117064. actionManager: Nullable<AbstractActionManager>;
  117065. private _meshCollisionData;
  117066. /**
  117067. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  117068. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117069. */
  117070. ellipsoid: Vector3;
  117071. /**
  117072. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  117073. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117074. */
  117075. ellipsoidOffset: Vector3;
  117076. /**
  117077. * Gets or sets a collision mask used to mask collisions (default is -1).
  117078. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  117079. */
  117080. get collisionMask(): number;
  117081. set collisionMask(mask: number);
  117082. /**
  117083. * Gets or sets a collision response flag (default is true).
  117084. * when collisionResponse is false, events are still triggered but colliding entity has no response
  117085. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  117086. * to respond to the collision.
  117087. */
  117088. get collisionResponse(): boolean;
  117089. set collisionResponse(response: boolean);
  117090. /**
  117091. * Gets or sets the current collision group mask (-1 by default).
  117092. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  117093. */
  117094. get collisionGroup(): number;
  117095. set collisionGroup(mask: number);
  117096. /**
  117097. * Gets or sets current surrounding meshes (null by default).
  117098. *
  117099. * By default collision detection is tested against every mesh in the scene.
  117100. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  117101. * meshes will be tested for the collision.
  117102. *
  117103. * Note: if set to an empty array no collision will happen when this mesh is moved.
  117104. */
  117105. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  117106. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  117107. /**
  117108. * Defines edge width used when edgesRenderer is enabled
  117109. * @see https://www.babylonjs-playground.com/#10OJSG#13
  117110. */
  117111. edgesWidth: number;
  117112. /**
  117113. * Defines edge color used when edgesRenderer is enabled
  117114. * @see https://www.babylonjs-playground.com/#10OJSG#13
  117115. */
  117116. edgesColor: Color4;
  117117. /** @hidden */
  117118. _edgesRenderer: Nullable<IEdgesRenderer>;
  117119. /** @hidden */
  117120. _masterMesh: Nullable<AbstractMesh>;
  117121. /** @hidden */
  117122. _boundingInfo: Nullable<BoundingInfo>;
  117123. /** @hidden */
  117124. _renderId: number;
  117125. /**
  117126. * Gets or sets the list of subMeshes
  117127. * @see https://doc.babylonjs.com/how_to/multi_materials
  117128. */
  117129. subMeshes: SubMesh[];
  117130. /** @hidden */
  117131. _intersectionsInProgress: AbstractMesh[];
  117132. /** @hidden */
  117133. _unIndexed: boolean;
  117134. /** @hidden */
  117135. _lightSources: Light[];
  117136. /** Gets the list of lights affecting that mesh */
  117137. get lightSources(): Light[];
  117138. /** @hidden */
  117139. get _positions(): Nullable<Vector3[]>;
  117140. /** @hidden */
  117141. _waitingData: {
  117142. lods: Nullable<any>;
  117143. actions: Nullable<any>;
  117144. freezeWorldMatrix: Nullable<boolean>;
  117145. };
  117146. /** @hidden */
  117147. _bonesTransformMatrices: Nullable<Float32Array>;
  117148. /** @hidden */
  117149. _transformMatrixTexture: Nullable<RawTexture>;
  117150. /**
  117151. * Gets or sets a skeleton to apply skining transformations
  117152. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  117153. */
  117154. set skeleton(value: Nullable<Skeleton>);
  117155. get skeleton(): Nullable<Skeleton>;
  117156. /**
  117157. * An event triggered when the mesh is rebuilt.
  117158. */
  117159. onRebuildObservable: Observable<AbstractMesh>;
  117160. /**
  117161. * Creates a new AbstractMesh
  117162. * @param name defines the name of the mesh
  117163. * @param scene defines the hosting scene
  117164. */
  117165. constructor(name: string, scene?: Nullable<Scene>);
  117166. /**
  117167. * Returns the string "AbstractMesh"
  117168. * @returns "AbstractMesh"
  117169. */
  117170. getClassName(): string;
  117171. /**
  117172. * Gets a string representation of the current mesh
  117173. * @param fullDetails defines a boolean indicating if full details must be included
  117174. * @returns a string representation of the current mesh
  117175. */
  117176. toString(fullDetails?: boolean): string;
  117177. /**
  117178. * @hidden
  117179. */
  117180. protected _getEffectiveParent(): Nullable<Node>;
  117181. /** @hidden */
  117182. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117183. /** @hidden */
  117184. _rebuild(): void;
  117185. /** @hidden */
  117186. _resyncLightSources(): void;
  117187. /** @hidden */
  117188. _resyncLightSource(light: Light): void;
  117189. /** @hidden */
  117190. _unBindEffect(): void;
  117191. /** @hidden */
  117192. _removeLightSource(light: Light, dispose: boolean): void;
  117193. private _markSubMeshesAsDirty;
  117194. /** @hidden */
  117195. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  117196. /** @hidden */
  117197. _markSubMeshesAsAttributesDirty(): void;
  117198. /** @hidden */
  117199. _markSubMeshesAsMiscDirty(): void;
  117200. /**
  117201. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  117202. */
  117203. get scaling(): Vector3;
  117204. set scaling(newScaling: Vector3);
  117205. /**
  117206. * Returns true if the mesh is blocked. Implemented by child classes
  117207. */
  117208. get isBlocked(): boolean;
  117209. /**
  117210. * Returns the mesh itself by default. Implemented by child classes
  117211. * @param camera defines the camera to use to pick the right LOD level
  117212. * @returns the currentAbstractMesh
  117213. */
  117214. getLOD(camera: Camera): Nullable<AbstractMesh>;
  117215. /**
  117216. * Returns 0 by default. Implemented by child classes
  117217. * @returns an integer
  117218. */
  117219. getTotalVertices(): number;
  117220. /**
  117221. * Returns a positive integer : the total number of indices in this mesh geometry.
  117222. * @returns the numner of indices or zero if the mesh has no geometry.
  117223. */
  117224. getTotalIndices(): number;
  117225. /**
  117226. * Returns null by default. Implemented by child classes
  117227. * @returns null
  117228. */
  117229. getIndices(): Nullable<IndicesArray>;
  117230. /**
  117231. * Returns the array of the requested vertex data kind. Implemented by child classes
  117232. * @param kind defines the vertex data kind to use
  117233. * @returns null
  117234. */
  117235. getVerticesData(kind: string): Nullable<FloatArray>;
  117236. /**
  117237. * Sets the vertex data of the mesh geometry for the requested `kind`.
  117238. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  117239. * Note that a new underlying VertexBuffer object is created each call.
  117240. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  117241. * @param kind defines vertex data kind:
  117242. * * VertexBuffer.PositionKind
  117243. * * VertexBuffer.UVKind
  117244. * * VertexBuffer.UV2Kind
  117245. * * VertexBuffer.UV3Kind
  117246. * * VertexBuffer.UV4Kind
  117247. * * VertexBuffer.UV5Kind
  117248. * * VertexBuffer.UV6Kind
  117249. * * VertexBuffer.ColorKind
  117250. * * VertexBuffer.MatricesIndicesKind
  117251. * * VertexBuffer.MatricesIndicesExtraKind
  117252. * * VertexBuffer.MatricesWeightsKind
  117253. * * VertexBuffer.MatricesWeightsExtraKind
  117254. * @param data defines the data source
  117255. * @param updatable defines if the data must be flagged as updatable (or static)
  117256. * @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
  117257. * @returns the current mesh
  117258. */
  117259. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  117260. /**
  117261. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  117262. * If the mesh has no geometry, it is simply returned as it is.
  117263. * @param kind defines vertex data kind:
  117264. * * VertexBuffer.PositionKind
  117265. * * VertexBuffer.UVKind
  117266. * * VertexBuffer.UV2Kind
  117267. * * VertexBuffer.UV3Kind
  117268. * * VertexBuffer.UV4Kind
  117269. * * VertexBuffer.UV5Kind
  117270. * * VertexBuffer.UV6Kind
  117271. * * VertexBuffer.ColorKind
  117272. * * VertexBuffer.MatricesIndicesKind
  117273. * * VertexBuffer.MatricesIndicesExtraKind
  117274. * * VertexBuffer.MatricesWeightsKind
  117275. * * VertexBuffer.MatricesWeightsExtraKind
  117276. * @param data defines the data source
  117277. * @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
  117278. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  117279. * @returns the current mesh
  117280. */
  117281. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117282. /**
  117283. * Sets the mesh indices,
  117284. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  117285. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  117286. * @param totalVertices Defines the total number of vertices
  117287. * @returns the current mesh
  117288. */
  117289. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  117290. /**
  117291. * Gets a boolean indicating if specific vertex data is present
  117292. * @param kind defines the vertex data kind to use
  117293. * @returns true is data kind is present
  117294. */
  117295. isVerticesDataPresent(kind: string): boolean;
  117296. /**
  117297. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  117298. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  117299. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  117300. * @returns a BoundingInfo
  117301. */
  117302. getBoundingInfo(): BoundingInfo;
  117303. /**
  117304. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  117305. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  117306. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  117307. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  117308. * @returns the current mesh
  117309. */
  117310. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  117311. /**
  117312. * Overwrite the current bounding info
  117313. * @param boundingInfo defines the new bounding info
  117314. * @returns the current mesh
  117315. */
  117316. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  117317. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  117318. get useBones(): boolean;
  117319. /** @hidden */
  117320. _preActivate(): void;
  117321. /** @hidden */
  117322. _preActivateForIntermediateRendering(renderId: number): void;
  117323. /** @hidden */
  117324. _activate(renderId: number, intermediateRendering: boolean): boolean;
  117325. /** @hidden */
  117326. _postActivate(): void;
  117327. /** @hidden */
  117328. _freeze(): void;
  117329. /** @hidden */
  117330. _unFreeze(): void;
  117331. /**
  117332. * Gets the current world matrix
  117333. * @returns a Matrix
  117334. */
  117335. getWorldMatrix(): Matrix;
  117336. /** @hidden */
  117337. _getWorldMatrixDeterminant(): number;
  117338. /**
  117339. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  117340. */
  117341. get isAnInstance(): boolean;
  117342. /**
  117343. * Gets a boolean indicating if this mesh has instances
  117344. */
  117345. get hasInstances(): boolean;
  117346. /**
  117347. * Gets a boolean indicating if this mesh has thin instances
  117348. */
  117349. get hasThinInstances(): boolean;
  117350. /**
  117351. * Perform relative position change from the point of view of behind the front of the mesh.
  117352. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117353. * Supports definition of mesh facing forward or backward
  117354. * @param amountRight defines the distance on the right axis
  117355. * @param amountUp defines the distance on the up axis
  117356. * @param amountForward defines the distance on the forward axis
  117357. * @returns the current mesh
  117358. */
  117359. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  117360. /**
  117361. * Calculate relative position change from the point of view of behind the front of the mesh.
  117362. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117363. * Supports definition of mesh facing forward or backward
  117364. * @param amountRight defines the distance on the right axis
  117365. * @param amountUp defines the distance on the up axis
  117366. * @param amountForward defines the distance on the forward axis
  117367. * @returns the new displacement vector
  117368. */
  117369. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  117370. /**
  117371. * Perform relative rotation change from the point of view of behind the front of the mesh.
  117372. * Supports definition of mesh facing forward or backward
  117373. * @param flipBack defines the flip
  117374. * @param twirlClockwise defines the twirl
  117375. * @param tiltRight defines the tilt
  117376. * @returns the current mesh
  117377. */
  117378. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  117379. /**
  117380. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  117381. * Supports definition of mesh facing forward or backward.
  117382. * @param flipBack defines the flip
  117383. * @param twirlClockwise defines the twirl
  117384. * @param tiltRight defines the tilt
  117385. * @returns the new rotation vector
  117386. */
  117387. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  117388. /**
  117389. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117390. * This means the mesh underlying bounding box and sphere are recomputed.
  117391. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117392. * @returns the current mesh
  117393. */
  117394. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  117395. /** @hidden */
  117396. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  117397. /** @hidden */
  117398. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  117399. /** @hidden */
  117400. _updateBoundingInfo(): AbstractMesh;
  117401. /** @hidden */
  117402. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  117403. /** @hidden */
  117404. protected _afterComputeWorldMatrix(): void;
  117405. /** @hidden */
  117406. get _effectiveMesh(): AbstractMesh;
  117407. /**
  117408. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  117409. * A mesh is in the frustum if its bounding box intersects the frustum
  117410. * @param frustumPlanes defines the frustum to test
  117411. * @returns true if the mesh is in the frustum planes
  117412. */
  117413. isInFrustum(frustumPlanes: Plane[]): boolean;
  117414. /**
  117415. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  117416. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  117417. * @param frustumPlanes defines the frustum to test
  117418. * @returns true if the mesh is completely in the frustum planes
  117419. */
  117420. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  117421. /**
  117422. * True if the mesh intersects another mesh or a SolidParticle object
  117423. * @param mesh defines a target mesh or SolidParticle to test
  117424. * @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)
  117425. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  117426. * @returns true if there is an intersection
  117427. */
  117428. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  117429. /**
  117430. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  117431. * @param point defines the point to test
  117432. * @returns true if there is an intersection
  117433. */
  117434. intersectsPoint(point: Vector3): boolean;
  117435. /**
  117436. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  117437. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117438. */
  117439. get checkCollisions(): boolean;
  117440. set checkCollisions(collisionEnabled: boolean);
  117441. /**
  117442. * Gets Collider object used to compute collisions (not physics)
  117443. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117444. */
  117445. get collider(): Nullable<Collider>;
  117446. /**
  117447. * Move the mesh using collision engine
  117448. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117449. * @param displacement defines the requested displacement vector
  117450. * @returns the current mesh
  117451. */
  117452. moveWithCollisions(displacement: Vector3): AbstractMesh;
  117453. private _onCollisionPositionChange;
  117454. /** @hidden */
  117455. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  117456. /** @hidden */
  117457. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  117458. /** @hidden */
  117459. _checkCollision(collider: Collider): AbstractMesh;
  117460. /** @hidden */
  117461. _generatePointsArray(): boolean;
  117462. /**
  117463. * Checks if the passed Ray intersects with the mesh
  117464. * @param ray defines the ray to use
  117465. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  117466. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117467. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  117468. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  117469. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  117470. * @returns the picking info
  117471. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  117472. */
  117473. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  117474. /**
  117475. * Clones the current mesh
  117476. * @param name defines the mesh name
  117477. * @param newParent defines the new mesh parent
  117478. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  117479. * @returns the new mesh
  117480. */
  117481. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  117482. /**
  117483. * Disposes all the submeshes of the current meshnp
  117484. * @returns the current mesh
  117485. */
  117486. releaseSubMeshes(): AbstractMesh;
  117487. /**
  117488. * Releases resources associated with this abstract mesh.
  117489. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117490. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117491. */
  117492. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117493. /**
  117494. * Adds the passed mesh as a child to the current mesh
  117495. * @param mesh defines the child mesh
  117496. * @returns the current mesh
  117497. */
  117498. addChild(mesh: AbstractMesh): AbstractMesh;
  117499. /**
  117500. * Removes the passed mesh from the current mesh children list
  117501. * @param mesh defines the child mesh
  117502. * @returns the current mesh
  117503. */
  117504. removeChild(mesh: AbstractMesh): AbstractMesh;
  117505. /** @hidden */
  117506. private _initFacetData;
  117507. /**
  117508. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  117509. * This method can be called within the render loop.
  117510. * 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
  117511. * @returns the current mesh
  117512. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117513. */
  117514. updateFacetData(): AbstractMesh;
  117515. /**
  117516. * Returns the facetLocalNormals array.
  117517. * The normals are expressed in the mesh local spac
  117518. * @returns an array of Vector3
  117519. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117520. */
  117521. getFacetLocalNormals(): Vector3[];
  117522. /**
  117523. * Returns the facetLocalPositions array.
  117524. * The facet positions are expressed in the mesh local space
  117525. * @returns an array of Vector3
  117526. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117527. */
  117528. getFacetLocalPositions(): Vector3[];
  117529. /**
  117530. * Returns the facetLocalPartioning array
  117531. * @returns an array of array of numbers
  117532. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117533. */
  117534. getFacetLocalPartitioning(): number[][];
  117535. /**
  117536. * Returns the i-th facet position in the world system.
  117537. * This method allocates a new Vector3 per call
  117538. * @param i defines the facet index
  117539. * @returns a new Vector3
  117540. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117541. */
  117542. getFacetPosition(i: number): Vector3;
  117543. /**
  117544. * Sets the reference Vector3 with the i-th facet position in the world system
  117545. * @param i defines the facet index
  117546. * @param ref defines the target vector
  117547. * @returns the current mesh
  117548. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117549. */
  117550. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  117551. /**
  117552. * Returns the i-th facet normal in the world system.
  117553. * This method allocates a new Vector3 per call
  117554. * @param i defines the facet index
  117555. * @returns a new Vector3
  117556. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117557. */
  117558. getFacetNormal(i: number): Vector3;
  117559. /**
  117560. * Sets the reference Vector3 with the i-th facet normal in the world system
  117561. * @param i defines the facet index
  117562. * @param ref defines the target vector
  117563. * @returns the current mesh
  117564. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117565. */
  117566. getFacetNormalToRef(i: number, ref: Vector3): this;
  117567. /**
  117568. * 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)
  117569. * @param x defines x coordinate
  117570. * @param y defines y coordinate
  117571. * @param z defines z coordinate
  117572. * @returns the array of facet indexes
  117573. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117574. */
  117575. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  117576. /**
  117577. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  117578. * @param projected sets as the (x,y,z) world projection on the facet
  117579. * @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
  117580. * @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
  117581. * @param x defines x coordinate
  117582. * @param y defines y coordinate
  117583. * @param z defines z coordinate
  117584. * @returns the face index if found (or null instead)
  117585. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117586. */
  117587. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117588. /**
  117589. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  117590. * @param projected sets as the (x,y,z) local projection on the facet
  117591. * @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
  117592. * @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
  117593. * @param x defines x coordinate
  117594. * @param y defines y coordinate
  117595. * @param z defines z coordinate
  117596. * @returns the face index if found (or null instead)
  117597. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117598. */
  117599. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117600. /**
  117601. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  117602. * @returns the parameters
  117603. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117604. */
  117605. getFacetDataParameters(): any;
  117606. /**
  117607. * Disables the feature FacetData and frees the related memory
  117608. * @returns the current mesh
  117609. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117610. */
  117611. disableFacetData(): AbstractMesh;
  117612. /**
  117613. * Updates the AbstractMesh indices array
  117614. * @param indices defines the data source
  117615. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117616. * @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)
  117617. * @returns the current mesh
  117618. */
  117619. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117620. /**
  117621. * Creates new normals data for the mesh
  117622. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  117623. * @returns the current mesh
  117624. */
  117625. createNormals(updatable: boolean): AbstractMesh;
  117626. /**
  117627. * Align the mesh with a normal
  117628. * @param normal defines the normal to use
  117629. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  117630. * @returns the current mesh
  117631. */
  117632. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  117633. /** @hidden */
  117634. _checkOcclusionQuery(): boolean;
  117635. /**
  117636. * Disables the mesh edge rendering mode
  117637. * @returns the currentAbstractMesh
  117638. */
  117639. disableEdgesRendering(): AbstractMesh;
  117640. /**
  117641. * Enables the edge rendering mode on the mesh.
  117642. * This mode makes the mesh edges visible
  117643. * @param epsilon defines the maximal distance between two angles to detect a face
  117644. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  117645. * @param options options to the edge renderer
  117646. * @returns the currentAbstractMesh
  117647. * @see https://www.babylonjs-playground.com/#19O9TU#0
  117648. */
  117649. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  117650. /**
  117651. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  117652. * @returns an array of particle systems in the scene that use the mesh as an emitter
  117653. */
  117654. getConnectedParticleSystems(): IParticleSystem[];
  117655. }
  117656. }
  117657. declare module BABYLON {
  117658. /**
  117659. * Interface used to define ActionEvent
  117660. */
  117661. export interface IActionEvent {
  117662. /** The mesh or sprite that triggered the action */
  117663. source: any;
  117664. /** The X mouse cursor position at the time of the event */
  117665. pointerX: number;
  117666. /** The Y mouse cursor position at the time of the event */
  117667. pointerY: number;
  117668. /** The mesh that is currently pointed at (can be null) */
  117669. meshUnderPointer: Nullable<AbstractMesh>;
  117670. /** the original (browser) event that triggered the ActionEvent */
  117671. sourceEvent?: any;
  117672. /** additional data for the event */
  117673. additionalData?: any;
  117674. }
  117675. /**
  117676. * ActionEvent is the event being sent when an action is triggered.
  117677. */
  117678. export class ActionEvent implements IActionEvent {
  117679. /** The mesh or sprite that triggered the action */
  117680. source: any;
  117681. /** The X mouse cursor position at the time of the event */
  117682. pointerX: number;
  117683. /** The Y mouse cursor position at the time of the event */
  117684. pointerY: number;
  117685. /** The mesh that is currently pointed at (can be null) */
  117686. meshUnderPointer: Nullable<AbstractMesh>;
  117687. /** the original (browser) event that triggered the ActionEvent */
  117688. sourceEvent?: any;
  117689. /** additional data for the event */
  117690. additionalData?: any;
  117691. /**
  117692. * Creates a new ActionEvent
  117693. * @param source The mesh or sprite that triggered the action
  117694. * @param pointerX The X mouse cursor position at the time of the event
  117695. * @param pointerY The Y mouse cursor position at the time of the event
  117696. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  117697. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  117698. * @param additionalData additional data for the event
  117699. */
  117700. constructor(
  117701. /** The mesh or sprite that triggered the action */
  117702. source: any,
  117703. /** The X mouse cursor position at the time of the event */
  117704. pointerX: number,
  117705. /** The Y mouse cursor position at the time of the event */
  117706. pointerY: number,
  117707. /** The mesh that is currently pointed at (can be null) */
  117708. meshUnderPointer: Nullable<AbstractMesh>,
  117709. /** the original (browser) event that triggered the ActionEvent */
  117710. sourceEvent?: any,
  117711. /** additional data for the event */
  117712. additionalData?: any);
  117713. /**
  117714. * Helper function to auto-create an ActionEvent from a source mesh.
  117715. * @param source The source mesh that triggered the event
  117716. * @param evt The original (browser) event
  117717. * @param additionalData additional data for the event
  117718. * @returns the new ActionEvent
  117719. */
  117720. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  117721. /**
  117722. * Helper function to auto-create an ActionEvent from a source sprite
  117723. * @param source The source sprite that triggered the event
  117724. * @param scene Scene associated with the sprite
  117725. * @param evt The original (browser) event
  117726. * @param additionalData additional data for the event
  117727. * @returns the new ActionEvent
  117728. */
  117729. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  117730. /**
  117731. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  117732. * @param scene the scene where the event occurred
  117733. * @param evt The original (browser) event
  117734. * @returns the new ActionEvent
  117735. */
  117736. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  117737. /**
  117738. * Helper function to auto-create an ActionEvent from a primitive
  117739. * @param prim defines the target primitive
  117740. * @param pointerPos defines the pointer position
  117741. * @param evt The original (browser) event
  117742. * @param additionalData additional data for the event
  117743. * @returns the new ActionEvent
  117744. */
  117745. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  117746. }
  117747. }
  117748. declare module BABYLON {
  117749. /**
  117750. * Abstract class used to decouple action Manager from scene and meshes.
  117751. * Do not instantiate.
  117752. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117753. */
  117754. export abstract class AbstractActionManager implements IDisposable {
  117755. /** Gets the list of active triggers */
  117756. static Triggers: {
  117757. [key: string]: number;
  117758. };
  117759. /** Gets the cursor to use when hovering items */
  117760. hoverCursor: string;
  117761. /** Gets the list of actions */
  117762. actions: IAction[];
  117763. /**
  117764. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  117765. */
  117766. isRecursive: boolean;
  117767. /**
  117768. * Releases all associated resources
  117769. */
  117770. abstract dispose(): void;
  117771. /**
  117772. * Does this action manager has pointer triggers
  117773. */
  117774. abstract get hasPointerTriggers(): boolean;
  117775. /**
  117776. * Does this action manager has pick triggers
  117777. */
  117778. abstract get hasPickTriggers(): boolean;
  117779. /**
  117780. * Process a specific trigger
  117781. * @param trigger defines the trigger to process
  117782. * @param evt defines the event details to be processed
  117783. */
  117784. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  117785. /**
  117786. * Does this action manager handles actions of any of the given triggers
  117787. * @param triggers defines the triggers to be tested
  117788. * @return a boolean indicating whether one (or more) of the triggers is handled
  117789. */
  117790. abstract hasSpecificTriggers(triggers: number[]): boolean;
  117791. /**
  117792. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  117793. * speed.
  117794. * @param triggerA defines the trigger to be tested
  117795. * @param triggerB defines the trigger to be tested
  117796. * @return a boolean indicating whether one (or more) of the triggers is handled
  117797. */
  117798. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  117799. /**
  117800. * Does this action manager handles actions of a given trigger
  117801. * @param trigger defines the trigger to be tested
  117802. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  117803. * @return whether the trigger is handled
  117804. */
  117805. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  117806. /**
  117807. * Serialize this manager to a JSON object
  117808. * @param name defines the property name to store this manager
  117809. * @returns a JSON representation of this manager
  117810. */
  117811. abstract serialize(name: string): any;
  117812. /**
  117813. * Registers an action to this action manager
  117814. * @param action defines the action to be registered
  117815. * @return the action amended (prepared) after registration
  117816. */
  117817. abstract registerAction(action: IAction): Nullable<IAction>;
  117818. /**
  117819. * Unregisters an action to this action manager
  117820. * @param action defines the action to be unregistered
  117821. * @return a boolean indicating whether the action has been unregistered
  117822. */
  117823. abstract unregisterAction(action: IAction): Boolean;
  117824. /**
  117825. * Does exist one action manager with at least one trigger
  117826. **/
  117827. static get HasTriggers(): boolean;
  117828. /**
  117829. * Does exist one action manager with at least one pick trigger
  117830. **/
  117831. static get HasPickTriggers(): boolean;
  117832. /**
  117833. * Does exist one action manager that handles actions of a given trigger
  117834. * @param trigger defines the trigger to be tested
  117835. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117836. **/
  117837. static HasSpecificTrigger(trigger: number): boolean;
  117838. }
  117839. }
  117840. declare module BABYLON {
  117841. /**
  117842. * Defines how a node can be built from a string name.
  117843. */
  117844. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117845. /**
  117846. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117847. */
  117848. export class Node implements IBehaviorAware<Node> {
  117849. /** @hidden */
  117850. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117851. private static _NodeConstructors;
  117852. /**
  117853. * Add a new node constructor
  117854. * @param type defines the type name of the node to construct
  117855. * @param constructorFunc defines the constructor function
  117856. */
  117857. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117858. /**
  117859. * Returns a node constructor based on type name
  117860. * @param type defines the type name
  117861. * @param name defines the new node name
  117862. * @param scene defines the hosting scene
  117863. * @param options defines optional options to transmit to constructors
  117864. * @returns the new constructor or null
  117865. */
  117866. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117867. /**
  117868. * Gets or sets the name of the node
  117869. */
  117870. name: string;
  117871. /**
  117872. * Gets or sets the id of the node
  117873. */
  117874. id: string;
  117875. /**
  117876. * Gets or sets the unique id of the node
  117877. */
  117878. uniqueId: number;
  117879. /**
  117880. * Gets or sets a string used to store user defined state for the node
  117881. */
  117882. state: string;
  117883. /**
  117884. * Gets or sets an object used to store user defined information for the node
  117885. */
  117886. metadata: any;
  117887. /**
  117888. * For internal use only. Please do not use.
  117889. */
  117890. reservedDataStore: any;
  117891. /**
  117892. * List of inspectable custom properties (used by the Inspector)
  117893. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117894. */
  117895. inspectableCustomProperties: IInspectable[];
  117896. private _doNotSerialize;
  117897. /**
  117898. * Gets or sets a boolean used to define if the node must be serialized
  117899. */
  117900. get doNotSerialize(): boolean;
  117901. set doNotSerialize(value: boolean);
  117902. /** @hidden */
  117903. _isDisposed: boolean;
  117904. /**
  117905. * Gets a list of Animations associated with the node
  117906. */
  117907. animations: Animation[];
  117908. protected _ranges: {
  117909. [name: string]: Nullable<AnimationRange>;
  117910. };
  117911. /**
  117912. * Callback raised when the node is ready to be used
  117913. */
  117914. onReady: Nullable<(node: Node) => void>;
  117915. private _isEnabled;
  117916. private _isParentEnabled;
  117917. private _isReady;
  117918. /** @hidden */
  117919. _currentRenderId: number;
  117920. private _parentUpdateId;
  117921. /** @hidden */
  117922. _childUpdateId: number;
  117923. /** @hidden */
  117924. _waitingParentId: Nullable<string>;
  117925. /** @hidden */
  117926. _scene: Scene;
  117927. /** @hidden */
  117928. _cache: any;
  117929. private _parentNode;
  117930. private _children;
  117931. /** @hidden */
  117932. _worldMatrix: Matrix;
  117933. /** @hidden */
  117934. _worldMatrixDeterminant: number;
  117935. /** @hidden */
  117936. _worldMatrixDeterminantIsDirty: boolean;
  117937. /** @hidden */
  117938. private _sceneRootNodesIndex;
  117939. /**
  117940. * Gets a boolean indicating if the node has been disposed
  117941. * @returns true if the node was disposed
  117942. */
  117943. isDisposed(): boolean;
  117944. /**
  117945. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117946. * @see https://doc.babylonjs.com/how_to/parenting
  117947. */
  117948. set parent(parent: Nullable<Node>);
  117949. get parent(): Nullable<Node>;
  117950. /** @hidden */
  117951. _addToSceneRootNodes(): void;
  117952. /** @hidden */
  117953. _removeFromSceneRootNodes(): void;
  117954. private _animationPropertiesOverride;
  117955. /**
  117956. * Gets or sets the animation properties override
  117957. */
  117958. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117959. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117960. /**
  117961. * Gets a string identifying the name of the class
  117962. * @returns "Node" string
  117963. */
  117964. getClassName(): string;
  117965. /** @hidden */
  117966. readonly _isNode: boolean;
  117967. /**
  117968. * An event triggered when the mesh is disposed
  117969. */
  117970. onDisposeObservable: Observable<Node>;
  117971. private _onDisposeObserver;
  117972. /**
  117973. * Sets a callback that will be raised when the node will be disposed
  117974. */
  117975. set onDispose(callback: () => void);
  117976. /**
  117977. * Creates a new Node
  117978. * @param name the name and id to be given to this node
  117979. * @param scene the scene this node will be added to
  117980. */
  117981. constructor(name: string, scene?: Nullable<Scene>);
  117982. /**
  117983. * Gets the scene of the node
  117984. * @returns a scene
  117985. */
  117986. getScene(): Scene;
  117987. /**
  117988. * Gets the engine of the node
  117989. * @returns a Engine
  117990. */
  117991. getEngine(): Engine;
  117992. private _behaviors;
  117993. /**
  117994. * Attach a behavior to the node
  117995. * @see https://doc.babylonjs.com/features/behaviour
  117996. * @param behavior defines the behavior to attach
  117997. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117998. * @returns the current Node
  117999. */
  118000. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  118001. /**
  118002. * Remove an attached behavior
  118003. * @see https://doc.babylonjs.com/features/behaviour
  118004. * @param behavior defines the behavior to attach
  118005. * @returns the current Node
  118006. */
  118007. removeBehavior(behavior: Behavior<Node>): Node;
  118008. /**
  118009. * Gets the list of attached behaviors
  118010. * @see https://doc.babylonjs.com/features/behaviour
  118011. */
  118012. get behaviors(): Behavior<Node>[];
  118013. /**
  118014. * Gets an attached behavior by name
  118015. * @param name defines the name of the behavior to look for
  118016. * @see https://doc.babylonjs.com/features/behaviour
  118017. * @returns null if behavior was not found else the requested behavior
  118018. */
  118019. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  118020. /**
  118021. * Returns the latest update of the World matrix
  118022. * @returns a Matrix
  118023. */
  118024. getWorldMatrix(): Matrix;
  118025. /** @hidden */
  118026. _getWorldMatrixDeterminant(): number;
  118027. /**
  118028. * Returns directly the latest state of the mesh World matrix.
  118029. * A Matrix is returned.
  118030. */
  118031. get worldMatrixFromCache(): Matrix;
  118032. /** @hidden */
  118033. _initCache(): void;
  118034. /** @hidden */
  118035. updateCache(force?: boolean): void;
  118036. /** @hidden */
  118037. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  118038. /** @hidden */
  118039. _updateCache(ignoreParentClass?: boolean): void;
  118040. /** @hidden */
  118041. _isSynchronized(): boolean;
  118042. /** @hidden */
  118043. _markSyncedWithParent(): void;
  118044. /** @hidden */
  118045. isSynchronizedWithParent(): boolean;
  118046. /** @hidden */
  118047. isSynchronized(): boolean;
  118048. /**
  118049. * Is this node ready to be used/rendered
  118050. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  118051. * @return true if the node is ready
  118052. */
  118053. isReady(completeCheck?: boolean): boolean;
  118054. /**
  118055. * Is this node enabled?
  118056. * 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
  118057. * @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
  118058. * @return whether this node (and its parent) is enabled
  118059. */
  118060. isEnabled(checkAncestors?: boolean): boolean;
  118061. /** @hidden */
  118062. protected _syncParentEnabledState(): void;
  118063. /**
  118064. * Set the enabled state of this node
  118065. * @param value defines the new enabled state
  118066. */
  118067. setEnabled(value: boolean): void;
  118068. /**
  118069. * Is this node a descendant of the given node?
  118070. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  118071. * @param ancestor defines the parent node to inspect
  118072. * @returns a boolean indicating if this node is a descendant of the given node
  118073. */
  118074. isDescendantOf(ancestor: Node): boolean;
  118075. /** @hidden */
  118076. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  118077. /**
  118078. * Will return all nodes that have this node as ascendant
  118079. * @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
  118080. * @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
  118081. * @return all children nodes of all types
  118082. */
  118083. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  118084. /**
  118085. * Get all child-meshes of this node
  118086. * @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)
  118087. * @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
  118088. * @returns an array of AbstractMesh
  118089. */
  118090. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  118091. /**
  118092. * Get all direct children of this node
  118093. * @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
  118094. * @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)
  118095. * @returns an array of Node
  118096. */
  118097. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  118098. /** @hidden */
  118099. _setReady(state: boolean): void;
  118100. /**
  118101. * Get an animation by name
  118102. * @param name defines the name of the animation to look for
  118103. * @returns null if not found else the requested animation
  118104. */
  118105. getAnimationByName(name: string): Nullable<Animation>;
  118106. /**
  118107. * Creates an animation range for this node
  118108. * @param name defines the name of the range
  118109. * @param from defines the starting key
  118110. * @param to defines the end key
  118111. */
  118112. createAnimationRange(name: string, from: number, to: number): void;
  118113. /**
  118114. * Delete a specific animation range
  118115. * @param name defines the name of the range to delete
  118116. * @param deleteFrames defines if animation frames from the range must be deleted as well
  118117. */
  118118. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  118119. /**
  118120. * Get an animation range by name
  118121. * @param name defines the name of the animation range to look for
  118122. * @returns null if not found else the requested animation range
  118123. */
  118124. getAnimationRange(name: string): Nullable<AnimationRange>;
  118125. /**
  118126. * Gets the list of all animation ranges defined on this node
  118127. * @returns an array
  118128. */
  118129. getAnimationRanges(): Nullable<AnimationRange>[];
  118130. /**
  118131. * Will start the animation sequence
  118132. * @param name defines the range frames for animation sequence
  118133. * @param loop defines if the animation should loop (false by default)
  118134. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  118135. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  118136. * @returns the object created for this animation. If range does not exist, it will return null
  118137. */
  118138. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  118139. /**
  118140. * Serialize animation ranges into a JSON compatible object
  118141. * @returns serialization object
  118142. */
  118143. serializeAnimationRanges(): any;
  118144. /**
  118145. * Computes the world matrix of the node
  118146. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  118147. * @returns the world matrix
  118148. */
  118149. computeWorldMatrix(force?: boolean): Matrix;
  118150. /**
  118151. * Releases resources associated with this node.
  118152. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118153. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118154. */
  118155. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118156. /**
  118157. * Parse animation range data from a serialization object and store them into a given node
  118158. * @param node defines where to store the animation ranges
  118159. * @param parsedNode defines the serialization object to read data from
  118160. * @param scene defines the hosting scene
  118161. */
  118162. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  118163. /**
  118164. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  118165. * @param includeDescendants Include bounding info from descendants as well (true by default)
  118166. * @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
  118167. * @returns the new bounding vectors
  118168. */
  118169. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  118170. min: Vector3;
  118171. max: Vector3;
  118172. };
  118173. }
  118174. }
  118175. declare module BABYLON {
  118176. /**
  118177. * @hidden
  118178. */
  118179. export class _IAnimationState {
  118180. key: number;
  118181. repeatCount: number;
  118182. workValue?: any;
  118183. loopMode?: number;
  118184. offsetValue?: any;
  118185. highLimitValue?: any;
  118186. }
  118187. /**
  118188. * Class used to store any kind of animation
  118189. */
  118190. export class Animation {
  118191. /**Name of the animation */
  118192. name: string;
  118193. /**Property to animate */
  118194. targetProperty: string;
  118195. /**The frames per second of the animation */
  118196. framePerSecond: number;
  118197. /**The data type of the animation */
  118198. dataType: number;
  118199. /**The loop mode of the animation */
  118200. loopMode?: number | undefined;
  118201. /**Specifies if blending should be enabled */
  118202. enableBlending?: boolean | undefined;
  118203. /**
  118204. * Use matrix interpolation instead of using direct key value when animating matrices
  118205. */
  118206. static AllowMatricesInterpolation: boolean;
  118207. /**
  118208. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  118209. */
  118210. static AllowMatrixDecomposeForInterpolation: boolean;
  118211. /** Define the Url to load snippets */
  118212. static SnippetUrl: string;
  118213. /** Snippet ID if the animation was created from the snippet server */
  118214. snippetId: string;
  118215. /**
  118216. * Stores the key frames of the animation
  118217. */
  118218. private _keys;
  118219. /**
  118220. * Stores the easing function of the animation
  118221. */
  118222. private _easingFunction;
  118223. /**
  118224. * @hidden Internal use only
  118225. */
  118226. _runtimeAnimations: RuntimeAnimation[];
  118227. /**
  118228. * The set of event that will be linked to this animation
  118229. */
  118230. private _events;
  118231. /**
  118232. * Stores an array of target property paths
  118233. */
  118234. targetPropertyPath: string[];
  118235. /**
  118236. * Stores the blending speed of the animation
  118237. */
  118238. blendingSpeed: number;
  118239. /**
  118240. * Stores the animation ranges for the animation
  118241. */
  118242. private _ranges;
  118243. /**
  118244. * @hidden Internal use
  118245. */
  118246. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  118247. /**
  118248. * Sets up an animation
  118249. * @param property The property to animate
  118250. * @param animationType The animation type to apply
  118251. * @param framePerSecond The frames per second of the animation
  118252. * @param easingFunction The easing function used in the animation
  118253. * @returns The created animation
  118254. */
  118255. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  118256. /**
  118257. * Create and start an animation on a node
  118258. * @param name defines the name of the global animation that will be run on all nodes
  118259. * @param node defines the root node where the animation will take place
  118260. * @param targetProperty defines property to animate
  118261. * @param framePerSecond defines the number of frame per second yo use
  118262. * @param totalFrame defines the number of frames in total
  118263. * @param from defines the initial value
  118264. * @param to defines the final value
  118265. * @param loopMode defines which loop mode you want to use (off by default)
  118266. * @param easingFunction defines the easing function to use (linear by default)
  118267. * @param onAnimationEnd defines the callback to call when animation end
  118268. * @returns the animatable created for this animation
  118269. */
  118270. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118271. /**
  118272. * Create and start an animation on a node and its descendants
  118273. * @param name defines the name of the global animation that will be run on all nodes
  118274. * @param node defines the root node where the animation will take place
  118275. * @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
  118276. * @param targetProperty defines property to animate
  118277. * @param framePerSecond defines the number of frame per second to use
  118278. * @param totalFrame defines the number of frames in total
  118279. * @param from defines the initial value
  118280. * @param to defines the final value
  118281. * @param loopMode defines which loop mode you want to use (off by default)
  118282. * @param easingFunction defines the easing function to use (linear by default)
  118283. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  118284. * @returns the list of animatables created for all nodes
  118285. * @example https://www.babylonjs-playground.com/#MH0VLI
  118286. */
  118287. 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[]>;
  118288. /**
  118289. * Creates a new animation, merges it with the existing animations and starts it
  118290. * @param name Name of the animation
  118291. * @param node Node which contains the scene that begins the animations
  118292. * @param targetProperty Specifies which property to animate
  118293. * @param framePerSecond The frames per second of the animation
  118294. * @param totalFrame The total number of frames
  118295. * @param from The frame at the beginning of the animation
  118296. * @param to The frame at the end of the animation
  118297. * @param loopMode Specifies the loop mode of the animation
  118298. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  118299. * @param onAnimationEnd Callback to run once the animation is complete
  118300. * @returns Nullable animation
  118301. */
  118302. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118303. /**
  118304. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118305. * @param sourceAnimation defines the Animation containing keyframes to convert
  118306. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118307. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  118308. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  118309. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  118310. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  118311. */
  118312. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  118313. /**
  118314. * Transition property of an host to the target Value
  118315. * @param property The property to transition
  118316. * @param targetValue The target Value of the property
  118317. * @param host The object where the property to animate belongs
  118318. * @param scene Scene used to run the animation
  118319. * @param frameRate Framerate (in frame/s) to use
  118320. * @param transition The transition type we want to use
  118321. * @param duration The duration of the animation, in milliseconds
  118322. * @param onAnimationEnd Callback trigger at the end of the animation
  118323. * @returns Nullable animation
  118324. */
  118325. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  118326. /**
  118327. * Return the array of runtime animations currently using this animation
  118328. */
  118329. get runtimeAnimations(): RuntimeAnimation[];
  118330. /**
  118331. * Specifies if any of the runtime animations are currently running
  118332. */
  118333. get hasRunningRuntimeAnimations(): boolean;
  118334. /**
  118335. * Initializes the animation
  118336. * @param name Name of the animation
  118337. * @param targetProperty Property to animate
  118338. * @param framePerSecond The frames per second of the animation
  118339. * @param dataType The data type of the animation
  118340. * @param loopMode The loop mode of the animation
  118341. * @param enableBlending Specifies if blending should be enabled
  118342. */
  118343. constructor(
  118344. /**Name of the animation */
  118345. name: string,
  118346. /**Property to animate */
  118347. targetProperty: string,
  118348. /**The frames per second of the animation */
  118349. framePerSecond: number,
  118350. /**The data type of the animation */
  118351. dataType: number,
  118352. /**The loop mode of the animation */
  118353. loopMode?: number | undefined,
  118354. /**Specifies if blending should be enabled */
  118355. enableBlending?: boolean | undefined);
  118356. /**
  118357. * Converts the animation to a string
  118358. * @param fullDetails support for multiple levels of logging within scene loading
  118359. * @returns String form of the animation
  118360. */
  118361. toString(fullDetails?: boolean): string;
  118362. /**
  118363. * Add an event to this animation
  118364. * @param event Event to add
  118365. */
  118366. addEvent(event: AnimationEvent): void;
  118367. /**
  118368. * Remove all events found at the given frame
  118369. * @param frame The frame to remove events from
  118370. */
  118371. removeEvents(frame: number): void;
  118372. /**
  118373. * Retrieves all the events from the animation
  118374. * @returns Events from the animation
  118375. */
  118376. getEvents(): AnimationEvent[];
  118377. /**
  118378. * Creates an animation range
  118379. * @param name Name of the animation range
  118380. * @param from Starting frame of the animation range
  118381. * @param to Ending frame of the animation
  118382. */
  118383. createRange(name: string, from: number, to: number): void;
  118384. /**
  118385. * Deletes an animation range by name
  118386. * @param name Name of the animation range to delete
  118387. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  118388. */
  118389. deleteRange(name: string, deleteFrames?: boolean): void;
  118390. /**
  118391. * Gets the animation range by name, or null if not defined
  118392. * @param name Name of the animation range
  118393. * @returns Nullable animation range
  118394. */
  118395. getRange(name: string): Nullable<AnimationRange>;
  118396. /**
  118397. * Gets the key frames from the animation
  118398. * @returns The key frames of the animation
  118399. */
  118400. getKeys(): Array<IAnimationKey>;
  118401. /**
  118402. * Gets the highest frame rate of the animation
  118403. * @returns Highest frame rate of the animation
  118404. */
  118405. getHighestFrame(): number;
  118406. /**
  118407. * Gets the easing function of the animation
  118408. * @returns Easing function of the animation
  118409. */
  118410. getEasingFunction(): IEasingFunction;
  118411. /**
  118412. * Sets the easing function of the animation
  118413. * @param easingFunction A custom mathematical formula for animation
  118414. */
  118415. setEasingFunction(easingFunction: EasingFunction): void;
  118416. /**
  118417. * Interpolates a scalar linearly
  118418. * @param startValue Start value of the animation curve
  118419. * @param endValue End value of the animation curve
  118420. * @param gradient Scalar amount to interpolate
  118421. * @returns Interpolated scalar value
  118422. */
  118423. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  118424. /**
  118425. * Interpolates a scalar cubically
  118426. * @param startValue Start value of the animation curve
  118427. * @param outTangent End tangent of the animation
  118428. * @param endValue End value of the animation curve
  118429. * @param inTangent Start tangent of the animation curve
  118430. * @param gradient Scalar amount to interpolate
  118431. * @returns Interpolated scalar value
  118432. */
  118433. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  118434. /**
  118435. * Interpolates a quaternion using a spherical linear interpolation
  118436. * @param startValue Start value of the animation curve
  118437. * @param endValue End value of the animation curve
  118438. * @param gradient Scalar amount to interpolate
  118439. * @returns Interpolated quaternion value
  118440. */
  118441. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  118442. /**
  118443. * Interpolates a quaternion cubically
  118444. * @param startValue Start value of the animation curve
  118445. * @param outTangent End tangent of the animation curve
  118446. * @param endValue End value of the animation curve
  118447. * @param inTangent Start tangent of the animation curve
  118448. * @param gradient Scalar amount to interpolate
  118449. * @returns Interpolated quaternion value
  118450. */
  118451. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  118452. /**
  118453. * Interpolates a Vector3 linearl
  118454. * @param startValue Start value of the animation curve
  118455. * @param endValue End value of the animation curve
  118456. * @param gradient Scalar amount to interpolate
  118457. * @returns Interpolated scalar value
  118458. */
  118459. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  118460. /**
  118461. * Interpolates a Vector3 cubically
  118462. * @param startValue Start value of the animation curve
  118463. * @param outTangent End tangent of the animation
  118464. * @param endValue End value of the animation curve
  118465. * @param inTangent Start tangent of the animation curve
  118466. * @param gradient Scalar amount to interpolate
  118467. * @returns InterpolatedVector3 value
  118468. */
  118469. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  118470. /**
  118471. * Interpolates a Vector2 linearly
  118472. * @param startValue Start value of the animation curve
  118473. * @param endValue End value of the animation curve
  118474. * @param gradient Scalar amount to interpolate
  118475. * @returns Interpolated Vector2 value
  118476. */
  118477. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  118478. /**
  118479. * Interpolates a Vector2 cubically
  118480. * @param startValue Start value of the animation curve
  118481. * @param outTangent End tangent of the animation
  118482. * @param endValue End value of the animation curve
  118483. * @param inTangent Start tangent of the animation curve
  118484. * @param gradient Scalar amount to interpolate
  118485. * @returns Interpolated Vector2 value
  118486. */
  118487. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  118488. /**
  118489. * Interpolates a size linearly
  118490. * @param startValue Start value of the animation curve
  118491. * @param endValue End value of the animation curve
  118492. * @param gradient Scalar amount to interpolate
  118493. * @returns Interpolated Size value
  118494. */
  118495. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  118496. /**
  118497. * Interpolates a Color3 linearly
  118498. * @param startValue Start value of the animation curve
  118499. * @param endValue End value of the animation curve
  118500. * @param gradient Scalar amount to interpolate
  118501. * @returns Interpolated Color3 value
  118502. */
  118503. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  118504. /**
  118505. * Interpolates a Color4 linearly
  118506. * @param startValue Start value of the animation curve
  118507. * @param endValue End value of the animation curve
  118508. * @param gradient Scalar amount to interpolate
  118509. * @returns Interpolated Color3 value
  118510. */
  118511. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  118512. /**
  118513. * @hidden Internal use only
  118514. */
  118515. _getKeyValue(value: any): any;
  118516. /**
  118517. * @hidden Internal use only
  118518. */
  118519. _interpolate(currentFrame: number, state: _IAnimationState): any;
  118520. /**
  118521. * Defines the function to use to interpolate matrices
  118522. * @param startValue defines the start matrix
  118523. * @param endValue defines the end matrix
  118524. * @param gradient defines the gradient between both matrices
  118525. * @param result defines an optional target matrix where to store the interpolation
  118526. * @returns the interpolated matrix
  118527. */
  118528. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  118529. /**
  118530. * Makes a copy of the animation
  118531. * @returns Cloned animation
  118532. */
  118533. clone(): Animation;
  118534. /**
  118535. * Sets the key frames of the animation
  118536. * @param values The animation key frames to set
  118537. */
  118538. setKeys(values: Array<IAnimationKey>): void;
  118539. /**
  118540. * Serializes the animation to an object
  118541. * @returns Serialized object
  118542. */
  118543. serialize(): any;
  118544. /**
  118545. * Float animation type
  118546. */
  118547. static readonly ANIMATIONTYPE_FLOAT: number;
  118548. /**
  118549. * Vector3 animation type
  118550. */
  118551. static readonly ANIMATIONTYPE_VECTOR3: number;
  118552. /**
  118553. * Quaternion animation type
  118554. */
  118555. static readonly ANIMATIONTYPE_QUATERNION: number;
  118556. /**
  118557. * Matrix animation type
  118558. */
  118559. static readonly ANIMATIONTYPE_MATRIX: number;
  118560. /**
  118561. * Color3 animation type
  118562. */
  118563. static readonly ANIMATIONTYPE_COLOR3: number;
  118564. /**
  118565. * Color3 animation type
  118566. */
  118567. static readonly ANIMATIONTYPE_COLOR4: number;
  118568. /**
  118569. * Vector2 animation type
  118570. */
  118571. static readonly ANIMATIONTYPE_VECTOR2: number;
  118572. /**
  118573. * Size animation type
  118574. */
  118575. static readonly ANIMATIONTYPE_SIZE: number;
  118576. /**
  118577. * Relative Loop Mode
  118578. */
  118579. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  118580. /**
  118581. * Cycle Loop Mode
  118582. */
  118583. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  118584. /**
  118585. * Constant Loop Mode
  118586. */
  118587. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  118588. /** @hidden */
  118589. static _UniversalLerp(left: any, right: any, amount: number): any;
  118590. /**
  118591. * Parses an animation object and creates an animation
  118592. * @param parsedAnimation Parsed animation object
  118593. * @returns Animation object
  118594. */
  118595. static Parse(parsedAnimation: any): Animation;
  118596. /**
  118597. * Appends the serialized animations from the source animations
  118598. * @param source Source containing the animations
  118599. * @param destination Target to store the animations
  118600. */
  118601. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118602. /**
  118603. * Creates a new animation or an array of animations from a snippet saved in a remote file
  118604. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  118605. * @param url defines the url to load from
  118606. * @returns a promise that will resolve to the new animation or an array of animations
  118607. */
  118608. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  118609. /**
  118610. * Creates an animation or an array of animations from a snippet saved by the Inspector
  118611. * @param snippetId defines the snippet to load
  118612. * @returns a promise that will resolve to the new animation or a new array of animations
  118613. */
  118614. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  118615. }
  118616. }
  118617. declare module BABYLON {
  118618. /**
  118619. * Interface containing an array of animations
  118620. */
  118621. export interface IAnimatable {
  118622. /**
  118623. * Array of animations
  118624. */
  118625. animations: Nullable<Array<Animation>>;
  118626. }
  118627. }
  118628. declare module BABYLON {
  118629. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  118630. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118631. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118632. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118633. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118634. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118635. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118636. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118637. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118638. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118639. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118640. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118641. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118642. /**
  118643. * Decorator used to define property that can be serialized as reference to a camera
  118644. * @param sourceName defines the name of the property to decorate
  118645. */
  118646. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118647. /**
  118648. * Class used to help serialization objects
  118649. */
  118650. export class SerializationHelper {
  118651. /** @hidden */
  118652. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  118653. /** @hidden */
  118654. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  118655. /** @hidden */
  118656. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  118657. /** @hidden */
  118658. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  118659. /**
  118660. * Appends the serialized animations from the source animations
  118661. * @param source Source containing the animations
  118662. * @param destination Target to store the animations
  118663. */
  118664. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118665. /**
  118666. * Static function used to serialized a specific entity
  118667. * @param entity defines the entity to serialize
  118668. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  118669. * @returns a JSON compatible object representing the serialization of the entity
  118670. */
  118671. static Serialize<T>(entity: T, serializationObject?: any): any;
  118672. /**
  118673. * Creates a new entity from a serialization data object
  118674. * @param creationFunction defines a function used to instanciated the new entity
  118675. * @param source defines the source serialization data
  118676. * @param scene defines the hosting scene
  118677. * @param rootUrl defines the root url for resources
  118678. * @returns a new entity
  118679. */
  118680. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  118681. /**
  118682. * Clones an object
  118683. * @param creationFunction defines the function used to instanciate the new object
  118684. * @param source defines the source object
  118685. * @returns the cloned object
  118686. */
  118687. static Clone<T>(creationFunction: () => T, source: T): T;
  118688. /**
  118689. * Instanciates a new object based on a source one (some data will be shared between both object)
  118690. * @param creationFunction defines the function used to instanciate the new object
  118691. * @param source defines the source object
  118692. * @returns the new object
  118693. */
  118694. static Instanciate<T>(creationFunction: () => T, source: T): T;
  118695. }
  118696. }
  118697. declare module BABYLON {
  118698. /**
  118699. * This is the base class of all the camera used in the application.
  118700. * @see https://doc.babylonjs.com/features/cameras
  118701. */
  118702. export class Camera extends Node {
  118703. /** @hidden */
  118704. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  118705. /**
  118706. * This is the default projection mode used by the cameras.
  118707. * It helps recreating a feeling of perspective and better appreciate depth.
  118708. * This is the best way to simulate real life cameras.
  118709. */
  118710. static readonly PERSPECTIVE_CAMERA: number;
  118711. /**
  118712. * This helps creating camera with an orthographic mode.
  118713. * 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.
  118714. */
  118715. static readonly ORTHOGRAPHIC_CAMERA: number;
  118716. /**
  118717. * This is the default FOV mode for perspective cameras.
  118718. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  118719. */
  118720. static readonly FOVMODE_VERTICAL_FIXED: number;
  118721. /**
  118722. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  118723. */
  118724. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  118725. /**
  118726. * This specifies ther is no need for a camera rig.
  118727. * Basically only one eye is rendered corresponding to the camera.
  118728. */
  118729. static readonly RIG_MODE_NONE: number;
  118730. /**
  118731. * Simulates a camera Rig with one blue eye and one red eye.
  118732. * This can be use with 3d blue and red glasses.
  118733. */
  118734. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  118735. /**
  118736. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  118737. */
  118738. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  118739. /**
  118740. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  118741. */
  118742. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  118743. /**
  118744. * Defines that both eyes of the camera will be rendered over under each other.
  118745. */
  118746. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  118747. /**
  118748. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  118749. */
  118750. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  118751. /**
  118752. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  118753. */
  118754. static readonly RIG_MODE_VR: number;
  118755. /**
  118756. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  118757. */
  118758. static readonly RIG_MODE_WEBVR: number;
  118759. /**
  118760. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  118761. */
  118762. static readonly RIG_MODE_CUSTOM: number;
  118763. /**
  118764. * Defines if by default attaching controls should prevent the default javascript event to continue.
  118765. */
  118766. static ForceAttachControlToAlwaysPreventDefault: boolean;
  118767. /**
  118768. * Define the input manager associated with the camera.
  118769. */
  118770. inputs: CameraInputsManager<Camera>;
  118771. /** @hidden */
  118772. _position: Vector3;
  118773. /**
  118774. * Define the current local position of the camera in the scene
  118775. */
  118776. get position(): Vector3;
  118777. set position(newPosition: Vector3);
  118778. protected _upVector: Vector3;
  118779. /**
  118780. * The vector the camera should consider as up.
  118781. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  118782. */
  118783. set upVector(vec: Vector3);
  118784. get upVector(): Vector3;
  118785. /**
  118786. * Define the current limit on the left side for an orthographic camera
  118787. * In scene unit
  118788. */
  118789. orthoLeft: Nullable<number>;
  118790. /**
  118791. * Define the current limit on the right side for an orthographic camera
  118792. * In scene unit
  118793. */
  118794. orthoRight: Nullable<number>;
  118795. /**
  118796. * Define the current limit on the bottom side for an orthographic camera
  118797. * In scene unit
  118798. */
  118799. orthoBottom: Nullable<number>;
  118800. /**
  118801. * Define the current limit on the top side for an orthographic camera
  118802. * In scene unit
  118803. */
  118804. orthoTop: Nullable<number>;
  118805. /**
  118806. * Field Of View is set in Radians. (default is 0.8)
  118807. */
  118808. fov: number;
  118809. /**
  118810. * Define the minimum distance the camera can see from.
  118811. * This is important to note that the depth buffer are not infinite and the closer it starts
  118812. * the more your scene might encounter depth fighting issue.
  118813. */
  118814. minZ: number;
  118815. /**
  118816. * Define the maximum distance the camera can see to.
  118817. * This is important to note that the depth buffer are not infinite and the further it end
  118818. * the more your scene might encounter depth fighting issue.
  118819. */
  118820. maxZ: number;
  118821. /**
  118822. * Define the default inertia of the camera.
  118823. * This helps giving a smooth feeling to the camera movement.
  118824. */
  118825. inertia: number;
  118826. /**
  118827. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  118828. */
  118829. mode: number;
  118830. /**
  118831. * Define whether the camera is intermediate.
  118832. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  118833. */
  118834. isIntermediate: boolean;
  118835. /**
  118836. * Define the viewport of the camera.
  118837. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  118838. */
  118839. viewport: Viewport;
  118840. /**
  118841. * Restricts the camera to viewing objects with the same layerMask.
  118842. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  118843. */
  118844. layerMask: number;
  118845. /**
  118846. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  118847. */
  118848. fovMode: number;
  118849. /**
  118850. * Rig mode of the camera.
  118851. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  118852. * This is normally controlled byt the camera themselves as internal use.
  118853. */
  118854. cameraRigMode: number;
  118855. /**
  118856. * Defines the distance between both "eyes" in case of a RIG
  118857. */
  118858. interaxialDistance: number;
  118859. /**
  118860. * Defines if stereoscopic rendering is done side by side or over under.
  118861. */
  118862. isStereoscopicSideBySide: boolean;
  118863. /**
  118864. * 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
  118865. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  118866. * else in the scene. (Eg. security camera)
  118867. *
  118868. * 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)
  118869. */
  118870. customRenderTargets: RenderTargetTexture[];
  118871. /**
  118872. * When set, the camera will render to this render target instead of the default canvas
  118873. *
  118874. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  118875. */
  118876. outputRenderTarget: Nullable<RenderTargetTexture>;
  118877. /**
  118878. * Observable triggered when the camera view matrix has changed.
  118879. */
  118880. onViewMatrixChangedObservable: Observable<Camera>;
  118881. /**
  118882. * Observable triggered when the camera Projection matrix has changed.
  118883. */
  118884. onProjectionMatrixChangedObservable: Observable<Camera>;
  118885. /**
  118886. * Observable triggered when the inputs have been processed.
  118887. */
  118888. onAfterCheckInputsObservable: Observable<Camera>;
  118889. /**
  118890. * Observable triggered when reset has been called and applied to the camera.
  118891. */
  118892. onRestoreStateObservable: Observable<Camera>;
  118893. /**
  118894. * Is this camera a part of a rig system?
  118895. */
  118896. isRigCamera: boolean;
  118897. /**
  118898. * If isRigCamera set to true this will be set with the parent camera.
  118899. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  118900. */
  118901. rigParent?: Camera;
  118902. /** @hidden */
  118903. _cameraRigParams: any;
  118904. /** @hidden */
  118905. _rigCameras: Camera[];
  118906. /** @hidden */
  118907. _rigPostProcess: Nullable<PostProcess>;
  118908. protected _webvrViewMatrix: Matrix;
  118909. /** @hidden */
  118910. _skipRendering: boolean;
  118911. /** @hidden */
  118912. _projectionMatrix: Matrix;
  118913. /** @hidden */
  118914. _postProcesses: Nullable<PostProcess>[];
  118915. /** @hidden */
  118916. _activeMeshes: SmartArray<AbstractMesh>;
  118917. protected _globalPosition: Vector3;
  118918. /** @hidden */
  118919. _computedViewMatrix: Matrix;
  118920. private _doNotComputeProjectionMatrix;
  118921. private _transformMatrix;
  118922. private _frustumPlanes;
  118923. private _refreshFrustumPlanes;
  118924. private _storedFov;
  118925. private _stateStored;
  118926. /**
  118927. * Instantiates a new camera object.
  118928. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  118929. * @see https://doc.babylonjs.com/features/cameras
  118930. * @param name Defines the name of the camera in the scene
  118931. * @param position Defines the position of the camera
  118932. * @param scene Defines the scene the camera belongs too
  118933. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  118934. */
  118935. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  118936. /**
  118937. * Store current camera state (fov, position, etc..)
  118938. * @returns the camera
  118939. */
  118940. storeState(): Camera;
  118941. /**
  118942. * Restores the camera state values if it has been stored. You must call storeState() first
  118943. */
  118944. protected _restoreStateValues(): boolean;
  118945. /**
  118946. * Restored camera state. You must call storeState() first.
  118947. * @returns true if restored and false otherwise
  118948. */
  118949. restoreState(): boolean;
  118950. /**
  118951. * Gets the class name of the camera.
  118952. * @returns the class name
  118953. */
  118954. getClassName(): string;
  118955. /** @hidden */
  118956. readonly _isCamera: boolean;
  118957. /**
  118958. * Gets a string representation of the camera useful for debug purpose.
  118959. * @param fullDetails Defines that a more verboe level of logging is required
  118960. * @returns the string representation
  118961. */
  118962. toString(fullDetails?: boolean): string;
  118963. /**
  118964. * Gets the current world space position of the camera.
  118965. */
  118966. get globalPosition(): Vector3;
  118967. /**
  118968. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  118969. * @returns the active meshe list
  118970. */
  118971. getActiveMeshes(): SmartArray<AbstractMesh>;
  118972. /**
  118973. * Check whether a mesh is part of the current active mesh list of the camera
  118974. * @param mesh Defines the mesh to check
  118975. * @returns true if active, false otherwise
  118976. */
  118977. isActiveMesh(mesh: Mesh): boolean;
  118978. /**
  118979. * Is this camera ready to be used/rendered
  118980. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  118981. * @return true if the camera is ready
  118982. */
  118983. isReady(completeCheck?: boolean): boolean;
  118984. /** @hidden */
  118985. _initCache(): void;
  118986. /** @hidden */
  118987. _updateCache(ignoreParentClass?: boolean): void;
  118988. /** @hidden */
  118989. _isSynchronized(): boolean;
  118990. /** @hidden */
  118991. _isSynchronizedViewMatrix(): boolean;
  118992. /** @hidden */
  118993. _isSynchronizedProjectionMatrix(): boolean;
  118994. /**
  118995. * Attach the input controls to a specific dom element to get the input from.
  118996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118997. */
  118998. attachControl(noPreventDefault?: boolean): void;
  118999. /**
  119000. * Attach the input controls to a specific dom element to get the input from.
  119001. * @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
  119002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119003. * BACK COMPAT SIGNATURE ONLY.
  119004. */
  119005. attachControl(ignored: any, noPreventDefault?: boolean): void;
  119006. /**
  119007. * Detach the current controls from the specified dom element.
  119008. */
  119009. detachControl(): void;
  119010. /**
  119011. * Detach the current controls from the specified dom element.
  119012. * @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
  119013. */
  119014. detachControl(ignored: any): void;
  119015. /**
  119016. * Update the camera state according to the different inputs gathered during the frame.
  119017. */
  119018. update(): void;
  119019. /** @hidden */
  119020. _checkInputs(): void;
  119021. /** @hidden */
  119022. get rigCameras(): Camera[];
  119023. /**
  119024. * Gets the post process used by the rig cameras
  119025. */
  119026. get rigPostProcess(): Nullable<PostProcess>;
  119027. /**
  119028. * Internal, gets the first post proces.
  119029. * @returns the first post process to be run on this camera.
  119030. */
  119031. _getFirstPostProcess(): Nullable<PostProcess>;
  119032. private _cascadePostProcessesToRigCams;
  119033. /**
  119034. * Attach a post process to the camera.
  119035. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  119036. * @param postProcess The post process to attach to the camera
  119037. * @param insertAt The position of the post process in case several of them are in use in the scene
  119038. * @returns the position the post process has been inserted at
  119039. */
  119040. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  119041. /**
  119042. * Detach a post process to the camera.
  119043. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  119044. * @param postProcess The post process to detach from the camera
  119045. */
  119046. detachPostProcess(postProcess: PostProcess): void;
  119047. /**
  119048. * Gets the current world matrix of the camera
  119049. */
  119050. getWorldMatrix(): Matrix;
  119051. /** @hidden */
  119052. _getViewMatrix(): Matrix;
  119053. /**
  119054. * Gets the current view matrix of the camera.
  119055. * @param force forces the camera to recompute the matrix without looking at the cached state
  119056. * @returns the view matrix
  119057. */
  119058. getViewMatrix(force?: boolean): Matrix;
  119059. /**
  119060. * Freeze the projection matrix.
  119061. * It will prevent the cache check of the camera projection compute and can speed up perf
  119062. * if no parameter of the camera are meant to change
  119063. * @param projection Defines manually a projection if necessary
  119064. */
  119065. freezeProjectionMatrix(projection?: Matrix): void;
  119066. /**
  119067. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  119068. */
  119069. unfreezeProjectionMatrix(): void;
  119070. /**
  119071. * Gets the current projection matrix of the camera.
  119072. * @param force forces the camera to recompute the matrix without looking at the cached state
  119073. * @returns the projection matrix
  119074. */
  119075. getProjectionMatrix(force?: boolean): Matrix;
  119076. /**
  119077. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  119078. * @returns a Matrix
  119079. */
  119080. getTransformationMatrix(): Matrix;
  119081. private _updateFrustumPlanes;
  119082. /**
  119083. * Checks if a cullable object (mesh...) is in the camera frustum
  119084. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  119085. * @param target The object to check
  119086. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  119087. * @returns true if the object is in frustum otherwise false
  119088. */
  119089. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  119090. /**
  119091. * Checks if a cullable object (mesh...) is in the camera frustum
  119092. * Unlike isInFrustum this cheks the full bounding box
  119093. * @param target The object to check
  119094. * @returns true if the object is in frustum otherwise false
  119095. */
  119096. isCompletelyInFrustum(target: ICullable): boolean;
  119097. /**
  119098. * Gets a ray in the forward direction from the camera.
  119099. * @param length Defines the length of the ray to create
  119100. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  119101. * @param origin Defines the start point of the ray which defaults to the camera position
  119102. * @returns the forward ray
  119103. */
  119104. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  119105. /**
  119106. * Gets a ray in the forward direction from the camera.
  119107. * @param refRay the ray to (re)use when setting the values
  119108. * @param length Defines the length of the ray to create
  119109. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  119110. * @param origin Defines the start point of the ray which defaults to the camera position
  119111. * @returns the forward ray
  119112. */
  119113. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  119114. /**
  119115. * Releases resources associated with this node.
  119116. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119117. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119118. */
  119119. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119120. /** @hidden */
  119121. _isLeftCamera: boolean;
  119122. /**
  119123. * Gets the left camera of a rig setup in case of Rigged Camera
  119124. */
  119125. get isLeftCamera(): boolean;
  119126. /** @hidden */
  119127. _isRightCamera: boolean;
  119128. /**
  119129. * Gets the right camera of a rig setup in case of Rigged Camera
  119130. */
  119131. get isRightCamera(): boolean;
  119132. /**
  119133. * Gets the left camera of a rig setup in case of Rigged Camera
  119134. */
  119135. get leftCamera(): Nullable<FreeCamera>;
  119136. /**
  119137. * Gets the right camera of a rig setup in case of Rigged Camera
  119138. */
  119139. get rightCamera(): Nullable<FreeCamera>;
  119140. /**
  119141. * Gets the left camera target of a rig setup in case of Rigged Camera
  119142. * @returns the target position
  119143. */
  119144. getLeftTarget(): Nullable<Vector3>;
  119145. /**
  119146. * Gets the right camera target of a rig setup in case of Rigged Camera
  119147. * @returns the target position
  119148. */
  119149. getRightTarget(): Nullable<Vector3>;
  119150. /**
  119151. * @hidden
  119152. */
  119153. setCameraRigMode(mode: number, rigParams: any): void;
  119154. /** @hidden */
  119155. static _setStereoscopicRigMode(camera: Camera): void;
  119156. /** @hidden */
  119157. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  119158. /** @hidden */
  119159. static _setVRRigMode(camera: Camera, rigParams: any): void;
  119160. /** @hidden */
  119161. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  119162. /** @hidden */
  119163. _getVRProjectionMatrix(): Matrix;
  119164. protected _updateCameraRotationMatrix(): void;
  119165. protected _updateWebVRCameraRotationMatrix(): void;
  119166. /**
  119167. * This function MUST be overwritten by the different WebVR cameras available.
  119168. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  119169. * @hidden
  119170. */
  119171. _getWebVRProjectionMatrix(): Matrix;
  119172. /**
  119173. * This function MUST be overwritten by the different WebVR cameras available.
  119174. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  119175. * @hidden
  119176. */
  119177. _getWebVRViewMatrix(): Matrix;
  119178. /** @hidden */
  119179. setCameraRigParameter(name: string, value: any): void;
  119180. /**
  119181. * needs to be overridden by children so sub has required properties to be copied
  119182. * @hidden
  119183. */
  119184. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  119185. /**
  119186. * May need to be overridden by children
  119187. * @hidden
  119188. */
  119189. _updateRigCameras(): void;
  119190. /** @hidden */
  119191. _setupInputs(): void;
  119192. /**
  119193. * Serialiaze the camera setup to a json represention
  119194. * @returns the JSON representation
  119195. */
  119196. serialize(): any;
  119197. /**
  119198. * Clones the current camera.
  119199. * @param name The cloned camera name
  119200. * @returns the cloned camera
  119201. */
  119202. clone(name: string): Camera;
  119203. /**
  119204. * Gets the direction of the camera relative to a given local axis.
  119205. * @param localAxis Defines the reference axis to provide a relative direction.
  119206. * @return the direction
  119207. */
  119208. getDirection(localAxis: Vector3): Vector3;
  119209. /**
  119210. * Returns the current camera absolute rotation
  119211. */
  119212. get absoluteRotation(): Quaternion;
  119213. /**
  119214. * Gets the direction of the camera relative to a given local axis into a passed vector.
  119215. * @param localAxis Defines the reference axis to provide a relative direction.
  119216. * @param result Defines the vector to store the result in
  119217. */
  119218. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  119219. /**
  119220. * Gets a camera constructor for a given camera type
  119221. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  119222. * @param name The name of the camera the result will be able to instantiate
  119223. * @param scene The scene the result will construct the camera in
  119224. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  119225. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  119226. * @returns a factory method to construc the camera
  119227. */
  119228. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  119229. /**
  119230. * Compute the world matrix of the camera.
  119231. * @returns the camera world matrix
  119232. */
  119233. computeWorldMatrix(): Matrix;
  119234. /**
  119235. * Parse a JSON and creates the camera from the parsed information
  119236. * @param parsedCamera The JSON to parse
  119237. * @param scene The scene to instantiate the camera in
  119238. * @returns the newly constructed camera
  119239. */
  119240. static Parse(parsedCamera: any, scene: Scene): Camera;
  119241. }
  119242. }
  119243. declare module BABYLON {
  119244. /**
  119245. * PostProcessManager is used to manage one or more post processes or post process pipelines
  119246. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119247. */
  119248. export class PostProcessManager {
  119249. private _scene;
  119250. private _indexBuffer;
  119251. private _vertexBuffers;
  119252. /**
  119253. * Creates a new instance PostProcess
  119254. * @param scene The scene that the post process is associated with.
  119255. */
  119256. constructor(scene: Scene);
  119257. private _prepareBuffers;
  119258. private _buildIndexBuffer;
  119259. /**
  119260. * Rebuilds the vertex buffers of the manager.
  119261. * @hidden
  119262. */
  119263. _rebuild(): void;
  119264. /**
  119265. * Prepares a frame to be run through a post process.
  119266. * @param sourceTexture The input texture to the post procesess. (default: null)
  119267. * @param postProcesses An array of post processes to be run. (default: null)
  119268. * @returns True if the post processes were able to be run.
  119269. * @hidden
  119270. */
  119271. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  119272. /**
  119273. * Manually render a set of post processes to a texture.
  119274. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  119275. * @param postProcesses An array of post processes to be run.
  119276. * @param targetTexture The target texture to render to.
  119277. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  119278. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  119279. * @param lodLevel defines which lod of the texture to render to
  119280. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  119281. */
  119282. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  119283. /**
  119284. * Finalize the result of the output of the postprocesses.
  119285. * @param doNotPresent If true the result will not be displayed to the screen.
  119286. * @param targetTexture The target texture to render to.
  119287. * @param faceIndex The index of the face to bind the target texture to.
  119288. * @param postProcesses The array of post processes to render.
  119289. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  119290. * @hidden
  119291. */
  119292. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  119293. /**
  119294. * Disposes of the post process manager.
  119295. */
  119296. dispose(): void;
  119297. }
  119298. }
  119299. declare module BABYLON {
  119300. /**
  119301. * This Helps creating a texture that will be created from a camera in your scene.
  119302. * It is basically a dynamic texture that could be used to create special effects for instance.
  119303. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  119304. */
  119305. export class RenderTargetTexture extends Texture {
  119306. /**
  119307. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  119308. */
  119309. static readonly REFRESHRATE_RENDER_ONCE: number;
  119310. /**
  119311. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  119312. */
  119313. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  119314. /**
  119315. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  119316. * the central point of your effect and can save a lot of performances.
  119317. */
  119318. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  119319. /**
  119320. * Use this predicate to dynamically define the list of mesh you want to render.
  119321. * If set, the renderList property will be overwritten.
  119322. */
  119323. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  119324. private _renderList;
  119325. /**
  119326. * Use this list to define the list of mesh you want to render.
  119327. */
  119328. get renderList(): Nullable<Array<AbstractMesh>>;
  119329. set renderList(value: Nullable<Array<AbstractMesh>>);
  119330. /**
  119331. * Use this function to overload the renderList array at rendering time.
  119332. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  119333. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  119334. * the cube (if the RTT is a cube, else layerOrFace=0).
  119335. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  119336. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  119337. * hold dummy elements!
  119338. */
  119339. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  119340. private _hookArray;
  119341. /**
  119342. * Define if particles should be rendered in your texture.
  119343. */
  119344. renderParticles: boolean;
  119345. /**
  119346. * Define if sprites should be rendered in your texture.
  119347. */
  119348. renderSprites: boolean;
  119349. /**
  119350. * Define the camera used to render the texture.
  119351. */
  119352. activeCamera: Nullable<Camera>;
  119353. /**
  119354. * Override the mesh isReady function with your own one.
  119355. */
  119356. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  119357. /**
  119358. * Override the render function of the texture with your own one.
  119359. */
  119360. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  119361. /**
  119362. * Define if camera post processes should be use while rendering the texture.
  119363. */
  119364. useCameraPostProcesses: boolean;
  119365. /**
  119366. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  119367. */
  119368. ignoreCameraViewport: boolean;
  119369. private _postProcessManager;
  119370. private _postProcesses;
  119371. private _resizeObserver;
  119372. /**
  119373. * An event triggered when the texture is unbind.
  119374. */
  119375. onBeforeBindObservable: Observable<RenderTargetTexture>;
  119376. /**
  119377. * An event triggered when the texture is unbind.
  119378. */
  119379. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  119380. private _onAfterUnbindObserver;
  119381. /**
  119382. * Set a after unbind callback in the texture.
  119383. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  119384. */
  119385. set onAfterUnbind(callback: () => void);
  119386. /**
  119387. * An event triggered before rendering the texture
  119388. */
  119389. onBeforeRenderObservable: Observable<number>;
  119390. private _onBeforeRenderObserver;
  119391. /**
  119392. * Set a before render callback in the texture.
  119393. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  119394. */
  119395. set onBeforeRender(callback: (faceIndex: number) => void);
  119396. /**
  119397. * An event triggered after rendering the texture
  119398. */
  119399. onAfterRenderObservable: Observable<number>;
  119400. private _onAfterRenderObserver;
  119401. /**
  119402. * Set a after render callback in the texture.
  119403. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  119404. */
  119405. set onAfterRender(callback: (faceIndex: number) => void);
  119406. /**
  119407. * An event triggered after the texture clear
  119408. */
  119409. onClearObservable: Observable<Engine>;
  119410. private _onClearObserver;
  119411. /**
  119412. * Set a clear callback in the texture.
  119413. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  119414. */
  119415. set onClear(callback: (Engine: Engine) => void);
  119416. /**
  119417. * An event triggered when the texture is resized.
  119418. */
  119419. onResizeObservable: Observable<RenderTargetTexture>;
  119420. /**
  119421. * Define the clear color of the Render Target if it should be different from the scene.
  119422. */
  119423. clearColor: Color4;
  119424. protected _size: number | {
  119425. width: number;
  119426. height: number;
  119427. layers?: number;
  119428. };
  119429. protected _initialSizeParameter: number | {
  119430. width: number;
  119431. height: number;
  119432. } | {
  119433. ratio: number;
  119434. };
  119435. protected _sizeRatio: Nullable<number>;
  119436. /** @hidden */
  119437. _generateMipMaps: boolean;
  119438. protected _renderingManager: RenderingManager;
  119439. /** @hidden */
  119440. _waitingRenderList?: string[];
  119441. protected _doNotChangeAspectRatio: boolean;
  119442. protected _currentRefreshId: number;
  119443. protected _refreshRate: number;
  119444. protected _textureMatrix: Matrix;
  119445. protected _samples: number;
  119446. protected _renderTargetOptions: RenderTargetCreationOptions;
  119447. /**
  119448. * Gets render target creation options that were used.
  119449. */
  119450. get renderTargetOptions(): RenderTargetCreationOptions;
  119451. protected _onRatioRescale(): void;
  119452. /**
  119453. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  119454. * It must define where the camera used to render the texture is set
  119455. */
  119456. boundingBoxPosition: Vector3;
  119457. private _boundingBoxSize;
  119458. /**
  119459. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  119460. * When defined, the cubemap will switch to local mode
  119461. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119462. * @example https://www.babylonjs-playground.com/#RNASML
  119463. */
  119464. set boundingBoxSize(value: Vector3);
  119465. get boundingBoxSize(): Vector3;
  119466. /**
  119467. * In case the RTT has been created with a depth texture, get the associated
  119468. * depth texture.
  119469. * Otherwise, return null.
  119470. */
  119471. get depthStencilTexture(): Nullable<InternalTexture>;
  119472. /**
  119473. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  119474. * or used a shadow, depth texture...
  119475. * @param name The friendly name of the texture
  119476. * @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)
  119477. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  119478. * @param generateMipMaps True if mip maps need to be generated after render.
  119479. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  119480. * @param type The type of the buffer in the RTT (int, half float, float...)
  119481. * @param isCube True if a cube texture needs to be created
  119482. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  119483. * @param generateDepthBuffer True to generate a depth buffer
  119484. * @param generateStencilBuffer True to generate a stencil buffer
  119485. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  119486. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  119487. * @param delayAllocation if the texture allocation should be delayed (default: false)
  119488. */
  119489. constructor(name: string, size: number | {
  119490. width: number;
  119491. height: number;
  119492. layers?: number;
  119493. } | {
  119494. ratio: number;
  119495. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  119496. /**
  119497. * Creates a depth stencil texture.
  119498. * This is only available in WebGL 2 or with the depth texture extension available.
  119499. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  119500. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  119501. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  119502. */
  119503. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  119504. private _processSizeParameter;
  119505. /**
  119506. * Define the number of samples to use in case of MSAA.
  119507. * It defaults to one meaning no MSAA has been enabled.
  119508. */
  119509. get samples(): number;
  119510. set samples(value: number);
  119511. /**
  119512. * Resets the refresh counter of the texture and start bak from scratch.
  119513. * Could be useful to regenerate the texture if it is setup to render only once.
  119514. */
  119515. resetRefreshCounter(): void;
  119516. /**
  119517. * Define the refresh rate of the texture or the rendering frequency.
  119518. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  119519. */
  119520. get refreshRate(): number;
  119521. set refreshRate(value: number);
  119522. /**
  119523. * Adds a post process to the render target rendering passes.
  119524. * @param postProcess define the post process to add
  119525. */
  119526. addPostProcess(postProcess: PostProcess): void;
  119527. /**
  119528. * Clear all the post processes attached to the render target
  119529. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  119530. */
  119531. clearPostProcesses(dispose?: boolean): void;
  119532. /**
  119533. * Remove one of the post process from the list of attached post processes to the texture
  119534. * @param postProcess define the post process to remove from the list
  119535. */
  119536. removePostProcess(postProcess: PostProcess): void;
  119537. /** @hidden */
  119538. _shouldRender(): boolean;
  119539. /**
  119540. * Gets the actual render size of the texture.
  119541. * @returns the width of the render size
  119542. */
  119543. getRenderSize(): number;
  119544. /**
  119545. * Gets the actual render width of the texture.
  119546. * @returns the width of the render size
  119547. */
  119548. getRenderWidth(): number;
  119549. /**
  119550. * Gets the actual render height of the texture.
  119551. * @returns the height of the render size
  119552. */
  119553. getRenderHeight(): number;
  119554. /**
  119555. * Gets the actual number of layers of the texture.
  119556. * @returns the number of layers
  119557. */
  119558. getRenderLayers(): number;
  119559. /**
  119560. * Get if the texture can be rescaled or not.
  119561. */
  119562. get canRescale(): boolean;
  119563. /**
  119564. * Resize the texture using a ratio.
  119565. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  119566. */
  119567. scale(ratio: number): void;
  119568. /**
  119569. * Get the texture reflection matrix used to rotate/transform the reflection.
  119570. * @returns the reflection matrix
  119571. */
  119572. getReflectionTextureMatrix(): Matrix;
  119573. /**
  119574. * Resize the texture to a new desired size.
  119575. * Be carrefull as it will recreate all the data in the new texture.
  119576. * @param size Define the new size. It can be:
  119577. * - a number for squared texture,
  119578. * - an object containing { width: number, height: number }
  119579. * - or an object containing a ratio { ratio: number }
  119580. */
  119581. resize(size: number | {
  119582. width: number;
  119583. height: number;
  119584. } | {
  119585. ratio: number;
  119586. }): void;
  119587. private _defaultRenderListPrepared;
  119588. /**
  119589. * Renders all the objects from the render list into the texture.
  119590. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  119591. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  119592. */
  119593. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  119594. private _bestReflectionRenderTargetDimension;
  119595. private _prepareRenderingManager;
  119596. /**
  119597. * @hidden
  119598. * @param faceIndex face index to bind to if this is a cubetexture
  119599. * @param layer defines the index of the texture to bind in the array
  119600. */
  119601. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  119602. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119603. private renderToTarget;
  119604. /**
  119605. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119606. * This allowed control for front to back rendering or reversly depending of the special needs.
  119607. *
  119608. * @param renderingGroupId The rendering group id corresponding to its index
  119609. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119610. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119611. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119612. */
  119613. 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;
  119614. /**
  119615. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119616. *
  119617. * @param renderingGroupId The rendering group id corresponding to its index
  119618. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119619. */
  119620. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119621. /**
  119622. * Clones the texture.
  119623. * @returns the cloned texture
  119624. */
  119625. clone(): RenderTargetTexture;
  119626. /**
  119627. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  119628. * @returns The JSON representation of the texture
  119629. */
  119630. serialize(): any;
  119631. /**
  119632. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  119633. */
  119634. disposeFramebufferObjects(): void;
  119635. /**
  119636. * Dispose the texture and release its associated resources.
  119637. */
  119638. dispose(): void;
  119639. /** @hidden */
  119640. _rebuild(): void;
  119641. /**
  119642. * Clear the info related to rendering groups preventing retention point in material dispose.
  119643. */
  119644. freeRenderingGroups(): void;
  119645. /**
  119646. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  119647. * @returns the view count
  119648. */
  119649. getViewCount(): number;
  119650. }
  119651. }
  119652. declare module BABYLON {
  119653. /**
  119654. * Options to be used when creating an effect.
  119655. */
  119656. export interface IEffectCreationOptions {
  119657. /**
  119658. * Atrributes that will be used in the shader.
  119659. */
  119660. attributes: string[];
  119661. /**
  119662. * Uniform varible names that will be set in the shader.
  119663. */
  119664. uniformsNames: string[];
  119665. /**
  119666. * Uniform buffer variable names that will be set in the shader.
  119667. */
  119668. uniformBuffersNames: string[];
  119669. /**
  119670. * Sampler texture variable names that will be set in the shader.
  119671. */
  119672. samplers: string[];
  119673. /**
  119674. * Define statements that will be set in the shader.
  119675. */
  119676. defines: any;
  119677. /**
  119678. * Possible fallbacks for this effect to improve performance when needed.
  119679. */
  119680. fallbacks: Nullable<IEffectFallbacks>;
  119681. /**
  119682. * Callback that will be called when the shader is compiled.
  119683. */
  119684. onCompiled: Nullable<(effect: Effect) => void>;
  119685. /**
  119686. * Callback that will be called if an error occurs during shader compilation.
  119687. */
  119688. onError: Nullable<(effect: Effect, errors: string) => void>;
  119689. /**
  119690. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119691. */
  119692. indexParameters?: any;
  119693. /**
  119694. * Max number of lights that can be used in the shader.
  119695. */
  119696. maxSimultaneousLights?: number;
  119697. /**
  119698. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  119699. */
  119700. transformFeedbackVaryings?: Nullable<string[]>;
  119701. /**
  119702. * 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
  119703. */
  119704. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  119705. /**
  119706. * Is this effect rendering to several color attachments ?
  119707. */
  119708. multiTarget?: boolean;
  119709. }
  119710. /**
  119711. * Effect containing vertex and fragment shader that can be executed on an object.
  119712. */
  119713. export class Effect implements IDisposable {
  119714. /**
  119715. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119716. */
  119717. static ShadersRepository: string;
  119718. /**
  119719. * Enable logging of the shader code when a compilation error occurs
  119720. */
  119721. static LogShaderCodeOnCompilationError: boolean;
  119722. /**
  119723. * Name of the effect.
  119724. */
  119725. name: any;
  119726. /**
  119727. * String container all the define statements that should be set on the shader.
  119728. */
  119729. defines: string;
  119730. /**
  119731. * Callback that will be called when the shader is compiled.
  119732. */
  119733. onCompiled: Nullable<(effect: Effect) => void>;
  119734. /**
  119735. * Callback that will be called if an error occurs during shader compilation.
  119736. */
  119737. onError: Nullable<(effect: Effect, errors: string) => void>;
  119738. /**
  119739. * Callback that will be called when effect is bound.
  119740. */
  119741. onBind: Nullable<(effect: Effect) => void>;
  119742. /**
  119743. * Unique ID of the effect.
  119744. */
  119745. uniqueId: number;
  119746. /**
  119747. * Observable that will be called when the shader is compiled.
  119748. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  119749. */
  119750. onCompileObservable: Observable<Effect>;
  119751. /**
  119752. * Observable that will be called if an error occurs during shader compilation.
  119753. */
  119754. onErrorObservable: Observable<Effect>;
  119755. /** @hidden */
  119756. _onBindObservable: Nullable<Observable<Effect>>;
  119757. /**
  119758. * @hidden
  119759. * Specifies if the effect was previously ready
  119760. */
  119761. _wasPreviouslyReady: boolean;
  119762. /**
  119763. * Observable that will be called when effect is bound.
  119764. */
  119765. get onBindObservable(): Observable<Effect>;
  119766. /** @hidden */
  119767. _bonesComputationForcedToCPU: boolean;
  119768. /** @hidden */
  119769. _multiTarget: boolean;
  119770. private static _uniqueIdSeed;
  119771. private _engine;
  119772. private _uniformBuffersNames;
  119773. private _uniformBuffersNamesList;
  119774. private _uniformsNames;
  119775. private _samplerList;
  119776. private _samplers;
  119777. private _isReady;
  119778. private _compilationError;
  119779. private _allFallbacksProcessed;
  119780. private _attributesNames;
  119781. private _attributes;
  119782. private _attributeLocationByName;
  119783. private _uniforms;
  119784. /**
  119785. * Key for the effect.
  119786. * @hidden
  119787. */
  119788. _key: string;
  119789. private _indexParameters;
  119790. private _fallbacks;
  119791. private _vertexSourceCode;
  119792. private _fragmentSourceCode;
  119793. private _vertexSourceCodeOverride;
  119794. private _fragmentSourceCodeOverride;
  119795. private _transformFeedbackVaryings;
  119796. private _rawVertexSourceCode;
  119797. private _rawFragmentSourceCode;
  119798. /**
  119799. * Compiled shader to webGL program.
  119800. * @hidden
  119801. */
  119802. _pipelineContext: Nullable<IPipelineContext>;
  119803. private _valueCache;
  119804. private static _baseCache;
  119805. /**
  119806. * Instantiates an effect.
  119807. * An effect can be used to create/manage/execute vertex and fragment shaders.
  119808. * @param baseName Name of the effect.
  119809. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  119810. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  119811. * @param samplers List of sampler variables that will be passed to the shader.
  119812. * @param engine Engine to be used to render the effect
  119813. * @param defines Define statements to be added to the shader.
  119814. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  119815. * @param onCompiled Callback that will be called when the shader is compiled.
  119816. * @param onError Callback that will be called if an error occurs during shader compilation.
  119817. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119818. */
  119819. 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);
  119820. private _useFinalCode;
  119821. /**
  119822. * Unique key for this effect
  119823. */
  119824. get key(): string;
  119825. /**
  119826. * If the effect has been compiled and prepared.
  119827. * @returns if the effect is compiled and prepared.
  119828. */
  119829. isReady(): boolean;
  119830. private _isReadyInternal;
  119831. /**
  119832. * The engine the effect was initialized with.
  119833. * @returns the engine.
  119834. */
  119835. getEngine(): Engine;
  119836. /**
  119837. * The pipeline context for this effect
  119838. * @returns the associated pipeline context
  119839. */
  119840. getPipelineContext(): Nullable<IPipelineContext>;
  119841. /**
  119842. * The set of names of attribute variables for the shader.
  119843. * @returns An array of attribute names.
  119844. */
  119845. getAttributesNames(): string[];
  119846. /**
  119847. * Returns the attribute at the given index.
  119848. * @param index The index of the attribute.
  119849. * @returns The location of the attribute.
  119850. */
  119851. getAttributeLocation(index: number): number;
  119852. /**
  119853. * Returns the attribute based on the name of the variable.
  119854. * @param name of the attribute to look up.
  119855. * @returns the attribute location.
  119856. */
  119857. getAttributeLocationByName(name: string): number;
  119858. /**
  119859. * The number of attributes.
  119860. * @returns the numnber of attributes.
  119861. */
  119862. getAttributesCount(): number;
  119863. /**
  119864. * Gets the index of a uniform variable.
  119865. * @param uniformName of the uniform to look up.
  119866. * @returns the index.
  119867. */
  119868. getUniformIndex(uniformName: string): number;
  119869. /**
  119870. * Returns the attribute based on the name of the variable.
  119871. * @param uniformName of the uniform to look up.
  119872. * @returns the location of the uniform.
  119873. */
  119874. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  119875. /**
  119876. * Returns an array of sampler variable names
  119877. * @returns The array of sampler variable names.
  119878. */
  119879. getSamplers(): string[];
  119880. /**
  119881. * Returns an array of uniform variable names
  119882. * @returns The array of uniform variable names.
  119883. */
  119884. getUniformNames(): string[];
  119885. /**
  119886. * Returns an array of uniform buffer variable names
  119887. * @returns The array of uniform buffer variable names.
  119888. */
  119889. getUniformBuffersNames(): string[];
  119890. /**
  119891. * Returns the index parameters used to create the effect
  119892. * @returns The index parameters object
  119893. */
  119894. getIndexParameters(): any;
  119895. /**
  119896. * The error from the last compilation.
  119897. * @returns the error string.
  119898. */
  119899. getCompilationError(): string;
  119900. /**
  119901. * Gets a boolean indicating that all fallbacks were used during compilation
  119902. * @returns true if all fallbacks were used
  119903. */
  119904. allFallbacksProcessed(): boolean;
  119905. /**
  119906. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  119907. * @param func The callback to be used.
  119908. */
  119909. executeWhenCompiled(func: (effect: Effect) => void): void;
  119910. private _checkIsReady;
  119911. private _loadShader;
  119912. /**
  119913. * Gets the vertex shader source code of this effect
  119914. */
  119915. get vertexSourceCode(): string;
  119916. /**
  119917. * Gets the fragment shader source code of this effect
  119918. */
  119919. get fragmentSourceCode(): string;
  119920. /**
  119921. * Gets the vertex shader source code before it has been processed by the preprocessor
  119922. */
  119923. get rawVertexSourceCode(): string;
  119924. /**
  119925. * Gets the fragment shader source code before it has been processed by the preprocessor
  119926. */
  119927. get rawFragmentSourceCode(): string;
  119928. /**
  119929. * Recompiles the webGL program
  119930. * @param vertexSourceCode The source code for the vertex shader.
  119931. * @param fragmentSourceCode The source code for the fragment shader.
  119932. * @param onCompiled Callback called when completed.
  119933. * @param onError Callback called on error.
  119934. * @hidden
  119935. */
  119936. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  119937. /**
  119938. * Prepares the effect
  119939. * @hidden
  119940. */
  119941. _prepareEffect(): void;
  119942. private _getShaderCodeAndErrorLine;
  119943. private _processCompilationErrors;
  119944. /**
  119945. * Checks if the effect is supported. (Must be called after compilation)
  119946. */
  119947. get isSupported(): boolean;
  119948. /**
  119949. * Binds a texture to the engine to be used as output of the shader.
  119950. * @param channel Name of the output variable.
  119951. * @param texture Texture to bind.
  119952. * @hidden
  119953. */
  119954. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  119955. /**
  119956. * Sets a texture on the engine to be used in the shader.
  119957. * @param channel Name of the sampler variable.
  119958. * @param texture Texture to set.
  119959. */
  119960. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  119961. /**
  119962. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  119963. * @param channel Name of the sampler variable.
  119964. * @param texture Texture to set.
  119965. */
  119966. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  119967. /**
  119968. * Sets an array of textures on the engine to be used in the shader.
  119969. * @param channel Name of the variable.
  119970. * @param textures Textures to set.
  119971. */
  119972. setTextureArray(channel: string, textures: ThinTexture[]): void;
  119973. /**
  119974. * 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)
  119975. * @param channel Name of the sampler variable.
  119976. * @param postProcess Post process to get the input texture from.
  119977. */
  119978. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  119979. /**
  119980. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  119981. * 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)
  119982. * @param channel Name of the sampler variable.
  119983. * @param postProcess Post process to get the output texture from.
  119984. */
  119985. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  119986. /** @hidden */
  119987. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  119988. /** @hidden */
  119989. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  119990. /** @hidden */
  119991. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  119992. /** @hidden */
  119993. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  119994. /**
  119995. * Binds a buffer to a uniform.
  119996. * @param buffer Buffer to bind.
  119997. * @param name Name of the uniform variable to bind to.
  119998. */
  119999. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  120000. /**
  120001. * Binds block to a uniform.
  120002. * @param blockName Name of the block to bind.
  120003. * @param index Index to bind.
  120004. */
  120005. bindUniformBlock(blockName: string, index: number): void;
  120006. /**
  120007. * Sets an interger value on a uniform variable.
  120008. * @param uniformName Name of the variable.
  120009. * @param value Value to be set.
  120010. * @returns this effect.
  120011. */
  120012. setInt(uniformName: string, value: number): Effect;
  120013. /**
  120014. * Sets an int array on a uniform variable.
  120015. * @param uniformName Name of the variable.
  120016. * @param array array to be set.
  120017. * @returns this effect.
  120018. */
  120019. setIntArray(uniformName: string, array: Int32Array): Effect;
  120020. /**
  120021. * 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)
  120022. * @param uniformName Name of the variable.
  120023. * @param array array to be set.
  120024. * @returns this effect.
  120025. */
  120026. setIntArray2(uniformName: string, array: Int32Array): Effect;
  120027. /**
  120028. * 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)
  120029. * @param uniformName Name of the variable.
  120030. * @param array array to be set.
  120031. * @returns this effect.
  120032. */
  120033. setIntArray3(uniformName: string, array: Int32Array): Effect;
  120034. /**
  120035. * 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)
  120036. * @param uniformName Name of the variable.
  120037. * @param array array to be set.
  120038. * @returns this effect.
  120039. */
  120040. setIntArray4(uniformName: string, array: Int32Array): Effect;
  120041. /**
  120042. * Sets an float array on a uniform variable.
  120043. * @param uniformName Name of the variable.
  120044. * @param array array to be set.
  120045. * @returns this effect.
  120046. */
  120047. setFloatArray(uniformName: string, array: Float32Array): Effect;
  120048. /**
  120049. * 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)
  120050. * @param uniformName Name of the variable.
  120051. * @param array array to be set.
  120052. * @returns this effect.
  120053. */
  120054. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  120055. /**
  120056. * 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)
  120057. * @param uniformName Name of the variable.
  120058. * @param array array to be set.
  120059. * @returns this effect.
  120060. */
  120061. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  120062. /**
  120063. * 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)
  120064. * @param uniformName Name of the variable.
  120065. * @param array array to be set.
  120066. * @returns this effect.
  120067. */
  120068. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  120069. /**
  120070. * Sets an array on a uniform variable.
  120071. * @param uniformName Name of the variable.
  120072. * @param array array to be set.
  120073. * @returns this effect.
  120074. */
  120075. setArray(uniformName: string, array: number[]): Effect;
  120076. /**
  120077. * 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)
  120078. * @param uniformName Name of the variable.
  120079. * @param array array to be set.
  120080. * @returns this effect.
  120081. */
  120082. setArray2(uniformName: string, array: number[]): Effect;
  120083. /**
  120084. * 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)
  120085. * @param uniformName Name of the variable.
  120086. * @param array array to be set.
  120087. * @returns this effect.
  120088. */
  120089. setArray3(uniformName: string, array: number[]): Effect;
  120090. /**
  120091. * 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)
  120092. * @param uniformName Name of the variable.
  120093. * @param array array to be set.
  120094. * @returns this effect.
  120095. */
  120096. setArray4(uniformName: string, array: number[]): Effect;
  120097. /**
  120098. * Sets matrices on a uniform variable.
  120099. * @param uniformName Name of the variable.
  120100. * @param matrices matrices to be set.
  120101. * @returns this effect.
  120102. */
  120103. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  120104. /**
  120105. * Sets matrix on a uniform variable.
  120106. * @param uniformName Name of the variable.
  120107. * @param matrix matrix to be set.
  120108. * @returns this effect.
  120109. */
  120110. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  120111. /**
  120112. * 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)
  120113. * @param uniformName Name of the variable.
  120114. * @param matrix matrix to be set.
  120115. * @returns this effect.
  120116. */
  120117. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  120118. /**
  120119. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  120120. * @param uniformName Name of the variable.
  120121. * @param matrix matrix to be set.
  120122. * @returns this effect.
  120123. */
  120124. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  120125. /**
  120126. * Sets a float on a uniform variable.
  120127. * @param uniformName Name of the variable.
  120128. * @param value value to be set.
  120129. * @returns this effect.
  120130. */
  120131. setFloat(uniformName: string, value: number): Effect;
  120132. /**
  120133. * Sets a boolean on a uniform variable.
  120134. * @param uniformName Name of the variable.
  120135. * @param bool value to be set.
  120136. * @returns this effect.
  120137. */
  120138. setBool(uniformName: string, bool: boolean): Effect;
  120139. /**
  120140. * Sets a Vector2 on a uniform variable.
  120141. * @param uniformName Name of the variable.
  120142. * @param vector2 vector2 to be set.
  120143. * @returns this effect.
  120144. */
  120145. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  120146. /**
  120147. * Sets a float2 on a uniform variable.
  120148. * @param uniformName Name of the variable.
  120149. * @param x First float in float2.
  120150. * @param y Second float in float2.
  120151. * @returns this effect.
  120152. */
  120153. setFloat2(uniformName: string, x: number, y: number): Effect;
  120154. /**
  120155. * Sets a Vector3 on a uniform variable.
  120156. * @param uniformName Name of the variable.
  120157. * @param vector3 Value to be set.
  120158. * @returns this effect.
  120159. */
  120160. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  120161. /**
  120162. * Sets a float3 on a uniform variable.
  120163. * @param uniformName Name of the variable.
  120164. * @param x First float in float3.
  120165. * @param y Second float in float3.
  120166. * @param z Third float in float3.
  120167. * @returns this effect.
  120168. */
  120169. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  120170. /**
  120171. * Sets a Vector4 on a uniform variable.
  120172. * @param uniformName Name of the variable.
  120173. * @param vector4 Value to be set.
  120174. * @returns this effect.
  120175. */
  120176. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  120177. /**
  120178. * Sets a float4 on a uniform variable.
  120179. * @param uniformName Name of the variable.
  120180. * @param x First float in float4.
  120181. * @param y Second float in float4.
  120182. * @param z Third float in float4.
  120183. * @param w Fourth float in float4.
  120184. * @returns this effect.
  120185. */
  120186. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  120187. /**
  120188. * Sets a Color3 on a uniform variable.
  120189. * @param uniformName Name of the variable.
  120190. * @param color3 Value to be set.
  120191. * @returns this effect.
  120192. */
  120193. setColor3(uniformName: string, color3: IColor3Like): Effect;
  120194. /**
  120195. * Sets a Color4 on a uniform variable.
  120196. * @param uniformName Name of the variable.
  120197. * @param color3 Value to be set.
  120198. * @param alpha Alpha value to be set.
  120199. * @returns this effect.
  120200. */
  120201. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  120202. /**
  120203. * Sets a Color4 on a uniform variable
  120204. * @param uniformName defines the name of the variable
  120205. * @param color4 defines the value to be set
  120206. * @returns this effect.
  120207. */
  120208. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  120209. /** Release all associated resources */
  120210. dispose(): void;
  120211. /**
  120212. * This function will add a new shader to the shader store
  120213. * @param name the name of the shader
  120214. * @param pixelShader optional pixel shader content
  120215. * @param vertexShader optional vertex shader content
  120216. */
  120217. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  120218. /**
  120219. * Store of each shader (The can be looked up using effect.key)
  120220. */
  120221. static ShadersStore: {
  120222. [key: string]: string;
  120223. };
  120224. /**
  120225. * Store of each included file for a shader (The can be looked up using effect.key)
  120226. */
  120227. static IncludesShadersStore: {
  120228. [key: string]: string;
  120229. };
  120230. /**
  120231. * Resets the cache of effects.
  120232. */
  120233. static ResetCache(): void;
  120234. }
  120235. }
  120236. declare module BABYLON {
  120237. /**
  120238. * Interface used to describe the capabilities of the engine relatively to the current browser
  120239. */
  120240. export interface EngineCapabilities {
  120241. /** Maximum textures units per fragment shader */
  120242. maxTexturesImageUnits: number;
  120243. /** Maximum texture units per vertex shader */
  120244. maxVertexTextureImageUnits: number;
  120245. /** Maximum textures units in the entire pipeline */
  120246. maxCombinedTexturesImageUnits: number;
  120247. /** Maximum texture size */
  120248. maxTextureSize: number;
  120249. /** Maximum texture samples */
  120250. maxSamples?: number;
  120251. /** Maximum cube texture size */
  120252. maxCubemapTextureSize: number;
  120253. /** Maximum render texture size */
  120254. maxRenderTextureSize: number;
  120255. /** Maximum number of vertex attributes */
  120256. maxVertexAttribs: number;
  120257. /** Maximum number of varyings */
  120258. maxVaryingVectors: number;
  120259. /** Maximum number of uniforms per vertex shader */
  120260. maxVertexUniformVectors: number;
  120261. /** Maximum number of uniforms per fragment shader */
  120262. maxFragmentUniformVectors: number;
  120263. /** Defines if standard derivates (dx/dy) are supported */
  120264. standardDerivatives: boolean;
  120265. /** Defines if s3tc texture compression is supported */
  120266. s3tc?: WEBGL_compressed_texture_s3tc;
  120267. /** Defines if pvrtc texture compression is supported */
  120268. pvrtc: any;
  120269. /** Defines if etc1 texture compression is supported */
  120270. etc1: any;
  120271. /** Defines if etc2 texture compression is supported */
  120272. etc2: any;
  120273. /** Defines if astc texture compression is supported */
  120274. astc: any;
  120275. /** Defines if bptc texture compression is supported */
  120276. bptc: any;
  120277. /** Defines if float textures are supported */
  120278. textureFloat: boolean;
  120279. /** Defines if vertex array objects are supported */
  120280. vertexArrayObject: boolean;
  120281. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  120282. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  120283. /** Gets the maximum level of anisotropy supported */
  120284. maxAnisotropy: number;
  120285. /** Defines if instancing is supported */
  120286. instancedArrays: boolean;
  120287. /** Defines if 32 bits indices are supported */
  120288. uintIndices: boolean;
  120289. /** Defines if high precision shaders are supported */
  120290. highPrecisionShaderSupported: boolean;
  120291. /** Defines if depth reading in the fragment shader is supported */
  120292. fragmentDepthSupported: boolean;
  120293. /** Defines if float texture linear filtering is supported*/
  120294. textureFloatLinearFiltering: boolean;
  120295. /** Defines if rendering to float textures is supported */
  120296. textureFloatRender: boolean;
  120297. /** Defines if half float textures are supported*/
  120298. textureHalfFloat: boolean;
  120299. /** Defines if half float texture linear filtering is supported*/
  120300. textureHalfFloatLinearFiltering: boolean;
  120301. /** Defines if rendering to half float textures is supported */
  120302. textureHalfFloatRender: boolean;
  120303. /** Defines if textureLOD shader command is supported */
  120304. textureLOD: boolean;
  120305. /** Defines if draw buffers extension is supported */
  120306. drawBuffersExtension: boolean;
  120307. /** Defines if depth textures are supported */
  120308. depthTextureExtension: boolean;
  120309. /** Defines if float color buffer are supported */
  120310. colorBufferFloat: boolean;
  120311. /** Gets disjoint timer query extension (null if not supported) */
  120312. timerQuery?: EXT_disjoint_timer_query;
  120313. /** Defines if timestamp can be used with timer query */
  120314. canUseTimestampForTimerQuery: boolean;
  120315. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  120316. multiview?: any;
  120317. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  120318. oculusMultiview?: any;
  120319. /** Function used to let the system compiles shaders in background */
  120320. parallelShaderCompile?: {
  120321. COMPLETION_STATUS_KHR: number;
  120322. };
  120323. /** Max number of texture samples for MSAA */
  120324. maxMSAASamples: number;
  120325. /** Defines if the blend min max extension is supported */
  120326. blendMinMax: boolean;
  120327. }
  120328. }
  120329. declare module BABYLON {
  120330. /**
  120331. * @hidden
  120332. **/
  120333. export class DepthCullingState {
  120334. private _isDepthTestDirty;
  120335. private _isDepthMaskDirty;
  120336. private _isDepthFuncDirty;
  120337. private _isCullFaceDirty;
  120338. private _isCullDirty;
  120339. private _isZOffsetDirty;
  120340. private _isFrontFaceDirty;
  120341. private _depthTest;
  120342. private _depthMask;
  120343. private _depthFunc;
  120344. private _cull;
  120345. private _cullFace;
  120346. private _zOffset;
  120347. private _frontFace;
  120348. /**
  120349. * Initializes the state.
  120350. */
  120351. constructor();
  120352. get isDirty(): boolean;
  120353. get zOffset(): number;
  120354. set zOffset(value: number);
  120355. get cullFace(): Nullable<number>;
  120356. set cullFace(value: Nullable<number>);
  120357. get cull(): Nullable<boolean>;
  120358. set cull(value: Nullable<boolean>);
  120359. get depthFunc(): Nullable<number>;
  120360. set depthFunc(value: Nullable<number>);
  120361. get depthMask(): boolean;
  120362. set depthMask(value: boolean);
  120363. get depthTest(): boolean;
  120364. set depthTest(value: boolean);
  120365. get frontFace(): Nullable<number>;
  120366. set frontFace(value: Nullable<number>);
  120367. reset(): void;
  120368. apply(gl: WebGLRenderingContext): void;
  120369. }
  120370. }
  120371. declare module BABYLON {
  120372. /**
  120373. * @hidden
  120374. **/
  120375. export class StencilState {
  120376. /** 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 */
  120377. static readonly ALWAYS: number;
  120378. /** Passed to stencilOperation to specify that stencil value must be kept */
  120379. static readonly KEEP: number;
  120380. /** Passed to stencilOperation to specify that stencil value must be replaced */
  120381. static readonly REPLACE: number;
  120382. private _isStencilTestDirty;
  120383. private _isStencilMaskDirty;
  120384. private _isStencilFuncDirty;
  120385. private _isStencilOpDirty;
  120386. private _stencilTest;
  120387. private _stencilMask;
  120388. private _stencilFunc;
  120389. private _stencilFuncRef;
  120390. private _stencilFuncMask;
  120391. private _stencilOpStencilFail;
  120392. private _stencilOpDepthFail;
  120393. private _stencilOpStencilDepthPass;
  120394. get isDirty(): boolean;
  120395. get stencilFunc(): number;
  120396. set stencilFunc(value: number);
  120397. get stencilFuncRef(): number;
  120398. set stencilFuncRef(value: number);
  120399. get stencilFuncMask(): number;
  120400. set stencilFuncMask(value: number);
  120401. get stencilOpStencilFail(): number;
  120402. set stencilOpStencilFail(value: number);
  120403. get stencilOpDepthFail(): number;
  120404. set stencilOpDepthFail(value: number);
  120405. get stencilOpStencilDepthPass(): number;
  120406. set stencilOpStencilDepthPass(value: number);
  120407. get stencilMask(): number;
  120408. set stencilMask(value: number);
  120409. get stencilTest(): boolean;
  120410. set stencilTest(value: boolean);
  120411. constructor();
  120412. reset(): void;
  120413. apply(gl: WebGLRenderingContext): void;
  120414. }
  120415. }
  120416. declare module BABYLON {
  120417. /**
  120418. * @hidden
  120419. **/
  120420. export class AlphaState {
  120421. private _isAlphaBlendDirty;
  120422. private _isBlendFunctionParametersDirty;
  120423. private _isBlendEquationParametersDirty;
  120424. private _isBlendConstantsDirty;
  120425. private _alphaBlend;
  120426. private _blendFunctionParameters;
  120427. private _blendEquationParameters;
  120428. private _blendConstants;
  120429. /**
  120430. * Initializes the state.
  120431. */
  120432. constructor();
  120433. get isDirty(): boolean;
  120434. get alphaBlend(): boolean;
  120435. set alphaBlend(value: boolean);
  120436. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  120437. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  120438. setAlphaEquationParameters(rgb: number, alpha: number): void;
  120439. reset(): void;
  120440. apply(gl: WebGLRenderingContext): void;
  120441. }
  120442. }
  120443. declare module BABYLON {
  120444. /** @hidden */
  120445. export class WebGLShaderProcessor implements IShaderProcessor {
  120446. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  120447. }
  120448. }
  120449. declare module BABYLON {
  120450. /** @hidden */
  120451. export class WebGL2ShaderProcessor implements IShaderProcessor {
  120452. attributeProcessor(attribute: string): string;
  120453. varyingProcessor(varying: string, isFragment: boolean): string;
  120454. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120455. }
  120456. }
  120457. declare module BABYLON {
  120458. /**
  120459. * Interface for attribute information associated with buffer instanciation
  120460. */
  120461. export interface InstancingAttributeInfo {
  120462. /**
  120463. * Name of the GLSL attribute
  120464. * if attribute index is not specified, this is used to retrieve the index from the effect
  120465. */
  120466. attributeName: string;
  120467. /**
  120468. * Index/offset of the attribute in the vertex shader
  120469. * if not specified, this will be computes from the name.
  120470. */
  120471. index?: number;
  120472. /**
  120473. * size of the attribute, 1, 2, 3 or 4
  120474. */
  120475. attributeSize: number;
  120476. /**
  120477. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  120478. */
  120479. offset: number;
  120480. /**
  120481. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  120482. * default to 1
  120483. */
  120484. divisor?: number;
  120485. /**
  120486. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  120487. * default is FLOAT
  120488. */
  120489. attributeType?: number;
  120490. /**
  120491. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  120492. */
  120493. normalized?: boolean;
  120494. }
  120495. }
  120496. declare module BABYLON {
  120497. interface ThinEngine {
  120498. /**
  120499. * Update a video texture
  120500. * @param texture defines the texture to update
  120501. * @param video defines the video element to use
  120502. * @param invertY defines if data must be stored with Y axis inverted
  120503. */
  120504. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  120505. }
  120506. }
  120507. declare module BABYLON {
  120508. interface ThinEngine {
  120509. /**
  120510. * Creates a dynamic texture
  120511. * @param width defines the width of the texture
  120512. * @param height defines the height of the texture
  120513. * @param generateMipMaps defines if the engine should generate the mip levels
  120514. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  120515. * @returns the dynamic texture inside an InternalTexture
  120516. */
  120517. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  120518. /**
  120519. * Update the content of a dynamic texture
  120520. * @param texture defines the texture to update
  120521. * @param source defines the source containing the data
  120522. * @param invertY defines if data must be stored with Y axis inverted
  120523. * @param premulAlpha defines if alpha is stored as premultiplied
  120524. * @param format defines the format of the data
  120525. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120526. */
  120527. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  120528. }
  120529. }
  120530. declare module BABYLON {
  120531. /**
  120532. * Settings for finer control over video usage
  120533. */
  120534. export interface VideoTextureSettings {
  120535. /**
  120536. * Applies `autoplay` to video, if specified
  120537. */
  120538. autoPlay?: boolean;
  120539. /**
  120540. * Applies `muted` to video, if specified
  120541. */
  120542. muted?: boolean;
  120543. /**
  120544. * Applies `loop` to video, if specified
  120545. */
  120546. loop?: boolean;
  120547. /**
  120548. * Automatically updates internal texture from video at every frame in the render loop
  120549. */
  120550. autoUpdateTexture: boolean;
  120551. /**
  120552. * Image src displayed during the video loading or until the user interacts with the video.
  120553. */
  120554. poster?: string;
  120555. }
  120556. /**
  120557. * If you want to display a video in your scene, this is the special texture for that.
  120558. * This special texture works similar to other textures, with the exception of a few parameters.
  120559. * @see https://doc.babylonjs.com/how_to/video_texture
  120560. */
  120561. export class VideoTexture extends Texture {
  120562. /**
  120563. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  120564. */
  120565. readonly autoUpdateTexture: boolean;
  120566. /**
  120567. * The video instance used by the texture internally
  120568. */
  120569. readonly video: HTMLVideoElement;
  120570. private _onUserActionRequestedObservable;
  120571. /**
  120572. * Event triggerd when a dom action is required by the user to play the video.
  120573. * This happens due to recent changes in browser policies preventing video to auto start.
  120574. */
  120575. get onUserActionRequestedObservable(): Observable<Texture>;
  120576. private _generateMipMaps;
  120577. private _stillImageCaptured;
  120578. private _displayingPosterTexture;
  120579. private _settings;
  120580. private _createInternalTextureOnEvent;
  120581. private _frameId;
  120582. private _currentSrc;
  120583. /**
  120584. * Creates a video texture.
  120585. * If you want to display a video in your scene, this is the special texture for that.
  120586. * This special texture works similar to other textures, with the exception of a few parameters.
  120587. * @see https://doc.babylonjs.com/how_to/video_texture
  120588. * @param name optional name, will detect from video source, if not defined
  120589. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  120590. * @param scene is obviously the current scene.
  120591. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  120592. * @param invertY is false by default but can be used to invert video on Y axis
  120593. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  120594. * @param settings allows finer control over video usage
  120595. */
  120596. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  120597. private _getName;
  120598. private _getVideo;
  120599. private _createInternalTexture;
  120600. private reset;
  120601. /**
  120602. * @hidden Internal method to initiate `update`.
  120603. */
  120604. _rebuild(): void;
  120605. /**
  120606. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  120607. */
  120608. update(): void;
  120609. /**
  120610. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  120611. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  120612. */
  120613. updateTexture(isVisible: boolean): void;
  120614. protected _updateInternalTexture: () => void;
  120615. /**
  120616. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  120617. * @param url New url.
  120618. */
  120619. updateURL(url: string): void;
  120620. /**
  120621. * Clones the texture.
  120622. * @returns the cloned texture
  120623. */
  120624. clone(): VideoTexture;
  120625. /**
  120626. * Dispose the texture and release its associated resources.
  120627. */
  120628. dispose(): void;
  120629. /**
  120630. * Creates a video texture straight from a stream.
  120631. * @param scene Define the scene the texture should be created in
  120632. * @param stream Define the stream the texture should be created from
  120633. * @returns The created video texture as a promise
  120634. */
  120635. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  120636. /**
  120637. * Creates a video texture straight from your WebCam video feed.
  120638. * @param scene Define the scene the texture should be created in
  120639. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120640. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120641. * @returns The created video texture as a promise
  120642. */
  120643. static CreateFromWebCamAsync(scene: Scene, constraints: {
  120644. minWidth: number;
  120645. maxWidth: number;
  120646. minHeight: number;
  120647. maxHeight: number;
  120648. deviceId: string;
  120649. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  120650. /**
  120651. * Creates a video texture straight from your WebCam video feed.
  120652. * @param scene Define the scene the texture should be created in
  120653. * @param onReady Define a callback to triggered once the texture will be ready
  120654. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120655. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120656. */
  120657. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  120658. minWidth: number;
  120659. maxWidth: number;
  120660. minHeight: number;
  120661. maxHeight: number;
  120662. deviceId: string;
  120663. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  120664. }
  120665. }
  120666. declare module BABYLON {
  120667. /**
  120668. * Defines the interface used by objects working like Scene
  120669. * @hidden
  120670. */
  120671. export interface ISceneLike {
  120672. _addPendingData(data: any): void;
  120673. _removePendingData(data: any): void;
  120674. offlineProvider: IOfflineProvider;
  120675. }
  120676. /**
  120677. * Information about the current host
  120678. */
  120679. export interface HostInformation {
  120680. /**
  120681. * Defines if the current host is a mobile
  120682. */
  120683. isMobile: boolean;
  120684. }
  120685. /** Interface defining initialization parameters for Engine class */
  120686. export interface EngineOptions extends WebGLContextAttributes {
  120687. /**
  120688. * Defines if the engine should no exceed a specified device ratio
  120689. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  120690. */
  120691. limitDeviceRatio?: number;
  120692. /**
  120693. * Defines if webvr should be enabled automatically
  120694. * @see https://doc.babylonjs.com/how_to/webvr_camera
  120695. */
  120696. autoEnableWebVR?: boolean;
  120697. /**
  120698. * Defines if webgl2 should be turned off even if supported
  120699. * @see https://doc.babylonjs.com/features/webgl2
  120700. */
  120701. disableWebGL2Support?: boolean;
  120702. /**
  120703. * Defines if webaudio should be initialized as well
  120704. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120705. */
  120706. audioEngine?: boolean;
  120707. /**
  120708. * Defines if animations should run using a deterministic lock step
  120709. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120710. */
  120711. deterministicLockstep?: boolean;
  120712. /** Defines the maximum steps to use with deterministic lock step mode */
  120713. lockstepMaxSteps?: number;
  120714. /** Defines the seconds between each deterministic lock step */
  120715. timeStep?: number;
  120716. /**
  120717. * Defines that engine should ignore context lost events
  120718. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  120719. */
  120720. doNotHandleContextLost?: boolean;
  120721. /**
  120722. * Defines that engine should ignore modifying touch action attribute and style
  120723. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  120724. */
  120725. doNotHandleTouchAction?: boolean;
  120726. /**
  120727. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  120728. */
  120729. useHighPrecisionFloats?: boolean;
  120730. /**
  120731. * Make the canvas XR Compatible for XR sessions
  120732. */
  120733. xrCompatible?: boolean;
  120734. /**
  120735. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  120736. */
  120737. useHighPrecisionMatrix?: boolean;
  120738. /**
  120739. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  120740. */
  120741. failIfMajorPerformanceCaveat?: boolean;
  120742. }
  120743. /**
  120744. * The base engine class (root of all engines)
  120745. */
  120746. export class ThinEngine {
  120747. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  120748. static ExceptionList: ({
  120749. key: string;
  120750. capture: string;
  120751. captureConstraint: number;
  120752. targets: string[];
  120753. } | {
  120754. key: string;
  120755. capture: null;
  120756. captureConstraint: null;
  120757. targets: string[];
  120758. })[];
  120759. /** @hidden */
  120760. static _TextureLoaders: IInternalTextureLoader[];
  120761. /**
  120762. * Returns the current npm package of the sdk
  120763. */
  120764. static get NpmPackage(): string;
  120765. /**
  120766. * Returns the current version of the framework
  120767. */
  120768. static get Version(): string;
  120769. /**
  120770. * Returns a string describing the current engine
  120771. */
  120772. get description(): string;
  120773. /**
  120774. * Gets or sets the epsilon value used by collision engine
  120775. */
  120776. static CollisionsEpsilon: number;
  120777. /**
  120778. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  120779. */
  120780. static get ShadersRepository(): string;
  120781. static set ShadersRepository(value: string);
  120782. /** @hidden */
  120783. _shaderProcessor: IShaderProcessor;
  120784. /**
  120785. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  120786. */
  120787. forcePOTTextures: boolean;
  120788. /**
  120789. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  120790. */
  120791. isFullscreen: boolean;
  120792. /**
  120793. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  120794. */
  120795. cullBackFaces: boolean;
  120796. /**
  120797. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  120798. */
  120799. renderEvenInBackground: boolean;
  120800. /**
  120801. * Gets or sets a boolean indicating that cache can be kept between frames
  120802. */
  120803. preventCacheWipeBetweenFrames: boolean;
  120804. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  120805. validateShaderPrograms: boolean;
  120806. /**
  120807. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  120808. * This can provide greater z depth for distant objects.
  120809. */
  120810. useReverseDepthBuffer: boolean;
  120811. /**
  120812. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  120813. */
  120814. disableUniformBuffers: boolean;
  120815. /** @hidden */
  120816. _uniformBuffers: UniformBuffer[];
  120817. /**
  120818. * Gets a boolean indicating that the engine supports uniform buffers
  120819. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  120820. */
  120821. get supportsUniformBuffers(): boolean;
  120822. /** @hidden */
  120823. _gl: WebGLRenderingContext;
  120824. /** @hidden */
  120825. _webGLVersion: number;
  120826. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  120827. protected _windowIsBackground: boolean;
  120828. protected _creationOptions: EngineOptions;
  120829. protected _highPrecisionShadersAllowed: boolean;
  120830. /** @hidden */
  120831. get _shouldUseHighPrecisionShader(): boolean;
  120832. /**
  120833. * Gets a boolean indicating that only power of 2 textures are supported
  120834. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  120835. */
  120836. get needPOTTextures(): boolean;
  120837. /** @hidden */
  120838. _badOS: boolean;
  120839. /** @hidden */
  120840. _badDesktopOS: boolean;
  120841. private _hardwareScalingLevel;
  120842. /** @hidden */
  120843. _caps: EngineCapabilities;
  120844. private _isStencilEnable;
  120845. private _glVersion;
  120846. private _glRenderer;
  120847. private _glVendor;
  120848. /** @hidden */
  120849. _videoTextureSupported: boolean;
  120850. protected _renderingQueueLaunched: boolean;
  120851. protected _activeRenderLoops: (() => void)[];
  120852. /**
  120853. * Observable signaled when a context lost event is raised
  120854. */
  120855. onContextLostObservable: Observable<ThinEngine>;
  120856. /**
  120857. * Observable signaled when a context restored event is raised
  120858. */
  120859. onContextRestoredObservable: Observable<ThinEngine>;
  120860. private _onContextLost;
  120861. private _onContextRestored;
  120862. protected _contextWasLost: boolean;
  120863. /** @hidden */
  120864. _doNotHandleContextLost: boolean;
  120865. /**
  120866. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  120867. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  120868. */
  120869. get doNotHandleContextLost(): boolean;
  120870. set doNotHandleContextLost(value: boolean);
  120871. /**
  120872. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  120873. */
  120874. disableVertexArrayObjects: boolean;
  120875. /** @hidden */
  120876. protected _colorWrite: boolean;
  120877. /** @hidden */
  120878. protected _colorWriteChanged: boolean;
  120879. /** @hidden */
  120880. protected _depthCullingState: DepthCullingState;
  120881. /** @hidden */
  120882. protected _stencilState: StencilState;
  120883. /** @hidden */
  120884. _alphaState: AlphaState;
  120885. /** @hidden */
  120886. _alphaMode: number;
  120887. /** @hidden */
  120888. _alphaEquation: number;
  120889. /** @hidden */
  120890. _internalTexturesCache: InternalTexture[];
  120891. /** @hidden */
  120892. protected _activeChannel: number;
  120893. private _currentTextureChannel;
  120894. /** @hidden */
  120895. protected _boundTexturesCache: {
  120896. [key: string]: Nullable<InternalTexture>;
  120897. };
  120898. /** @hidden */
  120899. protected _currentEffect: Nullable<Effect>;
  120900. /** @hidden */
  120901. protected _currentProgram: Nullable<WebGLProgram>;
  120902. private _compiledEffects;
  120903. private _vertexAttribArraysEnabled;
  120904. /** @hidden */
  120905. protected _cachedViewport: Nullable<IViewportLike>;
  120906. private _cachedVertexArrayObject;
  120907. /** @hidden */
  120908. protected _cachedVertexBuffers: any;
  120909. /** @hidden */
  120910. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  120911. /** @hidden */
  120912. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  120913. /** @hidden */
  120914. _currentRenderTarget: Nullable<InternalTexture>;
  120915. private _uintIndicesCurrentlySet;
  120916. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  120917. /** @hidden */
  120918. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  120919. /** @hidden */
  120920. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  120921. private _currentBufferPointers;
  120922. private _currentInstanceLocations;
  120923. private _currentInstanceBuffers;
  120924. private _textureUnits;
  120925. /** @hidden */
  120926. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120927. /** @hidden */
  120928. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120929. /** @hidden */
  120930. _boundRenderFunction: any;
  120931. private _vaoRecordInProgress;
  120932. private _mustWipeVertexAttributes;
  120933. private _emptyTexture;
  120934. private _emptyCubeTexture;
  120935. private _emptyTexture3D;
  120936. private _emptyTexture2DArray;
  120937. /** @hidden */
  120938. _frameHandler: number;
  120939. private _nextFreeTextureSlots;
  120940. private _maxSimultaneousTextures;
  120941. private _activeRequests;
  120942. /** @hidden */
  120943. _transformTextureUrl: Nullable<(url: string) => string>;
  120944. /**
  120945. * Gets information about the current host
  120946. */
  120947. hostInformation: HostInformation;
  120948. protected get _supportsHardwareTextureRescaling(): boolean;
  120949. private _framebufferDimensionsObject;
  120950. /**
  120951. * sets the object from which width and height will be taken from when getting render width and height
  120952. * Will fallback to the gl object
  120953. * @param dimensions the framebuffer width and height that will be used.
  120954. */
  120955. set framebufferDimensionsObject(dimensions: Nullable<{
  120956. framebufferWidth: number;
  120957. framebufferHeight: number;
  120958. }>);
  120959. /**
  120960. * Gets the current viewport
  120961. */
  120962. get currentViewport(): Nullable<IViewportLike>;
  120963. /**
  120964. * Gets the default empty texture
  120965. */
  120966. get emptyTexture(): InternalTexture;
  120967. /**
  120968. * Gets the default empty 3D texture
  120969. */
  120970. get emptyTexture3D(): InternalTexture;
  120971. /**
  120972. * Gets the default empty 2D array texture
  120973. */
  120974. get emptyTexture2DArray(): InternalTexture;
  120975. /**
  120976. * Gets the default empty cube texture
  120977. */
  120978. get emptyCubeTexture(): InternalTexture;
  120979. /**
  120980. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  120981. */
  120982. readonly premultipliedAlpha: boolean;
  120983. /**
  120984. * Observable event triggered before each texture is initialized
  120985. */
  120986. onBeforeTextureInitObservable: Observable<Texture>;
  120987. /**
  120988. * Creates a new engine
  120989. * @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
  120990. * @param antialias defines enable antialiasing (default: false)
  120991. * @param options defines further options to be sent to the getContext() function
  120992. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  120993. */
  120994. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  120995. private _rebuildInternalTextures;
  120996. private _rebuildEffects;
  120997. /**
  120998. * Gets a boolean indicating if all created effects are ready
  120999. * @returns true if all effects are ready
  121000. */
  121001. areAllEffectsReady(): boolean;
  121002. protected _rebuildBuffers(): void;
  121003. protected _initGLContext(): void;
  121004. /**
  121005. * Gets version of the current webGL context
  121006. */
  121007. get webGLVersion(): number;
  121008. /**
  121009. * Gets a string identifying the name of the class
  121010. * @returns "Engine" string
  121011. */
  121012. getClassName(): string;
  121013. /**
  121014. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  121015. */
  121016. get isStencilEnable(): boolean;
  121017. /** @hidden */
  121018. _prepareWorkingCanvas(): void;
  121019. /**
  121020. * Reset the texture cache to empty state
  121021. */
  121022. resetTextureCache(): void;
  121023. /**
  121024. * Gets an object containing information about the current webGL context
  121025. * @returns an object containing the vender, the renderer and the version of the current webGL context
  121026. */
  121027. getGlInfo(): {
  121028. vendor: string;
  121029. renderer: string;
  121030. version: string;
  121031. };
  121032. /**
  121033. * Defines the hardware scaling level.
  121034. * By default the hardware scaling level is computed from the window device ratio.
  121035. * 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.
  121036. * @param level defines the level to use
  121037. */
  121038. setHardwareScalingLevel(level: number): void;
  121039. /**
  121040. * Gets the current hardware scaling level.
  121041. * By default the hardware scaling level is computed from the window device ratio.
  121042. * 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.
  121043. * @returns a number indicating the current hardware scaling level
  121044. */
  121045. getHardwareScalingLevel(): number;
  121046. /**
  121047. * Gets the list of loaded textures
  121048. * @returns an array containing all loaded textures
  121049. */
  121050. getLoadedTexturesCache(): InternalTexture[];
  121051. /**
  121052. * Gets the object containing all engine capabilities
  121053. * @returns the EngineCapabilities object
  121054. */
  121055. getCaps(): EngineCapabilities;
  121056. /**
  121057. * stop executing a render loop function and remove it from the execution array
  121058. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  121059. */
  121060. stopRenderLoop(renderFunction?: () => void): void;
  121061. /** @hidden */
  121062. _renderLoop(): void;
  121063. /**
  121064. * Gets the HTML canvas attached with the current webGL context
  121065. * @returns a HTML canvas
  121066. */
  121067. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  121068. /**
  121069. * Gets host window
  121070. * @returns the host window object
  121071. */
  121072. getHostWindow(): Nullable<Window>;
  121073. /**
  121074. * Gets the current render width
  121075. * @param useScreen defines if screen size must be used (or the current render target if any)
  121076. * @returns a number defining the current render width
  121077. */
  121078. getRenderWidth(useScreen?: boolean): number;
  121079. /**
  121080. * Gets the current render height
  121081. * @param useScreen defines if screen size must be used (or the current render target if any)
  121082. * @returns a number defining the current render height
  121083. */
  121084. getRenderHeight(useScreen?: boolean): number;
  121085. /**
  121086. * Can be used to override the current requestAnimationFrame requester.
  121087. * @hidden
  121088. */
  121089. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  121090. /**
  121091. * Register and execute a render loop. The engine can have more than one render function
  121092. * @param renderFunction defines the function to continuously execute
  121093. */
  121094. runRenderLoop(renderFunction: () => void): void;
  121095. /**
  121096. * Clear the current render buffer or the current render target (if any is set up)
  121097. * @param color defines the color to use
  121098. * @param backBuffer defines if the back buffer must be cleared
  121099. * @param depth defines if the depth buffer must be cleared
  121100. * @param stencil defines if the stencil buffer must be cleared
  121101. */
  121102. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121103. private _viewportCached;
  121104. /** @hidden */
  121105. _viewport(x: number, y: number, width: number, height: number): void;
  121106. /**
  121107. * Set the WebGL's viewport
  121108. * @param viewport defines the viewport element to be used
  121109. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  121110. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  121111. */
  121112. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  121113. /**
  121114. * Begin a new frame
  121115. */
  121116. beginFrame(): void;
  121117. /**
  121118. * Enf the current frame
  121119. */
  121120. endFrame(): void;
  121121. /**
  121122. * Resize the view according to the canvas' size
  121123. */
  121124. resize(): void;
  121125. /**
  121126. * Force a specific size of the canvas
  121127. * @param width defines the new canvas' width
  121128. * @param height defines the new canvas' height
  121129. * @returns true if the size was changed
  121130. */
  121131. setSize(width: number, height: number): boolean;
  121132. /**
  121133. * Binds the frame buffer to the specified texture.
  121134. * @param texture The texture to render to or null for the default canvas
  121135. * @param faceIndex The face of the texture to render to in case of cube texture
  121136. * @param requiredWidth The width of the target to render to
  121137. * @param requiredHeight The height of the target to render to
  121138. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121139. * @param lodLevel defines the lod level to bind to the frame buffer
  121140. * @param layer defines the 2d array index to bind to frame buffer to
  121141. */
  121142. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  121143. /** @hidden */
  121144. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  121145. /**
  121146. * Unbind the current render target texture from the webGL context
  121147. * @param texture defines the render target texture to unbind
  121148. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121149. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121150. */
  121151. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121152. /**
  121153. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  121154. */
  121155. flushFramebuffer(): void;
  121156. /**
  121157. * Unbind the current render target and bind the default framebuffer
  121158. */
  121159. restoreDefaultFramebuffer(): void;
  121160. /** @hidden */
  121161. protected _resetVertexBufferBinding(): void;
  121162. /**
  121163. * Creates a vertex buffer
  121164. * @param data the data for the vertex buffer
  121165. * @returns the new WebGL static buffer
  121166. */
  121167. createVertexBuffer(data: DataArray): DataBuffer;
  121168. private _createVertexBuffer;
  121169. /**
  121170. * Creates a dynamic vertex buffer
  121171. * @param data the data for the dynamic vertex buffer
  121172. * @returns the new WebGL dynamic buffer
  121173. */
  121174. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121175. protected _resetIndexBufferBinding(): void;
  121176. /**
  121177. * Creates a new index buffer
  121178. * @param indices defines the content of the index buffer
  121179. * @param updatable defines if the index buffer must be updatable
  121180. * @returns a new webGL buffer
  121181. */
  121182. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  121183. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  121184. /**
  121185. * Bind a webGL buffer to the webGL context
  121186. * @param buffer defines the buffer to bind
  121187. */
  121188. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  121189. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  121190. private bindBuffer;
  121191. /**
  121192. * update the bound buffer with the given data
  121193. * @param data defines the data to update
  121194. */
  121195. updateArrayBuffer(data: Float32Array): void;
  121196. private _vertexAttribPointer;
  121197. /** @hidden */
  121198. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  121199. private _bindVertexBuffersAttributes;
  121200. /**
  121201. * Records a vertex array object
  121202. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  121203. * @param vertexBuffers defines the list of vertex buffers to store
  121204. * @param indexBuffer defines the index buffer to store
  121205. * @param effect defines the effect to store
  121206. * @returns the new vertex array object
  121207. */
  121208. recordVertexArrayObject(vertexBuffers: {
  121209. [key: string]: VertexBuffer;
  121210. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121211. /**
  121212. * Bind a specific vertex array object
  121213. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  121214. * @param vertexArrayObject defines the vertex array object to bind
  121215. * @param indexBuffer defines the index buffer to bind
  121216. */
  121217. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  121218. /**
  121219. * Bind webGl buffers directly to the webGL context
  121220. * @param vertexBuffer defines the vertex buffer to bind
  121221. * @param indexBuffer defines the index buffer to bind
  121222. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121223. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121224. * @param effect defines the effect associated with the vertex buffer
  121225. */
  121226. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  121227. private _unbindVertexArrayObject;
  121228. /**
  121229. * Bind a list of vertex buffers to the webGL context
  121230. * @param vertexBuffers defines the list of vertex buffers to bind
  121231. * @param indexBuffer defines the index buffer to bind
  121232. * @param effect defines the effect associated with the vertex buffers
  121233. */
  121234. bindBuffers(vertexBuffers: {
  121235. [key: string]: Nullable<VertexBuffer>;
  121236. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  121237. /**
  121238. * Unbind all instance attributes
  121239. */
  121240. unbindInstanceAttributes(): void;
  121241. /**
  121242. * Release and free the memory of a vertex array object
  121243. * @param vao defines the vertex array object to delete
  121244. */
  121245. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  121246. /** @hidden */
  121247. _releaseBuffer(buffer: DataBuffer): boolean;
  121248. protected _deleteBuffer(buffer: DataBuffer): void;
  121249. /**
  121250. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  121251. * @param instancesBuffer defines the webGL buffer to update and bind
  121252. * @param data defines the data to store in the buffer
  121253. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  121254. */
  121255. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  121256. /**
  121257. * Bind the content of a webGL buffer used with instantiation
  121258. * @param instancesBuffer defines the webGL buffer to bind
  121259. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  121260. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  121261. */
  121262. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  121263. /**
  121264. * Disable the instance attribute corresponding to the name in parameter
  121265. * @param name defines the name of the attribute to disable
  121266. */
  121267. disableInstanceAttributeByName(name: string): void;
  121268. /**
  121269. * Disable the instance attribute corresponding to the location in parameter
  121270. * @param attributeLocation defines the attribute location of the attribute to disable
  121271. */
  121272. disableInstanceAttribute(attributeLocation: number): void;
  121273. /**
  121274. * Disable the attribute corresponding to the location in parameter
  121275. * @param attributeLocation defines the attribute location of the attribute to disable
  121276. */
  121277. disableAttributeByIndex(attributeLocation: number): void;
  121278. /**
  121279. * Send a draw order
  121280. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121281. * @param indexStart defines the starting index
  121282. * @param indexCount defines the number of index to draw
  121283. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121284. */
  121285. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121286. /**
  121287. * Draw a list of points
  121288. * @param verticesStart defines the index of first vertex to draw
  121289. * @param verticesCount defines the count of vertices to draw
  121290. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121291. */
  121292. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121293. /**
  121294. * Draw a list of unindexed primitives
  121295. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121296. * @param verticesStart defines the index of first vertex to draw
  121297. * @param verticesCount defines the count of vertices to draw
  121298. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121299. */
  121300. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121301. /**
  121302. * Draw a list of indexed primitives
  121303. * @param fillMode defines the primitive to use
  121304. * @param indexStart defines the starting index
  121305. * @param indexCount defines the number of index to draw
  121306. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121307. */
  121308. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121309. /**
  121310. * Draw a list of unindexed primitives
  121311. * @param fillMode defines the primitive to use
  121312. * @param verticesStart defines the index of first vertex to draw
  121313. * @param verticesCount defines the count of vertices to draw
  121314. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121315. */
  121316. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121317. private _drawMode;
  121318. /** @hidden */
  121319. protected _reportDrawCall(): void;
  121320. /** @hidden */
  121321. _releaseEffect(effect: Effect): void;
  121322. /** @hidden */
  121323. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121324. /**
  121325. * Create a new effect (used to store vertex/fragment shaders)
  121326. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  121327. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  121328. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  121329. * @param samplers defines an array of string used to represent textures
  121330. * @param defines defines the string containing the defines to use to compile the shaders
  121331. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  121332. * @param onCompiled defines a function to call when the effect creation is successful
  121333. * @param onError defines a function to call when the effect creation has failed
  121334. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  121335. * @returns the new Effect
  121336. */
  121337. 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;
  121338. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  121339. private _compileShader;
  121340. private _compileRawShader;
  121341. /** @hidden */
  121342. _getShaderSource(shader: WebGLShader): Nullable<string>;
  121343. /**
  121344. * Directly creates a webGL program
  121345. * @param pipelineContext defines the pipeline context to attach to
  121346. * @param vertexCode defines the vertex shader code to use
  121347. * @param fragmentCode defines the fragment shader code to use
  121348. * @param context defines the webGL context to use (if not set, the current one will be used)
  121349. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121350. * @returns the new webGL program
  121351. */
  121352. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121353. /**
  121354. * Creates a webGL program
  121355. * @param pipelineContext defines the pipeline context to attach to
  121356. * @param vertexCode defines the vertex shader code to use
  121357. * @param fragmentCode defines the fragment shader code to use
  121358. * @param defines defines the string containing the defines to use to compile the shaders
  121359. * @param context defines the webGL context to use (if not set, the current one will be used)
  121360. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121361. * @returns the new webGL program
  121362. */
  121363. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121364. /**
  121365. * Creates a new pipeline context
  121366. * @returns the new pipeline
  121367. */
  121368. createPipelineContext(): IPipelineContext;
  121369. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121370. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  121371. /** @hidden */
  121372. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121373. /** @hidden */
  121374. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121375. /** @hidden */
  121376. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121377. /**
  121378. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121379. * @param pipelineContext defines the pipeline context to use
  121380. * @param uniformsNames defines the list of uniform names
  121381. * @returns an array of webGL uniform locations
  121382. */
  121383. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121384. /**
  121385. * Gets the lsit of active attributes for a given webGL program
  121386. * @param pipelineContext defines the pipeline context to use
  121387. * @param attributesNames defines the list of attribute names to get
  121388. * @returns an array of indices indicating the offset of each attribute
  121389. */
  121390. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121391. /**
  121392. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121393. * @param effect defines the effect to activate
  121394. */
  121395. enableEffect(effect: Nullable<Effect>): void;
  121396. /**
  121397. * Set the value of an uniform to a number (int)
  121398. * @param uniform defines the webGL uniform location where to store the value
  121399. * @param value defines the int number to store
  121400. * @returns true if the value was set
  121401. */
  121402. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121403. /**
  121404. * Set the value of an uniform to an array of int32
  121405. * @param uniform defines the webGL uniform location where to store the value
  121406. * @param array defines the array of int32 to store
  121407. * @returns true if the value was set
  121408. */
  121409. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121410. /**
  121411. * Set the value of an uniform to an array of int32 (stored as vec2)
  121412. * @param uniform defines the webGL uniform location where to store the value
  121413. * @param array defines the array of int32 to store
  121414. * @returns true if the value was set
  121415. */
  121416. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121417. /**
  121418. * Set the value of an uniform to an array of int32 (stored as vec3)
  121419. * @param uniform defines the webGL uniform location where to store the value
  121420. * @param array defines the array of int32 to store
  121421. * @returns true if the value was set
  121422. */
  121423. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121424. /**
  121425. * Set the value of an uniform to an array of int32 (stored as vec4)
  121426. * @param uniform defines the webGL uniform location where to store the value
  121427. * @param array defines the array of int32 to store
  121428. * @returns true if the value was set
  121429. */
  121430. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121431. /**
  121432. * Set the value of an uniform to an array of number
  121433. * @param uniform defines the webGL uniform location where to store the value
  121434. * @param array defines the array of number to store
  121435. * @returns true if the value was set
  121436. */
  121437. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121438. /**
  121439. * Set the value of an uniform to an array of number (stored as vec2)
  121440. * @param uniform defines the webGL uniform location where to store the value
  121441. * @param array defines the array of number to store
  121442. * @returns true if the value was set
  121443. */
  121444. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121445. /**
  121446. * Set the value of an uniform to an array of number (stored as vec3)
  121447. * @param uniform defines the webGL uniform location where to store the value
  121448. * @param array defines the array of number to store
  121449. * @returns true if the value was set
  121450. */
  121451. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121452. /**
  121453. * Set the value of an uniform to an array of number (stored as vec4)
  121454. * @param uniform defines the webGL uniform location where to store the value
  121455. * @param array defines the array of number to store
  121456. * @returns true if the value was set
  121457. */
  121458. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121459. /**
  121460. * Set the value of an uniform to an array of float32 (stored as matrices)
  121461. * @param uniform defines the webGL uniform location where to store the value
  121462. * @param matrices defines the array of float32 to store
  121463. * @returns true if the value was set
  121464. */
  121465. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  121466. /**
  121467. * Set the value of an uniform to a matrix (3x3)
  121468. * @param uniform defines the webGL uniform location where to store the value
  121469. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121470. * @returns true if the value was set
  121471. */
  121472. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121473. /**
  121474. * Set the value of an uniform to a matrix (2x2)
  121475. * @param uniform defines the webGL uniform location where to store the value
  121476. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121477. * @returns true if the value was set
  121478. */
  121479. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121480. /**
  121481. * Set the value of an uniform to a number (float)
  121482. * @param uniform defines the webGL uniform location where to store the value
  121483. * @param value defines the float number to store
  121484. * @returns true if the value was transfered
  121485. */
  121486. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121487. /**
  121488. * Set the value of an uniform to a vec2
  121489. * @param uniform defines the webGL uniform location where to store the value
  121490. * @param x defines the 1st component of the value
  121491. * @param y defines the 2nd component of the value
  121492. * @returns true if the value was set
  121493. */
  121494. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  121495. /**
  121496. * Set the value of an uniform to a vec3
  121497. * @param uniform defines the webGL uniform location where to store the value
  121498. * @param x defines the 1st component of the value
  121499. * @param y defines the 2nd component of the value
  121500. * @param z defines the 3rd component of the value
  121501. * @returns true if the value was set
  121502. */
  121503. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  121504. /**
  121505. * Set the value of an uniform to a vec4
  121506. * @param uniform defines the webGL uniform location where to store the value
  121507. * @param x defines the 1st component of the value
  121508. * @param y defines the 2nd component of the value
  121509. * @param z defines the 3rd component of the value
  121510. * @param w defines the 4th component of the value
  121511. * @returns true if the value was set
  121512. */
  121513. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  121514. /**
  121515. * Apply all cached states (depth, culling, stencil and alpha)
  121516. */
  121517. applyStates(): void;
  121518. /**
  121519. * Enable or disable color writing
  121520. * @param enable defines the state to set
  121521. */
  121522. setColorWrite(enable: boolean): void;
  121523. /**
  121524. * Gets a boolean indicating if color writing is enabled
  121525. * @returns the current color writing state
  121526. */
  121527. getColorWrite(): boolean;
  121528. /**
  121529. * Gets the depth culling state manager
  121530. */
  121531. get depthCullingState(): DepthCullingState;
  121532. /**
  121533. * Gets the alpha state manager
  121534. */
  121535. get alphaState(): AlphaState;
  121536. /**
  121537. * Gets the stencil state manager
  121538. */
  121539. get stencilState(): StencilState;
  121540. /**
  121541. * Clears the list of texture accessible through engine.
  121542. * This can help preventing texture load conflict due to name collision.
  121543. */
  121544. clearInternalTexturesCache(): void;
  121545. /**
  121546. * Force the entire cache to be cleared
  121547. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121548. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121549. */
  121550. wipeCaches(bruteForce?: boolean): void;
  121551. /** @hidden */
  121552. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  121553. min: number;
  121554. mag: number;
  121555. };
  121556. /** @hidden */
  121557. _createTexture(): WebGLTexture;
  121558. /**
  121559. * Usually called from Texture.ts.
  121560. * Passed information to create a WebGLTexture
  121561. * @param url defines a value which contains one of the following:
  121562. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121563. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121564. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121565. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121566. * @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)
  121567. * @param scene needed for loading to the correct scene
  121568. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121569. * @param onLoad optional callback to be called upon successful completion
  121570. * @param onError optional callback to be called upon failure
  121571. * @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
  121572. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121573. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121574. * @param forcedExtension defines the extension to use to pick the right loader
  121575. * @param mimeType defines an optional mime type
  121576. * @param loaderOptions options to be passed to the loader
  121577. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121578. */
  121579. 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;
  121580. /**
  121581. * Loads an image as an HTMLImageElement.
  121582. * @param input url string, ArrayBuffer, or Blob to load
  121583. * @param onLoad callback called when the image successfully loads
  121584. * @param onError callback called when the image fails to load
  121585. * @param offlineProvider offline provider for caching
  121586. * @param mimeType optional mime type
  121587. * @returns the HTMLImageElement of the loaded image
  121588. * @hidden
  121589. */
  121590. 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>;
  121591. /**
  121592. * @hidden
  121593. */
  121594. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121595. private _unpackFlipYCached;
  121596. /**
  121597. * In case you are sharing the context with other applications, it might
  121598. * be interested to not cache the unpack flip y state to ensure a consistent
  121599. * value would be set.
  121600. */
  121601. enableUnpackFlipYCached: boolean;
  121602. /** @hidden */
  121603. _unpackFlipY(value: boolean): void;
  121604. /** @hidden */
  121605. _getUnpackAlignement(): number;
  121606. private _getTextureTarget;
  121607. /**
  121608. * Update the sampling mode of a given texture
  121609. * @param samplingMode defines the required sampling mode
  121610. * @param texture defines the texture to update
  121611. * @param generateMipMaps defines whether to generate mipmaps for the texture
  121612. */
  121613. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  121614. /**
  121615. * Update the sampling mode of a given texture
  121616. * @param texture defines the texture to update
  121617. * @param wrapU defines the texture wrap mode of the u coordinates
  121618. * @param wrapV defines the texture wrap mode of the v coordinates
  121619. * @param wrapR defines the texture wrap mode of the r coordinates
  121620. */
  121621. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  121622. /** @hidden */
  121623. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  121624. width: number;
  121625. height: number;
  121626. layers?: number;
  121627. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  121628. /** @hidden */
  121629. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121630. /** @hidden */
  121631. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  121632. /**
  121633. * Update a portion of an internal texture
  121634. * @param texture defines the texture to update
  121635. * @param imageData defines the data to store into the texture
  121636. * @param xOffset defines the x coordinates of the update rectangle
  121637. * @param yOffset defines the y coordinates of the update rectangle
  121638. * @param width defines the width of the update rectangle
  121639. * @param height defines the height of the update rectangle
  121640. * @param faceIndex defines the face index if texture is a cube (0 by default)
  121641. * @param lod defines the lod level to update (0 by default)
  121642. */
  121643. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  121644. /** @hidden */
  121645. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121646. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  121647. private _prepareWebGLTexture;
  121648. /** @hidden */
  121649. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  121650. private _getDepthStencilBuffer;
  121651. /** @hidden */
  121652. _releaseFramebufferObjects(texture: InternalTexture): void;
  121653. /** @hidden */
  121654. _releaseTexture(texture: InternalTexture): void;
  121655. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121656. protected _setProgram(program: WebGLProgram): void;
  121657. protected _boundUniforms: {
  121658. [key: number]: WebGLUniformLocation;
  121659. };
  121660. /**
  121661. * Binds an effect to the webGL context
  121662. * @param effect defines the effect to bind
  121663. */
  121664. bindSamplers(effect: Effect): void;
  121665. private _activateCurrentTexture;
  121666. /** @hidden */
  121667. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  121668. /** @hidden */
  121669. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  121670. /**
  121671. * Unbind all textures from the webGL context
  121672. */
  121673. unbindAllTextures(): void;
  121674. /**
  121675. * Sets a texture to the according uniform.
  121676. * @param channel The texture channel
  121677. * @param uniform The uniform to set
  121678. * @param texture The texture to apply
  121679. */
  121680. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  121681. private _bindSamplerUniformToChannel;
  121682. private _getTextureWrapMode;
  121683. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121684. /**
  121685. * Sets an array of texture to the webGL context
  121686. * @param channel defines the channel where the texture array must be set
  121687. * @param uniform defines the associated uniform location
  121688. * @param textures defines the array of textures to bind
  121689. */
  121690. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  121691. /** @hidden */
  121692. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  121693. private _setTextureParameterFloat;
  121694. private _setTextureParameterInteger;
  121695. /**
  121696. * Unbind all vertex attributes from the webGL context
  121697. */
  121698. unbindAllAttributes(): void;
  121699. /**
  121700. * 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
  121701. */
  121702. releaseEffects(): void;
  121703. /**
  121704. * Dispose and release all associated resources
  121705. */
  121706. dispose(): void;
  121707. /**
  121708. * Attach a new callback raised when context lost event is fired
  121709. * @param callback defines the callback to call
  121710. */
  121711. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121712. /**
  121713. * Attach a new callback raised when context restored event is fired
  121714. * @param callback defines the callback to call
  121715. */
  121716. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121717. /**
  121718. * Get the current error code of the webGL context
  121719. * @returns the error code
  121720. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121721. */
  121722. getError(): number;
  121723. private _canRenderToFloatFramebuffer;
  121724. private _canRenderToHalfFloatFramebuffer;
  121725. private _canRenderToFramebuffer;
  121726. /** @hidden */
  121727. _getWebGLTextureType(type: number): number;
  121728. /** @hidden */
  121729. _getInternalFormat(format: number): number;
  121730. /** @hidden */
  121731. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  121732. /** @hidden */
  121733. _getRGBAMultiSampleBufferFormat(type: number): number;
  121734. /** @hidden */
  121735. _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;
  121736. /**
  121737. * Loads a file from a url
  121738. * @param url url to load
  121739. * @param onSuccess callback called when the file successfully loads
  121740. * @param onProgress callback called while file is loading (if the server supports this mode)
  121741. * @param offlineProvider defines the offline provider for caching
  121742. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121743. * @param onError callback called when the file fails to load
  121744. * @returns a file request object
  121745. * @hidden
  121746. */
  121747. 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;
  121748. /**
  121749. * Reads pixels from the current frame buffer. Please note that this function can be slow
  121750. * @param x defines the x coordinate of the rectangle where pixels must be read
  121751. * @param y defines the y coordinate of the rectangle where pixels must be read
  121752. * @param width defines the width of the rectangle where pixels must be read
  121753. * @param height defines the height of the rectangle where pixels must be read
  121754. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  121755. * @returns a Uint8Array containing RGBA colors
  121756. */
  121757. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  121758. private static _IsSupported;
  121759. private static _HasMajorPerformanceCaveat;
  121760. /**
  121761. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121762. */
  121763. static get IsSupported(): boolean;
  121764. /**
  121765. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121766. * @returns true if the engine can be created
  121767. * @ignorenaming
  121768. */
  121769. static isSupported(): boolean;
  121770. /**
  121771. * 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)
  121772. */
  121773. static get HasMajorPerformanceCaveat(): boolean;
  121774. /**
  121775. * Find the next highest power of two.
  121776. * @param x Number to start search from.
  121777. * @return Next highest power of two.
  121778. */
  121779. static CeilingPOT(x: number): number;
  121780. /**
  121781. * Find the next lowest power of two.
  121782. * @param x Number to start search from.
  121783. * @return Next lowest power of two.
  121784. */
  121785. static FloorPOT(x: number): number;
  121786. /**
  121787. * Find the nearest power of two.
  121788. * @param x Number to start search from.
  121789. * @return Next nearest power of two.
  121790. */
  121791. static NearestPOT(x: number): number;
  121792. /**
  121793. * Get the closest exponent of two
  121794. * @param value defines the value to approximate
  121795. * @param max defines the maximum value to return
  121796. * @param mode defines how to define the closest value
  121797. * @returns closest exponent of two of the given value
  121798. */
  121799. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  121800. /**
  121801. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  121802. * @param func - the function to be called
  121803. * @param requester - the object that will request the next frame. Falls back to window.
  121804. * @returns frame number
  121805. */
  121806. static QueueNewFrame(func: () => void, requester?: any): number;
  121807. /**
  121808. * Gets host document
  121809. * @returns the host document object
  121810. */
  121811. getHostDocument(): Nullable<Document>;
  121812. }
  121813. }
  121814. declare module BABYLON {
  121815. /**
  121816. * Defines the source of the internal texture
  121817. */
  121818. export enum InternalTextureSource {
  121819. /**
  121820. * The source of the texture data is unknown
  121821. */
  121822. Unknown = 0,
  121823. /**
  121824. * Texture data comes from an URL
  121825. */
  121826. Url = 1,
  121827. /**
  121828. * Texture data is only used for temporary storage
  121829. */
  121830. Temp = 2,
  121831. /**
  121832. * Texture data comes from raw data (ArrayBuffer)
  121833. */
  121834. Raw = 3,
  121835. /**
  121836. * Texture content is dynamic (video or dynamic texture)
  121837. */
  121838. Dynamic = 4,
  121839. /**
  121840. * Texture content is generated by rendering to it
  121841. */
  121842. RenderTarget = 5,
  121843. /**
  121844. * Texture content is part of a multi render target process
  121845. */
  121846. MultiRenderTarget = 6,
  121847. /**
  121848. * Texture data comes from a cube data file
  121849. */
  121850. Cube = 7,
  121851. /**
  121852. * Texture data comes from a raw cube data
  121853. */
  121854. CubeRaw = 8,
  121855. /**
  121856. * Texture data come from a prefiltered cube data file
  121857. */
  121858. CubePrefiltered = 9,
  121859. /**
  121860. * Texture content is raw 3D data
  121861. */
  121862. Raw3D = 10,
  121863. /**
  121864. * Texture content is raw 2D array data
  121865. */
  121866. Raw2DArray = 11,
  121867. /**
  121868. * Texture content is a depth texture
  121869. */
  121870. Depth = 12,
  121871. /**
  121872. * Texture data comes from a raw cube data encoded with RGBD
  121873. */
  121874. CubeRawRGBD = 13
  121875. }
  121876. /**
  121877. * Class used to store data associated with WebGL texture data for the engine
  121878. * This class should not be used directly
  121879. */
  121880. export class InternalTexture {
  121881. /** @hidden */
  121882. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  121883. /**
  121884. * Defines if the texture is ready
  121885. */
  121886. isReady: boolean;
  121887. /**
  121888. * Defines if the texture is a cube texture
  121889. */
  121890. isCube: boolean;
  121891. /**
  121892. * Defines if the texture contains 3D data
  121893. */
  121894. is3D: boolean;
  121895. /**
  121896. * Defines if the texture contains 2D array data
  121897. */
  121898. is2DArray: boolean;
  121899. /**
  121900. * Defines if the texture contains multiview data
  121901. */
  121902. isMultiview: boolean;
  121903. /**
  121904. * Gets the URL used to load this texture
  121905. */
  121906. url: string;
  121907. /** @hidden */
  121908. _originalUrl: string;
  121909. /**
  121910. * Gets the sampling mode of the texture
  121911. */
  121912. samplingMode: number;
  121913. /**
  121914. * Gets a boolean indicating if the texture needs mipmaps generation
  121915. */
  121916. generateMipMaps: boolean;
  121917. /**
  121918. * Gets the number of samples used by the texture (WebGL2+ only)
  121919. */
  121920. samples: number;
  121921. /**
  121922. * Gets the type of the texture (int, float...)
  121923. */
  121924. type: number;
  121925. /**
  121926. * Gets the format of the texture (RGB, RGBA...)
  121927. */
  121928. format: number;
  121929. /**
  121930. * Observable called when the texture is loaded
  121931. */
  121932. onLoadedObservable: Observable<InternalTexture>;
  121933. /**
  121934. * Gets the width of the texture
  121935. */
  121936. width: number;
  121937. /**
  121938. * Gets the height of the texture
  121939. */
  121940. height: number;
  121941. /**
  121942. * Gets the depth of the texture
  121943. */
  121944. depth: number;
  121945. /**
  121946. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  121947. */
  121948. baseWidth: number;
  121949. /**
  121950. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  121951. */
  121952. baseHeight: number;
  121953. /**
  121954. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  121955. */
  121956. baseDepth: number;
  121957. /**
  121958. * Gets a boolean indicating if the texture is inverted on Y axis
  121959. */
  121960. invertY: boolean;
  121961. /** @hidden */
  121962. _invertVScale: boolean;
  121963. /** @hidden */
  121964. _associatedChannel: number;
  121965. /** @hidden */
  121966. _source: InternalTextureSource;
  121967. /** @hidden */
  121968. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  121969. /** @hidden */
  121970. _bufferView: Nullable<ArrayBufferView>;
  121971. /** @hidden */
  121972. _bufferViewArray: Nullable<ArrayBufferView[]>;
  121973. /** @hidden */
  121974. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  121975. /** @hidden */
  121976. _size: number;
  121977. /** @hidden */
  121978. _extension: string;
  121979. /** @hidden */
  121980. _files: Nullable<string[]>;
  121981. /** @hidden */
  121982. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  121983. /** @hidden */
  121984. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  121985. /** @hidden */
  121986. _framebuffer: Nullable<WebGLFramebuffer>;
  121987. /** @hidden */
  121988. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  121989. /** @hidden */
  121990. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  121991. /** @hidden */
  121992. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  121993. /** @hidden */
  121994. _attachments: Nullable<number[]>;
  121995. /** @hidden */
  121996. _textureArray: Nullable<InternalTexture[]>;
  121997. /** @hidden */
  121998. _cachedCoordinatesMode: Nullable<number>;
  121999. /** @hidden */
  122000. _cachedWrapU: Nullable<number>;
  122001. /** @hidden */
  122002. _cachedWrapV: Nullable<number>;
  122003. /** @hidden */
  122004. _cachedWrapR: Nullable<number>;
  122005. /** @hidden */
  122006. _cachedAnisotropicFilteringLevel: Nullable<number>;
  122007. /** @hidden */
  122008. _isDisabled: boolean;
  122009. /** @hidden */
  122010. _compression: Nullable<string>;
  122011. /** @hidden */
  122012. _generateStencilBuffer: boolean;
  122013. /** @hidden */
  122014. _generateDepthBuffer: boolean;
  122015. /** @hidden */
  122016. _comparisonFunction: number;
  122017. /** @hidden */
  122018. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  122019. /** @hidden */
  122020. _lodGenerationScale: number;
  122021. /** @hidden */
  122022. _lodGenerationOffset: number;
  122023. /** @hidden */
  122024. _depthStencilTexture: Nullable<InternalTexture>;
  122025. /** @hidden */
  122026. _colorTextureArray: Nullable<WebGLTexture>;
  122027. /** @hidden */
  122028. _depthStencilTextureArray: Nullable<WebGLTexture>;
  122029. /** @hidden */
  122030. _lodTextureHigh: Nullable<BaseTexture>;
  122031. /** @hidden */
  122032. _lodTextureMid: Nullable<BaseTexture>;
  122033. /** @hidden */
  122034. _lodTextureLow: Nullable<BaseTexture>;
  122035. /** @hidden */
  122036. _isRGBD: boolean;
  122037. /** @hidden */
  122038. _linearSpecularLOD: boolean;
  122039. /** @hidden */
  122040. _irradianceTexture: Nullable<BaseTexture>;
  122041. /** @hidden */
  122042. _webGLTexture: Nullable<WebGLTexture>;
  122043. /** @hidden */
  122044. _references: number;
  122045. /** @hidden */
  122046. _gammaSpace: Nullable<boolean>;
  122047. private _engine;
  122048. /**
  122049. * Gets the Engine the texture belongs to.
  122050. * @returns The babylon engine
  122051. */
  122052. getEngine(): ThinEngine;
  122053. /**
  122054. * Gets the data source type of the texture
  122055. */
  122056. get source(): InternalTextureSource;
  122057. /**
  122058. * Creates a new InternalTexture
  122059. * @param engine defines the engine to use
  122060. * @param source defines the type of data that will be used
  122061. * @param delayAllocation if the texture allocation should be delayed (default: false)
  122062. */
  122063. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  122064. /**
  122065. * Increments the number of references (ie. the number of Texture that point to it)
  122066. */
  122067. incrementReferences(): void;
  122068. /**
  122069. * Change the size of the texture (not the size of the content)
  122070. * @param width defines the new width
  122071. * @param height defines the new height
  122072. * @param depth defines the new depth (1 by default)
  122073. */
  122074. updateSize(width: int, height: int, depth?: int): void;
  122075. /** @hidden */
  122076. _rebuild(): void;
  122077. /** @hidden */
  122078. _swapAndDie(target: InternalTexture): void;
  122079. /**
  122080. * Dispose the current allocated resources
  122081. */
  122082. dispose(): void;
  122083. }
  122084. }
  122085. declare module BABYLON {
  122086. /**
  122087. * Interface used to present a loading screen while loading a scene
  122088. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122089. */
  122090. export interface ILoadingScreen {
  122091. /**
  122092. * Function called to display the loading screen
  122093. */
  122094. displayLoadingUI: () => void;
  122095. /**
  122096. * Function called to hide the loading screen
  122097. */
  122098. hideLoadingUI: () => void;
  122099. /**
  122100. * Gets or sets the color to use for the background
  122101. */
  122102. loadingUIBackgroundColor: string;
  122103. /**
  122104. * Gets or sets the text to display while loading
  122105. */
  122106. loadingUIText: string;
  122107. }
  122108. /**
  122109. * Class used for the default loading screen
  122110. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122111. */
  122112. export class DefaultLoadingScreen implements ILoadingScreen {
  122113. private _renderingCanvas;
  122114. private _loadingText;
  122115. private _loadingDivBackgroundColor;
  122116. private _loadingDiv;
  122117. private _loadingTextDiv;
  122118. /** Gets or sets the logo url to use for the default loading screen */
  122119. static DefaultLogoUrl: string;
  122120. /** Gets or sets the spinner url to use for the default loading screen */
  122121. static DefaultSpinnerUrl: string;
  122122. /**
  122123. * Creates a new default loading screen
  122124. * @param _renderingCanvas defines the canvas used to render the scene
  122125. * @param _loadingText defines the default text to display
  122126. * @param _loadingDivBackgroundColor defines the default background color
  122127. */
  122128. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  122129. /**
  122130. * Function called to display the loading screen
  122131. */
  122132. displayLoadingUI(): void;
  122133. /**
  122134. * Function called to hide the loading screen
  122135. */
  122136. hideLoadingUI(): void;
  122137. /**
  122138. * Gets or sets the text to display while loading
  122139. */
  122140. set loadingUIText(text: string);
  122141. get loadingUIText(): string;
  122142. /**
  122143. * Gets or sets the color to use for the background
  122144. */
  122145. get loadingUIBackgroundColor(): string;
  122146. set loadingUIBackgroundColor(color: string);
  122147. private _resizeLoadingUI;
  122148. }
  122149. }
  122150. declare module BABYLON {
  122151. /**
  122152. * Interface for any object that can request an animation frame
  122153. */
  122154. export interface ICustomAnimationFrameRequester {
  122155. /**
  122156. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  122157. */
  122158. renderFunction?: Function;
  122159. /**
  122160. * Called to request the next frame to render to
  122161. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  122162. */
  122163. requestAnimationFrame: Function;
  122164. /**
  122165. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  122166. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  122167. */
  122168. requestID?: number;
  122169. }
  122170. }
  122171. declare module BABYLON {
  122172. /**
  122173. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  122174. */
  122175. export class PerformanceMonitor {
  122176. private _enabled;
  122177. private _rollingFrameTime;
  122178. private _lastFrameTimeMs;
  122179. /**
  122180. * constructor
  122181. * @param frameSampleSize The number of samples required to saturate the sliding window
  122182. */
  122183. constructor(frameSampleSize?: number);
  122184. /**
  122185. * Samples current frame
  122186. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  122187. */
  122188. sampleFrame(timeMs?: number): void;
  122189. /**
  122190. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  122191. */
  122192. get averageFrameTime(): number;
  122193. /**
  122194. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  122195. */
  122196. get averageFrameTimeVariance(): number;
  122197. /**
  122198. * Returns the frame time of the most recent frame
  122199. */
  122200. get instantaneousFrameTime(): number;
  122201. /**
  122202. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  122203. */
  122204. get averageFPS(): number;
  122205. /**
  122206. * Returns the average framerate in frames per second using the most recent frame time
  122207. */
  122208. get instantaneousFPS(): number;
  122209. /**
  122210. * Returns true if enough samples have been taken to completely fill the sliding window
  122211. */
  122212. get isSaturated(): boolean;
  122213. /**
  122214. * Enables contributions to the sliding window sample set
  122215. */
  122216. enable(): void;
  122217. /**
  122218. * Disables contributions to the sliding window sample set
  122219. * Samples will not be interpolated over the disabled period
  122220. */
  122221. disable(): void;
  122222. /**
  122223. * Returns true if sampling is enabled
  122224. */
  122225. get isEnabled(): boolean;
  122226. /**
  122227. * Resets performance monitor
  122228. */
  122229. reset(): void;
  122230. }
  122231. /**
  122232. * RollingAverage
  122233. *
  122234. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  122235. */
  122236. export class RollingAverage {
  122237. /**
  122238. * Current average
  122239. */
  122240. average: number;
  122241. /**
  122242. * Current variance
  122243. */
  122244. variance: number;
  122245. protected _samples: Array<number>;
  122246. protected _sampleCount: number;
  122247. protected _pos: number;
  122248. protected _m2: number;
  122249. /**
  122250. * constructor
  122251. * @param length The number of samples required to saturate the sliding window
  122252. */
  122253. constructor(length: number);
  122254. /**
  122255. * Adds a sample to the sample set
  122256. * @param v The sample value
  122257. */
  122258. add(v: number): void;
  122259. /**
  122260. * Returns previously added values or null if outside of history or outside the sliding window domain
  122261. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  122262. * @return Value previously recorded with add() or null if outside of range
  122263. */
  122264. history(i: number): number;
  122265. /**
  122266. * Returns true if enough samples have been taken to completely fill the sliding window
  122267. * @return true if sample-set saturated
  122268. */
  122269. isSaturated(): boolean;
  122270. /**
  122271. * Resets the rolling average (equivalent to 0 samples taken so far)
  122272. */
  122273. reset(): void;
  122274. /**
  122275. * Wraps a value around the sample range boundaries
  122276. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  122277. * @return Wrapped position in sample range
  122278. */
  122279. protected _wrapPosition(i: number): number;
  122280. }
  122281. }
  122282. declare module BABYLON {
  122283. /**
  122284. * This class is used to track a performance counter which is number based.
  122285. * The user has access to many properties which give statistics of different nature.
  122286. *
  122287. * The implementer can track two kinds of Performance Counter: time and count.
  122288. * 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.
  122289. * 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.
  122290. */
  122291. export class PerfCounter {
  122292. /**
  122293. * Gets or sets a global boolean to turn on and off all the counters
  122294. */
  122295. static Enabled: boolean;
  122296. /**
  122297. * Returns the smallest value ever
  122298. */
  122299. get min(): number;
  122300. /**
  122301. * Returns the biggest value ever
  122302. */
  122303. get max(): number;
  122304. /**
  122305. * Returns the average value since the performance counter is running
  122306. */
  122307. get average(): number;
  122308. /**
  122309. * Returns the average value of the last second the counter was monitored
  122310. */
  122311. get lastSecAverage(): number;
  122312. /**
  122313. * Returns the current value
  122314. */
  122315. get current(): number;
  122316. /**
  122317. * Gets the accumulated total
  122318. */
  122319. get total(): number;
  122320. /**
  122321. * Gets the total value count
  122322. */
  122323. get count(): number;
  122324. /**
  122325. * Creates a new counter
  122326. */
  122327. constructor();
  122328. /**
  122329. * Call this method to start monitoring a new frame.
  122330. * 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.
  122331. */
  122332. fetchNewFrame(): void;
  122333. /**
  122334. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  122335. * @param newCount the count value to add to the monitored count
  122336. * @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.
  122337. */
  122338. addCount(newCount: number, fetchResult: boolean): void;
  122339. /**
  122340. * Start monitoring this performance counter
  122341. */
  122342. beginMonitoring(): void;
  122343. /**
  122344. * Compute the time lapsed since the previous beginMonitoring() call.
  122345. * @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
  122346. */
  122347. endMonitoring(newFrame?: boolean): void;
  122348. private _fetchResult;
  122349. private _startMonitoringTime;
  122350. private _min;
  122351. private _max;
  122352. private _average;
  122353. private _current;
  122354. private _totalValueCount;
  122355. private _totalAccumulated;
  122356. private _lastSecAverage;
  122357. private _lastSecAccumulated;
  122358. private _lastSecTime;
  122359. private _lastSecValueCount;
  122360. }
  122361. }
  122362. declare module BABYLON {
  122363. interface ThinEngine {
  122364. /** @hidden */
  122365. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  122366. }
  122367. }
  122368. declare module BABYLON {
  122369. /**
  122370. * Class used to work with sound analyzer using fast fourier transform (FFT)
  122371. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122372. */
  122373. export class Analyser {
  122374. /**
  122375. * Gets or sets the smoothing
  122376. * @ignorenaming
  122377. */
  122378. SMOOTHING: number;
  122379. /**
  122380. * Gets or sets the FFT table size
  122381. * @ignorenaming
  122382. */
  122383. FFT_SIZE: number;
  122384. /**
  122385. * Gets or sets the bar graph amplitude
  122386. * @ignorenaming
  122387. */
  122388. BARGRAPHAMPLITUDE: number;
  122389. /**
  122390. * Gets or sets the position of the debug canvas
  122391. * @ignorenaming
  122392. */
  122393. DEBUGCANVASPOS: {
  122394. x: number;
  122395. y: number;
  122396. };
  122397. /**
  122398. * Gets or sets the debug canvas size
  122399. * @ignorenaming
  122400. */
  122401. DEBUGCANVASSIZE: {
  122402. width: number;
  122403. height: number;
  122404. };
  122405. private _byteFreqs;
  122406. private _byteTime;
  122407. private _floatFreqs;
  122408. private _webAudioAnalyser;
  122409. private _debugCanvas;
  122410. private _debugCanvasContext;
  122411. private _scene;
  122412. private _registerFunc;
  122413. private _audioEngine;
  122414. /**
  122415. * Creates a new analyser
  122416. * @param scene defines hosting scene
  122417. */
  122418. constructor(scene: Scene);
  122419. /**
  122420. * Get the number of data values you will have to play with for the visualization
  122421. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  122422. * @returns a number
  122423. */
  122424. getFrequencyBinCount(): number;
  122425. /**
  122426. * Gets the current frequency data as a byte array
  122427. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122428. * @returns a Uint8Array
  122429. */
  122430. getByteFrequencyData(): Uint8Array;
  122431. /**
  122432. * Gets the current waveform as a byte array
  122433. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  122434. * @returns a Uint8Array
  122435. */
  122436. getByteTimeDomainData(): Uint8Array;
  122437. /**
  122438. * Gets the current frequency data as a float array
  122439. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122440. * @returns a Float32Array
  122441. */
  122442. getFloatFrequencyData(): Float32Array;
  122443. /**
  122444. * Renders the debug canvas
  122445. */
  122446. drawDebugCanvas(): void;
  122447. /**
  122448. * Stops rendering the debug canvas and removes it
  122449. */
  122450. stopDebugCanvas(): void;
  122451. /**
  122452. * Connects two audio nodes
  122453. * @param inputAudioNode defines first node to connect
  122454. * @param outputAudioNode defines second node to connect
  122455. */
  122456. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  122457. /**
  122458. * Releases all associated resources
  122459. */
  122460. dispose(): void;
  122461. }
  122462. }
  122463. declare module BABYLON {
  122464. /**
  122465. * This represents an audio engine and it is responsible
  122466. * to play, synchronize and analyse sounds throughout the application.
  122467. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122468. */
  122469. export interface IAudioEngine extends IDisposable {
  122470. /**
  122471. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  122472. */
  122473. readonly canUseWebAudio: boolean;
  122474. /**
  122475. * Gets the current AudioContext if available.
  122476. */
  122477. readonly audioContext: Nullable<AudioContext>;
  122478. /**
  122479. * The master gain node defines the global audio volume of your audio engine.
  122480. */
  122481. readonly masterGain: GainNode;
  122482. /**
  122483. * Gets whether or not mp3 are supported by your browser.
  122484. */
  122485. readonly isMP3supported: boolean;
  122486. /**
  122487. * Gets whether or not ogg are supported by your browser.
  122488. */
  122489. readonly isOGGsupported: boolean;
  122490. /**
  122491. * Defines if Babylon should emit a warning if WebAudio is not supported.
  122492. * @ignoreNaming
  122493. */
  122494. WarnedWebAudioUnsupported: boolean;
  122495. /**
  122496. * Defines if the audio engine relies on a custom unlocked button.
  122497. * In this case, the embedded button will not be displayed.
  122498. */
  122499. useCustomUnlockedButton: boolean;
  122500. /**
  122501. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  122502. */
  122503. readonly unlocked: boolean;
  122504. /**
  122505. * Event raised when audio has been unlocked on the browser.
  122506. */
  122507. onAudioUnlockedObservable: Observable<IAudioEngine>;
  122508. /**
  122509. * Event raised when audio has been locked on the browser.
  122510. */
  122511. onAudioLockedObservable: Observable<IAudioEngine>;
  122512. /**
  122513. * Flags the audio engine in Locked state.
  122514. * This happens due to new browser policies preventing audio to autoplay.
  122515. */
  122516. lock(): void;
  122517. /**
  122518. * Unlocks the audio engine once a user action has been done on the dom.
  122519. * This is helpful to resume play once browser policies have been satisfied.
  122520. */
  122521. unlock(): void;
  122522. /**
  122523. * Gets the global volume sets on the master gain.
  122524. * @returns the global volume if set or -1 otherwise
  122525. */
  122526. getGlobalVolume(): number;
  122527. /**
  122528. * Sets the global volume of your experience (sets on the master gain).
  122529. * @param newVolume Defines the new global volume of the application
  122530. */
  122531. setGlobalVolume(newVolume: number): void;
  122532. /**
  122533. * Connect the audio engine to an audio analyser allowing some amazing
  122534. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122536. * @param analyser The analyser to connect to the engine
  122537. */
  122538. connectToAnalyser(analyser: Analyser): void;
  122539. }
  122540. }
  122541. declare module BABYLON {
  122542. /**
  122543. * Defines the interface used by display changed events
  122544. */
  122545. export interface IDisplayChangedEventArgs {
  122546. /** Gets the vrDisplay object (if any) */
  122547. vrDisplay: Nullable<any>;
  122548. /** Gets a boolean indicating if webVR is supported */
  122549. vrSupported: boolean;
  122550. }
  122551. /**
  122552. * Defines the interface used by objects containing a viewport (like a camera)
  122553. */
  122554. interface IViewportOwnerLike {
  122555. /**
  122556. * Gets or sets the viewport
  122557. */
  122558. viewport: IViewportLike;
  122559. }
  122560. /**
  122561. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  122562. */
  122563. export class Engine extends ThinEngine {
  122564. /** Defines that alpha blending is disabled */
  122565. static readonly ALPHA_DISABLE: number;
  122566. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  122567. static readonly ALPHA_ADD: number;
  122568. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  122569. static readonly ALPHA_COMBINE: number;
  122570. /** Defines that alpha blending to DEST - SRC * DEST */
  122571. static readonly ALPHA_SUBTRACT: number;
  122572. /** Defines that alpha blending to SRC * DEST */
  122573. static readonly ALPHA_MULTIPLY: number;
  122574. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  122575. static readonly ALPHA_MAXIMIZED: number;
  122576. /** Defines that alpha blending to SRC + DEST */
  122577. static readonly ALPHA_ONEONE: number;
  122578. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  122579. static readonly ALPHA_PREMULTIPLIED: number;
  122580. /**
  122581. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  122582. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  122583. */
  122584. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  122585. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  122586. static readonly ALPHA_INTERPOLATE: number;
  122587. /**
  122588. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  122589. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  122590. */
  122591. static readonly ALPHA_SCREENMODE: number;
  122592. /** Defines that the ressource is not delayed*/
  122593. static readonly DELAYLOADSTATE_NONE: number;
  122594. /** Defines that the ressource was successfully delay loaded */
  122595. static readonly DELAYLOADSTATE_LOADED: number;
  122596. /** Defines that the ressource is currently delay loading */
  122597. static readonly DELAYLOADSTATE_LOADING: number;
  122598. /** Defines that the ressource is delayed and has not started loading */
  122599. static readonly DELAYLOADSTATE_NOTLOADED: number;
  122600. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  122601. static readonly NEVER: number;
  122602. /** 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 */
  122603. static readonly ALWAYS: number;
  122604. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  122605. static readonly LESS: number;
  122606. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  122607. static readonly EQUAL: number;
  122608. /** 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 */
  122609. static readonly LEQUAL: number;
  122610. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  122611. static readonly GREATER: number;
  122612. /** 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 */
  122613. static readonly GEQUAL: number;
  122614. /** 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 */
  122615. static readonly NOTEQUAL: number;
  122616. /** Passed to stencilOperation to specify that stencil value must be kept */
  122617. static readonly KEEP: number;
  122618. /** Passed to stencilOperation to specify that stencil value must be replaced */
  122619. static readonly REPLACE: number;
  122620. /** Passed to stencilOperation to specify that stencil value must be incremented */
  122621. static readonly INCR: number;
  122622. /** Passed to stencilOperation to specify that stencil value must be decremented */
  122623. static readonly DECR: number;
  122624. /** Passed to stencilOperation to specify that stencil value must be inverted */
  122625. static readonly INVERT: number;
  122626. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  122627. static readonly INCR_WRAP: number;
  122628. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  122629. static readonly DECR_WRAP: number;
  122630. /** Texture is not repeating outside of 0..1 UVs */
  122631. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  122632. /** Texture is repeating outside of 0..1 UVs */
  122633. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  122634. /** Texture is repeating and mirrored */
  122635. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  122636. /** ALPHA */
  122637. static readonly TEXTUREFORMAT_ALPHA: number;
  122638. /** LUMINANCE */
  122639. static readonly TEXTUREFORMAT_LUMINANCE: number;
  122640. /** LUMINANCE_ALPHA */
  122641. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  122642. /** RGB */
  122643. static readonly TEXTUREFORMAT_RGB: number;
  122644. /** RGBA */
  122645. static readonly TEXTUREFORMAT_RGBA: number;
  122646. /** RED */
  122647. static readonly TEXTUREFORMAT_RED: number;
  122648. /** RED (2nd reference) */
  122649. static readonly TEXTUREFORMAT_R: number;
  122650. /** RG */
  122651. static readonly TEXTUREFORMAT_RG: number;
  122652. /** RED_INTEGER */
  122653. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  122654. /** RED_INTEGER (2nd reference) */
  122655. static readonly TEXTUREFORMAT_R_INTEGER: number;
  122656. /** RG_INTEGER */
  122657. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  122658. /** RGB_INTEGER */
  122659. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  122660. /** RGBA_INTEGER */
  122661. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  122662. /** UNSIGNED_BYTE */
  122663. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  122664. /** UNSIGNED_BYTE (2nd reference) */
  122665. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  122666. /** FLOAT */
  122667. static readonly TEXTURETYPE_FLOAT: number;
  122668. /** HALF_FLOAT */
  122669. static readonly TEXTURETYPE_HALF_FLOAT: number;
  122670. /** BYTE */
  122671. static readonly TEXTURETYPE_BYTE: number;
  122672. /** SHORT */
  122673. static readonly TEXTURETYPE_SHORT: number;
  122674. /** UNSIGNED_SHORT */
  122675. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  122676. /** INT */
  122677. static readonly TEXTURETYPE_INT: number;
  122678. /** UNSIGNED_INT */
  122679. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  122680. /** UNSIGNED_SHORT_4_4_4_4 */
  122681. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  122682. /** UNSIGNED_SHORT_5_5_5_1 */
  122683. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  122684. /** UNSIGNED_SHORT_5_6_5 */
  122685. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  122686. /** UNSIGNED_INT_2_10_10_10_REV */
  122687. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  122688. /** UNSIGNED_INT_24_8 */
  122689. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  122690. /** UNSIGNED_INT_10F_11F_11F_REV */
  122691. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  122692. /** UNSIGNED_INT_5_9_9_9_REV */
  122693. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  122694. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  122695. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122696. /** nearest is mag = nearest and min = nearest and mip = linear */
  122697. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  122698. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122699. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  122700. /** Trilinear is mag = linear and min = linear and mip = linear */
  122701. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  122702. /** nearest is mag = nearest and min = nearest and mip = linear */
  122703. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  122704. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122705. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  122706. /** Trilinear is mag = linear and min = linear and mip = linear */
  122707. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  122708. /** mag = nearest and min = nearest and mip = nearest */
  122709. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  122710. /** mag = nearest and min = linear and mip = nearest */
  122711. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  122712. /** mag = nearest and min = linear and mip = linear */
  122713. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  122714. /** mag = nearest and min = linear and mip = none */
  122715. static readonly TEXTURE_NEAREST_LINEAR: number;
  122716. /** mag = nearest and min = nearest and mip = none */
  122717. static readonly TEXTURE_NEAREST_NEAREST: number;
  122718. /** mag = linear and min = nearest and mip = nearest */
  122719. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  122720. /** mag = linear and min = nearest and mip = linear */
  122721. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  122722. /** mag = linear and min = linear and mip = none */
  122723. static readonly TEXTURE_LINEAR_LINEAR: number;
  122724. /** mag = linear and min = nearest and mip = none */
  122725. static readonly TEXTURE_LINEAR_NEAREST: number;
  122726. /** Explicit coordinates mode */
  122727. static readonly TEXTURE_EXPLICIT_MODE: number;
  122728. /** Spherical coordinates mode */
  122729. static readonly TEXTURE_SPHERICAL_MODE: number;
  122730. /** Planar coordinates mode */
  122731. static readonly TEXTURE_PLANAR_MODE: number;
  122732. /** Cubic coordinates mode */
  122733. static readonly TEXTURE_CUBIC_MODE: number;
  122734. /** Projection coordinates mode */
  122735. static readonly TEXTURE_PROJECTION_MODE: number;
  122736. /** Skybox coordinates mode */
  122737. static readonly TEXTURE_SKYBOX_MODE: number;
  122738. /** Inverse Cubic coordinates mode */
  122739. static readonly TEXTURE_INVCUBIC_MODE: number;
  122740. /** Equirectangular coordinates mode */
  122741. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  122742. /** Equirectangular Fixed coordinates mode */
  122743. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  122744. /** Equirectangular Fixed Mirrored coordinates mode */
  122745. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  122746. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  122747. static readonly SCALEMODE_FLOOR: number;
  122748. /** Defines that texture rescaling will look for the nearest power of 2 size */
  122749. static readonly SCALEMODE_NEAREST: number;
  122750. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  122751. static readonly SCALEMODE_CEILING: number;
  122752. /**
  122753. * Returns the current npm package of the sdk
  122754. */
  122755. static get NpmPackage(): string;
  122756. /**
  122757. * Returns the current version of the framework
  122758. */
  122759. static get Version(): string;
  122760. /** Gets the list of created engines */
  122761. static get Instances(): Engine[];
  122762. /**
  122763. * Gets the latest created engine
  122764. */
  122765. static get LastCreatedEngine(): Nullable<Engine>;
  122766. /**
  122767. * Gets the latest created scene
  122768. */
  122769. static get LastCreatedScene(): Nullable<Scene>;
  122770. /**
  122771. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  122772. * @param flag defines which part of the materials must be marked as dirty
  122773. * @param predicate defines a predicate used to filter which materials should be affected
  122774. */
  122775. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  122776. /**
  122777. * Method called to create the default loading screen.
  122778. * This can be overriden in your own app.
  122779. * @param canvas The rendering canvas element
  122780. * @returns The loading screen
  122781. */
  122782. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  122783. /**
  122784. * Method called to create the default rescale post process on each engine.
  122785. */
  122786. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  122787. /**
  122788. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  122789. **/
  122790. enableOfflineSupport: boolean;
  122791. /**
  122792. * 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)
  122793. **/
  122794. disableManifestCheck: boolean;
  122795. /**
  122796. * Gets the list of created scenes
  122797. */
  122798. scenes: Scene[];
  122799. /**
  122800. * Event raised when a new scene is created
  122801. */
  122802. onNewSceneAddedObservable: Observable<Scene>;
  122803. /**
  122804. * Gets the list of created postprocesses
  122805. */
  122806. postProcesses: PostProcess[];
  122807. /**
  122808. * Gets a boolean indicating if the pointer is currently locked
  122809. */
  122810. isPointerLock: boolean;
  122811. /**
  122812. * Observable event triggered each time the rendering canvas is resized
  122813. */
  122814. onResizeObservable: Observable<Engine>;
  122815. /**
  122816. * Observable event triggered each time the canvas loses focus
  122817. */
  122818. onCanvasBlurObservable: Observable<Engine>;
  122819. /**
  122820. * Observable event triggered each time the canvas gains focus
  122821. */
  122822. onCanvasFocusObservable: Observable<Engine>;
  122823. /**
  122824. * Observable event triggered each time the canvas receives pointerout event
  122825. */
  122826. onCanvasPointerOutObservable: Observable<PointerEvent>;
  122827. /**
  122828. * Observable raised when the engine begins a new frame
  122829. */
  122830. onBeginFrameObservable: Observable<Engine>;
  122831. /**
  122832. * If set, will be used to request the next animation frame for the render loop
  122833. */
  122834. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  122835. /**
  122836. * Observable raised when the engine ends the current frame
  122837. */
  122838. onEndFrameObservable: Observable<Engine>;
  122839. /**
  122840. * Observable raised when the engine is about to compile a shader
  122841. */
  122842. onBeforeShaderCompilationObservable: Observable<Engine>;
  122843. /**
  122844. * Observable raised when the engine has jsut compiled a shader
  122845. */
  122846. onAfterShaderCompilationObservable: Observable<Engine>;
  122847. /**
  122848. * Gets the audio engine
  122849. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122850. * @ignorenaming
  122851. */
  122852. static audioEngine: IAudioEngine;
  122853. /**
  122854. * Default AudioEngine factory responsible of creating the Audio Engine.
  122855. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  122856. */
  122857. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  122858. /**
  122859. * Default offline support factory responsible of creating a tool used to store data locally.
  122860. * By default, this will create a Database object if the workload has been embedded.
  122861. */
  122862. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  122863. private _loadingScreen;
  122864. private _pointerLockRequested;
  122865. private _rescalePostProcess;
  122866. private _deterministicLockstep;
  122867. private _lockstepMaxSteps;
  122868. private _timeStep;
  122869. protected get _supportsHardwareTextureRescaling(): boolean;
  122870. private _fps;
  122871. private _deltaTime;
  122872. /** @hidden */
  122873. _drawCalls: PerfCounter;
  122874. /** 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 */
  122875. canvasTabIndex: number;
  122876. /**
  122877. * Turn this value on if you want to pause FPS computation when in background
  122878. */
  122879. disablePerformanceMonitorInBackground: boolean;
  122880. private _performanceMonitor;
  122881. /**
  122882. * Gets the performance monitor attached to this engine
  122883. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122884. */
  122885. get performanceMonitor(): PerformanceMonitor;
  122886. private _onFocus;
  122887. private _onBlur;
  122888. private _onCanvasPointerOut;
  122889. private _onCanvasBlur;
  122890. private _onCanvasFocus;
  122891. private _onFullscreenChange;
  122892. private _onPointerLockChange;
  122893. /**
  122894. * Gets the HTML element used to attach event listeners
  122895. * @returns a HTML element
  122896. */
  122897. getInputElement(): Nullable<HTMLElement>;
  122898. /**
  122899. * Creates a new engine
  122900. * @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
  122901. * @param antialias defines enable antialiasing (default: false)
  122902. * @param options defines further options to be sent to the getContext() function
  122903. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  122904. */
  122905. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  122906. /**
  122907. * Gets current aspect ratio
  122908. * @param viewportOwner defines the camera to use to get the aspect ratio
  122909. * @param useScreen defines if screen size must be used (or the current render target if any)
  122910. * @returns a number defining the aspect ratio
  122911. */
  122912. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  122913. /**
  122914. * Gets current screen aspect ratio
  122915. * @returns a number defining the aspect ratio
  122916. */
  122917. getScreenAspectRatio(): number;
  122918. /**
  122919. * Gets the client rect of the HTML canvas attached with the current webGL context
  122920. * @returns a client rectanglee
  122921. */
  122922. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  122923. /**
  122924. * Gets the client rect of the HTML element used for events
  122925. * @returns a client rectanglee
  122926. */
  122927. getInputElementClientRect(): Nullable<ClientRect>;
  122928. /**
  122929. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122930. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122931. * @returns true if engine is in deterministic lock step mode
  122932. */
  122933. isDeterministicLockStep(): boolean;
  122934. /**
  122935. * Gets the max steps when engine is running in deterministic lock step
  122936. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122937. * @returns the max steps
  122938. */
  122939. getLockstepMaxSteps(): number;
  122940. /**
  122941. * Returns the time in ms between steps when using deterministic lock step.
  122942. * @returns time step in (ms)
  122943. */
  122944. getTimeStep(): number;
  122945. /**
  122946. * Force the mipmap generation for the given render target texture
  122947. * @param texture defines the render target texture to use
  122948. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  122949. */
  122950. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  122951. /** States */
  122952. /**
  122953. * Set various states to the webGL context
  122954. * @param culling defines backface culling state
  122955. * @param zOffset defines the value to apply to zOffset (0 by default)
  122956. * @param force defines if states must be applied even if cache is up to date
  122957. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122958. */
  122959. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122960. /**
  122961. * Set the z offset to apply to current rendering
  122962. * @param value defines the offset to apply
  122963. */
  122964. setZOffset(value: number): void;
  122965. /**
  122966. * Gets the current value of the zOffset
  122967. * @returns the current zOffset state
  122968. */
  122969. getZOffset(): number;
  122970. /**
  122971. * Enable or disable depth buffering
  122972. * @param enable defines the state to set
  122973. */
  122974. setDepthBuffer(enable: boolean): void;
  122975. /**
  122976. * Gets a boolean indicating if depth writing is enabled
  122977. * @returns the current depth writing state
  122978. */
  122979. getDepthWrite(): boolean;
  122980. /**
  122981. * Enable or disable depth writing
  122982. * @param enable defines the state to set
  122983. */
  122984. setDepthWrite(enable: boolean): void;
  122985. /**
  122986. * Gets a boolean indicating if stencil buffer is enabled
  122987. * @returns the current stencil buffer state
  122988. */
  122989. getStencilBuffer(): boolean;
  122990. /**
  122991. * Enable or disable the stencil buffer
  122992. * @param enable defines if the stencil buffer must be enabled or disabled
  122993. */
  122994. setStencilBuffer(enable: boolean): void;
  122995. /**
  122996. * Gets the current stencil mask
  122997. * @returns a number defining the new stencil mask to use
  122998. */
  122999. getStencilMask(): number;
  123000. /**
  123001. * Sets the current stencil mask
  123002. * @param mask defines the new stencil mask to use
  123003. */
  123004. setStencilMask(mask: number): void;
  123005. /**
  123006. * Gets the current stencil function
  123007. * @returns a number defining the stencil function to use
  123008. */
  123009. getStencilFunction(): number;
  123010. /**
  123011. * Gets the current stencil reference value
  123012. * @returns a number defining the stencil reference value to use
  123013. */
  123014. getStencilFunctionReference(): number;
  123015. /**
  123016. * Gets the current stencil mask
  123017. * @returns a number defining the stencil mask to use
  123018. */
  123019. getStencilFunctionMask(): number;
  123020. /**
  123021. * Sets the current stencil function
  123022. * @param stencilFunc defines the new stencil function to use
  123023. */
  123024. setStencilFunction(stencilFunc: number): void;
  123025. /**
  123026. * Sets the current stencil reference
  123027. * @param reference defines the new stencil reference to use
  123028. */
  123029. setStencilFunctionReference(reference: number): void;
  123030. /**
  123031. * Sets the current stencil mask
  123032. * @param mask defines the new stencil mask to use
  123033. */
  123034. setStencilFunctionMask(mask: number): void;
  123035. /**
  123036. * Gets the current stencil operation when stencil fails
  123037. * @returns a number defining stencil operation to use when stencil fails
  123038. */
  123039. getStencilOperationFail(): number;
  123040. /**
  123041. * Gets the current stencil operation when depth fails
  123042. * @returns a number defining stencil operation to use when depth fails
  123043. */
  123044. getStencilOperationDepthFail(): number;
  123045. /**
  123046. * Gets the current stencil operation when stencil passes
  123047. * @returns a number defining stencil operation to use when stencil passes
  123048. */
  123049. getStencilOperationPass(): number;
  123050. /**
  123051. * Sets the stencil operation to use when stencil fails
  123052. * @param operation defines the stencil operation to use when stencil fails
  123053. */
  123054. setStencilOperationFail(operation: number): void;
  123055. /**
  123056. * Sets the stencil operation to use when depth fails
  123057. * @param operation defines the stencil operation to use when depth fails
  123058. */
  123059. setStencilOperationDepthFail(operation: number): void;
  123060. /**
  123061. * Sets the stencil operation to use when stencil passes
  123062. * @param operation defines the stencil operation to use when stencil passes
  123063. */
  123064. setStencilOperationPass(operation: number): void;
  123065. /**
  123066. * Sets a boolean indicating if the dithering state is enabled or disabled
  123067. * @param value defines the dithering state
  123068. */
  123069. setDitheringState(value: boolean): void;
  123070. /**
  123071. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  123072. * @param value defines the rasterizer state
  123073. */
  123074. setRasterizerState(value: boolean): void;
  123075. /**
  123076. * Gets the current depth function
  123077. * @returns a number defining the depth function
  123078. */
  123079. getDepthFunction(): Nullable<number>;
  123080. /**
  123081. * Sets the current depth function
  123082. * @param depthFunc defines the function to use
  123083. */
  123084. setDepthFunction(depthFunc: number): void;
  123085. /**
  123086. * Sets the current depth function to GREATER
  123087. */
  123088. setDepthFunctionToGreater(): void;
  123089. /**
  123090. * Sets the current depth function to GEQUAL
  123091. */
  123092. setDepthFunctionToGreaterOrEqual(): void;
  123093. /**
  123094. * Sets the current depth function to LESS
  123095. */
  123096. setDepthFunctionToLess(): void;
  123097. /**
  123098. * Sets the current depth function to LEQUAL
  123099. */
  123100. setDepthFunctionToLessOrEqual(): void;
  123101. private _cachedStencilBuffer;
  123102. private _cachedStencilFunction;
  123103. private _cachedStencilMask;
  123104. private _cachedStencilOperationPass;
  123105. private _cachedStencilOperationFail;
  123106. private _cachedStencilOperationDepthFail;
  123107. private _cachedStencilReference;
  123108. /**
  123109. * Caches the the state of the stencil buffer
  123110. */
  123111. cacheStencilState(): void;
  123112. /**
  123113. * Restores the state of the stencil buffer
  123114. */
  123115. restoreStencilState(): void;
  123116. /**
  123117. * Directly set the WebGL Viewport
  123118. * @param x defines the x coordinate of the viewport (in screen space)
  123119. * @param y defines the y coordinate of the viewport (in screen space)
  123120. * @param width defines the width of the viewport (in screen space)
  123121. * @param height defines the height of the viewport (in screen space)
  123122. * @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
  123123. */
  123124. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  123125. /**
  123126. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  123127. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  123128. * @param y defines the y-coordinate of the corner of the clear rectangle
  123129. * @param width defines the width of the clear rectangle
  123130. * @param height defines the height of the clear rectangle
  123131. * @param clearColor defines the clear color
  123132. */
  123133. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  123134. /**
  123135. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  123136. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  123137. * @param y defines the y-coordinate of the corner of the clear rectangle
  123138. * @param width defines the width of the clear rectangle
  123139. * @param height defines the height of the clear rectangle
  123140. */
  123141. enableScissor(x: number, y: number, width: number, height: number): void;
  123142. /**
  123143. * Disable previously set scissor test rectangle
  123144. */
  123145. disableScissor(): void;
  123146. protected _reportDrawCall(): void;
  123147. /**
  123148. * Initializes a webVR display and starts listening to display change events
  123149. * The onVRDisplayChangedObservable will be notified upon these changes
  123150. * @returns The onVRDisplayChangedObservable
  123151. */
  123152. initWebVR(): Observable<IDisplayChangedEventArgs>;
  123153. /** @hidden */
  123154. _prepareVRComponent(): void;
  123155. /** @hidden */
  123156. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  123157. /** @hidden */
  123158. _submitVRFrame(): void;
  123159. /**
  123160. * Call this function to leave webVR mode
  123161. * Will do nothing if webVR is not supported or if there is no webVR device
  123162. * @see https://doc.babylonjs.com/how_to/webvr_camera
  123163. */
  123164. disableVR(): void;
  123165. /**
  123166. * Gets a boolean indicating that the system is in VR mode and is presenting
  123167. * @returns true if VR mode is engaged
  123168. */
  123169. isVRPresenting(): boolean;
  123170. /** @hidden */
  123171. _requestVRFrame(): void;
  123172. /** @hidden */
  123173. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  123174. /**
  123175. * Gets the source code of the vertex shader associated with a specific webGL program
  123176. * @param program defines the program to use
  123177. * @returns a string containing the source code of the vertex shader associated with the program
  123178. */
  123179. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  123180. /**
  123181. * Gets the source code of the fragment shader associated with a specific webGL program
  123182. * @param program defines the program to use
  123183. * @returns a string containing the source code of the fragment shader associated with the program
  123184. */
  123185. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  123186. /**
  123187. * Sets a depth stencil texture from a render target to the according uniform.
  123188. * @param channel The texture channel
  123189. * @param uniform The uniform to set
  123190. * @param texture The render target texture containing the depth stencil texture to apply
  123191. */
  123192. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  123193. /**
  123194. * Sets a texture to the webGL context from a postprocess
  123195. * @param channel defines the channel to use
  123196. * @param postProcess defines the source postprocess
  123197. */
  123198. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  123199. /**
  123200. * Binds the output of the passed in post process to the texture channel specified
  123201. * @param channel The channel the texture should be bound to
  123202. * @param postProcess The post process which's output should be bound
  123203. */
  123204. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  123205. protected _rebuildBuffers(): void;
  123206. /** @hidden */
  123207. _renderFrame(): void;
  123208. _renderLoop(): void;
  123209. /** @hidden */
  123210. _renderViews(): boolean;
  123211. /**
  123212. * Toggle full screen mode
  123213. * @param requestPointerLock defines if a pointer lock should be requested from the user
  123214. */
  123215. switchFullscreen(requestPointerLock: boolean): void;
  123216. /**
  123217. * Enters full screen mode
  123218. * @param requestPointerLock defines if a pointer lock should be requested from the user
  123219. */
  123220. enterFullscreen(requestPointerLock: boolean): void;
  123221. /**
  123222. * Exits full screen mode
  123223. */
  123224. exitFullscreen(): void;
  123225. /**
  123226. * Enters Pointerlock mode
  123227. */
  123228. enterPointerlock(): void;
  123229. /**
  123230. * Exits Pointerlock mode
  123231. */
  123232. exitPointerlock(): void;
  123233. /**
  123234. * Begin a new frame
  123235. */
  123236. beginFrame(): void;
  123237. /**
  123238. * Enf the current frame
  123239. */
  123240. endFrame(): void;
  123241. resize(): void;
  123242. /**
  123243. * Force a specific size of the canvas
  123244. * @param width defines the new canvas' width
  123245. * @param height defines the new canvas' height
  123246. * @returns true if the size was changed
  123247. */
  123248. setSize(width: number, height: number): boolean;
  123249. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  123250. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  123251. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  123252. _releaseTexture(texture: InternalTexture): void;
  123253. /**
  123254. * @hidden
  123255. * Rescales a texture
  123256. * @param source input texutre
  123257. * @param destination destination texture
  123258. * @param scene scene to use to render the resize
  123259. * @param internalFormat format to use when resizing
  123260. * @param onComplete callback to be called when resize has completed
  123261. */
  123262. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  123263. /**
  123264. * Gets the current framerate
  123265. * @returns a number representing the framerate
  123266. */
  123267. getFps(): number;
  123268. /**
  123269. * Gets the time spent between current and previous frame
  123270. * @returns a number representing the delta time in ms
  123271. */
  123272. getDeltaTime(): number;
  123273. private _measureFps;
  123274. /** @hidden */
  123275. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  123276. /**
  123277. * Updates the sample count of a render target texture
  123278. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123279. * @param texture defines the texture to update
  123280. * @param samples defines the sample count to set
  123281. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123282. */
  123283. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  123284. /**
  123285. * Updates a depth texture Comparison Mode and Function.
  123286. * If the comparison Function is equal to 0, the mode will be set to none.
  123287. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  123288. * @param texture The texture to set the comparison function for
  123289. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  123290. */
  123291. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  123292. /**
  123293. * Creates a webGL buffer to use with instanciation
  123294. * @param capacity defines the size of the buffer
  123295. * @returns the webGL buffer
  123296. */
  123297. createInstancesBuffer(capacity: number): DataBuffer;
  123298. /**
  123299. * Delete a webGL buffer used with instanciation
  123300. * @param buffer defines the webGL buffer to delete
  123301. */
  123302. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  123303. private _clientWaitAsync;
  123304. /** @hidden */
  123305. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  123306. dispose(): void;
  123307. private _disableTouchAction;
  123308. /**
  123309. * Display the loading screen
  123310. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123311. */
  123312. displayLoadingUI(): void;
  123313. /**
  123314. * Hide the loading screen
  123315. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123316. */
  123317. hideLoadingUI(): void;
  123318. /**
  123319. * Gets the current loading screen object
  123320. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123321. */
  123322. get loadingScreen(): ILoadingScreen;
  123323. /**
  123324. * Sets the current loading screen object
  123325. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123326. */
  123327. set loadingScreen(loadingScreen: ILoadingScreen);
  123328. /**
  123329. * Sets the current loading screen text
  123330. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123331. */
  123332. set loadingUIText(text: string);
  123333. /**
  123334. * Sets the current loading screen background color
  123335. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123336. */
  123337. set loadingUIBackgroundColor(color: string);
  123338. /** Pointerlock and fullscreen */
  123339. /**
  123340. * Ask the browser to promote the current element to pointerlock mode
  123341. * @param element defines the DOM element to promote
  123342. */
  123343. static _RequestPointerlock(element: HTMLElement): void;
  123344. /**
  123345. * Asks the browser to exit pointerlock mode
  123346. */
  123347. static _ExitPointerlock(): void;
  123348. /**
  123349. * Ask the browser to promote the current element to fullscreen rendering mode
  123350. * @param element defines the DOM element to promote
  123351. */
  123352. static _RequestFullscreen(element: HTMLElement): void;
  123353. /**
  123354. * Asks the browser to exit fullscreen mode
  123355. */
  123356. static _ExitFullscreen(): void;
  123357. }
  123358. }
  123359. declare module BABYLON {
  123360. /**
  123361. * The engine store class is responsible to hold all the instances of Engine and Scene created
  123362. * during the life time of the application.
  123363. */
  123364. export class EngineStore {
  123365. /** Gets the list of created engines */
  123366. static Instances: Engine[];
  123367. /** @hidden */
  123368. static _LastCreatedScene: Nullable<Scene>;
  123369. /**
  123370. * Gets the latest created engine
  123371. */
  123372. static get LastCreatedEngine(): Nullable<Engine>;
  123373. /**
  123374. * Gets the latest created scene
  123375. */
  123376. static get LastCreatedScene(): Nullable<Scene>;
  123377. /**
  123378. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123379. * @ignorenaming
  123380. */
  123381. static UseFallbackTexture: boolean;
  123382. /**
  123383. * Texture content used if a texture cannot loaded
  123384. * @ignorenaming
  123385. */
  123386. static FallbackTexture: string;
  123387. }
  123388. }
  123389. declare module BABYLON {
  123390. /**
  123391. * Helper class that provides a small promise polyfill
  123392. */
  123393. export class PromisePolyfill {
  123394. /**
  123395. * Static function used to check if the polyfill is required
  123396. * If this is the case then the function will inject the polyfill to window.Promise
  123397. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  123398. */
  123399. static Apply(force?: boolean): void;
  123400. }
  123401. }
  123402. declare module BABYLON {
  123403. /**
  123404. * Interface for screenshot methods with describe argument called `size` as object with options
  123405. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  123406. */
  123407. export interface IScreenshotSize {
  123408. /**
  123409. * number in pixels for canvas height
  123410. */
  123411. height?: number;
  123412. /**
  123413. * multiplier allowing render at a higher or lower resolution
  123414. * If value is defined then height and width will be ignored and taken from camera
  123415. */
  123416. precision?: number;
  123417. /**
  123418. * number in pixels for canvas width
  123419. */
  123420. width?: number;
  123421. }
  123422. }
  123423. declare module BABYLON {
  123424. interface IColor4Like {
  123425. r: float;
  123426. g: float;
  123427. b: float;
  123428. a: float;
  123429. }
  123430. /**
  123431. * Class containing a set of static utilities functions
  123432. */
  123433. export class Tools {
  123434. /**
  123435. * Gets or sets the base URL to use to load assets
  123436. */
  123437. static get BaseUrl(): string;
  123438. static set BaseUrl(value: string);
  123439. /**
  123440. * Enable/Disable Custom HTTP Request Headers globally.
  123441. * default = false
  123442. * @see CustomRequestHeaders
  123443. */
  123444. static UseCustomRequestHeaders: boolean;
  123445. /**
  123446. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  123447. * i.e. when loading files, where the server/service expects an Authorization header
  123448. */
  123449. static CustomRequestHeaders: {
  123450. [key: string]: string;
  123451. };
  123452. /**
  123453. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  123454. */
  123455. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  123456. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  123457. /**
  123458. * Default behaviour for cors in the application.
  123459. * It can be a string if the expected behavior is identical in the entire app.
  123460. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  123461. */
  123462. static get CorsBehavior(): string | ((url: string | string[]) => string);
  123463. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  123464. /**
  123465. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123466. * @ignorenaming
  123467. */
  123468. static get UseFallbackTexture(): boolean;
  123469. static set UseFallbackTexture(value: boolean);
  123470. /**
  123471. * Use this object to register external classes like custom textures or material
  123472. * to allow the laoders to instantiate them
  123473. */
  123474. static get RegisteredExternalClasses(): {
  123475. [key: string]: Object;
  123476. };
  123477. static set RegisteredExternalClasses(classes: {
  123478. [key: string]: Object;
  123479. });
  123480. /**
  123481. * Texture content used if a texture cannot loaded
  123482. * @ignorenaming
  123483. */
  123484. static get fallbackTexture(): string;
  123485. static set fallbackTexture(value: string);
  123486. /**
  123487. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  123488. * @param u defines the coordinate on X axis
  123489. * @param v defines the coordinate on Y axis
  123490. * @param width defines the width of the source data
  123491. * @param height defines the height of the source data
  123492. * @param pixels defines the source byte array
  123493. * @param color defines the output color
  123494. */
  123495. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  123496. /**
  123497. * Interpolates between a and b via alpha
  123498. * @param a The lower value (returned when alpha = 0)
  123499. * @param b The upper value (returned when alpha = 1)
  123500. * @param alpha The interpolation-factor
  123501. * @return The mixed value
  123502. */
  123503. static Mix(a: number, b: number, alpha: number): number;
  123504. /**
  123505. * Tries to instantiate a new object from a given class name
  123506. * @param className defines the class name to instantiate
  123507. * @returns the new object or null if the system was not able to do the instantiation
  123508. */
  123509. static Instantiate(className: string): any;
  123510. /**
  123511. * Provides a slice function that will work even on IE
  123512. * @param data defines the array to slice
  123513. * @param start defines the start of the data (optional)
  123514. * @param end defines the end of the data (optional)
  123515. * @returns the new sliced array
  123516. */
  123517. static Slice<T>(data: T, start?: number, end?: number): T;
  123518. /**
  123519. * Provides a slice function that will work even on IE
  123520. * The difference between this and Slice is that this will force-convert to array
  123521. * @param data defines the array to slice
  123522. * @param start defines the start of the data (optional)
  123523. * @param end defines the end of the data (optional)
  123524. * @returns the new sliced array
  123525. */
  123526. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  123527. /**
  123528. * Polyfill for setImmediate
  123529. * @param action defines the action to execute after the current execution block
  123530. */
  123531. static SetImmediate(action: () => void): void;
  123532. /**
  123533. * Function indicating if a number is an exponent of 2
  123534. * @param value defines the value to test
  123535. * @returns true if the value is an exponent of 2
  123536. */
  123537. static IsExponentOfTwo(value: number): boolean;
  123538. private static _tmpFloatArray;
  123539. /**
  123540. * Returns the nearest 32-bit single precision float representation of a Number
  123541. * @param value A Number. If the parameter is of a different type, it will get converted
  123542. * to a number or to NaN if it cannot be converted
  123543. * @returns number
  123544. */
  123545. static FloatRound(value: number): number;
  123546. /**
  123547. * Extracts the filename from a path
  123548. * @param path defines the path to use
  123549. * @returns the filename
  123550. */
  123551. static GetFilename(path: string): string;
  123552. /**
  123553. * Extracts the "folder" part of a path (everything before the filename).
  123554. * @param uri The URI to extract the info from
  123555. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  123556. * @returns The "folder" part of the path
  123557. */
  123558. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  123559. /**
  123560. * Extracts text content from a DOM element hierarchy
  123561. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  123562. */
  123563. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  123564. /**
  123565. * Convert an angle in radians to degrees
  123566. * @param angle defines the angle to convert
  123567. * @returns the angle in degrees
  123568. */
  123569. static ToDegrees(angle: number): number;
  123570. /**
  123571. * Convert an angle in degrees to radians
  123572. * @param angle defines the angle to convert
  123573. * @returns the angle in radians
  123574. */
  123575. static ToRadians(angle: number): number;
  123576. /**
  123577. * Returns an array if obj is not an array
  123578. * @param obj defines the object to evaluate as an array
  123579. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  123580. * @returns either obj directly if obj is an array or a new array containing obj
  123581. */
  123582. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  123583. /**
  123584. * Gets the pointer prefix to use
  123585. * @param engine defines the engine we are finding the prefix for
  123586. * @returns "pointer" if touch is enabled. Else returns "mouse"
  123587. */
  123588. static GetPointerPrefix(engine: Engine): string;
  123589. /**
  123590. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  123591. * @param url define the url we are trying
  123592. * @param element define the dom element where to configure the cors policy
  123593. */
  123594. static SetCorsBehavior(url: string | string[], element: {
  123595. crossOrigin: string | null;
  123596. }): void;
  123597. /**
  123598. * Removes unwanted characters from an url
  123599. * @param url defines the url to clean
  123600. * @returns the cleaned url
  123601. */
  123602. static CleanUrl(url: string): string;
  123603. /**
  123604. * Gets or sets a function used to pre-process url before using them to load assets
  123605. */
  123606. static get PreprocessUrl(): (url: string) => string;
  123607. static set PreprocessUrl(processor: (url: string) => string);
  123608. /**
  123609. * Loads an image as an HTMLImageElement.
  123610. * @param input url string, ArrayBuffer, or Blob to load
  123611. * @param onLoad callback called when the image successfully loads
  123612. * @param onError callback called when the image fails to load
  123613. * @param offlineProvider offline provider for caching
  123614. * @param mimeType optional mime type
  123615. * @returns the HTMLImageElement of the loaded image
  123616. */
  123617. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  123618. /**
  123619. * Loads a file from a url
  123620. * @param url url string, ArrayBuffer, or Blob to load
  123621. * @param onSuccess callback called when the file successfully loads
  123622. * @param onProgress callback called while file is loading (if the server supports this mode)
  123623. * @param offlineProvider defines the offline provider for caching
  123624. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123625. * @param onError callback called when the file fails to load
  123626. * @returns a file request object
  123627. */
  123628. 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;
  123629. /**
  123630. * Loads a file from a url
  123631. * @param url the file url to load
  123632. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123633. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  123634. */
  123635. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  123636. /**
  123637. * Load a script (identified by an url). When the url returns, the
  123638. * content of this file is added into a new script element, attached to the DOM (body element)
  123639. * @param scriptUrl defines the url of the script to laod
  123640. * @param onSuccess defines the callback called when the script is loaded
  123641. * @param onError defines the callback to call if an error occurs
  123642. * @param scriptId defines the id of the script element
  123643. */
  123644. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  123645. /**
  123646. * Load an asynchronous script (identified by an url). When the url returns, the
  123647. * content of this file is added into a new script element, attached to the DOM (body element)
  123648. * @param scriptUrl defines the url of the script to laod
  123649. * @param scriptId defines the id of the script element
  123650. * @returns a promise request object
  123651. */
  123652. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  123653. /**
  123654. * Loads a file from a blob
  123655. * @param fileToLoad defines the blob to use
  123656. * @param callback defines the callback to call when data is loaded
  123657. * @param progressCallback defines the callback to call during loading process
  123658. * @returns a file request object
  123659. */
  123660. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  123661. /**
  123662. * Reads a file from a File object
  123663. * @param file defines the file to load
  123664. * @param onSuccess defines the callback to call when data is loaded
  123665. * @param onProgress defines the callback to call during loading process
  123666. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123667. * @param onError defines the callback to call when an error occurs
  123668. * @returns a file request object
  123669. */
  123670. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  123671. /**
  123672. * Creates a data url from a given string content
  123673. * @param content defines the content to convert
  123674. * @returns the new data url link
  123675. */
  123676. static FileAsURL(content: string): string;
  123677. /**
  123678. * Format the given number to a specific decimal format
  123679. * @param value defines the number to format
  123680. * @param decimals defines the number of decimals to use
  123681. * @returns the formatted string
  123682. */
  123683. static Format(value: number, decimals?: number): string;
  123684. /**
  123685. * Tries to copy an object by duplicating every property
  123686. * @param source defines the source object
  123687. * @param destination defines the target object
  123688. * @param doNotCopyList defines a list of properties to avoid
  123689. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  123690. */
  123691. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  123692. /**
  123693. * Gets a boolean indicating if the given object has no own property
  123694. * @param obj defines the object to test
  123695. * @returns true if object has no own property
  123696. */
  123697. static IsEmpty(obj: any): boolean;
  123698. /**
  123699. * Function used to register events at window level
  123700. * @param windowElement defines the Window object to use
  123701. * @param events defines the events to register
  123702. */
  123703. static RegisterTopRootEvents(windowElement: Window, events: {
  123704. name: string;
  123705. handler: Nullable<(e: FocusEvent) => any>;
  123706. }[]): void;
  123707. /**
  123708. * Function used to unregister events from window level
  123709. * @param windowElement defines the Window object to use
  123710. * @param events defines the events to unregister
  123711. */
  123712. static UnregisterTopRootEvents(windowElement: Window, events: {
  123713. name: string;
  123714. handler: Nullable<(e: FocusEvent) => any>;
  123715. }[]): void;
  123716. /**
  123717. * @ignore
  123718. */
  123719. static _ScreenshotCanvas: HTMLCanvasElement;
  123720. /**
  123721. * Dumps the current bound framebuffer
  123722. * @param width defines the rendering width
  123723. * @param height defines the rendering height
  123724. * @param engine defines the hosting engine
  123725. * @param successCallback defines the callback triggered once the data are available
  123726. * @param mimeType defines the mime type of the result
  123727. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  123728. */
  123729. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123730. /**
  123731. * Converts the canvas data to blob.
  123732. * This acts as a polyfill for browsers not supporting the to blob function.
  123733. * @param canvas Defines the canvas to extract the data from
  123734. * @param successCallback Defines the callback triggered once the data are available
  123735. * @param mimeType Defines the mime type of the result
  123736. */
  123737. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  123738. /**
  123739. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  123740. * @param successCallback defines the callback triggered once the data are available
  123741. * @param mimeType defines the mime type of the result
  123742. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  123743. */
  123744. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123745. /**
  123746. * Downloads a blob in the browser
  123747. * @param blob defines the blob to download
  123748. * @param fileName defines the name of the downloaded file
  123749. */
  123750. static Download(blob: Blob, fileName: string): void;
  123751. /**
  123752. * Will return the right value of the noPreventDefault variable
  123753. * Needed to keep backwards compatibility to the old API.
  123754. *
  123755. * @param args arguments passed to the attachControl function
  123756. * @returns the correct value for noPreventDefault
  123757. */
  123758. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  123759. /**
  123760. * Captures a screenshot of the current rendering
  123761. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123762. * @param engine defines the rendering engine
  123763. * @param camera defines the source camera
  123764. * @param size This parameter can be set to a single number or to an object with the
  123765. * following (optional) properties: precision, width, height. If a single number is passed,
  123766. * it will be used for both width and height. If an object is passed, the screenshot size
  123767. * will be derived from the parameters. The precision property is a multiplier allowing
  123768. * rendering at a higher or lower resolution
  123769. * @param successCallback defines the callback receives a single parameter which contains the
  123770. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123771. * src parameter of an <img> to display it
  123772. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123773. * Check your browser for supported MIME types
  123774. */
  123775. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  123776. /**
  123777. * Captures a screenshot of the current rendering
  123778. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123779. * @param engine defines the rendering engine
  123780. * @param camera defines the source camera
  123781. * @param size This parameter can be set to a single number or to an object with the
  123782. * following (optional) properties: precision, width, height. If a single number is passed,
  123783. * it will be used for both width and height. If an object is passed, the screenshot size
  123784. * will be derived from the parameters. The precision property is a multiplier allowing
  123785. * rendering at a higher or lower resolution
  123786. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123787. * Check your browser for supported MIME types
  123788. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123789. * to the src parameter of an <img> to display it
  123790. */
  123791. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  123792. /**
  123793. * Generates an image screenshot from the specified camera.
  123794. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123795. * @param engine The engine to use for rendering
  123796. * @param camera The camera to use for rendering
  123797. * @param size This parameter can be set to a single number or to an object with the
  123798. * following (optional) properties: precision, width, height. If a single number is passed,
  123799. * it will be used for both width and height. If an object is passed, the screenshot size
  123800. * will be derived from the parameters. The precision property is a multiplier allowing
  123801. * rendering at a higher or lower resolution
  123802. * @param successCallback The callback receives a single parameter which contains the
  123803. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123804. * src parameter of an <img> to display it
  123805. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123806. * Check your browser for supported MIME types
  123807. * @param samples Texture samples (default: 1)
  123808. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123809. * @param fileName A name for for the downloaded file.
  123810. */
  123811. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123812. /**
  123813. * Generates an image screenshot from the specified camera.
  123814. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123815. * @param engine The engine to use for rendering
  123816. * @param camera The camera to use for rendering
  123817. * @param size This parameter can be set to a single number or to an object with the
  123818. * following (optional) properties: precision, width, height. If a single number is passed,
  123819. * it will be used for both width and height. If an object is passed, the screenshot size
  123820. * will be derived from the parameters. The precision property is a multiplier allowing
  123821. * rendering at a higher or lower resolution
  123822. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123823. * Check your browser for supported MIME types
  123824. * @param samples Texture samples (default: 1)
  123825. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123826. * @param fileName A name for for the downloaded file.
  123827. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123828. * to the src parameter of an <img> to display it
  123829. */
  123830. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  123831. /**
  123832. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  123833. * Be aware Math.random() could cause collisions, but:
  123834. * "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"
  123835. * @returns a pseudo random id
  123836. */
  123837. static RandomId(): string;
  123838. /**
  123839. * Test if the given uri is a base64 string
  123840. * @param uri The uri to test
  123841. * @return True if the uri is a base64 string or false otherwise
  123842. */
  123843. static IsBase64(uri: string): boolean;
  123844. /**
  123845. * Decode the given base64 uri.
  123846. * @param uri The uri to decode
  123847. * @return The decoded base64 data.
  123848. */
  123849. static DecodeBase64(uri: string): ArrayBuffer;
  123850. /**
  123851. * Gets the absolute url.
  123852. * @param url the input url
  123853. * @return the absolute url
  123854. */
  123855. static GetAbsoluteUrl(url: string): string;
  123856. /**
  123857. * No log
  123858. */
  123859. static readonly NoneLogLevel: number;
  123860. /**
  123861. * Only message logs
  123862. */
  123863. static readonly MessageLogLevel: number;
  123864. /**
  123865. * Only warning logs
  123866. */
  123867. static readonly WarningLogLevel: number;
  123868. /**
  123869. * Only error logs
  123870. */
  123871. static readonly ErrorLogLevel: number;
  123872. /**
  123873. * All logs
  123874. */
  123875. static readonly AllLogLevel: number;
  123876. /**
  123877. * Gets a value indicating the number of loading errors
  123878. * @ignorenaming
  123879. */
  123880. static get errorsCount(): number;
  123881. /**
  123882. * Callback called when a new log is added
  123883. */
  123884. static OnNewCacheEntry: (entry: string) => void;
  123885. /**
  123886. * Log a message to the console
  123887. * @param message defines the message to log
  123888. */
  123889. static Log(message: string): void;
  123890. /**
  123891. * Write a warning message to the console
  123892. * @param message defines the message to log
  123893. */
  123894. static Warn(message: string): void;
  123895. /**
  123896. * Write an error message to the console
  123897. * @param message defines the message to log
  123898. */
  123899. static Error(message: string): void;
  123900. /**
  123901. * Gets current log cache (list of logs)
  123902. */
  123903. static get LogCache(): string;
  123904. /**
  123905. * Clears the log cache
  123906. */
  123907. static ClearLogCache(): void;
  123908. /**
  123909. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  123910. */
  123911. static set LogLevels(level: number);
  123912. /**
  123913. * Checks if the window object exists
  123914. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  123915. */
  123916. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  123917. /**
  123918. * No performance log
  123919. */
  123920. static readonly PerformanceNoneLogLevel: number;
  123921. /**
  123922. * Use user marks to log performance
  123923. */
  123924. static readonly PerformanceUserMarkLogLevel: number;
  123925. /**
  123926. * Log performance to the console
  123927. */
  123928. static readonly PerformanceConsoleLogLevel: number;
  123929. private static _performance;
  123930. /**
  123931. * Sets the current performance log level
  123932. */
  123933. static set PerformanceLogLevel(level: number);
  123934. private static _StartPerformanceCounterDisabled;
  123935. private static _EndPerformanceCounterDisabled;
  123936. private static _StartUserMark;
  123937. private static _EndUserMark;
  123938. private static _StartPerformanceConsole;
  123939. private static _EndPerformanceConsole;
  123940. /**
  123941. * Starts a performance counter
  123942. */
  123943. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123944. /**
  123945. * Ends a specific performance coutner
  123946. */
  123947. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123948. /**
  123949. * Gets either window.performance.now() if supported or Date.now() else
  123950. */
  123951. static get Now(): number;
  123952. /**
  123953. * This method will return the name of the class used to create the instance of the given object.
  123954. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  123955. * @param object the object to get the class name from
  123956. * @param isType defines if the object is actually a type
  123957. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  123958. */
  123959. static GetClassName(object: any, isType?: boolean): string;
  123960. /**
  123961. * Gets the first element of an array satisfying a given predicate
  123962. * @param array defines the array to browse
  123963. * @param predicate defines the predicate to use
  123964. * @returns null if not found or the element
  123965. */
  123966. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  123967. /**
  123968. * This method will return the name of the full name of the class, including its owning module (if any).
  123969. * 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).
  123970. * @param object the object to get the class name from
  123971. * @param isType defines if the object is actually a type
  123972. * @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.
  123973. * @ignorenaming
  123974. */
  123975. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  123976. /**
  123977. * Returns a promise that resolves after the given amount of time.
  123978. * @param delay Number of milliseconds to delay
  123979. * @returns Promise that resolves after the given amount of time
  123980. */
  123981. static DelayAsync(delay: number): Promise<void>;
  123982. /**
  123983. * Utility function to detect if the current user agent is Safari
  123984. * @returns whether or not the current user agent is safari
  123985. */
  123986. static IsSafari(): boolean;
  123987. }
  123988. /**
  123989. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  123990. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  123991. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  123992. * @param name The name of the class, case should be preserved
  123993. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  123994. */
  123995. export function className(name: string, module?: string): (target: Object) => void;
  123996. /**
  123997. * An implementation of a loop for asynchronous functions.
  123998. */
  123999. export class AsyncLoop {
  124000. /**
  124001. * Defines the number of iterations for the loop
  124002. */
  124003. iterations: number;
  124004. /**
  124005. * Defines the current index of the loop.
  124006. */
  124007. index: number;
  124008. private _done;
  124009. private _fn;
  124010. private _successCallback;
  124011. /**
  124012. * Constructor.
  124013. * @param iterations the number of iterations.
  124014. * @param func the function to run each iteration
  124015. * @param successCallback the callback that will be called upon succesful execution
  124016. * @param offset starting offset.
  124017. */
  124018. constructor(
  124019. /**
  124020. * Defines the number of iterations for the loop
  124021. */
  124022. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  124023. /**
  124024. * Execute the next iteration. Must be called after the last iteration was finished.
  124025. */
  124026. executeNext(): void;
  124027. /**
  124028. * Break the loop and run the success callback.
  124029. */
  124030. breakLoop(): void;
  124031. /**
  124032. * Create and run an async loop.
  124033. * @param iterations the number of iterations.
  124034. * @param fn the function to run each iteration
  124035. * @param successCallback the callback that will be called upon succesful execution
  124036. * @param offset starting offset.
  124037. * @returns the created async loop object
  124038. */
  124039. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  124040. /**
  124041. * A for-loop that will run a given number of iterations synchronous and the rest async.
  124042. * @param iterations total number of iterations
  124043. * @param syncedIterations number of synchronous iterations in each async iteration.
  124044. * @param fn the function to call each iteration.
  124045. * @param callback a success call back that will be called when iterating stops.
  124046. * @param breakFunction a break condition (optional)
  124047. * @param timeout timeout settings for the setTimeout function. default - 0.
  124048. * @returns the created async loop object
  124049. */
  124050. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  124051. }
  124052. }
  124053. declare module BABYLON {
  124054. /**
  124055. * This class implement a typical dictionary using a string as key and the generic type T as value.
  124056. * The underlying implementation relies on an associative array to ensure the best performances.
  124057. * The value can be anything including 'null' but except 'undefined'
  124058. */
  124059. export class StringDictionary<T> {
  124060. /**
  124061. * This will clear this dictionary and copy the content from the 'source' one.
  124062. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  124063. * @param source the dictionary to take the content from and copy to this dictionary
  124064. */
  124065. copyFrom(source: StringDictionary<T>): void;
  124066. /**
  124067. * Get a value based from its key
  124068. * @param key the given key to get the matching value from
  124069. * @return the value if found, otherwise undefined is returned
  124070. */
  124071. get(key: string): T | undefined;
  124072. /**
  124073. * Get a value from its key or add it if it doesn't exist.
  124074. * This method will ensure you that a given key/data will be present in the dictionary.
  124075. * @param key the given key to get the matching value from
  124076. * @param factory the factory that will create the value if the key is not present in the dictionary.
  124077. * The factory will only be invoked if there's no data for the given key.
  124078. * @return the value corresponding to the key.
  124079. */
  124080. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  124081. /**
  124082. * Get a value from its key if present in the dictionary otherwise add it
  124083. * @param key the key to get the value from
  124084. * @param val if there's no such key/value pair in the dictionary add it with this value
  124085. * @return the value corresponding to the key
  124086. */
  124087. getOrAdd(key: string, val: T): T;
  124088. /**
  124089. * Check if there's a given key in the dictionary
  124090. * @param key the key to check for
  124091. * @return true if the key is present, false otherwise
  124092. */
  124093. contains(key: string): boolean;
  124094. /**
  124095. * Add a new key and its corresponding value
  124096. * @param key the key to add
  124097. * @param value the value corresponding to the key
  124098. * @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
  124099. */
  124100. add(key: string, value: T): boolean;
  124101. /**
  124102. * Update a specific value associated to a key
  124103. * @param key defines the key to use
  124104. * @param value defines the value to store
  124105. * @returns true if the value was updated (or false if the key was not found)
  124106. */
  124107. set(key: string, value: T): boolean;
  124108. /**
  124109. * Get the element of the given key and remove it from the dictionary
  124110. * @param key defines the key to search
  124111. * @returns the value associated with the key or null if not found
  124112. */
  124113. getAndRemove(key: string): Nullable<T>;
  124114. /**
  124115. * Remove a key/value from the dictionary.
  124116. * @param key the key to remove
  124117. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  124118. */
  124119. remove(key: string): boolean;
  124120. /**
  124121. * Clear the whole content of the dictionary
  124122. */
  124123. clear(): void;
  124124. /**
  124125. * Gets the current count
  124126. */
  124127. get count(): number;
  124128. /**
  124129. * Execute a callback on each key/val of the dictionary.
  124130. * Note that you can remove any element in this dictionary in the callback implementation
  124131. * @param callback the callback to execute on a given key/value pair
  124132. */
  124133. forEach(callback: (key: string, val: T) => void): void;
  124134. /**
  124135. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  124136. * If the callback returns null or undefined the method will iterate to the next key/value pair
  124137. * Note that you can remove any element in this dictionary in the callback implementation
  124138. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  124139. * @returns the first item
  124140. */
  124141. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  124142. private _count;
  124143. private _data;
  124144. }
  124145. }
  124146. declare module BABYLON {
  124147. /** @hidden */
  124148. export interface ICollisionCoordinator {
  124149. createCollider(): Collider;
  124150. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  124151. init(scene: Scene): void;
  124152. }
  124153. /** @hidden */
  124154. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  124155. private _scene;
  124156. private _scaledPosition;
  124157. private _scaledVelocity;
  124158. private _finalPosition;
  124159. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  124160. createCollider(): Collider;
  124161. init(scene: Scene): void;
  124162. private _collideWithWorld;
  124163. }
  124164. }
  124165. declare module BABYLON {
  124166. /**
  124167. * Class used to manage all inputs for the scene.
  124168. */
  124169. export class InputManager {
  124170. /** The distance in pixel that you have to move to prevent some events */
  124171. static DragMovementThreshold: number;
  124172. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  124173. static LongPressDelay: number;
  124174. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  124175. static DoubleClickDelay: number;
  124176. /** If you need to check double click without raising a single click at first click, enable this flag */
  124177. static ExclusiveDoubleClickMode: boolean;
  124178. /** 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. */
  124179. private _alreadyAttached;
  124180. private _alreadyAttachedTo;
  124181. private _wheelEventName;
  124182. private _onPointerMove;
  124183. private _onPointerDown;
  124184. private _onPointerUp;
  124185. private _initClickEvent;
  124186. private _initActionManager;
  124187. private _delayedSimpleClick;
  124188. private _delayedSimpleClickTimeout;
  124189. private _previousDelayedSimpleClickTimeout;
  124190. private _meshPickProceed;
  124191. private _previousButtonPressed;
  124192. private _currentPickResult;
  124193. private _previousPickResult;
  124194. private _totalPointersPressed;
  124195. private _doubleClickOccured;
  124196. private _pointerOverMesh;
  124197. private _pickedDownMesh;
  124198. private _pickedUpMesh;
  124199. private _pointerX;
  124200. private _pointerY;
  124201. private _unTranslatedPointerX;
  124202. private _unTranslatedPointerY;
  124203. private _startingPointerPosition;
  124204. private _previousStartingPointerPosition;
  124205. private _startingPointerTime;
  124206. private _previousStartingPointerTime;
  124207. private _pointerCaptures;
  124208. private _meshUnderPointerId;
  124209. private _onKeyDown;
  124210. private _onKeyUp;
  124211. private _keyboardIsAttached;
  124212. private _onCanvasFocusObserver;
  124213. private _onCanvasBlurObserver;
  124214. private _scene;
  124215. /**
  124216. * Creates a new InputManager
  124217. * @param scene defines the hosting scene
  124218. */
  124219. constructor(scene: Scene);
  124220. /**
  124221. * Gets the mesh that is currently under the pointer
  124222. */
  124223. get meshUnderPointer(): Nullable<AbstractMesh>;
  124224. /**
  124225. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  124226. * @param pointerId the pointer id to use
  124227. * @returns The mesh under this pointer id or null if not found
  124228. */
  124229. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  124230. /**
  124231. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  124232. */
  124233. get unTranslatedPointer(): Vector2;
  124234. /**
  124235. * Gets or sets the current on-screen X position of the pointer
  124236. */
  124237. get pointerX(): number;
  124238. set pointerX(value: number);
  124239. /**
  124240. * Gets or sets the current on-screen Y position of the pointer
  124241. */
  124242. get pointerY(): number;
  124243. set pointerY(value: number);
  124244. private _updatePointerPosition;
  124245. private _processPointerMove;
  124246. private _setRayOnPointerInfo;
  124247. private _checkPrePointerObservable;
  124248. /**
  124249. * Use this method to simulate a pointer move on a mesh
  124250. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124251. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124252. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124253. */
  124254. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  124255. /**
  124256. * Use this method to simulate a pointer down on a mesh
  124257. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124258. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124259. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124260. */
  124261. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  124262. private _processPointerDown;
  124263. /** @hidden */
  124264. _isPointerSwiping(): boolean;
  124265. /**
  124266. * Use this method to simulate a pointer up on a mesh
  124267. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124268. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124269. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124270. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124271. */
  124272. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  124273. private _processPointerUp;
  124274. /**
  124275. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124276. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124277. * @returns true if the pointer was captured
  124278. */
  124279. isPointerCaptured(pointerId?: number): boolean;
  124280. /**
  124281. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124282. * @param attachUp defines if you want to attach events to pointerup
  124283. * @param attachDown defines if you want to attach events to pointerdown
  124284. * @param attachMove defines if you want to attach events to pointermove
  124285. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  124286. */
  124287. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  124288. /**
  124289. * Detaches all event handlers
  124290. */
  124291. detachControl(): void;
  124292. /**
  124293. * Force the value of meshUnderPointer
  124294. * @param mesh defines the mesh to use
  124295. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  124296. */
  124297. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124298. /**
  124299. * Gets the mesh under the pointer
  124300. * @returns a Mesh or null if no mesh is under the pointer
  124301. */
  124302. getPointerOverMesh(): Nullable<AbstractMesh>;
  124303. }
  124304. }
  124305. declare module BABYLON {
  124306. /**
  124307. * This class defines the direct association between an animation and a target
  124308. */
  124309. export class TargetedAnimation {
  124310. /**
  124311. * Animation to perform
  124312. */
  124313. animation: Animation;
  124314. /**
  124315. * Target to animate
  124316. */
  124317. target: any;
  124318. /**
  124319. * Returns the string "TargetedAnimation"
  124320. * @returns "TargetedAnimation"
  124321. */
  124322. getClassName(): string;
  124323. /**
  124324. * Serialize the object
  124325. * @returns the JSON object representing the current entity
  124326. */
  124327. serialize(): any;
  124328. }
  124329. /**
  124330. * Use this class to create coordinated animations on multiple targets
  124331. */
  124332. export class AnimationGroup implements IDisposable {
  124333. /** The name of the animation group */
  124334. name: string;
  124335. private _scene;
  124336. private _targetedAnimations;
  124337. private _animatables;
  124338. private _from;
  124339. private _to;
  124340. private _isStarted;
  124341. private _isPaused;
  124342. private _speedRatio;
  124343. private _loopAnimation;
  124344. private _isAdditive;
  124345. /**
  124346. * Gets or sets the unique id of the node
  124347. */
  124348. uniqueId: number;
  124349. /**
  124350. * This observable will notify when one animation have ended
  124351. */
  124352. onAnimationEndObservable: Observable<TargetedAnimation>;
  124353. /**
  124354. * Observer raised when one animation loops
  124355. */
  124356. onAnimationLoopObservable: Observable<TargetedAnimation>;
  124357. /**
  124358. * Observer raised when all animations have looped
  124359. */
  124360. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  124361. /**
  124362. * This observable will notify when all animations have ended.
  124363. */
  124364. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  124365. /**
  124366. * This observable will notify when all animations have paused.
  124367. */
  124368. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  124369. /**
  124370. * This observable will notify when all animations are playing.
  124371. */
  124372. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  124373. /**
  124374. * Gets the first frame
  124375. */
  124376. get from(): number;
  124377. /**
  124378. * Gets the last frame
  124379. */
  124380. get to(): number;
  124381. /**
  124382. * Define if the animations are started
  124383. */
  124384. get isStarted(): boolean;
  124385. /**
  124386. * Gets a value indicating that the current group is playing
  124387. */
  124388. get isPlaying(): boolean;
  124389. /**
  124390. * Gets or sets the speed ratio to use for all animations
  124391. */
  124392. get speedRatio(): number;
  124393. /**
  124394. * Gets or sets the speed ratio to use for all animations
  124395. */
  124396. set speedRatio(value: number);
  124397. /**
  124398. * Gets or sets if all animations should loop or not
  124399. */
  124400. get loopAnimation(): boolean;
  124401. set loopAnimation(value: boolean);
  124402. /**
  124403. * Gets or sets if all animations should be evaluated additively
  124404. */
  124405. get isAdditive(): boolean;
  124406. set isAdditive(value: boolean);
  124407. /**
  124408. * Gets the targeted animations for this animation group
  124409. */
  124410. get targetedAnimations(): Array<TargetedAnimation>;
  124411. /**
  124412. * returning the list of animatables controlled by this animation group.
  124413. */
  124414. get animatables(): Array<Animatable>;
  124415. /**
  124416. * Gets the list of target animations
  124417. */
  124418. get children(): TargetedAnimation[];
  124419. /**
  124420. * Instantiates a new Animation Group.
  124421. * This helps managing several animations at once.
  124422. * @see https://doc.babylonjs.com/how_to/group
  124423. * @param name Defines the name of the group
  124424. * @param scene Defines the scene the group belongs to
  124425. */
  124426. constructor(
  124427. /** The name of the animation group */
  124428. name: string, scene?: Nullable<Scene>);
  124429. /**
  124430. * Add an animation (with its target) in the group
  124431. * @param animation defines the animation we want to add
  124432. * @param target defines the target of the animation
  124433. * @returns the TargetedAnimation object
  124434. */
  124435. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  124436. /**
  124437. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  124438. * It can add constant keys at begin or end
  124439. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  124440. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  124441. * @returns the animation group
  124442. */
  124443. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  124444. private _animationLoopCount;
  124445. private _animationLoopFlags;
  124446. private _processLoop;
  124447. /**
  124448. * Start all animations on given targets
  124449. * @param loop defines if animations must loop
  124450. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  124451. * @param from defines the from key (optional)
  124452. * @param to defines the to key (optional)
  124453. * @param isAdditive defines the additive state for the resulting animatables (optional)
  124454. * @returns the current animation group
  124455. */
  124456. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  124457. /**
  124458. * Pause all animations
  124459. * @returns the animation group
  124460. */
  124461. pause(): AnimationGroup;
  124462. /**
  124463. * Play all animations to initial state
  124464. * This function will start() the animations if they were not started or will restart() them if they were paused
  124465. * @param loop defines if animations must loop
  124466. * @returns the animation group
  124467. */
  124468. play(loop?: boolean): AnimationGroup;
  124469. /**
  124470. * Reset all animations to initial state
  124471. * @returns the animation group
  124472. */
  124473. reset(): AnimationGroup;
  124474. /**
  124475. * Restart animations from key 0
  124476. * @returns the animation group
  124477. */
  124478. restart(): AnimationGroup;
  124479. /**
  124480. * Stop all animations
  124481. * @returns the animation group
  124482. */
  124483. stop(): AnimationGroup;
  124484. /**
  124485. * Set animation weight for all animatables
  124486. * @param weight defines the weight to use
  124487. * @return the animationGroup
  124488. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124489. */
  124490. setWeightForAllAnimatables(weight: number): AnimationGroup;
  124491. /**
  124492. * Synchronize and normalize all animatables with a source animatable
  124493. * @param root defines the root animatable to synchronize with
  124494. * @return the animationGroup
  124495. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124496. */
  124497. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  124498. /**
  124499. * Goes to a specific frame in this animation group
  124500. * @param frame the frame number to go to
  124501. * @return the animationGroup
  124502. */
  124503. goToFrame(frame: number): AnimationGroup;
  124504. /**
  124505. * Dispose all associated resources
  124506. */
  124507. dispose(): void;
  124508. private _checkAnimationGroupEnded;
  124509. /**
  124510. * Clone the current animation group and returns a copy
  124511. * @param newName defines the name of the new group
  124512. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  124513. * @returns the new aniamtion group
  124514. */
  124515. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  124516. /**
  124517. * Serializes the animationGroup to an object
  124518. * @returns Serialized object
  124519. */
  124520. serialize(): any;
  124521. /**
  124522. * Returns a new AnimationGroup object parsed from the source provided.
  124523. * @param parsedAnimationGroup defines the source
  124524. * @param scene defines the scene that will receive the animationGroup
  124525. * @returns a new AnimationGroup
  124526. */
  124527. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  124528. /**
  124529. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  124530. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  124531. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  124532. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  124533. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  124534. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  124535. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  124536. */
  124537. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  124538. /**
  124539. * Returns the string "AnimationGroup"
  124540. * @returns "AnimationGroup"
  124541. */
  124542. getClassName(): string;
  124543. /**
  124544. * Creates a detailled string about the object
  124545. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  124546. * @returns a string representing the object
  124547. */
  124548. toString(fullDetails?: boolean): string;
  124549. }
  124550. }
  124551. declare module BABYLON {
  124552. /**
  124553. * Define an interface for all classes that will hold resources
  124554. */
  124555. export interface IDisposable {
  124556. /**
  124557. * Releases all held resources
  124558. */
  124559. dispose(): void;
  124560. }
  124561. /** Interface defining initialization parameters for Scene class */
  124562. export interface SceneOptions {
  124563. /**
  124564. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  124565. * It will improve performance when the number of geometries becomes important.
  124566. */
  124567. useGeometryUniqueIdsMap?: boolean;
  124568. /**
  124569. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  124570. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124571. */
  124572. useMaterialMeshMap?: boolean;
  124573. /**
  124574. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  124575. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124576. */
  124577. useClonedMeshMap?: boolean;
  124578. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  124579. virtual?: boolean;
  124580. }
  124581. /**
  124582. * Represents a scene to be rendered by the engine.
  124583. * @see https://doc.babylonjs.com/features/scene
  124584. */
  124585. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  124586. /** The fog is deactivated */
  124587. static readonly FOGMODE_NONE: number;
  124588. /** The fog density is following an exponential function */
  124589. static readonly FOGMODE_EXP: number;
  124590. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  124591. static readonly FOGMODE_EXP2: number;
  124592. /** The fog density is following a linear function. */
  124593. static readonly FOGMODE_LINEAR: number;
  124594. /**
  124595. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  124596. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124597. */
  124598. static MinDeltaTime: number;
  124599. /**
  124600. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  124601. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124602. */
  124603. static MaxDeltaTime: number;
  124604. /**
  124605. * Factory used to create the default material.
  124606. * @param name The name of the material to create
  124607. * @param scene The scene to create the material for
  124608. * @returns The default material
  124609. */
  124610. static DefaultMaterialFactory(scene: Scene): Material;
  124611. /**
  124612. * Factory used to create the a collision coordinator.
  124613. * @returns The collision coordinator
  124614. */
  124615. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  124616. /** @hidden */
  124617. _inputManager: InputManager;
  124618. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  124619. cameraToUseForPointers: Nullable<Camera>;
  124620. /** @hidden */
  124621. readonly _isScene: boolean;
  124622. /** @hidden */
  124623. _blockEntityCollection: boolean;
  124624. /**
  124625. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  124626. */
  124627. autoClear: boolean;
  124628. /**
  124629. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  124630. */
  124631. autoClearDepthAndStencil: boolean;
  124632. /**
  124633. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  124634. */
  124635. clearColor: Color4;
  124636. /**
  124637. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  124638. */
  124639. ambientColor: Color3;
  124640. /**
  124641. * This is use to store the default BRDF lookup for PBR materials in your scene.
  124642. * It should only be one of the following (if not the default embedded one):
  124643. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124644. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  124645. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124646. * The material properties need to be setup according to the type of texture in use.
  124647. */
  124648. environmentBRDFTexture: BaseTexture;
  124649. /**
  124650. * Texture used in all pbr material as the reflection texture.
  124651. * As in the majority of the scene they are the same (exception for multi room and so on),
  124652. * this is easier to reference from here than from all the materials.
  124653. */
  124654. get environmentTexture(): Nullable<BaseTexture>;
  124655. /**
  124656. * Texture used in all pbr material as the reflection texture.
  124657. * As in the majority of the scene they are the same (exception for multi room and so on),
  124658. * this is easier to set here than in all the materials.
  124659. */
  124660. set environmentTexture(value: Nullable<BaseTexture>);
  124661. /** @hidden */
  124662. protected _environmentIntensity: number;
  124663. /**
  124664. * Intensity of the environment in all pbr material.
  124665. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124666. * As in the majority of the scene they are the same (exception for multi room and so on),
  124667. * this is easier to reference from here than from all the materials.
  124668. */
  124669. get environmentIntensity(): number;
  124670. /**
  124671. * Intensity of the environment in all pbr material.
  124672. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124673. * As in the majority of the scene they are the same (exception for multi room and so on),
  124674. * this is easier to set here than in all the materials.
  124675. */
  124676. set environmentIntensity(value: number);
  124677. /** @hidden */
  124678. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124679. /**
  124680. * Default image processing configuration used either in the rendering
  124681. * Forward main pass or through the imageProcessingPostProcess if present.
  124682. * As in the majority of the scene they are the same (exception for multi camera),
  124683. * this is easier to reference from here than from all the materials and post process.
  124684. *
  124685. * No setter as we it is a shared configuration, you can set the values instead.
  124686. */
  124687. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124688. private _forceWireframe;
  124689. /**
  124690. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  124691. */
  124692. set forceWireframe(value: boolean);
  124693. get forceWireframe(): boolean;
  124694. private _skipFrustumClipping;
  124695. /**
  124696. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  124697. */
  124698. set skipFrustumClipping(value: boolean);
  124699. get skipFrustumClipping(): boolean;
  124700. private _forcePointsCloud;
  124701. /**
  124702. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  124703. */
  124704. set forcePointsCloud(value: boolean);
  124705. get forcePointsCloud(): boolean;
  124706. /**
  124707. * Gets or sets the active clipplane 1
  124708. */
  124709. clipPlane: Nullable<Plane>;
  124710. /**
  124711. * Gets or sets the active clipplane 2
  124712. */
  124713. clipPlane2: Nullable<Plane>;
  124714. /**
  124715. * Gets or sets the active clipplane 3
  124716. */
  124717. clipPlane3: Nullable<Plane>;
  124718. /**
  124719. * Gets or sets the active clipplane 4
  124720. */
  124721. clipPlane4: Nullable<Plane>;
  124722. /**
  124723. * Gets or sets the active clipplane 5
  124724. */
  124725. clipPlane5: Nullable<Plane>;
  124726. /**
  124727. * Gets or sets the active clipplane 6
  124728. */
  124729. clipPlane6: Nullable<Plane>;
  124730. /**
  124731. * Gets or sets a boolean indicating if animations are enabled
  124732. */
  124733. animationsEnabled: boolean;
  124734. private _animationPropertiesOverride;
  124735. /**
  124736. * Gets or sets the animation properties override
  124737. */
  124738. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  124739. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  124740. /**
  124741. * Gets or sets a boolean indicating if a constant deltatime has to be used
  124742. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  124743. */
  124744. useConstantAnimationDeltaTime: boolean;
  124745. /**
  124746. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  124747. * Please note that it requires to run a ray cast through the scene on every frame
  124748. */
  124749. constantlyUpdateMeshUnderPointer: boolean;
  124750. /**
  124751. * Defines the HTML cursor to use when hovering over interactive elements
  124752. */
  124753. hoverCursor: string;
  124754. /**
  124755. * Defines the HTML default cursor to use (empty by default)
  124756. */
  124757. defaultCursor: string;
  124758. /**
  124759. * Defines whether cursors are handled by the scene.
  124760. */
  124761. doNotHandleCursors: boolean;
  124762. /**
  124763. * This is used to call preventDefault() on pointer down
  124764. * in order to block unwanted artifacts like system double clicks
  124765. */
  124766. preventDefaultOnPointerDown: boolean;
  124767. /**
  124768. * This is used to call preventDefault() on pointer up
  124769. * in order to block unwanted artifacts like system double clicks
  124770. */
  124771. preventDefaultOnPointerUp: boolean;
  124772. /**
  124773. * Gets or sets user defined metadata
  124774. */
  124775. metadata: any;
  124776. /**
  124777. * For internal use only. Please do not use.
  124778. */
  124779. reservedDataStore: any;
  124780. /**
  124781. * Gets the name of the plugin used to load this scene (null by default)
  124782. */
  124783. loadingPluginName: string;
  124784. /**
  124785. * Use this array to add regular expressions used to disable offline support for specific urls
  124786. */
  124787. disableOfflineSupportExceptionRules: RegExp[];
  124788. /**
  124789. * An event triggered when the scene is disposed.
  124790. */
  124791. onDisposeObservable: Observable<Scene>;
  124792. private _onDisposeObserver;
  124793. /** Sets a function to be executed when this scene is disposed. */
  124794. set onDispose(callback: () => void);
  124795. /**
  124796. * An event triggered before rendering the scene (right after animations and physics)
  124797. */
  124798. onBeforeRenderObservable: Observable<Scene>;
  124799. private _onBeforeRenderObserver;
  124800. /** Sets a function to be executed before rendering this scene */
  124801. set beforeRender(callback: Nullable<() => void>);
  124802. /**
  124803. * An event triggered after rendering the scene
  124804. */
  124805. onAfterRenderObservable: Observable<Scene>;
  124806. /**
  124807. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  124808. */
  124809. onAfterRenderCameraObservable: Observable<Camera>;
  124810. private _onAfterRenderObserver;
  124811. /** Sets a function to be executed after rendering this scene */
  124812. set afterRender(callback: Nullable<() => void>);
  124813. /**
  124814. * An event triggered before animating the scene
  124815. */
  124816. onBeforeAnimationsObservable: Observable<Scene>;
  124817. /**
  124818. * An event triggered after animations processing
  124819. */
  124820. onAfterAnimationsObservable: Observable<Scene>;
  124821. /**
  124822. * An event triggered before draw calls are ready to be sent
  124823. */
  124824. onBeforeDrawPhaseObservable: Observable<Scene>;
  124825. /**
  124826. * An event triggered after draw calls have been sent
  124827. */
  124828. onAfterDrawPhaseObservable: Observable<Scene>;
  124829. /**
  124830. * An event triggered when the scene is ready
  124831. */
  124832. onReadyObservable: Observable<Scene>;
  124833. /**
  124834. * An event triggered before rendering a camera
  124835. */
  124836. onBeforeCameraRenderObservable: Observable<Camera>;
  124837. private _onBeforeCameraRenderObserver;
  124838. /** Sets a function to be executed before rendering a camera*/
  124839. set beforeCameraRender(callback: () => void);
  124840. /**
  124841. * An event triggered after rendering a camera
  124842. */
  124843. onAfterCameraRenderObservable: Observable<Camera>;
  124844. private _onAfterCameraRenderObserver;
  124845. /** Sets a function to be executed after rendering a camera*/
  124846. set afterCameraRender(callback: () => void);
  124847. /**
  124848. * An event triggered when active meshes evaluation is about to start
  124849. */
  124850. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  124851. /**
  124852. * An event triggered when active meshes evaluation is done
  124853. */
  124854. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  124855. /**
  124856. * An event triggered when particles rendering is about to start
  124857. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124858. */
  124859. onBeforeParticlesRenderingObservable: Observable<Scene>;
  124860. /**
  124861. * An event triggered when particles rendering is done
  124862. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124863. */
  124864. onAfterParticlesRenderingObservable: Observable<Scene>;
  124865. /**
  124866. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  124867. */
  124868. onDataLoadedObservable: Observable<Scene>;
  124869. /**
  124870. * An event triggered when a camera is created
  124871. */
  124872. onNewCameraAddedObservable: Observable<Camera>;
  124873. /**
  124874. * An event triggered when a camera is removed
  124875. */
  124876. onCameraRemovedObservable: Observable<Camera>;
  124877. /**
  124878. * An event triggered when a light is created
  124879. */
  124880. onNewLightAddedObservable: Observable<Light>;
  124881. /**
  124882. * An event triggered when a light is removed
  124883. */
  124884. onLightRemovedObservable: Observable<Light>;
  124885. /**
  124886. * An event triggered when a geometry is created
  124887. */
  124888. onNewGeometryAddedObservable: Observable<Geometry>;
  124889. /**
  124890. * An event triggered when a geometry is removed
  124891. */
  124892. onGeometryRemovedObservable: Observable<Geometry>;
  124893. /**
  124894. * An event triggered when a transform node is created
  124895. */
  124896. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  124897. /**
  124898. * An event triggered when a transform node is removed
  124899. */
  124900. onTransformNodeRemovedObservable: Observable<TransformNode>;
  124901. /**
  124902. * An event triggered when a mesh is created
  124903. */
  124904. onNewMeshAddedObservable: Observable<AbstractMesh>;
  124905. /**
  124906. * An event triggered when a mesh is removed
  124907. */
  124908. onMeshRemovedObservable: Observable<AbstractMesh>;
  124909. /**
  124910. * An event triggered when a skeleton is created
  124911. */
  124912. onNewSkeletonAddedObservable: Observable<Skeleton>;
  124913. /**
  124914. * An event triggered when a skeleton is removed
  124915. */
  124916. onSkeletonRemovedObservable: Observable<Skeleton>;
  124917. /**
  124918. * An event triggered when a material is created
  124919. */
  124920. onNewMaterialAddedObservable: Observable<Material>;
  124921. /**
  124922. * An event triggered when a multi material is created
  124923. */
  124924. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  124925. /**
  124926. * An event triggered when a material is removed
  124927. */
  124928. onMaterialRemovedObservable: Observable<Material>;
  124929. /**
  124930. * An event triggered when a multi material is removed
  124931. */
  124932. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  124933. /**
  124934. * An event triggered when a texture is created
  124935. */
  124936. onNewTextureAddedObservable: Observable<BaseTexture>;
  124937. /**
  124938. * An event triggered when a texture is removed
  124939. */
  124940. onTextureRemovedObservable: Observable<BaseTexture>;
  124941. /**
  124942. * An event triggered when render targets are about to be rendered
  124943. * Can happen multiple times per frame.
  124944. */
  124945. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  124946. /**
  124947. * An event triggered when render targets were rendered.
  124948. * Can happen multiple times per frame.
  124949. */
  124950. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  124951. /**
  124952. * An event triggered before calculating deterministic simulation step
  124953. */
  124954. onBeforeStepObservable: Observable<Scene>;
  124955. /**
  124956. * An event triggered after calculating deterministic simulation step
  124957. */
  124958. onAfterStepObservable: Observable<Scene>;
  124959. /**
  124960. * An event triggered when the activeCamera property is updated
  124961. */
  124962. onActiveCameraChanged: Observable<Scene>;
  124963. /**
  124964. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  124965. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124966. * 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)
  124967. */
  124968. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124969. /**
  124970. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  124971. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124972. * 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)
  124973. */
  124974. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124975. /**
  124976. * This Observable will when a mesh has been imported into the scene.
  124977. */
  124978. onMeshImportedObservable: Observable<AbstractMesh>;
  124979. /**
  124980. * This Observable will when an animation file has been imported into the scene.
  124981. */
  124982. onAnimationFileImportedObservable: Observable<Scene>;
  124983. /**
  124984. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  124985. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  124986. */
  124987. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  124988. /** @hidden */
  124989. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  124990. /**
  124991. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  124992. */
  124993. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  124994. /**
  124995. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  124996. */
  124997. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  124998. /**
  124999. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  125000. */
  125001. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  125002. /** Callback called when a pointer move is detected */
  125003. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  125004. /** Callback called when a pointer down is detected */
  125005. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  125006. /** Callback called when a pointer up is detected */
  125007. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  125008. /** Callback called when a pointer pick is detected */
  125009. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  125010. /**
  125011. * 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).
  125012. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  125013. */
  125014. onPrePointerObservable: Observable<PointerInfoPre>;
  125015. /**
  125016. * Observable event triggered each time an input event is received from the rendering canvas
  125017. */
  125018. onPointerObservable: Observable<PointerInfo>;
  125019. /**
  125020. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  125021. */
  125022. get unTranslatedPointer(): Vector2;
  125023. /**
  125024. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  125025. */
  125026. static get DragMovementThreshold(): number;
  125027. static set DragMovementThreshold(value: number);
  125028. /**
  125029. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  125030. */
  125031. static get LongPressDelay(): number;
  125032. static set LongPressDelay(value: number);
  125033. /**
  125034. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  125035. */
  125036. static get DoubleClickDelay(): number;
  125037. static set DoubleClickDelay(value: number);
  125038. /** If you need to check double click without raising a single click at first click, enable this flag */
  125039. static get ExclusiveDoubleClickMode(): boolean;
  125040. static set ExclusiveDoubleClickMode(value: boolean);
  125041. /** @hidden */
  125042. _mirroredCameraPosition: Nullable<Vector3>;
  125043. /**
  125044. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  125045. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  125046. */
  125047. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  125048. /**
  125049. * Observable event triggered each time an keyboard event is received from the hosting window
  125050. */
  125051. onKeyboardObservable: Observable<KeyboardInfo>;
  125052. private _useRightHandedSystem;
  125053. /**
  125054. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  125055. */
  125056. set useRightHandedSystem(value: boolean);
  125057. get useRightHandedSystem(): boolean;
  125058. private _timeAccumulator;
  125059. private _currentStepId;
  125060. private _currentInternalStep;
  125061. /**
  125062. * Sets the step Id used by deterministic lock step
  125063. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  125064. * @param newStepId defines the step Id
  125065. */
  125066. setStepId(newStepId: number): void;
  125067. /**
  125068. * Gets the step Id used by deterministic lock step
  125069. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  125070. * @returns the step Id
  125071. */
  125072. getStepId(): number;
  125073. /**
  125074. * Gets the internal step used by deterministic lock step
  125075. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  125076. * @returns the internal step
  125077. */
  125078. getInternalStep(): number;
  125079. private _fogEnabled;
  125080. /**
  125081. * Gets or sets a boolean indicating if fog is enabled on this scene
  125082. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125083. * (Default is true)
  125084. */
  125085. set fogEnabled(value: boolean);
  125086. get fogEnabled(): boolean;
  125087. private _fogMode;
  125088. /**
  125089. * Gets or sets the fog mode to use
  125090. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125091. * | mode | value |
  125092. * | --- | --- |
  125093. * | FOGMODE_NONE | 0 |
  125094. * | FOGMODE_EXP | 1 |
  125095. * | FOGMODE_EXP2 | 2 |
  125096. * | FOGMODE_LINEAR | 3 |
  125097. */
  125098. set fogMode(value: number);
  125099. get fogMode(): number;
  125100. /**
  125101. * Gets or sets the fog color to use
  125102. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125103. * (Default is Color3(0.2, 0.2, 0.3))
  125104. */
  125105. fogColor: Color3;
  125106. /**
  125107. * Gets or sets the fog density to use
  125108. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125109. * (Default is 0.1)
  125110. */
  125111. fogDensity: number;
  125112. /**
  125113. * Gets or sets the fog start distance to use
  125114. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125115. * (Default is 0)
  125116. */
  125117. fogStart: number;
  125118. /**
  125119. * Gets or sets the fog end distance to use
  125120. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125121. * (Default is 1000)
  125122. */
  125123. fogEnd: number;
  125124. /**
  125125. * Flag indicating that the frame buffer binding is handled by another component
  125126. */
  125127. prePass: boolean;
  125128. private _shadowsEnabled;
  125129. /**
  125130. * Gets or sets a boolean indicating if shadows are enabled on this scene
  125131. */
  125132. set shadowsEnabled(value: boolean);
  125133. get shadowsEnabled(): boolean;
  125134. private _lightsEnabled;
  125135. /**
  125136. * Gets or sets a boolean indicating if lights are enabled on this scene
  125137. */
  125138. set lightsEnabled(value: boolean);
  125139. get lightsEnabled(): boolean;
  125140. /** All of the active cameras added to this scene. */
  125141. activeCameras: Nullable<Camera[]>;
  125142. /** @hidden */
  125143. _activeCamera: Nullable<Camera>;
  125144. /** Gets or sets the current active camera */
  125145. get activeCamera(): Nullable<Camera>;
  125146. set activeCamera(value: Nullable<Camera>);
  125147. private _defaultMaterial;
  125148. /** The default material used on meshes when no material is affected */
  125149. get defaultMaterial(): Material;
  125150. /** The default material used on meshes when no material is affected */
  125151. set defaultMaterial(value: Material);
  125152. private _texturesEnabled;
  125153. /**
  125154. * Gets or sets a boolean indicating if textures are enabled on this scene
  125155. */
  125156. set texturesEnabled(value: boolean);
  125157. get texturesEnabled(): boolean;
  125158. /**
  125159. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  125160. */
  125161. physicsEnabled: boolean;
  125162. /**
  125163. * Gets or sets a boolean indicating if particles are enabled on this scene
  125164. */
  125165. particlesEnabled: boolean;
  125166. /**
  125167. * Gets or sets a boolean indicating if sprites are enabled on this scene
  125168. */
  125169. spritesEnabled: boolean;
  125170. private _skeletonsEnabled;
  125171. /**
  125172. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  125173. */
  125174. set skeletonsEnabled(value: boolean);
  125175. get skeletonsEnabled(): boolean;
  125176. /**
  125177. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  125178. */
  125179. lensFlaresEnabled: boolean;
  125180. /**
  125181. * Gets or sets a boolean indicating if collisions are enabled on this scene
  125182. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  125183. */
  125184. collisionsEnabled: boolean;
  125185. private _collisionCoordinator;
  125186. /** @hidden */
  125187. get collisionCoordinator(): ICollisionCoordinator;
  125188. /**
  125189. * Defines the gravity applied to this scene (used only for collisions)
  125190. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  125191. */
  125192. gravity: Vector3;
  125193. /**
  125194. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  125195. */
  125196. postProcessesEnabled: boolean;
  125197. /**
  125198. * Gets the current postprocess manager
  125199. */
  125200. postProcessManager: PostProcessManager;
  125201. /**
  125202. * Gets or sets a boolean indicating if render targets are enabled on this scene
  125203. */
  125204. renderTargetsEnabled: boolean;
  125205. /**
  125206. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  125207. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  125208. */
  125209. dumpNextRenderTargets: boolean;
  125210. /**
  125211. * The list of user defined render targets added to the scene
  125212. */
  125213. customRenderTargets: RenderTargetTexture[];
  125214. /**
  125215. * Defines if texture loading must be delayed
  125216. * If true, textures will only be loaded when they need to be rendered
  125217. */
  125218. useDelayedTextureLoading: boolean;
  125219. /**
  125220. * Gets the list of meshes imported to the scene through SceneLoader
  125221. */
  125222. importedMeshesFiles: String[];
  125223. /**
  125224. * Gets or sets a boolean indicating if probes are enabled on this scene
  125225. */
  125226. probesEnabled: boolean;
  125227. /**
  125228. * Gets or sets the current offline provider to use to store scene data
  125229. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125230. */
  125231. offlineProvider: IOfflineProvider;
  125232. /**
  125233. * Gets or sets the action manager associated with the scene
  125234. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125235. */
  125236. actionManager: AbstractActionManager;
  125237. private _meshesForIntersections;
  125238. /**
  125239. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  125240. */
  125241. proceduralTexturesEnabled: boolean;
  125242. private _engine;
  125243. private _totalVertices;
  125244. /** @hidden */
  125245. _activeIndices: PerfCounter;
  125246. /** @hidden */
  125247. _activeParticles: PerfCounter;
  125248. /** @hidden */
  125249. _activeBones: PerfCounter;
  125250. private _animationRatio;
  125251. /** @hidden */
  125252. _animationTimeLast: number;
  125253. /** @hidden */
  125254. _animationTime: number;
  125255. /**
  125256. * Gets or sets a general scale for animation speed
  125257. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  125258. */
  125259. animationTimeScale: number;
  125260. /** @hidden */
  125261. _cachedMaterial: Nullable<Material>;
  125262. /** @hidden */
  125263. _cachedEffect: Nullable<Effect>;
  125264. /** @hidden */
  125265. _cachedVisibility: Nullable<number>;
  125266. private _renderId;
  125267. private _frameId;
  125268. private _executeWhenReadyTimeoutId;
  125269. private _intermediateRendering;
  125270. private _viewUpdateFlag;
  125271. private _projectionUpdateFlag;
  125272. /** @hidden */
  125273. _toBeDisposed: Nullable<IDisposable>[];
  125274. private _activeRequests;
  125275. /** @hidden */
  125276. _pendingData: any[];
  125277. private _isDisposed;
  125278. /**
  125279. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  125280. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  125281. */
  125282. dispatchAllSubMeshesOfActiveMeshes: boolean;
  125283. private _activeMeshes;
  125284. private _processedMaterials;
  125285. private _renderTargets;
  125286. /** @hidden */
  125287. _activeParticleSystems: SmartArray<IParticleSystem>;
  125288. private _activeSkeletons;
  125289. private _softwareSkinnedMeshes;
  125290. private _renderingManager;
  125291. /** @hidden */
  125292. _activeAnimatables: Animatable[];
  125293. private _transformMatrix;
  125294. private _sceneUbo;
  125295. /** @hidden */
  125296. _viewMatrix: Matrix;
  125297. private _projectionMatrix;
  125298. /** @hidden */
  125299. _forcedViewPosition: Nullable<Vector3>;
  125300. /** @hidden */
  125301. _frustumPlanes: Plane[];
  125302. /**
  125303. * Gets the list of frustum planes (built from the active camera)
  125304. */
  125305. get frustumPlanes(): Plane[];
  125306. /**
  125307. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  125308. * This is useful if there are more lights that the maximum simulteanous authorized
  125309. */
  125310. requireLightSorting: boolean;
  125311. /** @hidden */
  125312. readonly useMaterialMeshMap: boolean;
  125313. /** @hidden */
  125314. readonly useClonedMeshMap: boolean;
  125315. private _externalData;
  125316. private _uid;
  125317. /**
  125318. * @hidden
  125319. * Backing store of defined scene components.
  125320. */
  125321. _components: ISceneComponent[];
  125322. /**
  125323. * @hidden
  125324. * Backing store of defined scene components.
  125325. */
  125326. _serializableComponents: ISceneSerializableComponent[];
  125327. /**
  125328. * List of components to register on the next registration step.
  125329. */
  125330. private _transientComponents;
  125331. /**
  125332. * Registers the transient components if needed.
  125333. */
  125334. private _registerTransientComponents;
  125335. /**
  125336. * @hidden
  125337. * Add a component to the scene.
  125338. * Note that the ccomponent could be registered on th next frame if this is called after
  125339. * the register component stage.
  125340. * @param component Defines the component to add to the scene
  125341. */
  125342. _addComponent(component: ISceneComponent): void;
  125343. /**
  125344. * @hidden
  125345. * Gets a component from the scene.
  125346. * @param name defines the name of the component to retrieve
  125347. * @returns the component or null if not present
  125348. */
  125349. _getComponent(name: string): Nullable<ISceneComponent>;
  125350. /**
  125351. * @hidden
  125352. * Defines the actions happening before camera updates.
  125353. */
  125354. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  125355. /**
  125356. * @hidden
  125357. * Defines the actions happening before clear the canvas.
  125358. */
  125359. _beforeClearStage: Stage<SimpleStageAction>;
  125360. /**
  125361. * @hidden
  125362. * Defines the actions when collecting render targets for the frame.
  125363. */
  125364. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125365. /**
  125366. * @hidden
  125367. * Defines the actions happening for one camera in the frame.
  125368. */
  125369. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125370. /**
  125371. * @hidden
  125372. * Defines the actions happening during the per mesh ready checks.
  125373. */
  125374. _isReadyForMeshStage: Stage<MeshStageAction>;
  125375. /**
  125376. * @hidden
  125377. * Defines the actions happening before evaluate active mesh checks.
  125378. */
  125379. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  125380. /**
  125381. * @hidden
  125382. * Defines the actions happening during the evaluate sub mesh checks.
  125383. */
  125384. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  125385. /**
  125386. * @hidden
  125387. * Defines the actions happening during the active mesh stage.
  125388. */
  125389. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  125390. /**
  125391. * @hidden
  125392. * Defines the actions happening during the per camera render target step.
  125393. */
  125394. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  125395. /**
  125396. * @hidden
  125397. * Defines the actions happening just before the active camera is drawing.
  125398. */
  125399. _beforeCameraDrawStage: Stage<CameraStageAction>;
  125400. /**
  125401. * @hidden
  125402. * Defines the actions happening just before a render target is drawing.
  125403. */
  125404. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125405. /**
  125406. * @hidden
  125407. * Defines the actions happening just before a rendering group is drawing.
  125408. */
  125409. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125410. /**
  125411. * @hidden
  125412. * Defines the actions happening just before a mesh is drawing.
  125413. */
  125414. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125415. /**
  125416. * @hidden
  125417. * Defines the actions happening just after a mesh has been drawn.
  125418. */
  125419. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125420. /**
  125421. * @hidden
  125422. * Defines the actions happening just after a rendering group has been drawn.
  125423. */
  125424. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125425. /**
  125426. * @hidden
  125427. * Defines the actions happening just after the active camera has been drawn.
  125428. */
  125429. _afterCameraDrawStage: Stage<CameraStageAction>;
  125430. /**
  125431. * @hidden
  125432. * Defines the actions happening just after a render target has been drawn.
  125433. */
  125434. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125435. /**
  125436. * @hidden
  125437. * Defines the actions happening just after rendering all cameras and computing intersections.
  125438. */
  125439. _afterRenderStage: Stage<SimpleStageAction>;
  125440. /**
  125441. * @hidden
  125442. * Defines the actions happening when a pointer move event happens.
  125443. */
  125444. _pointerMoveStage: Stage<PointerMoveStageAction>;
  125445. /**
  125446. * @hidden
  125447. * Defines the actions happening when a pointer down event happens.
  125448. */
  125449. _pointerDownStage: Stage<PointerUpDownStageAction>;
  125450. /**
  125451. * @hidden
  125452. * Defines the actions happening when a pointer up event happens.
  125453. */
  125454. _pointerUpStage: Stage<PointerUpDownStageAction>;
  125455. /**
  125456. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  125457. */
  125458. private geometriesByUniqueId;
  125459. /**
  125460. * Creates a new Scene
  125461. * @param engine defines the engine to use to render this scene
  125462. * @param options defines the scene options
  125463. */
  125464. constructor(engine: Engine, options?: SceneOptions);
  125465. /**
  125466. * Gets a string identifying the name of the class
  125467. * @returns "Scene" string
  125468. */
  125469. getClassName(): string;
  125470. private _defaultMeshCandidates;
  125471. /**
  125472. * @hidden
  125473. */
  125474. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  125475. private _defaultSubMeshCandidates;
  125476. /**
  125477. * @hidden
  125478. */
  125479. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  125480. /**
  125481. * Sets the default candidate providers for the scene.
  125482. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  125483. * and getCollidingSubMeshCandidates to their default function
  125484. */
  125485. setDefaultCandidateProviders(): void;
  125486. /**
  125487. * Gets the mesh that is currently under the pointer
  125488. */
  125489. get meshUnderPointer(): Nullable<AbstractMesh>;
  125490. /**
  125491. * Gets or sets the current on-screen X position of the pointer
  125492. */
  125493. get pointerX(): number;
  125494. set pointerX(value: number);
  125495. /**
  125496. * Gets or sets the current on-screen Y position of the pointer
  125497. */
  125498. get pointerY(): number;
  125499. set pointerY(value: number);
  125500. /**
  125501. * Gets the cached material (ie. the latest rendered one)
  125502. * @returns the cached material
  125503. */
  125504. getCachedMaterial(): Nullable<Material>;
  125505. /**
  125506. * Gets the cached effect (ie. the latest rendered one)
  125507. * @returns the cached effect
  125508. */
  125509. getCachedEffect(): Nullable<Effect>;
  125510. /**
  125511. * Gets the cached visibility state (ie. the latest rendered one)
  125512. * @returns the cached visibility state
  125513. */
  125514. getCachedVisibility(): Nullable<number>;
  125515. /**
  125516. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  125517. * @param material defines the current material
  125518. * @param effect defines the current effect
  125519. * @param visibility defines the current visibility state
  125520. * @returns true if one parameter is not cached
  125521. */
  125522. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  125523. /**
  125524. * Gets the engine associated with the scene
  125525. * @returns an Engine
  125526. */
  125527. getEngine(): Engine;
  125528. /**
  125529. * Gets the total number of vertices rendered per frame
  125530. * @returns the total number of vertices rendered per frame
  125531. */
  125532. getTotalVertices(): number;
  125533. /**
  125534. * Gets the performance counter for total vertices
  125535. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125536. */
  125537. get totalVerticesPerfCounter(): PerfCounter;
  125538. /**
  125539. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  125540. * @returns the total number of active indices rendered per frame
  125541. */
  125542. getActiveIndices(): number;
  125543. /**
  125544. * Gets the performance counter for active indices
  125545. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125546. */
  125547. get totalActiveIndicesPerfCounter(): PerfCounter;
  125548. /**
  125549. * Gets the total number of active particles rendered per frame
  125550. * @returns the total number of active particles rendered per frame
  125551. */
  125552. getActiveParticles(): number;
  125553. /**
  125554. * Gets the performance counter for active particles
  125555. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125556. */
  125557. get activeParticlesPerfCounter(): PerfCounter;
  125558. /**
  125559. * Gets the total number of active bones rendered per frame
  125560. * @returns the total number of active bones rendered per frame
  125561. */
  125562. getActiveBones(): number;
  125563. /**
  125564. * Gets the performance counter for active bones
  125565. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125566. */
  125567. get activeBonesPerfCounter(): PerfCounter;
  125568. /**
  125569. * Gets the array of active meshes
  125570. * @returns an array of AbstractMesh
  125571. */
  125572. getActiveMeshes(): SmartArray<AbstractMesh>;
  125573. /**
  125574. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  125575. * @returns a number
  125576. */
  125577. getAnimationRatio(): number;
  125578. /**
  125579. * Gets an unique Id for the current render phase
  125580. * @returns a number
  125581. */
  125582. getRenderId(): number;
  125583. /**
  125584. * Gets an unique Id for the current frame
  125585. * @returns a number
  125586. */
  125587. getFrameId(): number;
  125588. /** Call this function if you want to manually increment the render Id*/
  125589. incrementRenderId(): void;
  125590. private _createUbo;
  125591. /**
  125592. * Use this method to simulate a pointer move on a mesh
  125593. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125594. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125595. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125596. * @returns the current scene
  125597. */
  125598. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125599. /**
  125600. * Use this method to simulate a pointer down on a mesh
  125601. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125602. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125603. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125604. * @returns the current scene
  125605. */
  125606. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125607. /**
  125608. * Use this method to simulate a pointer up on a mesh
  125609. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125610. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125611. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125612. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  125613. * @returns the current scene
  125614. */
  125615. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  125616. /**
  125617. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  125618. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  125619. * @returns true if the pointer was captured
  125620. */
  125621. isPointerCaptured(pointerId?: number): boolean;
  125622. /**
  125623. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  125624. * @param attachUp defines if you want to attach events to pointerup
  125625. * @param attachDown defines if you want to attach events to pointerdown
  125626. * @param attachMove defines if you want to attach events to pointermove
  125627. */
  125628. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  125629. /** Detaches all event handlers*/
  125630. detachControl(): void;
  125631. /**
  125632. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  125633. * Delay loaded resources are not taking in account
  125634. * @return true if all required resources are ready
  125635. */
  125636. isReady(): boolean;
  125637. /** Resets all cached information relative to material (including effect and visibility) */
  125638. resetCachedMaterial(): void;
  125639. /**
  125640. * Registers a function to be called before every frame render
  125641. * @param func defines the function to register
  125642. */
  125643. registerBeforeRender(func: () => void): void;
  125644. /**
  125645. * Unregisters a function called before every frame render
  125646. * @param func defines the function to unregister
  125647. */
  125648. unregisterBeforeRender(func: () => void): void;
  125649. /**
  125650. * Registers a function to be called after every frame render
  125651. * @param func defines the function to register
  125652. */
  125653. registerAfterRender(func: () => void): void;
  125654. /**
  125655. * Unregisters a function called after every frame render
  125656. * @param func defines the function to unregister
  125657. */
  125658. unregisterAfterRender(func: () => void): void;
  125659. private _executeOnceBeforeRender;
  125660. /**
  125661. * The provided function will run before render once and will be disposed afterwards.
  125662. * A timeout delay can be provided so that the function will be executed in N ms.
  125663. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  125664. * @param func The function to be executed.
  125665. * @param timeout optional delay in ms
  125666. */
  125667. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  125668. /** @hidden */
  125669. _addPendingData(data: any): void;
  125670. /** @hidden */
  125671. _removePendingData(data: any): void;
  125672. /**
  125673. * Returns the number of items waiting to be loaded
  125674. * @returns the number of items waiting to be loaded
  125675. */
  125676. getWaitingItemsCount(): number;
  125677. /**
  125678. * Returns a boolean indicating if the scene is still loading data
  125679. */
  125680. get isLoading(): boolean;
  125681. /**
  125682. * Registers a function to be executed when the scene is ready
  125683. * @param {Function} func - the function to be executed
  125684. */
  125685. executeWhenReady(func: () => void): void;
  125686. /**
  125687. * Returns a promise that resolves when the scene is ready
  125688. * @returns A promise that resolves when the scene is ready
  125689. */
  125690. whenReadyAsync(): Promise<void>;
  125691. /** @hidden */
  125692. _checkIsReady(): void;
  125693. /**
  125694. * Gets all animatable attached to the scene
  125695. */
  125696. get animatables(): Animatable[];
  125697. /**
  125698. * Resets the last animation time frame.
  125699. * Useful to override when animations start running when loading a scene for the first time.
  125700. */
  125701. resetLastAnimationTimeFrame(): void;
  125702. /**
  125703. * Gets the current view matrix
  125704. * @returns a Matrix
  125705. */
  125706. getViewMatrix(): Matrix;
  125707. /**
  125708. * Gets the current projection matrix
  125709. * @returns a Matrix
  125710. */
  125711. getProjectionMatrix(): Matrix;
  125712. /**
  125713. * Gets the current transform matrix
  125714. * @returns a Matrix made of View * Projection
  125715. */
  125716. getTransformMatrix(): Matrix;
  125717. /**
  125718. * Sets the current transform matrix
  125719. * @param viewL defines the View matrix to use
  125720. * @param projectionL defines the Projection matrix to use
  125721. * @param viewR defines the right View matrix to use (if provided)
  125722. * @param projectionR defines the right Projection matrix to use (if provided)
  125723. */
  125724. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  125725. /**
  125726. * Gets the uniform buffer used to store scene data
  125727. * @returns a UniformBuffer
  125728. */
  125729. getSceneUniformBuffer(): UniformBuffer;
  125730. /**
  125731. * Gets an unique (relatively to the current scene) Id
  125732. * @returns an unique number for the scene
  125733. */
  125734. getUniqueId(): number;
  125735. /**
  125736. * Add a mesh to the list of scene's meshes
  125737. * @param newMesh defines the mesh to add
  125738. * @param recursive if all child meshes should also be added to the scene
  125739. */
  125740. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  125741. /**
  125742. * Remove a mesh for the list of scene's meshes
  125743. * @param toRemove defines the mesh to remove
  125744. * @param recursive if all child meshes should also be removed from the scene
  125745. * @returns the index where the mesh was in the mesh list
  125746. */
  125747. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  125748. /**
  125749. * Add a transform node to the list of scene's transform nodes
  125750. * @param newTransformNode defines the transform node to add
  125751. */
  125752. addTransformNode(newTransformNode: TransformNode): void;
  125753. /**
  125754. * Remove a transform node for the list of scene's transform nodes
  125755. * @param toRemove defines the transform node to remove
  125756. * @returns the index where the transform node was in the transform node list
  125757. */
  125758. removeTransformNode(toRemove: TransformNode): number;
  125759. /**
  125760. * Remove a skeleton for the list of scene's skeletons
  125761. * @param toRemove defines the skeleton to remove
  125762. * @returns the index where the skeleton was in the skeleton list
  125763. */
  125764. removeSkeleton(toRemove: Skeleton): number;
  125765. /**
  125766. * Remove a morph target for the list of scene's morph targets
  125767. * @param toRemove defines the morph target to remove
  125768. * @returns the index where the morph target was in the morph target list
  125769. */
  125770. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  125771. /**
  125772. * Remove a light for the list of scene's lights
  125773. * @param toRemove defines the light to remove
  125774. * @returns the index where the light was in the light list
  125775. */
  125776. removeLight(toRemove: Light): number;
  125777. /**
  125778. * Remove a camera for the list of scene's cameras
  125779. * @param toRemove defines the camera to remove
  125780. * @returns the index where the camera was in the camera list
  125781. */
  125782. removeCamera(toRemove: Camera): number;
  125783. /**
  125784. * Remove a particle system for the list of scene's particle systems
  125785. * @param toRemove defines the particle system to remove
  125786. * @returns the index where the particle system was in the particle system list
  125787. */
  125788. removeParticleSystem(toRemove: IParticleSystem): number;
  125789. /**
  125790. * Remove a animation for the list of scene's animations
  125791. * @param toRemove defines the animation to remove
  125792. * @returns the index where the animation was in the animation list
  125793. */
  125794. removeAnimation(toRemove: Animation): number;
  125795. /**
  125796. * Will stop the animation of the given target
  125797. * @param target - the target
  125798. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  125799. * @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)
  125800. */
  125801. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  125802. /**
  125803. * Removes the given animation group from this scene.
  125804. * @param toRemove The animation group to remove
  125805. * @returns The index of the removed animation group
  125806. */
  125807. removeAnimationGroup(toRemove: AnimationGroup): number;
  125808. /**
  125809. * Removes the given multi-material from this scene.
  125810. * @param toRemove The multi-material to remove
  125811. * @returns The index of the removed multi-material
  125812. */
  125813. removeMultiMaterial(toRemove: MultiMaterial): number;
  125814. /**
  125815. * Removes the given material from this scene.
  125816. * @param toRemove The material to remove
  125817. * @returns The index of the removed material
  125818. */
  125819. removeMaterial(toRemove: Material): number;
  125820. /**
  125821. * Removes the given action manager from this scene.
  125822. * @param toRemove The action manager to remove
  125823. * @returns The index of the removed action manager
  125824. */
  125825. removeActionManager(toRemove: AbstractActionManager): number;
  125826. /**
  125827. * Removes the given texture from this scene.
  125828. * @param toRemove The texture to remove
  125829. * @returns The index of the removed texture
  125830. */
  125831. removeTexture(toRemove: BaseTexture): number;
  125832. /**
  125833. * Adds the given light to this scene
  125834. * @param newLight The light to add
  125835. */
  125836. addLight(newLight: Light): void;
  125837. /**
  125838. * Sorts the list list based on light priorities
  125839. */
  125840. sortLightsByPriority(): void;
  125841. /**
  125842. * Adds the given camera to this scene
  125843. * @param newCamera The camera to add
  125844. */
  125845. addCamera(newCamera: Camera): void;
  125846. /**
  125847. * Adds the given skeleton to this scene
  125848. * @param newSkeleton The skeleton to add
  125849. */
  125850. addSkeleton(newSkeleton: Skeleton): void;
  125851. /**
  125852. * Adds the given particle system to this scene
  125853. * @param newParticleSystem The particle system to add
  125854. */
  125855. addParticleSystem(newParticleSystem: IParticleSystem): void;
  125856. /**
  125857. * Adds the given animation to this scene
  125858. * @param newAnimation The animation to add
  125859. */
  125860. addAnimation(newAnimation: Animation): void;
  125861. /**
  125862. * Adds the given animation group to this scene.
  125863. * @param newAnimationGroup The animation group to add
  125864. */
  125865. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  125866. /**
  125867. * Adds the given multi-material to this scene
  125868. * @param newMultiMaterial The multi-material to add
  125869. */
  125870. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  125871. /**
  125872. * Adds the given material to this scene
  125873. * @param newMaterial The material to add
  125874. */
  125875. addMaterial(newMaterial: Material): void;
  125876. /**
  125877. * Adds the given morph target to this scene
  125878. * @param newMorphTargetManager The morph target to add
  125879. */
  125880. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  125881. /**
  125882. * Adds the given geometry to this scene
  125883. * @param newGeometry The geometry to add
  125884. */
  125885. addGeometry(newGeometry: Geometry): void;
  125886. /**
  125887. * Adds the given action manager to this scene
  125888. * @param newActionManager The action manager to add
  125889. */
  125890. addActionManager(newActionManager: AbstractActionManager): void;
  125891. /**
  125892. * Adds the given texture to this scene.
  125893. * @param newTexture The texture to add
  125894. */
  125895. addTexture(newTexture: BaseTexture): void;
  125896. /**
  125897. * Switch active camera
  125898. * @param newCamera defines the new active camera
  125899. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  125900. */
  125901. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  125902. /**
  125903. * sets the active camera of the scene using its ID
  125904. * @param id defines the camera's ID
  125905. * @return the new active camera or null if none found.
  125906. */
  125907. setActiveCameraByID(id: string): Nullable<Camera>;
  125908. /**
  125909. * sets the active camera of the scene using its name
  125910. * @param name defines the camera's name
  125911. * @returns the new active camera or null if none found.
  125912. */
  125913. setActiveCameraByName(name: string): Nullable<Camera>;
  125914. /**
  125915. * get an animation group using its name
  125916. * @param name defines the material's name
  125917. * @return the animation group or null if none found.
  125918. */
  125919. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  125920. /**
  125921. * Get a material using its unique id
  125922. * @param uniqueId defines the material's unique id
  125923. * @return the material or null if none found.
  125924. */
  125925. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  125926. /**
  125927. * get a material using its id
  125928. * @param id defines the material's ID
  125929. * @return the material or null if none found.
  125930. */
  125931. getMaterialByID(id: string): Nullable<Material>;
  125932. /**
  125933. * Gets a the last added material using a given id
  125934. * @param id defines the material's ID
  125935. * @return the last material with the given id or null if none found.
  125936. */
  125937. getLastMaterialByID(id: string): Nullable<Material>;
  125938. /**
  125939. * Gets a material using its name
  125940. * @param name defines the material's name
  125941. * @return the material or null if none found.
  125942. */
  125943. getMaterialByName(name: string): Nullable<Material>;
  125944. /**
  125945. * Get a texture using its unique id
  125946. * @param uniqueId defines the texture's unique id
  125947. * @return the texture or null if none found.
  125948. */
  125949. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  125950. /**
  125951. * Gets a camera using its id
  125952. * @param id defines the id to look for
  125953. * @returns the camera or null if not found
  125954. */
  125955. getCameraByID(id: string): Nullable<Camera>;
  125956. /**
  125957. * Gets a camera using its unique id
  125958. * @param uniqueId defines the unique id to look for
  125959. * @returns the camera or null if not found
  125960. */
  125961. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  125962. /**
  125963. * Gets a camera using its name
  125964. * @param name defines the camera's name
  125965. * @return the camera or null if none found.
  125966. */
  125967. getCameraByName(name: string): Nullable<Camera>;
  125968. /**
  125969. * Gets a bone using its id
  125970. * @param id defines the bone's id
  125971. * @return the bone or null if not found
  125972. */
  125973. getBoneByID(id: string): Nullable<Bone>;
  125974. /**
  125975. * Gets a bone using its id
  125976. * @param name defines the bone's name
  125977. * @return the bone or null if not found
  125978. */
  125979. getBoneByName(name: string): Nullable<Bone>;
  125980. /**
  125981. * Gets a light node using its name
  125982. * @param name defines the the light's name
  125983. * @return the light or null if none found.
  125984. */
  125985. getLightByName(name: string): Nullable<Light>;
  125986. /**
  125987. * Gets a light node using its id
  125988. * @param id defines the light's id
  125989. * @return the light or null if none found.
  125990. */
  125991. getLightByID(id: string): Nullable<Light>;
  125992. /**
  125993. * Gets a light node using its scene-generated unique ID
  125994. * @param uniqueId defines the light's unique id
  125995. * @return the light or null if none found.
  125996. */
  125997. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  125998. /**
  125999. * Gets a particle system by id
  126000. * @param id defines the particle system id
  126001. * @return the corresponding system or null if none found
  126002. */
  126003. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  126004. /**
  126005. * Gets a geometry using its ID
  126006. * @param id defines the geometry's id
  126007. * @return the geometry or null if none found.
  126008. */
  126009. getGeometryByID(id: string): Nullable<Geometry>;
  126010. private _getGeometryByUniqueID;
  126011. /**
  126012. * Add a new geometry to this scene
  126013. * @param geometry defines the geometry to be added to the scene.
  126014. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  126015. * @return a boolean defining if the geometry was added or not
  126016. */
  126017. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  126018. /**
  126019. * Removes an existing geometry
  126020. * @param geometry defines the geometry to be removed from the scene
  126021. * @return a boolean defining if the geometry was removed or not
  126022. */
  126023. removeGeometry(geometry: Geometry): boolean;
  126024. /**
  126025. * Gets the list of geometries attached to the scene
  126026. * @returns an array of Geometry
  126027. */
  126028. getGeometries(): Geometry[];
  126029. /**
  126030. * Gets the first added mesh found of a given ID
  126031. * @param id defines the id to search for
  126032. * @return the mesh found or null if not found at all
  126033. */
  126034. getMeshByID(id: string): Nullable<AbstractMesh>;
  126035. /**
  126036. * Gets a list of meshes using their id
  126037. * @param id defines the id to search for
  126038. * @returns a list of meshes
  126039. */
  126040. getMeshesByID(id: string): Array<AbstractMesh>;
  126041. /**
  126042. * Gets the first added transform node found of a given ID
  126043. * @param id defines the id to search for
  126044. * @return the found transform node or null if not found at all.
  126045. */
  126046. getTransformNodeByID(id: string): Nullable<TransformNode>;
  126047. /**
  126048. * Gets a transform node with its auto-generated unique id
  126049. * @param uniqueId efines the unique id to search for
  126050. * @return the found transform node or null if not found at all.
  126051. */
  126052. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  126053. /**
  126054. * Gets a list of transform nodes using their id
  126055. * @param id defines the id to search for
  126056. * @returns a list of transform nodes
  126057. */
  126058. getTransformNodesByID(id: string): Array<TransformNode>;
  126059. /**
  126060. * Gets a mesh with its auto-generated unique id
  126061. * @param uniqueId defines the unique id to search for
  126062. * @return the found mesh or null if not found at all.
  126063. */
  126064. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  126065. /**
  126066. * Gets a the last added mesh using a given id
  126067. * @param id defines the id to search for
  126068. * @return the found mesh or null if not found at all.
  126069. */
  126070. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  126071. /**
  126072. * Gets a the last added node (Mesh, Camera, Light) using a given id
  126073. * @param id defines the id to search for
  126074. * @return the found node or null if not found at all
  126075. */
  126076. getLastEntryByID(id: string): Nullable<Node>;
  126077. /**
  126078. * Gets a node (Mesh, Camera, Light) using a given id
  126079. * @param id defines the id to search for
  126080. * @return the found node or null if not found at all
  126081. */
  126082. getNodeByID(id: string): Nullable<Node>;
  126083. /**
  126084. * Gets a node (Mesh, Camera, Light) using a given name
  126085. * @param name defines the name to search for
  126086. * @return the found node or null if not found at all.
  126087. */
  126088. getNodeByName(name: string): Nullable<Node>;
  126089. /**
  126090. * Gets a mesh using a given name
  126091. * @param name defines the name to search for
  126092. * @return the found mesh or null if not found at all.
  126093. */
  126094. getMeshByName(name: string): Nullable<AbstractMesh>;
  126095. /**
  126096. * Gets a transform node using a given name
  126097. * @param name defines the name to search for
  126098. * @return the found transform node or null if not found at all.
  126099. */
  126100. getTransformNodeByName(name: string): Nullable<TransformNode>;
  126101. /**
  126102. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  126103. * @param id defines the id to search for
  126104. * @return the found skeleton or null if not found at all.
  126105. */
  126106. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  126107. /**
  126108. * Gets a skeleton using a given auto generated unique id
  126109. * @param uniqueId defines the unique id to search for
  126110. * @return the found skeleton or null if not found at all.
  126111. */
  126112. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  126113. /**
  126114. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  126115. * @param id defines the id to search for
  126116. * @return the found skeleton or null if not found at all.
  126117. */
  126118. getSkeletonById(id: string): Nullable<Skeleton>;
  126119. /**
  126120. * Gets a skeleton using a given name
  126121. * @param name defines the name to search for
  126122. * @return the found skeleton or null if not found at all.
  126123. */
  126124. getSkeletonByName(name: string): Nullable<Skeleton>;
  126125. /**
  126126. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  126127. * @param id defines the id to search for
  126128. * @return the found morph target manager or null if not found at all.
  126129. */
  126130. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  126131. /**
  126132. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  126133. * @param id defines the id to search for
  126134. * @return the found morph target or null if not found at all.
  126135. */
  126136. getMorphTargetById(id: string): Nullable<MorphTarget>;
  126137. /**
  126138. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  126139. * @param name defines the name to search for
  126140. * @return the found morph target or null if not found at all.
  126141. */
  126142. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  126143. /**
  126144. * Gets a post process using a given name (if many are found, this function will pick the first one)
  126145. * @param name defines the name to search for
  126146. * @return the found post process or null if not found at all.
  126147. */
  126148. getPostProcessByName(name: string): Nullable<PostProcess>;
  126149. /**
  126150. * Gets a boolean indicating if the given mesh is active
  126151. * @param mesh defines the mesh to look for
  126152. * @returns true if the mesh is in the active list
  126153. */
  126154. isActiveMesh(mesh: AbstractMesh): boolean;
  126155. /**
  126156. * Return a unique id as a string which can serve as an identifier for the scene
  126157. */
  126158. get uid(): string;
  126159. /**
  126160. * Add an externaly attached data from its key.
  126161. * This method call will fail and return false, if such key already exists.
  126162. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  126163. * @param key the unique key that identifies the data
  126164. * @param data the data object to associate to the key for this Engine instance
  126165. * @return true if no such key were already present and the data was added successfully, false otherwise
  126166. */
  126167. addExternalData<T>(key: string, data: T): boolean;
  126168. /**
  126169. * Get an externaly attached data from its key
  126170. * @param key the unique key that identifies the data
  126171. * @return the associated data, if present (can be null), or undefined if not present
  126172. */
  126173. getExternalData<T>(key: string): Nullable<T>;
  126174. /**
  126175. * Get an externaly attached data from its key, create it using a factory if it's not already present
  126176. * @param key the unique key that identifies the data
  126177. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  126178. * @return the associated data, can be null if the factory returned null.
  126179. */
  126180. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  126181. /**
  126182. * Remove an externaly attached data from the Engine instance
  126183. * @param key the unique key that identifies the data
  126184. * @return true if the data was successfully removed, false if it doesn't exist
  126185. */
  126186. removeExternalData(key: string): boolean;
  126187. private _evaluateSubMesh;
  126188. /**
  126189. * Clear the processed materials smart array preventing retention point in material dispose.
  126190. */
  126191. freeProcessedMaterials(): void;
  126192. private _preventFreeActiveMeshesAndRenderingGroups;
  126193. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  126194. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  126195. * when disposing several meshes in a row or a hierarchy of meshes.
  126196. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  126197. */
  126198. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  126199. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  126200. /**
  126201. * Clear the active meshes smart array preventing retention point in mesh dispose.
  126202. */
  126203. freeActiveMeshes(): void;
  126204. /**
  126205. * Clear the info related to rendering groups preventing retention points during dispose.
  126206. */
  126207. freeRenderingGroups(): void;
  126208. /** @hidden */
  126209. _isInIntermediateRendering(): boolean;
  126210. /**
  126211. * Lambda returning the list of potentially active meshes.
  126212. */
  126213. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  126214. /**
  126215. * Lambda returning the list of potentially active sub meshes.
  126216. */
  126217. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  126218. /**
  126219. * Lambda returning the list of potentially intersecting sub meshes.
  126220. */
  126221. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  126222. /**
  126223. * Lambda returning the list of potentially colliding sub meshes.
  126224. */
  126225. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  126226. /** @hidden */
  126227. _activeMeshesFrozen: boolean;
  126228. private _skipEvaluateActiveMeshesCompletely;
  126229. /**
  126230. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  126231. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  126232. * @param onSuccess optional success callback
  126233. * @param onError optional error callback
  126234. * @returns the current scene
  126235. */
  126236. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  126237. /**
  126238. * Use this function to restart evaluating active meshes on every frame
  126239. * @returns the current scene
  126240. */
  126241. unfreezeActiveMeshes(): Scene;
  126242. private _evaluateActiveMeshes;
  126243. private _activeMesh;
  126244. /**
  126245. * Update the transform matrix to update from the current active camera
  126246. * @param force defines a boolean used to force the update even if cache is up to date
  126247. */
  126248. updateTransformMatrix(force?: boolean): void;
  126249. private _bindFrameBuffer;
  126250. /** @hidden */
  126251. _allowPostProcessClearColor: boolean;
  126252. /** @hidden */
  126253. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  126254. private _processSubCameras;
  126255. private _checkIntersections;
  126256. /** @hidden */
  126257. _advancePhysicsEngineStep(step: number): void;
  126258. /**
  126259. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  126260. */
  126261. getDeterministicFrameTime: () => number;
  126262. /** @hidden */
  126263. _animate(): void;
  126264. /** Execute all animations (for a frame) */
  126265. animate(): void;
  126266. /**
  126267. * Render the scene
  126268. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  126269. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  126270. */
  126271. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  126272. /**
  126273. * Freeze all materials
  126274. * A frozen material will not be updatable but should be faster to render
  126275. */
  126276. freezeMaterials(): void;
  126277. /**
  126278. * Unfreeze all materials
  126279. * A frozen material will not be updatable but should be faster to render
  126280. */
  126281. unfreezeMaterials(): void;
  126282. /**
  126283. * Releases all held ressources
  126284. */
  126285. dispose(): void;
  126286. /**
  126287. * Gets if the scene is already disposed
  126288. */
  126289. get isDisposed(): boolean;
  126290. /**
  126291. * Call this function to reduce memory footprint of the scene.
  126292. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  126293. */
  126294. clearCachedVertexData(): void;
  126295. /**
  126296. * This function will remove the local cached buffer data from texture.
  126297. * It will save memory but will prevent the texture from being rebuilt
  126298. */
  126299. cleanCachedTextureBuffer(): void;
  126300. /**
  126301. * Get the world extend vectors with an optional filter
  126302. *
  126303. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  126304. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  126305. */
  126306. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  126307. min: Vector3;
  126308. max: Vector3;
  126309. };
  126310. /**
  126311. * Creates a ray that can be used to pick in the scene
  126312. * @param x defines the x coordinate of the origin (on-screen)
  126313. * @param y defines the y coordinate of the origin (on-screen)
  126314. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  126315. * @param camera defines the camera to use for the picking
  126316. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  126317. * @returns a Ray
  126318. */
  126319. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  126320. /**
  126321. * Creates a ray that can be used to pick in the scene
  126322. * @param x defines the x coordinate of the origin (on-screen)
  126323. * @param y defines the y coordinate of the origin (on-screen)
  126324. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  126325. * @param result defines the ray where to store the picking ray
  126326. * @param camera defines the camera to use for the picking
  126327. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  126328. * @returns the current scene
  126329. */
  126330. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  126331. /**
  126332. * Creates a ray that can be used to pick in the scene
  126333. * @param x defines the x coordinate of the origin (on-screen)
  126334. * @param y defines the y coordinate of the origin (on-screen)
  126335. * @param camera defines the camera to use for the picking
  126336. * @returns a Ray
  126337. */
  126338. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  126339. /**
  126340. * Creates a ray that can be used to pick in the scene
  126341. * @param x defines the x coordinate of the origin (on-screen)
  126342. * @param y defines the y coordinate of the origin (on-screen)
  126343. * @param result defines the ray where to store the picking ray
  126344. * @param camera defines the camera to use for the picking
  126345. * @returns the current scene
  126346. */
  126347. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  126348. /** Launch a ray to try to pick a mesh in the scene
  126349. * @param x position on screen
  126350. * @param y position on screen
  126351. * @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
  126352. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126353. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126354. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126355. * @returns a PickingInfo
  126356. */
  126357. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126358. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  126359. * @param x position on screen
  126360. * @param y position on screen
  126361. * @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
  126362. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126363. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126364. * @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)
  126365. */
  126366. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  126367. /** Use the given ray to pick a mesh in the scene
  126368. * @param ray The ray to use to pick meshes
  126369. * @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
  126370. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126371. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126372. * @returns a PickingInfo
  126373. */
  126374. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126375. /**
  126376. * Launch a ray to try to pick a mesh in the scene
  126377. * @param x X position on screen
  126378. * @param y Y position on screen
  126379. * @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
  126380. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126381. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126382. * @returns an array of PickingInfo
  126383. */
  126384. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126385. /**
  126386. * Launch a ray to try to pick a mesh in the scene
  126387. * @param ray Ray to use
  126388. * @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
  126389. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126390. * @returns an array of PickingInfo
  126391. */
  126392. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126393. /**
  126394. * Force the value of meshUnderPointer
  126395. * @param mesh defines the mesh to use
  126396. * @param pointerId optional pointer id when using more than one pointer
  126397. */
  126398. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  126399. /**
  126400. * Gets the mesh under the pointer
  126401. * @returns a Mesh or null if no mesh is under the pointer
  126402. */
  126403. getPointerOverMesh(): Nullable<AbstractMesh>;
  126404. /** @hidden */
  126405. _rebuildGeometries(): void;
  126406. /** @hidden */
  126407. _rebuildTextures(): void;
  126408. private _getByTags;
  126409. /**
  126410. * Get a list of meshes by tags
  126411. * @param tagsQuery defines the tags query to use
  126412. * @param forEach defines a predicate used to filter results
  126413. * @returns an array of Mesh
  126414. */
  126415. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  126416. /**
  126417. * Get a list of cameras by tags
  126418. * @param tagsQuery defines the tags query to use
  126419. * @param forEach defines a predicate used to filter results
  126420. * @returns an array of Camera
  126421. */
  126422. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  126423. /**
  126424. * Get a list of lights by tags
  126425. * @param tagsQuery defines the tags query to use
  126426. * @param forEach defines a predicate used to filter results
  126427. * @returns an array of Light
  126428. */
  126429. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  126430. /**
  126431. * Get a list of materials by tags
  126432. * @param tagsQuery defines the tags query to use
  126433. * @param forEach defines a predicate used to filter results
  126434. * @returns an array of Material
  126435. */
  126436. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  126437. /**
  126438. * Get a list of transform nodes by tags
  126439. * @param tagsQuery defines the tags query to use
  126440. * @param forEach defines a predicate used to filter results
  126441. * @returns an array of TransformNode
  126442. */
  126443. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  126444. /**
  126445. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  126446. * This allowed control for front to back rendering or reversly depending of the special needs.
  126447. *
  126448. * @param renderingGroupId The rendering group id corresponding to its index
  126449. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  126450. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  126451. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  126452. */
  126453. 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;
  126454. /**
  126455. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  126456. *
  126457. * @param renderingGroupId The rendering group id corresponding to its index
  126458. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126459. * @param depth Automatically clears depth between groups if true and autoClear is true.
  126460. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  126461. */
  126462. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  126463. /**
  126464. * Gets the current auto clear configuration for one rendering group of the rendering
  126465. * manager.
  126466. * @param index the rendering group index to get the information for
  126467. * @returns The auto clear setup for the requested rendering group
  126468. */
  126469. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  126470. private _blockMaterialDirtyMechanism;
  126471. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  126472. get blockMaterialDirtyMechanism(): boolean;
  126473. set blockMaterialDirtyMechanism(value: boolean);
  126474. /**
  126475. * Will flag all materials as dirty to trigger new shader compilation
  126476. * @param flag defines the flag used to specify which material part must be marked as dirty
  126477. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  126478. */
  126479. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  126480. /** @hidden */
  126481. _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;
  126482. /** @hidden */
  126483. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126484. /** @hidden */
  126485. _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;
  126486. /** @hidden */
  126487. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  126488. /** @hidden */
  126489. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  126490. /** @hidden */
  126491. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126492. }
  126493. }
  126494. declare module BABYLON {
  126495. /**
  126496. * Set of assets to keep when moving a scene into an asset container.
  126497. */
  126498. export class KeepAssets extends AbstractScene {
  126499. }
  126500. /**
  126501. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  126502. */
  126503. export class InstantiatedEntries {
  126504. /**
  126505. * List of new root nodes (eg. nodes with no parent)
  126506. */
  126507. rootNodes: TransformNode[];
  126508. /**
  126509. * List of new skeletons
  126510. */
  126511. skeletons: Skeleton[];
  126512. /**
  126513. * List of new animation groups
  126514. */
  126515. animationGroups: AnimationGroup[];
  126516. }
  126517. /**
  126518. * Container with a set of assets that can be added or removed from a scene.
  126519. */
  126520. export class AssetContainer extends AbstractScene {
  126521. private _wasAddedToScene;
  126522. /**
  126523. * The scene the AssetContainer belongs to.
  126524. */
  126525. scene: Scene;
  126526. /**
  126527. * Instantiates an AssetContainer.
  126528. * @param scene The scene the AssetContainer belongs to.
  126529. */
  126530. constructor(scene: Scene);
  126531. /**
  126532. * Instantiate or clone all meshes and add the new ones to the scene.
  126533. * Skeletons and animation groups will all be cloned
  126534. * @param nameFunction defines an optional function used to get new names for clones
  126535. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  126536. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  126537. */
  126538. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  126539. /**
  126540. * Adds all the assets from the container to the scene.
  126541. */
  126542. addAllToScene(): void;
  126543. /**
  126544. * Removes all the assets in the container from the scene
  126545. */
  126546. removeAllFromScene(): void;
  126547. /**
  126548. * Disposes all the assets in the container
  126549. */
  126550. dispose(): void;
  126551. private _moveAssets;
  126552. /**
  126553. * Removes all the assets contained in the scene and adds them to the container.
  126554. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126555. */
  126556. moveAllFromScene(keepAssets?: KeepAssets): void;
  126557. /**
  126558. * 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.
  126559. * @returns the root mesh
  126560. */
  126561. createRootMesh(): Mesh;
  126562. /**
  126563. * Merge animations (direct and animation groups) from this asset container into a scene
  126564. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126565. * @param animatables set of animatables to retarget to a node from the scene
  126566. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  126567. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  126568. */
  126569. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  126570. }
  126571. }
  126572. declare module BABYLON {
  126573. /**
  126574. * Defines how the parser contract is defined.
  126575. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  126576. */
  126577. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  126578. /**
  126579. * Defines how the individual parser contract is defined.
  126580. * These parser can parse an individual asset
  126581. */
  126582. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  126583. /**
  126584. * Base class of the scene acting as a container for the different elements composing a scene.
  126585. * This class is dynamically extended by the different components of the scene increasing
  126586. * flexibility and reducing coupling
  126587. */
  126588. export abstract class AbstractScene {
  126589. /**
  126590. * Stores the list of available parsers in the application.
  126591. */
  126592. private static _BabylonFileParsers;
  126593. /**
  126594. * Stores the list of available individual parsers in the application.
  126595. */
  126596. private static _IndividualBabylonFileParsers;
  126597. /**
  126598. * Adds a parser in the list of available ones
  126599. * @param name Defines the name of the parser
  126600. * @param parser Defines the parser to add
  126601. */
  126602. static AddParser(name: string, parser: BabylonFileParser): void;
  126603. /**
  126604. * Gets a general parser from the list of avaialble ones
  126605. * @param name Defines the name of the parser
  126606. * @returns the requested parser or null
  126607. */
  126608. static GetParser(name: string): Nullable<BabylonFileParser>;
  126609. /**
  126610. * Adds n individual parser in the list of available ones
  126611. * @param name Defines the name of the parser
  126612. * @param parser Defines the parser to add
  126613. */
  126614. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  126615. /**
  126616. * Gets an individual parser from the list of avaialble ones
  126617. * @param name Defines the name of the parser
  126618. * @returns the requested parser or null
  126619. */
  126620. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  126621. /**
  126622. * Parser json data and populate both a scene and its associated container object
  126623. * @param jsonData Defines the data to parse
  126624. * @param scene Defines the scene to parse the data for
  126625. * @param container Defines the container attached to the parsing sequence
  126626. * @param rootUrl Defines the root url of the data
  126627. */
  126628. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  126629. /**
  126630. * Gets the list of root nodes (ie. nodes with no parent)
  126631. */
  126632. rootNodes: Node[];
  126633. /** All of the cameras added to this scene
  126634. * @see https://doc.babylonjs.com/babylon101/cameras
  126635. */
  126636. cameras: Camera[];
  126637. /**
  126638. * All of the lights added to this scene
  126639. * @see https://doc.babylonjs.com/babylon101/lights
  126640. */
  126641. lights: Light[];
  126642. /**
  126643. * All of the (abstract) meshes added to this scene
  126644. */
  126645. meshes: AbstractMesh[];
  126646. /**
  126647. * The list of skeletons added to the scene
  126648. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  126649. */
  126650. skeletons: Skeleton[];
  126651. /**
  126652. * All of the particle systems added to this scene
  126653. * @see https://doc.babylonjs.com/babylon101/particles
  126654. */
  126655. particleSystems: IParticleSystem[];
  126656. /**
  126657. * Gets a list of Animations associated with the scene
  126658. */
  126659. animations: Animation[];
  126660. /**
  126661. * All of the animation groups added to this scene
  126662. * @see https://doc.babylonjs.com/how_to/group
  126663. */
  126664. animationGroups: AnimationGroup[];
  126665. /**
  126666. * All of the multi-materials added to this scene
  126667. * @see https://doc.babylonjs.com/how_to/multi_materials
  126668. */
  126669. multiMaterials: MultiMaterial[];
  126670. /**
  126671. * All of the materials added to this scene
  126672. * In the context of a Scene, it is not supposed to be modified manually.
  126673. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  126674. * Note also that the order of the Material within the array is not significant and might change.
  126675. * @see https://doc.babylonjs.com/babylon101/materials
  126676. */
  126677. materials: Material[];
  126678. /**
  126679. * The list of morph target managers added to the scene
  126680. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  126681. */
  126682. morphTargetManagers: MorphTargetManager[];
  126683. /**
  126684. * The list of geometries used in the scene.
  126685. */
  126686. geometries: Geometry[];
  126687. /**
  126688. * All of the tranform nodes added to this scene
  126689. * In the context of a Scene, it is not supposed to be modified manually.
  126690. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  126691. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  126692. * @see https://doc.babylonjs.com/how_to/transformnode
  126693. */
  126694. transformNodes: TransformNode[];
  126695. /**
  126696. * ActionManagers available on the scene.
  126697. */
  126698. actionManagers: AbstractActionManager[];
  126699. /**
  126700. * Textures to keep.
  126701. */
  126702. textures: BaseTexture[];
  126703. /** @hidden */
  126704. protected _environmentTexture: Nullable<BaseTexture>;
  126705. /**
  126706. * Texture used in all pbr material as the reflection texture.
  126707. * As in the majority of the scene they are the same (exception for multi room and so on),
  126708. * this is easier to reference from here than from all the materials.
  126709. */
  126710. get environmentTexture(): Nullable<BaseTexture>;
  126711. set environmentTexture(value: Nullable<BaseTexture>);
  126712. /**
  126713. * The list of postprocesses added to the scene
  126714. */
  126715. postProcesses: PostProcess[];
  126716. /**
  126717. * @returns all meshes, lights, cameras, transformNodes and bones
  126718. */
  126719. getNodes(): Array<Node>;
  126720. }
  126721. }
  126722. declare module BABYLON {
  126723. /**
  126724. * Interface used to define options for Sound class
  126725. */
  126726. export interface ISoundOptions {
  126727. /**
  126728. * Does the sound autoplay once loaded.
  126729. */
  126730. autoplay?: boolean;
  126731. /**
  126732. * Does the sound loop after it finishes playing once.
  126733. */
  126734. loop?: boolean;
  126735. /**
  126736. * Sound's volume
  126737. */
  126738. volume?: number;
  126739. /**
  126740. * Is it a spatial sound?
  126741. */
  126742. spatialSound?: boolean;
  126743. /**
  126744. * Maximum distance to hear that sound
  126745. */
  126746. maxDistance?: number;
  126747. /**
  126748. * Uses user defined attenuation function
  126749. */
  126750. useCustomAttenuation?: boolean;
  126751. /**
  126752. * Define the roll off factor of spatial sounds.
  126753. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126754. */
  126755. rolloffFactor?: number;
  126756. /**
  126757. * Define the reference distance the sound should be heard perfectly.
  126758. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126759. */
  126760. refDistance?: number;
  126761. /**
  126762. * Define the distance attenuation model the sound will follow.
  126763. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126764. */
  126765. distanceModel?: string;
  126766. /**
  126767. * Defines the playback speed (1 by default)
  126768. */
  126769. playbackRate?: number;
  126770. /**
  126771. * Defines if the sound is from a streaming source
  126772. */
  126773. streaming?: boolean;
  126774. /**
  126775. * Defines an optional length (in seconds) inside the sound file
  126776. */
  126777. length?: number;
  126778. /**
  126779. * Defines an optional offset (in seconds) inside the sound file
  126780. */
  126781. offset?: number;
  126782. /**
  126783. * If true, URLs will not be required to state the audio file codec to use.
  126784. */
  126785. skipCodecCheck?: boolean;
  126786. }
  126787. }
  126788. declare module BABYLON {
  126789. /**
  126790. * Defines a sound that can be played in the application.
  126791. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  126792. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126793. */
  126794. export class Sound {
  126795. /**
  126796. * The name of the sound in the scene.
  126797. */
  126798. name: string;
  126799. /**
  126800. * Does the sound autoplay once loaded.
  126801. */
  126802. autoplay: boolean;
  126803. /**
  126804. * Does the sound loop after it finishes playing once.
  126805. */
  126806. loop: boolean;
  126807. /**
  126808. * Does the sound use a custom attenuation curve to simulate the falloff
  126809. * happening when the source gets further away from the camera.
  126810. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126811. */
  126812. useCustomAttenuation: boolean;
  126813. /**
  126814. * The sound track id this sound belongs to.
  126815. */
  126816. soundTrackId: number;
  126817. /**
  126818. * Is this sound currently played.
  126819. */
  126820. isPlaying: boolean;
  126821. /**
  126822. * Is this sound currently paused.
  126823. */
  126824. isPaused: boolean;
  126825. /**
  126826. * Does this sound enables spatial sound.
  126827. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126828. */
  126829. spatialSound: boolean;
  126830. /**
  126831. * Define the reference distance the sound should be heard perfectly.
  126832. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126833. */
  126834. refDistance: number;
  126835. /**
  126836. * Define the roll off factor of spatial sounds.
  126837. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126838. */
  126839. rolloffFactor: number;
  126840. /**
  126841. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  126842. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126843. */
  126844. maxDistance: number;
  126845. /**
  126846. * Define the distance attenuation model the sound will follow.
  126847. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126848. */
  126849. distanceModel: string;
  126850. /**
  126851. * @hidden
  126852. * Back Compat
  126853. **/
  126854. onended: () => any;
  126855. /**
  126856. * Gets or sets an object used to store user defined information for the sound.
  126857. */
  126858. metadata: any;
  126859. /**
  126860. * Observable event when the current playing sound finishes.
  126861. */
  126862. onEndedObservable: Observable<Sound>;
  126863. /**
  126864. * Gets the current time for the sound.
  126865. */
  126866. get currentTime(): number;
  126867. private _panningModel;
  126868. private _playbackRate;
  126869. private _streaming;
  126870. private _startTime;
  126871. private _startOffset;
  126872. private _position;
  126873. /** @hidden */
  126874. _positionInEmitterSpace: boolean;
  126875. private _localDirection;
  126876. private _volume;
  126877. private _isReadyToPlay;
  126878. private _isDirectional;
  126879. private _readyToPlayCallback;
  126880. private _audioBuffer;
  126881. private _soundSource;
  126882. private _streamingSource;
  126883. private _soundPanner;
  126884. private _soundGain;
  126885. private _inputAudioNode;
  126886. private _outputAudioNode;
  126887. private _coneInnerAngle;
  126888. private _coneOuterAngle;
  126889. private _coneOuterGain;
  126890. private _scene;
  126891. private _connectedTransformNode;
  126892. private _customAttenuationFunction;
  126893. private _registerFunc;
  126894. private _isOutputConnected;
  126895. private _htmlAudioElement;
  126896. private _urlType;
  126897. private _length?;
  126898. private _offset?;
  126899. /** @hidden */
  126900. static _SceneComponentInitialization: (scene: Scene) => void;
  126901. /**
  126902. * Create a sound and attach it to a scene
  126903. * @param name Name of your sound
  126904. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  126905. * @param scene defines the scene the sound belongs to
  126906. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  126907. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  126908. */
  126909. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  126910. /**
  126911. * Release the sound and its associated resources
  126912. */
  126913. dispose(): void;
  126914. /**
  126915. * Gets if the sounds is ready to be played or not.
  126916. * @returns true if ready, otherwise false
  126917. */
  126918. isReady(): boolean;
  126919. private _soundLoaded;
  126920. /**
  126921. * Sets the data of the sound from an audiobuffer
  126922. * @param audioBuffer The audioBuffer containing the data
  126923. */
  126924. setAudioBuffer(audioBuffer: AudioBuffer): void;
  126925. /**
  126926. * Updates the current sounds options such as maxdistance, loop...
  126927. * @param options A JSON object containing values named as the object properties
  126928. */
  126929. updateOptions(options: ISoundOptions): void;
  126930. private _createSpatialParameters;
  126931. private _updateSpatialParameters;
  126932. /**
  126933. * Switch the panning model to HRTF:
  126934. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126935. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126936. */
  126937. switchPanningModelToHRTF(): void;
  126938. /**
  126939. * Switch the panning model to Equal Power:
  126940. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126941. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126942. */
  126943. switchPanningModelToEqualPower(): void;
  126944. private _switchPanningModel;
  126945. /**
  126946. * Connect this sound to a sound track audio node like gain...
  126947. * @param soundTrackAudioNode the sound track audio node to connect to
  126948. */
  126949. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  126950. /**
  126951. * Transform this sound into a directional source
  126952. * @param coneInnerAngle Size of the inner cone in degree
  126953. * @param coneOuterAngle Size of the outer cone in degree
  126954. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  126955. */
  126956. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  126957. /**
  126958. * Gets or sets the inner angle for the directional cone.
  126959. */
  126960. get directionalConeInnerAngle(): number;
  126961. /**
  126962. * Gets or sets the inner angle for the directional cone.
  126963. */
  126964. set directionalConeInnerAngle(value: number);
  126965. /**
  126966. * Gets or sets the outer angle for the directional cone.
  126967. */
  126968. get directionalConeOuterAngle(): number;
  126969. /**
  126970. * Gets or sets the outer angle for the directional cone.
  126971. */
  126972. set directionalConeOuterAngle(value: number);
  126973. /**
  126974. * Sets the position of the emitter if spatial sound is enabled
  126975. * @param newPosition Defines the new posisiton
  126976. */
  126977. setPosition(newPosition: Vector3): void;
  126978. /**
  126979. * Sets the local direction of the emitter if spatial sound is enabled
  126980. * @param newLocalDirection Defines the new local direction
  126981. */
  126982. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  126983. private _updateDirection;
  126984. /** @hidden */
  126985. updateDistanceFromListener(): void;
  126986. /**
  126987. * Sets a new custom attenuation function for the sound.
  126988. * @param callback Defines the function used for the attenuation
  126989. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126990. */
  126991. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  126992. /**
  126993. * Play the sound
  126994. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  126995. * @param offset (optional) Start the sound at a specific time in seconds
  126996. * @param length (optional) Sound duration (in seconds)
  126997. */
  126998. play(time?: number, offset?: number, length?: number): void;
  126999. private _onended;
  127000. /**
  127001. * Stop the sound
  127002. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  127003. */
  127004. stop(time?: number): void;
  127005. /**
  127006. * Put the sound in pause
  127007. */
  127008. pause(): void;
  127009. /**
  127010. * Sets a dedicated volume for this sounds
  127011. * @param newVolume Define the new volume of the sound
  127012. * @param time Define time for gradual change to new volume
  127013. */
  127014. setVolume(newVolume: number, time?: number): void;
  127015. /**
  127016. * Set the sound play back rate
  127017. * @param newPlaybackRate Define the playback rate the sound should be played at
  127018. */
  127019. setPlaybackRate(newPlaybackRate: number): void;
  127020. /**
  127021. * Gets the volume of the sound.
  127022. * @returns the volume of the sound
  127023. */
  127024. getVolume(): number;
  127025. /**
  127026. * Attach the sound to a dedicated mesh
  127027. * @param transformNode The transform node to connect the sound with
  127028. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  127029. */
  127030. attachToMesh(transformNode: TransformNode): void;
  127031. /**
  127032. * Detach the sound from the previously attached mesh
  127033. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  127034. */
  127035. detachFromMesh(): void;
  127036. private _onRegisterAfterWorldMatrixUpdate;
  127037. /**
  127038. * Clone the current sound in the scene.
  127039. * @returns the new sound clone
  127040. */
  127041. clone(): Nullable<Sound>;
  127042. /**
  127043. * Gets the current underlying audio buffer containing the data
  127044. * @returns the audio buffer
  127045. */
  127046. getAudioBuffer(): Nullable<AudioBuffer>;
  127047. /**
  127048. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  127049. * @returns the source node
  127050. */
  127051. getSoundSource(): Nullable<AudioBufferSourceNode>;
  127052. /**
  127053. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  127054. * @returns the gain node
  127055. */
  127056. getSoundGain(): Nullable<GainNode>;
  127057. /**
  127058. * Serializes the Sound in a JSON representation
  127059. * @returns the JSON representation of the sound
  127060. */
  127061. serialize(): any;
  127062. /**
  127063. * Parse a JSON representation of a sound to innstantiate in a given scene
  127064. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  127065. * @param scene Define the scene the new parsed sound should be created in
  127066. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  127067. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  127068. * @returns the newly parsed sound
  127069. */
  127070. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  127071. }
  127072. }
  127073. declare module BABYLON {
  127074. /**
  127075. * This defines an action helpful to play a defined sound on a triggered action.
  127076. */
  127077. export class PlaySoundAction extends Action {
  127078. private _sound;
  127079. /**
  127080. * Instantiate the action
  127081. * @param triggerOptions defines the trigger options
  127082. * @param sound defines the sound to play
  127083. * @param condition defines the trigger related conditions
  127084. */
  127085. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  127086. /** @hidden */
  127087. _prepare(): void;
  127088. /**
  127089. * Execute the action and play the sound.
  127090. */
  127091. execute(): void;
  127092. /**
  127093. * Serializes the actions and its related information.
  127094. * @param parent defines the object to serialize in
  127095. * @returns the serialized object
  127096. */
  127097. serialize(parent: any): any;
  127098. }
  127099. /**
  127100. * This defines an action helpful to stop a defined sound on a triggered action.
  127101. */
  127102. export class StopSoundAction extends Action {
  127103. private _sound;
  127104. /**
  127105. * Instantiate the action
  127106. * @param triggerOptions defines the trigger options
  127107. * @param sound defines the sound to stop
  127108. * @param condition defines the trigger related conditions
  127109. */
  127110. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  127111. /** @hidden */
  127112. _prepare(): void;
  127113. /**
  127114. * Execute the action and stop the sound.
  127115. */
  127116. execute(): void;
  127117. /**
  127118. * Serializes the actions and its related information.
  127119. * @param parent defines the object to serialize in
  127120. * @returns the serialized object
  127121. */
  127122. serialize(parent: any): any;
  127123. }
  127124. }
  127125. declare module BABYLON {
  127126. /**
  127127. * This defines an action responsible to change the value of a property
  127128. * by interpolating between its current value and the newly set one once triggered.
  127129. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  127130. */
  127131. export class InterpolateValueAction extends Action {
  127132. /**
  127133. * Defines the path of the property where the value should be interpolated
  127134. */
  127135. propertyPath: string;
  127136. /**
  127137. * Defines the target value at the end of the interpolation.
  127138. */
  127139. value: any;
  127140. /**
  127141. * Defines the time it will take for the property to interpolate to the value.
  127142. */
  127143. duration: number;
  127144. /**
  127145. * Defines if the other scene animations should be stopped when the action has been triggered
  127146. */
  127147. stopOtherAnimations?: boolean;
  127148. /**
  127149. * Defines a callback raised once the interpolation animation has been done.
  127150. */
  127151. onInterpolationDone?: () => void;
  127152. /**
  127153. * Observable triggered once the interpolation animation has been done.
  127154. */
  127155. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  127156. private _target;
  127157. private _effectiveTarget;
  127158. private _property;
  127159. /**
  127160. * Instantiate the action
  127161. * @param triggerOptions defines the trigger options
  127162. * @param target defines the object containing the value to interpolate
  127163. * @param propertyPath defines the path to the property in the target object
  127164. * @param value defines the target value at the end of the interpolation
  127165. * @param duration deines the time it will take for the property to interpolate to the value.
  127166. * @param condition defines the trigger related conditions
  127167. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  127168. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  127169. */
  127170. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  127171. /** @hidden */
  127172. _prepare(): void;
  127173. /**
  127174. * Execute the action starts the value interpolation.
  127175. */
  127176. execute(): void;
  127177. /**
  127178. * Serializes the actions and its related information.
  127179. * @param parent defines the object to serialize in
  127180. * @returns the serialized object
  127181. */
  127182. serialize(parent: any): any;
  127183. }
  127184. }
  127185. declare module BABYLON {
  127186. /**
  127187. * This represents the default audio engine used in babylon.
  127188. * It is responsible to play, synchronize and analyse sounds throughout the application.
  127189. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127190. */
  127191. export class AudioEngine implements IAudioEngine {
  127192. private _audioContext;
  127193. private _audioContextInitialized;
  127194. private _muteButton;
  127195. private _hostElement;
  127196. /**
  127197. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  127198. */
  127199. canUseWebAudio: boolean;
  127200. /**
  127201. * The master gain node defines the global audio volume of your audio engine.
  127202. */
  127203. masterGain: GainNode;
  127204. /**
  127205. * Defines if Babylon should emit a warning if WebAudio is not supported.
  127206. * @ignoreNaming
  127207. */
  127208. WarnedWebAudioUnsupported: boolean;
  127209. /**
  127210. * Gets whether or not mp3 are supported by your browser.
  127211. */
  127212. isMP3supported: boolean;
  127213. /**
  127214. * Gets whether or not ogg are supported by your browser.
  127215. */
  127216. isOGGsupported: boolean;
  127217. /**
  127218. * Gets whether audio has been unlocked on the device.
  127219. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  127220. * a user interaction has happened.
  127221. */
  127222. unlocked: boolean;
  127223. /**
  127224. * Defines if the audio engine relies on a custom unlocked button.
  127225. * In this case, the embedded button will not be displayed.
  127226. */
  127227. useCustomUnlockedButton: boolean;
  127228. /**
  127229. * Event raised when audio has been unlocked on the browser.
  127230. */
  127231. onAudioUnlockedObservable: Observable<IAudioEngine>;
  127232. /**
  127233. * Event raised when audio has been locked on the browser.
  127234. */
  127235. onAudioLockedObservable: Observable<IAudioEngine>;
  127236. /**
  127237. * Gets the current AudioContext if available.
  127238. */
  127239. get audioContext(): Nullable<AudioContext>;
  127240. private _connectedAnalyser;
  127241. /**
  127242. * Instantiates a new audio engine.
  127243. *
  127244. * There should be only one per page as some browsers restrict the number
  127245. * of audio contexts you can create.
  127246. * @param hostElement defines the host element where to display the mute icon if necessary
  127247. */
  127248. constructor(hostElement?: Nullable<HTMLElement>);
  127249. /**
  127250. * Flags the audio engine in Locked state.
  127251. * This happens due to new browser policies preventing audio to autoplay.
  127252. */
  127253. lock(): void;
  127254. /**
  127255. * Unlocks the audio engine once a user action has been done on the dom.
  127256. * This is helpful to resume play once browser policies have been satisfied.
  127257. */
  127258. unlock(): void;
  127259. private _resumeAudioContext;
  127260. private _initializeAudioContext;
  127261. private _tryToRun;
  127262. private _triggerRunningState;
  127263. private _triggerSuspendedState;
  127264. private _displayMuteButton;
  127265. private _moveButtonToTopLeft;
  127266. private _onResize;
  127267. private _hideMuteButton;
  127268. /**
  127269. * Destroy and release the resources associated with the audio ccontext.
  127270. */
  127271. dispose(): void;
  127272. /**
  127273. * Gets the global volume sets on the master gain.
  127274. * @returns the global volume if set or -1 otherwise
  127275. */
  127276. getGlobalVolume(): number;
  127277. /**
  127278. * Sets the global volume of your experience (sets on the master gain).
  127279. * @param newVolume Defines the new global volume of the application
  127280. */
  127281. setGlobalVolume(newVolume: number): void;
  127282. /**
  127283. * Connect the audio engine to an audio analyser allowing some amazing
  127284. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127285. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127286. * @param analyser The analyser to connect to the engine
  127287. */
  127288. connectToAnalyser(analyser: Analyser): void;
  127289. }
  127290. }
  127291. declare module BABYLON {
  127292. /**
  127293. * Options allowed during the creation of a sound track.
  127294. */
  127295. export interface ISoundTrackOptions {
  127296. /**
  127297. * The volume the sound track should take during creation
  127298. */
  127299. volume?: number;
  127300. /**
  127301. * Define if the sound track is the main sound track of the scene
  127302. */
  127303. mainTrack?: boolean;
  127304. }
  127305. /**
  127306. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  127307. * It will be also used in a future release to apply effects on a specific track.
  127308. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  127309. */
  127310. export class SoundTrack {
  127311. /**
  127312. * The unique identifier of the sound track in the scene.
  127313. */
  127314. id: number;
  127315. /**
  127316. * The list of sounds included in the sound track.
  127317. */
  127318. soundCollection: Array<Sound>;
  127319. private _outputAudioNode;
  127320. private _scene;
  127321. private _connectedAnalyser;
  127322. private _options;
  127323. private _isInitialized;
  127324. /**
  127325. * Creates a new sound track.
  127326. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  127327. * @param scene Define the scene the sound track belongs to
  127328. * @param options
  127329. */
  127330. constructor(scene: Scene, options?: ISoundTrackOptions);
  127331. private _initializeSoundTrackAudioGraph;
  127332. /**
  127333. * Release the sound track and its associated resources
  127334. */
  127335. dispose(): void;
  127336. /**
  127337. * Adds a sound to this sound track
  127338. * @param sound define the cound to add
  127339. * @ignoreNaming
  127340. */
  127341. addSound(sound: Sound): void;
  127342. /**
  127343. * Removes a sound to this sound track
  127344. * @param sound define the cound to remove
  127345. * @ignoreNaming
  127346. */
  127347. removeSound(sound: Sound): void;
  127348. /**
  127349. * Set a global volume for the full sound track.
  127350. * @param newVolume Define the new volume of the sound track
  127351. */
  127352. setVolume(newVolume: number): void;
  127353. /**
  127354. * Switch the panning model to HRTF:
  127355. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  127356. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127357. */
  127358. switchPanningModelToHRTF(): void;
  127359. /**
  127360. * Switch the panning model to Equal Power:
  127361. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  127362. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127363. */
  127364. switchPanningModelToEqualPower(): void;
  127365. /**
  127366. * Connect the sound track to an audio analyser allowing some amazing
  127367. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127368. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127369. * @param analyser The analyser to connect to the engine
  127370. */
  127371. connectToAnalyser(analyser: Analyser): void;
  127372. }
  127373. }
  127374. declare module BABYLON {
  127375. interface AbstractScene {
  127376. /**
  127377. * The list of sounds used in the scene.
  127378. */
  127379. sounds: Nullable<Array<Sound>>;
  127380. }
  127381. interface Scene {
  127382. /**
  127383. * @hidden
  127384. * Backing field
  127385. */
  127386. _mainSoundTrack: SoundTrack;
  127387. /**
  127388. * The main sound track played by the scene.
  127389. * It cotains your primary collection of sounds.
  127390. */
  127391. mainSoundTrack: SoundTrack;
  127392. /**
  127393. * The list of sound tracks added to the scene
  127394. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127395. */
  127396. soundTracks: Nullable<Array<SoundTrack>>;
  127397. /**
  127398. * Gets a sound using a given name
  127399. * @param name defines the name to search for
  127400. * @return the found sound or null if not found at all.
  127401. */
  127402. getSoundByName(name: string): Nullable<Sound>;
  127403. /**
  127404. * Gets or sets if audio support is enabled
  127405. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127406. */
  127407. audioEnabled: boolean;
  127408. /**
  127409. * Gets or sets if audio will be output to headphones
  127410. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127411. */
  127412. headphone: boolean;
  127413. /**
  127414. * Gets or sets custom audio listener position provider
  127415. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127416. */
  127417. audioListenerPositionProvider: Nullable<() => Vector3>;
  127418. /**
  127419. * Gets or sets a refresh rate when using 3D audio positioning
  127420. */
  127421. audioPositioningRefreshRate: number;
  127422. }
  127423. /**
  127424. * Defines the sound scene component responsible to manage any sounds
  127425. * in a given scene.
  127426. */
  127427. export class AudioSceneComponent implements ISceneSerializableComponent {
  127428. private static _CameraDirectionLH;
  127429. private static _CameraDirectionRH;
  127430. /**
  127431. * The component name helpfull to identify the component in the list of scene components.
  127432. */
  127433. readonly name: string;
  127434. /**
  127435. * The scene the component belongs to.
  127436. */
  127437. scene: Scene;
  127438. private _audioEnabled;
  127439. /**
  127440. * Gets whether audio is enabled or not.
  127441. * Please use related enable/disable method to switch state.
  127442. */
  127443. get audioEnabled(): boolean;
  127444. private _headphone;
  127445. /**
  127446. * Gets whether audio is outputing to headphone or not.
  127447. * Please use the according Switch methods to change output.
  127448. */
  127449. get headphone(): boolean;
  127450. /**
  127451. * Gets or sets a refresh rate when using 3D audio positioning
  127452. */
  127453. audioPositioningRefreshRate: number;
  127454. private _audioListenerPositionProvider;
  127455. /**
  127456. * Gets the current audio listener position provider
  127457. */
  127458. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  127459. /**
  127460. * Sets a custom listener position for all sounds in the scene
  127461. * By default, this is the position of the first active camera
  127462. */
  127463. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  127464. /**
  127465. * Creates a new instance of the component for the given scene
  127466. * @param scene Defines the scene to register the component in
  127467. */
  127468. constructor(scene: Scene);
  127469. /**
  127470. * Registers the component in a given scene
  127471. */
  127472. register(): void;
  127473. /**
  127474. * Rebuilds the elements related to this component in case of
  127475. * context lost for instance.
  127476. */
  127477. rebuild(): void;
  127478. /**
  127479. * Serializes the component data to the specified json object
  127480. * @param serializationObject The object to serialize to
  127481. */
  127482. serialize(serializationObject: any): void;
  127483. /**
  127484. * Adds all the elements from the container to the scene
  127485. * @param container the container holding the elements
  127486. */
  127487. addFromContainer(container: AbstractScene): void;
  127488. /**
  127489. * Removes all the elements in the container from the scene
  127490. * @param container contains the elements to remove
  127491. * @param dispose if the removed element should be disposed (default: false)
  127492. */
  127493. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127494. /**
  127495. * Disposes the component and the associated ressources.
  127496. */
  127497. dispose(): void;
  127498. /**
  127499. * Disables audio in the associated scene.
  127500. */
  127501. disableAudio(): void;
  127502. /**
  127503. * Enables audio in the associated scene.
  127504. */
  127505. enableAudio(): void;
  127506. /**
  127507. * Switch audio to headphone output.
  127508. */
  127509. switchAudioModeForHeadphones(): void;
  127510. /**
  127511. * Switch audio to normal speakers.
  127512. */
  127513. switchAudioModeForNormalSpeakers(): void;
  127514. private _cachedCameraDirection;
  127515. private _cachedCameraPosition;
  127516. private _lastCheck;
  127517. private _afterRender;
  127518. }
  127519. }
  127520. declare module BABYLON {
  127521. /**
  127522. * Wraps one or more Sound objects and selects one with random weight for playback.
  127523. */
  127524. export class WeightedSound {
  127525. /** When true a Sound will be selected and played when the current playing Sound completes. */
  127526. loop: boolean;
  127527. private _coneInnerAngle;
  127528. private _coneOuterAngle;
  127529. private _volume;
  127530. /** A Sound is currently playing. */
  127531. isPlaying: boolean;
  127532. /** A Sound is currently paused. */
  127533. isPaused: boolean;
  127534. private _sounds;
  127535. private _weights;
  127536. private _currentIndex?;
  127537. /**
  127538. * Creates a new WeightedSound from the list of sounds given.
  127539. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  127540. * @param sounds Array of Sounds that will be selected from.
  127541. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  127542. */
  127543. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  127544. /**
  127545. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  127546. */
  127547. get directionalConeInnerAngle(): number;
  127548. /**
  127549. * The size of cone in degress for a directional sound in which there will be no attenuation.
  127550. */
  127551. set directionalConeInnerAngle(value: number);
  127552. /**
  127553. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127554. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127555. */
  127556. get directionalConeOuterAngle(): number;
  127557. /**
  127558. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127559. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127560. */
  127561. set directionalConeOuterAngle(value: number);
  127562. /**
  127563. * Playback volume.
  127564. */
  127565. get volume(): number;
  127566. /**
  127567. * Playback volume.
  127568. */
  127569. set volume(value: number);
  127570. private _onended;
  127571. /**
  127572. * Suspend playback
  127573. */
  127574. pause(): void;
  127575. /**
  127576. * Stop playback
  127577. */
  127578. stop(): void;
  127579. /**
  127580. * Start playback.
  127581. * @param startOffset Position the clip head at a specific time in seconds.
  127582. */
  127583. play(startOffset?: number): void;
  127584. }
  127585. }
  127586. declare module BABYLON {
  127587. /**
  127588. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  127589. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127590. */
  127591. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  127592. /**
  127593. * Gets the name of the behavior.
  127594. */
  127595. get name(): string;
  127596. /**
  127597. * The easing function used by animations
  127598. */
  127599. static EasingFunction: BackEase;
  127600. /**
  127601. * The easing mode used by animations
  127602. */
  127603. static EasingMode: number;
  127604. /**
  127605. * The duration of the animation, in milliseconds
  127606. */
  127607. transitionDuration: number;
  127608. /**
  127609. * Length of the distance animated by the transition when lower radius is reached
  127610. */
  127611. lowerRadiusTransitionRange: number;
  127612. /**
  127613. * Length of the distance animated by the transition when upper radius is reached
  127614. */
  127615. upperRadiusTransitionRange: number;
  127616. private _autoTransitionRange;
  127617. /**
  127618. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127619. */
  127620. get autoTransitionRange(): boolean;
  127621. /**
  127622. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127623. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  127624. */
  127625. set autoTransitionRange(value: boolean);
  127626. private _attachedCamera;
  127627. private _onAfterCheckInputsObserver;
  127628. private _onMeshTargetChangedObserver;
  127629. /**
  127630. * Initializes the behavior.
  127631. */
  127632. init(): void;
  127633. /**
  127634. * Attaches the behavior to its arc rotate camera.
  127635. * @param camera Defines the camera to attach the behavior to
  127636. */
  127637. attach(camera: ArcRotateCamera): void;
  127638. /**
  127639. * Detaches the behavior from its current arc rotate camera.
  127640. */
  127641. detach(): void;
  127642. private _radiusIsAnimating;
  127643. private _radiusBounceTransition;
  127644. private _animatables;
  127645. private _cachedWheelPrecision;
  127646. /**
  127647. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  127648. * @param radiusLimit The limit to check against.
  127649. * @return Bool to indicate if at limit.
  127650. */
  127651. private _isRadiusAtLimit;
  127652. /**
  127653. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  127654. * @param radiusDelta The delta by which to animate to. Can be negative.
  127655. */
  127656. private _applyBoundRadiusAnimation;
  127657. /**
  127658. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  127659. */
  127660. protected _clearAnimationLocks(): void;
  127661. /**
  127662. * Stops and removes all animations that have been applied to the camera
  127663. */
  127664. stopAllAnimations(): void;
  127665. }
  127666. }
  127667. declare module BABYLON {
  127668. /**
  127669. * 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.
  127670. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127671. */
  127672. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  127673. /**
  127674. * Gets the name of the behavior.
  127675. */
  127676. get name(): string;
  127677. private _mode;
  127678. private _radiusScale;
  127679. private _positionScale;
  127680. private _defaultElevation;
  127681. private _elevationReturnTime;
  127682. private _elevationReturnWaitTime;
  127683. private _zoomStopsAnimation;
  127684. private _framingTime;
  127685. /**
  127686. * The easing function used by animations
  127687. */
  127688. static EasingFunction: ExponentialEase;
  127689. /**
  127690. * The easing mode used by animations
  127691. */
  127692. static EasingMode: number;
  127693. /**
  127694. * Sets the current mode used by the behavior
  127695. */
  127696. set mode(mode: number);
  127697. /**
  127698. * Gets current mode used by the behavior.
  127699. */
  127700. get mode(): number;
  127701. /**
  127702. * Sets the scale applied to the radius (1 by default)
  127703. */
  127704. set radiusScale(radius: number);
  127705. /**
  127706. * Gets the scale applied to the radius
  127707. */
  127708. get radiusScale(): number;
  127709. /**
  127710. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127711. */
  127712. set positionScale(scale: number);
  127713. /**
  127714. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127715. */
  127716. get positionScale(): number;
  127717. /**
  127718. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127719. * behaviour is triggered, in radians.
  127720. */
  127721. set defaultElevation(elevation: number);
  127722. /**
  127723. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127724. * behaviour is triggered, in radians.
  127725. */
  127726. get defaultElevation(): number;
  127727. /**
  127728. * Sets the time (in milliseconds) taken to return to the default beta position.
  127729. * Negative value indicates camera should not return to default.
  127730. */
  127731. set elevationReturnTime(speed: number);
  127732. /**
  127733. * Gets the time (in milliseconds) taken to return to the default beta position.
  127734. * Negative value indicates camera should not return to default.
  127735. */
  127736. get elevationReturnTime(): number;
  127737. /**
  127738. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127739. */
  127740. set elevationReturnWaitTime(time: number);
  127741. /**
  127742. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127743. */
  127744. get elevationReturnWaitTime(): number;
  127745. /**
  127746. * Sets the flag that indicates if user zooming should stop animation.
  127747. */
  127748. set zoomStopsAnimation(flag: boolean);
  127749. /**
  127750. * Gets the flag that indicates if user zooming should stop animation.
  127751. */
  127752. get zoomStopsAnimation(): boolean;
  127753. /**
  127754. * Sets the transition time when framing the mesh, in milliseconds
  127755. */
  127756. set framingTime(time: number);
  127757. /**
  127758. * Gets the transition time when framing the mesh, in milliseconds
  127759. */
  127760. get framingTime(): number;
  127761. /**
  127762. * Define if the behavior should automatically change the configured
  127763. * camera limits and sensibilities.
  127764. */
  127765. autoCorrectCameraLimitsAndSensibility: boolean;
  127766. private _onPrePointerObservableObserver;
  127767. private _onAfterCheckInputsObserver;
  127768. private _onMeshTargetChangedObserver;
  127769. private _attachedCamera;
  127770. private _isPointerDown;
  127771. private _lastInteractionTime;
  127772. /**
  127773. * Initializes the behavior.
  127774. */
  127775. init(): void;
  127776. /**
  127777. * Attaches the behavior to its arc rotate camera.
  127778. * @param camera Defines the camera to attach the behavior to
  127779. */
  127780. attach(camera: ArcRotateCamera): void;
  127781. /**
  127782. * Detaches the behavior from its current arc rotate camera.
  127783. */
  127784. detach(): void;
  127785. private _animatables;
  127786. private _betaIsAnimating;
  127787. private _betaTransition;
  127788. private _radiusTransition;
  127789. private _vectorTransition;
  127790. /**
  127791. * Targets the given mesh and updates zoom level accordingly.
  127792. * @param mesh The mesh to target.
  127793. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127794. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127795. */
  127796. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127797. /**
  127798. * Targets the given mesh with its children and updates zoom level accordingly.
  127799. * @param mesh The mesh to target.
  127800. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127801. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127802. */
  127803. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127804. /**
  127805. * Targets the given meshes with their children and updates zoom level accordingly.
  127806. * @param meshes The mesh to target.
  127807. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127808. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127809. */
  127810. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127811. /**
  127812. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  127813. * @param minimumWorld Determines the smaller position of the bounding box extend
  127814. * @param maximumWorld Determines the bigger position of the bounding box extend
  127815. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127816. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127817. */
  127818. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127819. /**
  127820. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  127821. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  127822. * frustum width.
  127823. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  127824. * to fully enclose the mesh in the viewing frustum.
  127825. */
  127826. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  127827. /**
  127828. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  127829. * is automatically returned to its default position (expected to be above ground plane).
  127830. */
  127831. private _maintainCameraAboveGround;
  127832. /**
  127833. * Returns the frustum slope based on the canvas ratio and camera FOV
  127834. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  127835. */
  127836. private _getFrustumSlope;
  127837. /**
  127838. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  127839. */
  127840. private _clearAnimationLocks;
  127841. /**
  127842. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127843. */
  127844. private _applyUserInteraction;
  127845. /**
  127846. * Stops and removes all animations that have been applied to the camera
  127847. */
  127848. stopAllAnimations(): void;
  127849. /**
  127850. * Gets a value indicating if the user is moving the camera
  127851. */
  127852. get isUserIsMoving(): boolean;
  127853. /**
  127854. * The camera can move all the way towards the mesh.
  127855. */
  127856. static IgnoreBoundsSizeMode: number;
  127857. /**
  127858. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  127859. */
  127860. static FitFrustumSidesMode: number;
  127861. }
  127862. }
  127863. declare module BABYLON {
  127864. /**
  127865. * Base class for Camera Pointer Inputs.
  127866. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  127867. * for example usage.
  127868. */
  127869. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  127870. /**
  127871. * Defines the camera the input is attached to.
  127872. */
  127873. abstract camera: Camera;
  127874. /**
  127875. * Whether keyboard modifier keys are pressed at time of last mouse event.
  127876. */
  127877. protected _altKey: boolean;
  127878. protected _ctrlKey: boolean;
  127879. protected _metaKey: boolean;
  127880. protected _shiftKey: boolean;
  127881. /**
  127882. * Which mouse buttons were pressed at time of last mouse event.
  127883. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  127884. */
  127885. protected _buttonsPressed: number;
  127886. /**
  127887. * Defines the buttons associated with the input to handle camera move.
  127888. */
  127889. buttons: number[];
  127890. /**
  127891. * Attach the input controls to a specific dom element to get the input from.
  127892. * @param element Defines the element the controls should be listened from
  127893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127894. */
  127895. attachControl(noPreventDefault?: boolean): void;
  127896. /**
  127897. * Detach the current controls from the specified dom element.
  127898. */
  127899. detachControl(): void;
  127900. /**
  127901. * Gets the class name of the current input.
  127902. * @returns the class name
  127903. */
  127904. getClassName(): string;
  127905. /**
  127906. * Get the friendly name associated with the input class.
  127907. * @returns the input friendly name
  127908. */
  127909. getSimpleName(): string;
  127910. /**
  127911. * Called on pointer POINTERDOUBLETAP event.
  127912. * Override this method to provide functionality on POINTERDOUBLETAP event.
  127913. */
  127914. protected onDoubleTap(type: string): void;
  127915. /**
  127916. * Called on pointer POINTERMOVE event if only a single touch is active.
  127917. * Override this method to provide functionality.
  127918. */
  127919. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127920. /**
  127921. * Called on pointer POINTERMOVE event if multiple touches are active.
  127922. * Override this method to provide functionality.
  127923. */
  127924. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127925. /**
  127926. * Called on JS contextmenu event.
  127927. * Override this method to provide functionality.
  127928. */
  127929. protected onContextMenu(evt: PointerEvent): void;
  127930. /**
  127931. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127932. * press.
  127933. * Override this method to provide functionality.
  127934. */
  127935. protected onButtonDown(evt: PointerEvent): void;
  127936. /**
  127937. * Called each time a new POINTERUP event occurs. Ie, for each button
  127938. * release.
  127939. * Override this method to provide functionality.
  127940. */
  127941. protected onButtonUp(evt: PointerEvent): void;
  127942. /**
  127943. * Called when window becomes inactive.
  127944. * Override this method to provide functionality.
  127945. */
  127946. protected onLostFocus(): void;
  127947. private _pointerInput;
  127948. private _observer;
  127949. private _onLostFocus;
  127950. private pointA;
  127951. private pointB;
  127952. }
  127953. }
  127954. declare module BABYLON {
  127955. /**
  127956. * Manage the pointers inputs to control an arc rotate camera.
  127957. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127958. */
  127959. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  127960. /**
  127961. * Defines the camera the input is attached to.
  127962. */
  127963. camera: ArcRotateCamera;
  127964. /**
  127965. * Gets the class name of the current input.
  127966. * @returns the class name
  127967. */
  127968. getClassName(): string;
  127969. /**
  127970. * Defines the buttons associated with the input to handle camera move.
  127971. */
  127972. buttons: number[];
  127973. /**
  127974. * Defines the pointer angular sensibility along the X axis or how fast is
  127975. * the camera rotating.
  127976. */
  127977. angularSensibilityX: number;
  127978. /**
  127979. * Defines the pointer angular sensibility along the Y axis or how fast is
  127980. * the camera rotating.
  127981. */
  127982. angularSensibilityY: number;
  127983. /**
  127984. * Defines the pointer pinch precision or how fast is the camera zooming.
  127985. */
  127986. pinchPrecision: number;
  127987. /**
  127988. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  127989. * from 0.
  127990. * It defines the percentage of current camera.radius to use as delta when
  127991. * pinch zoom is used.
  127992. */
  127993. pinchDeltaPercentage: number;
  127994. /**
  127995. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127996. * that any object in the plane at the camera's target point will scale
  127997. * perfectly with finger motion.
  127998. * Overrides pinchDeltaPercentage and pinchPrecision.
  127999. */
  128000. useNaturalPinchZoom: boolean;
  128001. /**
  128002. * Defines the pointer panning sensibility or how fast is the camera moving.
  128003. */
  128004. panningSensibility: number;
  128005. /**
  128006. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  128007. */
  128008. multiTouchPanning: boolean;
  128009. /**
  128010. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  128011. * zoom (pinch) through multitouch.
  128012. */
  128013. multiTouchPanAndZoom: boolean;
  128014. /**
  128015. * Revers pinch action direction.
  128016. */
  128017. pinchInwards: boolean;
  128018. private _isPanClick;
  128019. private _twoFingerActivityCount;
  128020. private _isPinching;
  128021. /**
  128022. * Called on pointer POINTERMOVE event if only a single touch is active.
  128023. */
  128024. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  128025. /**
  128026. * Called on pointer POINTERDOUBLETAP event.
  128027. */
  128028. protected onDoubleTap(type: string): void;
  128029. /**
  128030. * Called on pointer POINTERMOVE event if multiple touches are active.
  128031. */
  128032. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  128033. /**
  128034. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  128035. * press.
  128036. */
  128037. protected onButtonDown(evt: PointerEvent): void;
  128038. /**
  128039. * Called each time a new POINTERUP event occurs. Ie, for each button
  128040. * release.
  128041. */
  128042. protected onButtonUp(evt: PointerEvent): void;
  128043. /**
  128044. * Called when window becomes inactive.
  128045. */
  128046. protected onLostFocus(): void;
  128047. }
  128048. }
  128049. declare module BABYLON {
  128050. /**
  128051. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  128052. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128053. */
  128054. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  128055. /**
  128056. * Defines the camera the input is attached to.
  128057. */
  128058. camera: ArcRotateCamera;
  128059. /**
  128060. * Defines the list of key codes associated with the up action (increase alpha)
  128061. */
  128062. keysUp: number[];
  128063. /**
  128064. * Defines the list of key codes associated with the down action (decrease alpha)
  128065. */
  128066. keysDown: number[];
  128067. /**
  128068. * Defines the list of key codes associated with the left action (increase beta)
  128069. */
  128070. keysLeft: number[];
  128071. /**
  128072. * Defines the list of key codes associated with the right action (decrease beta)
  128073. */
  128074. keysRight: number[];
  128075. /**
  128076. * Defines the list of key codes associated with the reset action.
  128077. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  128078. */
  128079. keysReset: number[];
  128080. /**
  128081. * Defines the panning sensibility of the inputs.
  128082. * (How fast is the camera panning)
  128083. */
  128084. panningSensibility: number;
  128085. /**
  128086. * Defines the zooming sensibility of the inputs.
  128087. * (How fast is the camera zooming)
  128088. */
  128089. zoomingSensibility: number;
  128090. /**
  128091. * Defines whether maintaining the alt key down switch the movement mode from
  128092. * orientation to zoom.
  128093. */
  128094. useAltToZoom: boolean;
  128095. /**
  128096. * Rotation speed of the camera
  128097. */
  128098. angularSpeed: number;
  128099. private _keys;
  128100. private _ctrlPressed;
  128101. private _altPressed;
  128102. private _onCanvasBlurObserver;
  128103. private _onKeyboardObserver;
  128104. private _engine;
  128105. private _scene;
  128106. /**
  128107. * Attach the input controls to a specific dom element to get the input from.
  128108. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128109. */
  128110. attachControl(noPreventDefault?: boolean): void;
  128111. /**
  128112. * Detach the current controls from the specified dom element.
  128113. */
  128114. detachControl(): void;
  128115. /**
  128116. * Update the current camera state depending on the inputs that have been used this frame.
  128117. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128118. */
  128119. checkInputs(): void;
  128120. /**
  128121. * Gets the class name of the current intput.
  128122. * @returns the class name
  128123. */
  128124. getClassName(): string;
  128125. /**
  128126. * Get the friendly name associated with the input class.
  128127. * @returns the input friendly name
  128128. */
  128129. getSimpleName(): string;
  128130. }
  128131. }
  128132. declare module BABYLON {
  128133. /**
  128134. * Manage the mouse wheel inputs to control an arc rotate camera.
  128135. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128136. */
  128137. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  128138. /**
  128139. * Defines the camera the input is attached to.
  128140. */
  128141. camera: ArcRotateCamera;
  128142. /**
  128143. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  128144. */
  128145. wheelPrecision: number;
  128146. /**
  128147. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128148. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128149. */
  128150. wheelDeltaPercentage: number;
  128151. private _wheel;
  128152. private _observer;
  128153. private computeDeltaFromMouseWheelLegacyEvent;
  128154. /**
  128155. * Attach the input controls to a specific dom element to get the input from.
  128156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128157. */
  128158. attachControl(noPreventDefault?: boolean): void;
  128159. /**
  128160. * Detach the current controls from the specified dom element.
  128161. */
  128162. detachControl(): void;
  128163. /**
  128164. * Gets the class name of the current intput.
  128165. * @returns the class name
  128166. */
  128167. getClassName(): string;
  128168. /**
  128169. * Get the friendly name associated with the input class.
  128170. * @returns the input friendly name
  128171. */
  128172. getSimpleName(): string;
  128173. }
  128174. }
  128175. declare module BABYLON {
  128176. /**
  128177. * Default Inputs manager for the ArcRotateCamera.
  128178. * It groups all the default supported inputs for ease of use.
  128179. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128180. */
  128181. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  128182. /**
  128183. * Instantiates a new ArcRotateCameraInputsManager.
  128184. * @param camera Defines the camera the inputs belong to
  128185. */
  128186. constructor(camera: ArcRotateCamera);
  128187. /**
  128188. * Add mouse wheel input support to the input manager.
  128189. * @returns the current input manager
  128190. */
  128191. addMouseWheel(): ArcRotateCameraInputsManager;
  128192. /**
  128193. * Add pointers input support to the input manager.
  128194. * @returns the current input manager
  128195. */
  128196. addPointers(): ArcRotateCameraInputsManager;
  128197. /**
  128198. * Add keyboard input support to the input manager.
  128199. * @returns the current input manager
  128200. */
  128201. addKeyboard(): ArcRotateCameraInputsManager;
  128202. }
  128203. }
  128204. declare module BABYLON {
  128205. /**
  128206. * This represents an orbital type of camera.
  128207. *
  128208. * 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.
  128209. * 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.
  128210. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  128211. */
  128212. export class ArcRotateCamera extends TargetCamera {
  128213. /**
  128214. * Defines the rotation angle of the camera along the longitudinal axis.
  128215. */
  128216. alpha: number;
  128217. /**
  128218. * Defines the rotation angle of the camera along the latitudinal axis.
  128219. */
  128220. beta: number;
  128221. /**
  128222. * Defines the radius of the camera from it s target point.
  128223. */
  128224. radius: number;
  128225. protected _target: Vector3;
  128226. protected _targetHost: Nullable<AbstractMesh>;
  128227. /**
  128228. * Defines the target point of the camera.
  128229. * The camera looks towards it form the radius distance.
  128230. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  128231. */
  128232. get target(): Vector3;
  128233. set target(value: Vector3);
  128234. /**
  128235. * Define the current local position of the camera in the scene
  128236. */
  128237. get position(): Vector3;
  128238. set position(newPosition: Vector3);
  128239. protected _upToYMatrix: Matrix;
  128240. protected _YToUpMatrix: Matrix;
  128241. /**
  128242. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  128243. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  128244. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  128245. */
  128246. set upVector(vec: Vector3);
  128247. get upVector(): Vector3;
  128248. /**
  128249. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  128250. */
  128251. setMatUp(): void;
  128252. /**
  128253. * Current inertia value on the longitudinal axis.
  128254. * The bigger this number the longer it will take for the camera to stop.
  128255. */
  128256. inertialAlphaOffset: number;
  128257. /**
  128258. * Current inertia value on the latitudinal axis.
  128259. * The bigger this number the longer it will take for the camera to stop.
  128260. */
  128261. inertialBetaOffset: number;
  128262. /**
  128263. * Current inertia value on the radius axis.
  128264. * The bigger this number the longer it will take for the camera to stop.
  128265. */
  128266. inertialRadiusOffset: number;
  128267. /**
  128268. * Minimum allowed angle on the longitudinal axis.
  128269. * This can help limiting how the Camera is able to move in the scene.
  128270. */
  128271. lowerAlphaLimit: Nullable<number>;
  128272. /**
  128273. * Maximum allowed angle on the longitudinal axis.
  128274. * This can help limiting how the Camera is able to move in the scene.
  128275. */
  128276. upperAlphaLimit: Nullable<number>;
  128277. /**
  128278. * Minimum allowed angle on the latitudinal axis.
  128279. * This can help limiting how the Camera is able to move in the scene.
  128280. */
  128281. lowerBetaLimit: number;
  128282. /**
  128283. * Maximum allowed angle on the latitudinal axis.
  128284. * This can help limiting how the Camera is able to move in the scene.
  128285. */
  128286. upperBetaLimit: number;
  128287. /**
  128288. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  128289. * This can help limiting how the Camera is able to move in the scene.
  128290. */
  128291. lowerRadiusLimit: Nullable<number>;
  128292. /**
  128293. * Maximum allowed distance of the camera to the target (The camera can not get further).
  128294. * This can help limiting how the Camera is able to move in the scene.
  128295. */
  128296. upperRadiusLimit: Nullable<number>;
  128297. /**
  128298. * Defines the current inertia value used during panning of the camera along the X axis.
  128299. */
  128300. inertialPanningX: number;
  128301. /**
  128302. * Defines the current inertia value used during panning of the camera along the Y axis.
  128303. */
  128304. inertialPanningY: number;
  128305. /**
  128306. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  128307. * Basically if your fingers moves away from more than this distance you will be considered
  128308. * in pinch mode.
  128309. */
  128310. pinchToPanMaxDistance: number;
  128311. /**
  128312. * Defines the maximum distance the camera can pan.
  128313. * This could help keeping the cammera always in your scene.
  128314. */
  128315. panningDistanceLimit: Nullable<number>;
  128316. /**
  128317. * Defines the target of the camera before paning.
  128318. */
  128319. panningOriginTarget: Vector3;
  128320. /**
  128321. * Defines the value of the inertia used during panning.
  128322. * 0 would mean stop inertia and one would mean no decelleration at all.
  128323. */
  128324. panningInertia: number;
  128325. /**
  128326. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  128327. */
  128328. get angularSensibilityX(): number;
  128329. set angularSensibilityX(value: number);
  128330. /**
  128331. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  128332. */
  128333. get angularSensibilityY(): number;
  128334. set angularSensibilityY(value: number);
  128335. /**
  128336. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  128337. */
  128338. get pinchPrecision(): number;
  128339. set pinchPrecision(value: number);
  128340. /**
  128341. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  128342. * It will be used instead of pinchDeltaPrecision if different from 0.
  128343. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128344. */
  128345. get pinchDeltaPercentage(): number;
  128346. set pinchDeltaPercentage(value: number);
  128347. /**
  128348. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  128349. * and pinch delta percentage.
  128350. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  128351. * that any object in the plane at the camera's target point will scale
  128352. * perfectly with finger motion.
  128353. */
  128354. get useNaturalPinchZoom(): boolean;
  128355. set useNaturalPinchZoom(value: boolean);
  128356. /**
  128357. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  128358. */
  128359. get panningSensibility(): number;
  128360. set panningSensibility(value: number);
  128361. /**
  128362. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  128363. */
  128364. get keysUp(): number[];
  128365. set keysUp(value: number[]);
  128366. /**
  128367. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  128368. */
  128369. get keysDown(): number[];
  128370. set keysDown(value: number[]);
  128371. /**
  128372. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  128373. */
  128374. get keysLeft(): number[];
  128375. set keysLeft(value: number[]);
  128376. /**
  128377. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  128378. */
  128379. get keysRight(): number[];
  128380. set keysRight(value: number[]);
  128381. /**
  128382. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  128383. */
  128384. get wheelPrecision(): number;
  128385. set wheelPrecision(value: number);
  128386. /**
  128387. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  128388. * It will be used instead of pinchDeltaPrecision if different from 0.
  128389. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128390. */
  128391. get wheelDeltaPercentage(): number;
  128392. set wheelDeltaPercentage(value: number);
  128393. /**
  128394. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  128395. */
  128396. zoomOnFactor: number;
  128397. /**
  128398. * Defines a screen offset for the camera position.
  128399. */
  128400. targetScreenOffset: Vector2;
  128401. /**
  128402. * Allows the camera to be completely reversed.
  128403. * If false the camera can not arrive upside down.
  128404. */
  128405. allowUpsideDown: boolean;
  128406. /**
  128407. * Define if double tap/click is used to restore the previously saved state of the camera.
  128408. */
  128409. useInputToRestoreState: boolean;
  128410. /** @hidden */
  128411. _viewMatrix: Matrix;
  128412. /** @hidden */
  128413. _useCtrlForPanning: boolean;
  128414. /** @hidden */
  128415. _panningMouseButton: number;
  128416. /**
  128417. * Defines the input associated to the camera.
  128418. */
  128419. inputs: ArcRotateCameraInputsManager;
  128420. /** @hidden */
  128421. _reset: () => void;
  128422. /**
  128423. * Defines the allowed panning axis.
  128424. */
  128425. panningAxis: Vector3;
  128426. protected _localDirection: Vector3;
  128427. protected _transformedDirection: Vector3;
  128428. private _bouncingBehavior;
  128429. /**
  128430. * Gets the bouncing behavior of the camera if it has been enabled.
  128431. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128432. */
  128433. get bouncingBehavior(): Nullable<BouncingBehavior>;
  128434. /**
  128435. * Defines if the bouncing behavior of the camera is enabled on the camera.
  128436. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128437. */
  128438. get useBouncingBehavior(): boolean;
  128439. set useBouncingBehavior(value: boolean);
  128440. private _framingBehavior;
  128441. /**
  128442. * Gets the framing behavior of the camera if it has been enabled.
  128443. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128444. */
  128445. get framingBehavior(): Nullable<FramingBehavior>;
  128446. /**
  128447. * Defines if the framing behavior of the camera is enabled on the camera.
  128448. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128449. */
  128450. get useFramingBehavior(): boolean;
  128451. set useFramingBehavior(value: boolean);
  128452. private _autoRotationBehavior;
  128453. /**
  128454. * Gets the auto rotation behavior of the camera if it has been enabled.
  128455. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128456. */
  128457. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  128458. /**
  128459. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  128460. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128461. */
  128462. get useAutoRotationBehavior(): boolean;
  128463. set useAutoRotationBehavior(value: boolean);
  128464. /**
  128465. * Observable triggered when the mesh target has been changed on the camera.
  128466. */
  128467. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  128468. /**
  128469. * Event raised when the camera is colliding with a mesh.
  128470. */
  128471. onCollide: (collidedMesh: AbstractMesh) => void;
  128472. /**
  128473. * Defines whether the camera should check collision with the objects oh the scene.
  128474. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  128475. */
  128476. checkCollisions: boolean;
  128477. /**
  128478. * Defines the collision radius of the camera.
  128479. * This simulates a sphere around the camera.
  128480. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128481. */
  128482. collisionRadius: Vector3;
  128483. protected _collider: Collider;
  128484. protected _previousPosition: Vector3;
  128485. protected _collisionVelocity: Vector3;
  128486. protected _newPosition: Vector3;
  128487. protected _previousAlpha: number;
  128488. protected _previousBeta: number;
  128489. protected _previousRadius: number;
  128490. protected _collisionTriggered: boolean;
  128491. protected _targetBoundingCenter: Nullable<Vector3>;
  128492. private _computationVector;
  128493. /**
  128494. * Instantiates a new ArcRotateCamera in a given scene
  128495. * @param name Defines the name of the camera
  128496. * @param alpha Defines the camera rotation along the logitudinal axis
  128497. * @param beta Defines the camera rotation along the latitudinal axis
  128498. * @param radius Defines the camera distance from its target
  128499. * @param target Defines the camera target
  128500. * @param scene Defines the scene the camera belongs to
  128501. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  128502. */
  128503. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128504. /** @hidden */
  128505. _initCache(): void;
  128506. /** @hidden */
  128507. _updateCache(ignoreParentClass?: boolean): void;
  128508. protected _getTargetPosition(): Vector3;
  128509. private _storedAlpha;
  128510. private _storedBeta;
  128511. private _storedRadius;
  128512. private _storedTarget;
  128513. private _storedTargetScreenOffset;
  128514. /**
  128515. * Stores the current state of the camera (alpha, beta, radius and target)
  128516. * @returns the camera itself
  128517. */
  128518. storeState(): Camera;
  128519. /**
  128520. * @hidden
  128521. * Restored camera state. You must call storeState() first
  128522. */
  128523. _restoreStateValues(): boolean;
  128524. /** @hidden */
  128525. _isSynchronizedViewMatrix(): boolean;
  128526. /**
  128527. * Attach the input controls to a specific dom element to get the input from.
  128528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128529. */
  128530. attachControl(noPreventDefault?: boolean): void;
  128531. /**
  128532. * Attach the input controls to a specific dom element to get the input from.
  128533. * @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
  128534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128535. */
  128536. attachControl(ignored: any, noPreventDefault?: boolean): void;
  128537. /**
  128538. * Attached controls to the current camera.
  128539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128540. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128541. */
  128542. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128543. /**
  128544. * Attached controls to the current camera.
  128545. * @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
  128546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128547. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128548. */
  128549. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128550. /**
  128551. * Attached controls to the current camera.
  128552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128553. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128554. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  128555. */
  128556. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  128557. /**
  128558. * Detach the current controls from the specified dom element.
  128559. */
  128560. detachControl(): void;
  128561. /**
  128562. * Detach the current controls from the specified dom element.
  128563. * @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
  128564. */
  128565. detachControl(ignored: any): void;
  128566. /** @hidden */
  128567. _checkInputs(): void;
  128568. protected _checkLimits(): void;
  128569. /**
  128570. * Rebuilds angles (alpha, beta) and radius from the give position and target
  128571. */
  128572. rebuildAnglesAndRadius(): void;
  128573. /**
  128574. * Use a position to define the current camera related information like alpha, beta and radius
  128575. * @param position Defines the position to set the camera at
  128576. */
  128577. setPosition(position: Vector3): void;
  128578. /**
  128579. * Defines the target the camera should look at.
  128580. * This will automatically adapt alpha beta and radius to fit within the new target.
  128581. * @param target Defines the new target as a Vector or a mesh
  128582. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  128583. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  128584. */
  128585. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  128586. /** @hidden */
  128587. _getViewMatrix(): Matrix;
  128588. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  128589. /**
  128590. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  128591. * @param meshes Defines the mesh to zoom on
  128592. * @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)
  128593. */
  128594. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  128595. /**
  128596. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  128597. * The target will be changed but the radius
  128598. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  128599. * @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)
  128600. */
  128601. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  128602. min: Vector3;
  128603. max: Vector3;
  128604. distance: number;
  128605. }, doNotUpdateMaxZ?: boolean): void;
  128606. /**
  128607. * @override
  128608. * Override Camera.createRigCamera
  128609. */
  128610. createRigCamera(name: string, cameraIndex: number): Camera;
  128611. /**
  128612. * @hidden
  128613. * @override
  128614. * Override Camera._updateRigCameras
  128615. */
  128616. _updateRigCameras(): void;
  128617. /**
  128618. * Destroy the camera and release the current resources hold by it.
  128619. */
  128620. dispose(): void;
  128621. /**
  128622. * Gets the current object class name.
  128623. * @return the class name
  128624. */
  128625. getClassName(): string;
  128626. }
  128627. }
  128628. declare module BABYLON {
  128629. /**
  128630. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  128631. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128632. */
  128633. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  128634. /**
  128635. * Gets the name of the behavior.
  128636. */
  128637. get name(): string;
  128638. private _zoomStopsAnimation;
  128639. private _idleRotationSpeed;
  128640. private _idleRotationWaitTime;
  128641. private _idleRotationSpinupTime;
  128642. /**
  128643. * Sets the flag that indicates if user zooming should stop animation.
  128644. */
  128645. set zoomStopsAnimation(flag: boolean);
  128646. /**
  128647. * Gets the flag that indicates if user zooming should stop animation.
  128648. */
  128649. get zoomStopsAnimation(): boolean;
  128650. /**
  128651. * Sets the default speed at which the camera rotates around the model.
  128652. */
  128653. set idleRotationSpeed(speed: number);
  128654. /**
  128655. * Gets the default speed at which the camera rotates around the model.
  128656. */
  128657. get idleRotationSpeed(): number;
  128658. /**
  128659. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  128660. */
  128661. set idleRotationWaitTime(time: number);
  128662. /**
  128663. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  128664. */
  128665. get idleRotationWaitTime(): number;
  128666. /**
  128667. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128668. */
  128669. set idleRotationSpinupTime(time: number);
  128670. /**
  128671. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128672. */
  128673. get idleRotationSpinupTime(): number;
  128674. /**
  128675. * Gets a value indicating if the camera is currently rotating because of this behavior
  128676. */
  128677. get rotationInProgress(): boolean;
  128678. private _onPrePointerObservableObserver;
  128679. private _onAfterCheckInputsObserver;
  128680. private _attachedCamera;
  128681. private _isPointerDown;
  128682. private _lastFrameTime;
  128683. private _lastInteractionTime;
  128684. private _cameraRotationSpeed;
  128685. /**
  128686. * Initializes the behavior.
  128687. */
  128688. init(): void;
  128689. /**
  128690. * Attaches the behavior to its arc rotate camera.
  128691. * @param camera Defines the camera to attach the behavior to
  128692. */
  128693. attach(camera: ArcRotateCamera): void;
  128694. /**
  128695. * Detaches the behavior from its current arc rotate camera.
  128696. */
  128697. detach(): void;
  128698. /**
  128699. * Returns true if user is scrolling.
  128700. * @return true if user is scrolling.
  128701. */
  128702. private _userIsZooming;
  128703. private _lastFrameRadius;
  128704. private _shouldAnimationStopForInteraction;
  128705. /**
  128706. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  128707. */
  128708. private _applyUserInteraction;
  128709. private _userIsMoving;
  128710. }
  128711. }
  128712. declare module BABYLON {
  128713. /**
  128714. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  128715. */
  128716. export class AttachToBoxBehavior implements Behavior<Mesh> {
  128717. private ui;
  128718. /**
  128719. * The name of the behavior
  128720. */
  128721. name: string;
  128722. /**
  128723. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  128724. */
  128725. distanceAwayFromFace: number;
  128726. /**
  128727. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  128728. */
  128729. distanceAwayFromBottomOfFace: number;
  128730. private _faceVectors;
  128731. private _target;
  128732. private _scene;
  128733. private _onRenderObserver;
  128734. private _tmpMatrix;
  128735. private _tmpVector;
  128736. /**
  128737. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  128738. * @param ui The transform node that should be attched to the mesh
  128739. */
  128740. constructor(ui: TransformNode);
  128741. /**
  128742. * Initializes the behavior
  128743. */
  128744. init(): void;
  128745. private _closestFace;
  128746. private _zeroVector;
  128747. private _lookAtTmpMatrix;
  128748. private _lookAtToRef;
  128749. /**
  128750. * Attaches the AttachToBoxBehavior to the passed in mesh
  128751. * @param target The mesh that the specified node will be attached to
  128752. */
  128753. attach(target: Mesh): void;
  128754. /**
  128755. * Detaches the behavior from the mesh
  128756. */
  128757. detach(): void;
  128758. }
  128759. }
  128760. declare module BABYLON {
  128761. /**
  128762. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  128763. */
  128764. export class FadeInOutBehavior implements Behavior<Mesh> {
  128765. /**
  128766. * Time in milliseconds to delay before fading in (Default: 0)
  128767. */
  128768. delay: number;
  128769. /**
  128770. * Time in milliseconds for the mesh to fade in (Default: 300)
  128771. */
  128772. fadeInTime: number;
  128773. private _millisecondsPerFrame;
  128774. private _hovered;
  128775. private _hoverValue;
  128776. private _ownerNode;
  128777. /**
  128778. * Instatiates the FadeInOutBehavior
  128779. */
  128780. constructor();
  128781. /**
  128782. * The name of the behavior
  128783. */
  128784. get name(): string;
  128785. /**
  128786. * Initializes the behavior
  128787. */
  128788. init(): void;
  128789. /**
  128790. * Attaches the fade behavior on the passed in mesh
  128791. * @param ownerNode The mesh that will be faded in/out once attached
  128792. */
  128793. attach(ownerNode: Mesh): void;
  128794. /**
  128795. * Detaches the behavior from the mesh
  128796. */
  128797. detach(): void;
  128798. /**
  128799. * Triggers the mesh to begin fading in or out
  128800. * @param value if the object should fade in or out (true to fade in)
  128801. */
  128802. fadeIn(value: boolean): void;
  128803. private _update;
  128804. private _setAllVisibility;
  128805. }
  128806. }
  128807. declare module BABYLON {
  128808. /**
  128809. * Class containing a set of static utilities functions for managing Pivots
  128810. * @hidden
  128811. */
  128812. export class PivotTools {
  128813. private static _PivotCached;
  128814. private static _OldPivotPoint;
  128815. private static _PivotTranslation;
  128816. private static _PivotTmpVector;
  128817. private static _PivotPostMultiplyPivotMatrix;
  128818. /** @hidden */
  128819. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  128820. /** @hidden */
  128821. static _RestorePivotPoint(mesh: AbstractMesh): void;
  128822. }
  128823. }
  128824. declare module BABYLON {
  128825. /**
  128826. * Class containing static functions to help procedurally build meshes
  128827. */
  128828. export class PlaneBuilder {
  128829. /**
  128830. * Creates a plane mesh
  128831. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  128832. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  128833. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  128834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128837. * @param name defines the name of the mesh
  128838. * @param options defines the options used to create the mesh
  128839. * @param scene defines the hosting scene
  128840. * @returns the plane mesh
  128841. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  128842. */
  128843. static CreatePlane(name: string, options: {
  128844. size?: number;
  128845. width?: number;
  128846. height?: number;
  128847. sideOrientation?: number;
  128848. frontUVs?: Vector4;
  128849. backUVs?: Vector4;
  128850. updatable?: boolean;
  128851. sourcePlane?: Plane;
  128852. }, scene?: Nullable<Scene>): Mesh;
  128853. }
  128854. }
  128855. declare module BABYLON {
  128856. /**
  128857. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  128858. */
  128859. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  128860. private static _AnyMouseID;
  128861. /**
  128862. * Abstract mesh the behavior is set on
  128863. */
  128864. attachedNode: AbstractMesh;
  128865. private _dragPlane;
  128866. private _scene;
  128867. private _pointerObserver;
  128868. private _beforeRenderObserver;
  128869. private static _planeScene;
  128870. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  128871. /**
  128872. * 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)
  128873. */
  128874. maxDragAngle: number;
  128875. /**
  128876. * @hidden
  128877. */
  128878. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  128879. /**
  128880. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128881. */
  128882. currentDraggingPointerID: number;
  128883. /**
  128884. * The last position where the pointer hit the drag plane in world space
  128885. */
  128886. lastDragPosition: Vector3;
  128887. /**
  128888. * If the behavior is currently in a dragging state
  128889. */
  128890. dragging: boolean;
  128891. /**
  128892. * 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)
  128893. */
  128894. dragDeltaRatio: number;
  128895. /**
  128896. * If the drag plane orientation should be updated during the dragging (Default: true)
  128897. */
  128898. updateDragPlane: boolean;
  128899. private _debugMode;
  128900. private _moving;
  128901. /**
  128902. * Fires each time the attached mesh is dragged with the pointer
  128903. * * delta between last drag position and current drag position in world space
  128904. * * dragDistance along the drag axis
  128905. * * dragPlaneNormal normal of the current drag plane used during the drag
  128906. * * dragPlanePoint in world space where the drag intersects the drag plane
  128907. */
  128908. onDragObservable: Observable<{
  128909. delta: Vector3;
  128910. dragPlanePoint: Vector3;
  128911. dragPlaneNormal: Vector3;
  128912. dragDistance: number;
  128913. pointerId: number;
  128914. }>;
  128915. /**
  128916. * Fires each time a drag begins (eg. mouse down on mesh)
  128917. */
  128918. onDragStartObservable: Observable<{
  128919. dragPlanePoint: Vector3;
  128920. pointerId: number;
  128921. }>;
  128922. /**
  128923. * Fires each time a drag ends (eg. mouse release after drag)
  128924. */
  128925. onDragEndObservable: Observable<{
  128926. dragPlanePoint: Vector3;
  128927. pointerId: number;
  128928. }>;
  128929. /**
  128930. * If the attached mesh should be moved when dragged
  128931. */
  128932. moveAttached: boolean;
  128933. /**
  128934. * If the drag behavior will react to drag events (Default: true)
  128935. */
  128936. enabled: boolean;
  128937. /**
  128938. * If pointer events should start and release the drag (Default: true)
  128939. */
  128940. startAndReleaseDragOnPointerEvents: boolean;
  128941. /**
  128942. * If camera controls should be detached during the drag
  128943. */
  128944. detachCameraControls: boolean;
  128945. /**
  128946. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  128947. */
  128948. useObjectOrientationForDragging: boolean;
  128949. private _options;
  128950. /**
  128951. * Gets the options used by the behavior
  128952. */
  128953. get options(): {
  128954. dragAxis?: Vector3;
  128955. dragPlaneNormal?: Vector3;
  128956. };
  128957. /**
  128958. * Sets the options used by the behavior
  128959. */
  128960. set options(options: {
  128961. dragAxis?: Vector3;
  128962. dragPlaneNormal?: Vector3;
  128963. });
  128964. /**
  128965. * Creates a pointer drag behavior that can be attached to a mesh
  128966. * @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)
  128967. */
  128968. constructor(options?: {
  128969. dragAxis?: Vector3;
  128970. dragPlaneNormal?: Vector3;
  128971. });
  128972. /**
  128973. * Predicate to determine if it is valid to move the object to a new position when it is moved
  128974. */
  128975. validateDrag: (targetPosition: Vector3) => boolean;
  128976. /**
  128977. * The name of the behavior
  128978. */
  128979. get name(): string;
  128980. /**
  128981. * Initializes the behavior
  128982. */
  128983. init(): void;
  128984. private _tmpVector;
  128985. private _alternatePickedPoint;
  128986. private _worldDragAxis;
  128987. private _targetPosition;
  128988. private _attachedToElement;
  128989. /**
  128990. * Attaches the drag behavior the passed in mesh
  128991. * @param ownerNode The mesh that will be dragged around once attached
  128992. * @param predicate Predicate to use for pick filtering
  128993. */
  128994. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  128995. /**
  128996. * Force relase the drag action by code.
  128997. */
  128998. releaseDrag(): void;
  128999. private _startDragRay;
  129000. private _lastPointerRay;
  129001. /**
  129002. * Simulates the start of a pointer drag event on the behavior
  129003. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  129004. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  129005. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  129006. */
  129007. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  129008. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  129009. private _dragDelta;
  129010. protected _moveDrag(ray: Ray): void;
  129011. private _pickWithRayOnDragPlane;
  129012. private _pointA;
  129013. private _pointC;
  129014. private _localAxis;
  129015. private _lookAt;
  129016. private _updateDragPlanePosition;
  129017. /**
  129018. * Detaches the behavior from the mesh
  129019. */
  129020. detach(): void;
  129021. }
  129022. }
  129023. declare module BABYLON {
  129024. /**
  129025. * A behavior that when attached to a mesh will allow the mesh to be scaled
  129026. */
  129027. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  129028. private _dragBehaviorA;
  129029. private _dragBehaviorB;
  129030. private _startDistance;
  129031. private _initialScale;
  129032. private _targetScale;
  129033. private _ownerNode;
  129034. private _sceneRenderObserver;
  129035. /**
  129036. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  129037. */
  129038. constructor();
  129039. /**
  129040. * The name of the behavior
  129041. */
  129042. get name(): string;
  129043. /**
  129044. * Initializes the behavior
  129045. */
  129046. init(): void;
  129047. private _getCurrentDistance;
  129048. /**
  129049. * Attaches the scale behavior the passed in mesh
  129050. * @param ownerNode The mesh that will be scaled around once attached
  129051. */
  129052. attach(ownerNode: Mesh): void;
  129053. /**
  129054. * Detaches the behavior from the mesh
  129055. */
  129056. detach(): void;
  129057. }
  129058. }
  129059. declare module BABYLON {
  129060. /**
  129061. * 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
  129062. */
  129063. export class SixDofDragBehavior implements Behavior<Mesh> {
  129064. private static _virtualScene;
  129065. private _ownerNode;
  129066. private _sceneRenderObserver;
  129067. private _scene;
  129068. private _targetPosition;
  129069. private _virtualOriginMesh;
  129070. private _virtualDragMesh;
  129071. private _pointerObserver;
  129072. private _moving;
  129073. private _startingOrientation;
  129074. private _attachedToElement;
  129075. /**
  129076. * 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)
  129077. */
  129078. private zDragFactor;
  129079. /**
  129080. * If the object should rotate to face the drag origin
  129081. */
  129082. rotateDraggedObject: boolean;
  129083. /**
  129084. * If the behavior is currently in a dragging state
  129085. */
  129086. dragging: boolean;
  129087. /**
  129088. * 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)
  129089. */
  129090. dragDeltaRatio: number;
  129091. /**
  129092. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  129093. */
  129094. currentDraggingPointerID: number;
  129095. /**
  129096. * If camera controls should be detached during the drag
  129097. */
  129098. detachCameraControls: boolean;
  129099. /**
  129100. * Fires each time a drag starts
  129101. */
  129102. onDragStartObservable: Observable<{}>;
  129103. /**
  129104. * Fires each time a drag happens
  129105. */
  129106. onDragObservable: Observable<void>;
  129107. /**
  129108. * Fires each time a drag ends (eg. mouse release after drag)
  129109. */
  129110. onDragEndObservable: Observable<{}>;
  129111. /**
  129112. * 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
  129113. */
  129114. constructor();
  129115. /**
  129116. * The name of the behavior
  129117. */
  129118. get name(): string;
  129119. /**
  129120. * Initializes the behavior
  129121. */
  129122. init(): void;
  129123. /**
  129124. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  129125. */
  129126. private get _pointerCamera();
  129127. /**
  129128. * Attaches the scale behavior the passed in mesh
  129129. * @param ownerNode The mesh that will be scaled around once attached
  129130. */
  129131. attach(ownerNode: Mesh): void;
  129132. /**
  129133. * Detaches the behavior from the mesh
  129134. */
  129135. detach(): void;
  129136. }
  129137. }
  129138. declare module BABYLON {
  129139. /**
  129140. * Class used to apply inverse kinematics to bones
  129141. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  129142. */
  129143. export class BoneIKController {
  129144. private static _tmpVecs;
  129145. private static _tmpQuat;
  129146. private static _tmpMats;
  129147. /**
  129148. * Gets or sets the target mesh
  129149. */
  129150. targetMesh: AbstractMesh;
  129151. /** Gets or sets the mesh used as pole */
  129152. poleTargetMesh: AbstractMesh;
  129153. /**
  129154. * Gets or sets the bone used as pole
  129155. */
  129156. poleTargetBone: Nullable<Bone>;
  129157. /**
  129158. * Gets or sets the target position
  129159. */
  129160. targetPosition: Vector3;
  129161. /**
  129162. * Gets or sets the pole target position
  129163. */
  129164. poleTargetPosition: Vector3;
  129165. /**
  129166. * Gets or sets the pole target local offset
  129167. */
  129168. poleTargetLocalOffset: Vector3;
  129169. /**
  129170. * Gets or sets the pole angle
  129171. */
  129172. poleAngle: number;
  129173. /**
  129174. * Gets or sets the mesh associated with the controller
  129175. */
  129176. mesh: AbstractMesh;
  129177. /**
  129178. * 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)
  129179. */
  129180. slerpAmount: number;
  129181. private _bone1Quat;
  129182. private _bone1Mat;
  129183. private _bone2Ang;
  129184. private _bone1;
  129185. private _bone2;
  129186. private _bone1Length;
  129187. private _bone2Length;
  129188. private _maxAngle;
  129189. private _maxReach;
  129190. private _rightHandedSystem;
  129191. private _bendAxis;
  129192. private _slerping;
  129193. private _adjustRoll;
  129194. /**
  129195. * Gets or sets maximum allowed angle
  129196. */
  129197. get maxAngle(): number;
  129198. set maxAngle(value: number);
  129199. /**
  129200. * Creates a new BoneIKController
  129201. * @param mesh defines the mesh to control
  129202. * @param bone defines the bone to control
  129203. * @param options defines options to set up the controller
  129204. */
  129205. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  129206. targetMesh?: AbstractMesh;
  129207. poleTargetMesh?: AbstractMesh;
  129208. poleTargetBone?: Bone;
  129209. poleTargetLocalOffset?: Vector3;
  129210. poleAngle?: number;
  129211. bendAxis?: Vector3;
  129212. maxAngle?: number;
  129213. slerpAmount?: number;
  129214. });
  129215. private _setMaxAngle;
  129216. /**
  129217. * Force the controller to update the bones
  129218. */
  129219. update(): void;
  129220. }
  129221. }
  129222. declare module BABYLON {
  129223. /**
  129224. * Class used to make a bone look toward a point in space
  129225. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  129226. */
  129227. export class BoneLookController {
  129228. private static _tmpVecs;
  129229. private static _tmpQuat;
  129230. private static _tmpMats;
  129231. /**
  129232. * The target Vector3 that the bone will look at
  129233. */
  129234. target: Vector3;
  129235. /**
  129236. * The mesh that the bone is attached to
  129237. */
  129238. mesh: AbstractMesh;
  129239. /**
  129240. * The bone that will be looking to the target
  129241. */
  129242. bone: Bone;
  129243. /**
  129244. * The up axis of the coordinate system that is used when the bone is rotated
  129245. */
  129246. upAxis: Vector3;
  129247. /**
  129248. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  129249. */
  129250. upAxisSpace: Space;
  129251. /**
  129252. * Used to make an adjustment to the yaw of the bone
  129253. */
  129254. adjustYaw: number;
  129255. /**
  129256. * Used to make an adjustment to the pitch of the bone
  129257. */
  129258. adjustPitch: number;
  129259. /**
  129260. * Used to make an adjustment to the roll of the bone
  129261. */
  129262. adjustRoll: number;
  129263. /**
  129264. * 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)
  129265. */
  129266. slerpAmount: number;
  129267. private _minYaw;
  129268. private _maxYaw;
  129269. private _minPitch;
  129270. private _maxPitch;
  129271. private _minYawSin;
  129272. private _minYawCos;
  129273. private _maxYawSin;
  129274. private _maxYawCos;
  129275. private _midYawConstraint;
  129276. private _minPitchTan;
  129277. private _maxPitchTan;
  129278. private _boneQuat;
  129279. private _slerping;
  129280. private _transformYawPitch;
  129281. private _transformYawPitchInv;
  129282. private _firstFrameSkipped;
  129283. private _yawRange;
  129284. private _fowardAxis;
  129285. /**
  129286. * Gets or sets the minimum yaw angle that the bone can look to
  129287. */
  129288. get minYaw(): number;
  129289. set minYaw(value: number);
  129290. /**
  129291. * Gets or sets the maximum yaw angle that the bone can look to
  129292. */
  129293. get maxYaw(): number;
  129294. set maxYaw(value: number);
  129295. /**
  129296. * Gets or sets the minimum pitch angle that the bone can look to
  129297. */
  129298. get minPitch(): number;
  129299. set minPitch(value: number);
  129300. /**
  129301. * Gets or sets the maximum pitch angle that the bone can look to
  129302. */
  129303. get maxPitch(): number;
  129304. set maxPitch(value: number);
  129305. /**
  129306. * Create a BoneLookController
  129307. * @param mesh the mesh that the bone belongs to
  129308. * @param bone the bone that will be looking to the target
  129309. * @param target the target Vector3 to look at
  129310. * @param options optional settings:
  129311. * * maxYaw: the maximum angle the bone will yaw to
  129312. * * minYaw: the minimum angle the bone will yaw to
  129313. * * maxPitch: the maximum angle the bone will pitch to
  129314. * * minPitch: the minimum angle the bone will yaw to
  129315. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  129316. * * upAxis: the up axis of the coordinate system
  129317. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  129318. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  129319. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  129320. * * adjustYaw: used to make an adjustment to the yaw of the bone
  129321. * * adjustPitch: used to make an adjustment to the pitch of the bone
  129322. * * adjustRoll: used to make an adjustment to the roll of the bone
  129323. **/
  129324. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  129325. maxYaw?: number;
  129326. minYaw?: number;
  129327. maxPitch?: number;
  129328. minPitch?: number;
  129329. slerpAmount?: number;
  129330. upAxis?: Vector3;
  129331. upAxisSpace?: Space;
  129332. yawAxis?: Vector3;
  129333. pitchAxis?: Vector3;
  129334. adjustYaw?: number;
  129335. adjustPitch?: number;
  129336. adjustRoll?: number;
  129337. });
  129338. /**
  129339. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  129340. */
  129341. update(): void;
  129342. private _getAngleDiff;
  129343. private _getAngleBetween;
  129344. private _isAngleBetween;
  129345. }
  129346. }
  129347. declare module BABYLON {
  129348. /**
  129349. * Manage the gamepad inputs to control an arc rotate camera.
  129350. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129351. */
  129352. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  129353. /**
  129354. * Defines the camera the input is attached to.
  129355. */
  129356. camera: ArcRotateCamera;
  129357. /**
  129358. * Defines the gamepad the input is gathering event from.
  129359. */
  129360. gamepad: Nullable<Gamepad>;
  129361. /**
  129362. * Defines the gamepad rotation sensiblity.
  129363. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129364. */
  129365. gamepadRotationSensibility: number;
  129366. /**
  129367. * Defines the gamepad move sensiblity.
  129368. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129369. */
  129370. gamepadMoveSensibility: number;
  129371. private _yAxisScale;
  129372. /**
  129373. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  129374. */
  129375. get invertYAxis(): boolean;
  129376. set invertYAxis(value: boolean);
  129377. private _onGamepadConnectedObserver;
  129378. private _onGamepadDisconnectedObserver;
  129379. /**
  129380. * Attach the input controls to a specific dom element to get the input from.
  129381. */
  129382. attachControl(): void;
  129383. /**
  129384. * Detach the current controls from the specified dom element.
  129385. */
  129386. detachControl(): void;
  129387. /**
  129388. * Update the current camera state depending on the inputs that have been used this frame.
  129389. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129390. */
  129391. checkInputs(): void;
  129392. /**
  129393. * Gets the class name of the current intput.
  129394. * @returns the class name
  129395. */
  129396. getClassName(): string;
  129397. /**
  129398. * Get the friendly name associated with the input class.
  129399. * @returns the input friendly name
  129400. */
  129401. getSimpleName(): string;
  129402. }
  129403. }
  129404. declare module BABYLON {
  129405. interface ArcRotateCameraInputsManager {
  129406. /**
  129407. * Add orientation input support to the input manager.
  129408. * @returns the current input manager
  129409. */
  129410. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  129411. }
  129412. /**
  129413. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  129414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129415. */
  129416. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  129417. /**
  129418. * Defines the camera the input is attached to.
  129419. */
  129420. camera: ArcRotateCamera;
  129421. /**
  129422. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  129423. */
  129424. alphaCorrection: number;
  129425. /**
  129426. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  129427. */
  129428. gammaCorrection: number;
  129429. private _alpha;
  129430. private _gamma;
  129431. private _dirty;
  129432. private _deviceOrientationHandler;
  129433. /**
  129434. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  129435. */
  129436. constructor();
  129437. /**
  129438. * Attach the input controls to a specific dom element to get the input from.
  129439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129440. */
  129441. attachControl(noPreventDefault?: boolean): void;
  129442. /** @hidden */
  129443. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  129444. /**
  129445. * Update the current camera state depending on the inputs that have been used this frame.
  129446. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129447. */
  129448. checkInputs(): void;
  129449. /**
  129450. * Detach the current controls from the specified dom element.
  129451. */
  129452. detachControl(): void;
  129453. /**
  129454. * Gets the class name of the current intput.
  129455. * @returns the class name
  129456. */
  129457. getClassName(): string;
  129458. /**
  129459. * Get the friendly name associated with the input class.
  129460. * @returns the input friendly name
  129461. */
  129462. getSimpleName(): string;
  129463. }
  129464. }
  129465. declare module BABYLON {
  129466. /**
  129467. * Listen to mouse events to control the camera.
  129468. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129469. */
  129470. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  129471. /**
  129472. * Defines the camera the input is attached to.
  129473. */
  129474. camera: FlyCamera;
  129475. /**
  129476. * Defines if touch is enabled. (Default is true.)
  129477. */
  129478. touchEnabled: boolean;
  129479. /**
  129480. * Defines the buttons associated with the input to handle camera rotation.
  129481. */
  129482. buttons: number[];
  129483. /**
  129484. * Assign buttons for Yaw control.
  129485. */
  129486. buttonsYaw: number[];
  129487. /**
  129488. * Assign buttons for Pitch control.
  129489. */
  129490. buttonsPitch: number[];
  129491. /**
  129492. * Assign buttons for Roll control.
  129493. */
  129494. buttonsRoll: number[];
  129495. /**
  129496. * Detect if any button is being pressed while mouse is moved.
  129497. * -1 = Mouse locked.
  129498. * 0 = Left button.
  129499. * 1 = Middle Button.
  129500. * 2 = Right Button.
  129501. */
  129502. activeButton: number;
  129503. /**
  129504. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  129505. * Higher values reduce its sensitivity.
  129506. */
  129507. angularSensibility: number;
  129508. private _observer;
  129509. private _rollObserver;
  129510. private previousPosition;
  129511. private noPreventDefault;
  129512. private element;
  129513. /**
  129514. * Listen to mouse events to control the camera.
  129515. * @param touchEnabled Define if touch is enabled. (Default is true.)
  129516. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129517. */
  129518. constructor(touchEnabled?: boolean);
  129519. /**
  129520. * Attach the mouse control to the HTML DOM element.
  129521. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  129522. */
  129523. attachControl(noPreventDefault?: boolean): void;
  129524. /**
  129525. * Detach the current controls from the specified dom element.
  129526. */
  129527. detachControl(): void;
  129528. /**
  129529. * Gets the class name of the current input.
  129530. * @returns the class name.
  129531. */
  129532. getClassName(): string;
  129533. /**
  129534. * Get the friendly name associated with the input class.
  129535. * @returns the input's friendly name.
  129536. */
  129537. getSimpleName(): string;
  129538. private _pointerInput;
  129539. private _onMouseMove;
  129540. /**
  129541. * Rotate camera by mouse offset.
  129542. */
  129543. private rotateCamera;
  129544. }
  129545. }
  129546. declare module BABYLON {
  129547. /**
  129548. * Default Inputs manager for the FlyCamera.
  129549. * It groups all the default supported inputs for ease of use.
  129550. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129551. */
  129552. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  129553. /**
  129554. * Instantiates a new FlyCameraInputsManager.
  129555. * @param camera Defines the camera the inputs belong to.
  129556. */
  129557. constructor(camera: FlyCamera);
  129558. /**
  129559. * Add keyboard input support to the input manager.
  129560. * @returns the new FlyCameraKeyboardMoveInput().
  129561. */
  129562. addKeyboard(): FlyCameraInputsManager;
  129563. /**
  129564. * Add mouse input support to the input manager.
  129565. * @param touchEnabled Enable touch screen support.
  129566. * @returns the new FlyCameraMouseInput().
  129567. */
  129568. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  129569. }
  129570. }
  129571. declare module BABYLON {
  129572. /**
  129573. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129574. * such as in a 3D Space Shooter or a Flight Simulator.
  129575. */
  129576. export class FlyCamera extends TargetCamera {
  129577. /**
  129578. * Define the collision ellipsoid of the camera.
  129579. * This is helpful for simulating a camera body, like a player's body.
  129580. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  129581. */
  129582. ellipsoid: Vector3;
  129583. /**
  129584. * Define an offset for the position of the ellipsoid around the camera.
  129585. * This can be helpful if the camera is attached away from the player's body center,
  129586. * such as at its head.
  129587. */
  129588. ellipsoidOffset: Vector3;
  129589. /**
  129590. * Enable or disable collisions of the camera with the rest of the scene objects.
  129591. */
  129592. checkCollisions: boolean;
  129593. /**
  129594. * Enable or disable gravity on the camera.
  129595. */
  129596. applyGravity: boolean;
  129597. /**
  129598. * Define the current direction the camera is moving to.
  129599. */
  129600. cameraDirection: Vector3;
  129601. /**
  129602. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  129603. * This overrides and empties cameraRotation.
  129604. */
  129605. rotationQuaternion: Quaternion;
  129606. /**
  129607. * Track Roll to maintain the wanted Rolling when looking around.
  129608. */
  129609. _trackRoll: number;
  129610. /**
  129611. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  129612. */
  129613. rollCorrect: number;
  129614. /**
  129615. * Mimic a banked turn, Rolling the camera when Yawing.
  129616. * It's recommended to use rollCorrect = 10 for faster banking correction.
  129617. */
  129618. bankedTurn: boolean;
  129619. /**
  129620. * Limit in radians for how much Roll banking will add. (Default: 90°)
  129621. */
  129622. bankedTurnLimit: number;
  129623. /**
  129624. * Value of 0 disables the banked Roll.
  129625. * Value of 1 is equal to the Yaw angle in radians.
  129626. */
  129627. bankedTurnMultiplier: number;
  129628. /**
  129629. * The inputs manager loads all the input sources, such as keyboard and mouse.
  129630. */
  129631. inputs: FlyCameraInputsManager;
  129632. /**
  129633. * Gets the input sensibility for mouse input.
  129634. * Higher values reduce sensitivity.
  129635. */
  129636. get angularSensibility(): number;
  129637. /**
  129638. * Sets the input sensibility for a mouse input.
  129639. * Higher values reduce sensitivity.
  129640. */
  129641. set angularSensibility(value: number);
  129642. /**
  129643. * Get the keys for camera movement forward.
  129644. */
  129645. get keysForward(): number[];
  129646. /**
  129647. * Set the keys for camera movement forward.
  129648. */
  129649. set keysForward(value: number[]);
  129650. /**
  129651. * Get the keys for camera movement backward.
  129652. */
  129653. get keysBackward(): number[];
  129654. set keysBackward(value: number[]);
  129655. /**
  129656. * Get the keys for camera movement up.
  129657. */
  129658. get keysUp(): number[];
  129659. /**
  129660. * Set the keys for camera movement up.
  129661. */
  129662. set keysUp(value: number[]);
  129663. /**
  129664. * Get the keys for camera movement down.
  129665. */
  129666. get keysDown(): number[];
  129667. /**
  129668. * Set the keys for camera movement down.
  129669. */
  129670. set keysDown(value: number[]);
  129671. /**
  129672. * Get the keys for camera movement left.
  129673. */
  129674. get keysLeft(): number[];
  129675. /**
  129676. * Set the keys for camera movement left.
  129677. */
  129678. set keysLeft(value: number[]);
  129679. /**
  129680. * Set the keys for camera movement right.
  129681. */
  129682. get keysRight(): number[];
  129683. /**
  129684. * Set the keys for camera movement right.
  129685. */
  129686. set keysRight(value: number[]);
  129687. /**
  129688. * Event raised when the camera collides with a mesh in the scene.
  129689. */
  129690. onCollide: (collidedMesh: AbstractMesh) => void;
  129691. private _collider;
  129692. private _needMoveForGravity;
  129693. private _oldPosition;
  129694. private _diffPosition;
  129695. private _newPosition;
  129696. /** @hidden */
  129697. _localDirection: Vector3;
  129698. /** @hidden */
  129699. _transformedDirection: Vector3;
  129700. /**
  129701. * Instantiates a FlyCamera.
  129702. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129703. * such as in a 3D Space Shooter or a Flight Simulator.
  129704. * @param name Define the name of the camera in the scene.
  129705. * @param position Define the starting position of the camera in the scene.
  129706. * @param scene Define the scene the camera belongs to.
  129707. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  129708. */
  129709. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  129710. /**
  129711. * Attach the input controls to a specific dom element to get the input from.
  129712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129713. */
  129714. attachControl(noPreventDefault?: boolean): void;
  129715. /**
  129716. * Detach a control from the HTML DOM element.
  129717. * The camera will stop reacting to that input.
  129718. */
  129719. detachControl(): void;
  129720. private _collisionMask;
  129721. /**
  129722. * Get the mask that the camera ignores in collision events.
  129723. */
  129724. get collisionMask(): number;
  129725. /**
  129726. * Set the mask that the camera ignores in collision events.
  129727. */
  129728. set collisionMask(mask: number);
  129729. /** @hidden */
  129730. _collideWithWorld(displacement: Vector3): void;
  129731. /** @hidden */
  129732. private _onCollisionPositionChange;
  129733. /** @hidden */
  129734. _checkInputs(): void;
  129735. /** @hidden */
  129736. _decideIfNeedsToMove(): boolean;
  129737. /** @hidden */
  129738. _updatePosition(): void;
  129739. /**
  129740. * Restore the Roll to its target value at the rate specified.
  129741. * @param rate - Higher means slower restoring.
  129742. * @hidden
  129743. */
  129744. restoreRoll(rate: number): void;
  129745. /**
  129746. * Destroy the camera and release the current resources held by it.
  129747. */
  129748. dispose(): void;
  129749. /**
  129750. * Get the current object class name.
  129751. * @returns the class name.
  129752. */
  129753. getClassName(): string;
  129754. }
  129755. }
  129756. declare module BABYLON {
  129757. /**
  129758. * Listen to keyboard events to control the camera.
  129759. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129760. */
  129761. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  129762. /**
  129763. * Defines the camera the input is attached to.
  129764. */
  129765. camera: FlyCamera;
  129766. /**
  129767. * The list of keyboard keys used to control the forward move of the camera.
  129768. */
  129769. keysForward: number[];
  129770. /**
  129771. * The list of keyboard keys used to control the backward move of the camera.
  129772. */
  129773. keysBackward: number[];
  129774. /**
  129775. * The list of keyboard keys used to control the forward move of the camera.
  129776. */
  129777. keysUp: number[];
  129778. /**
  129779. * The list of keyboard keys used to control the backward move of the camera.
  129780. */
  129781. keysDown: number[];
  129782. /**
  129783. * The list of keyboard keys used to control the right strafe move of the camera.
  129784. */
  129785. keysRight: number[];
  129786. /**
  129787. * The list of keyboard keys used to control the left strafe move of the camera.
  129788. */
  129789. keysLeft: number[];
  129790. private _keys;
  129791. private _onCanvasBlurObserver;
  129792. private _onKeyboardObserver;
  129793. private _engine;
  129794. private _scene;
  129795. /**
  129796. * Attach the input controls to a specific dom element to get the input from.
  129797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129798. */
  129799. attachControl(noPreventDefault?: boolean): void;
  129800. /**
  129801. * Detach the current controls from the specified dom element.
  129802. */
  129803. detachControl(): void;
  129804. /**
  129805. * Gets the class name of the current intput.
  129806. * @returns the class name
  129807. */
  129808. getClassName(): string;
  129809. /** @hidden */
  129810. _onLostFocus(e: FocusEvent): void;
  129811. /**
  129812. * Get the friendly name associated with the input class.
  129813. * @returns the input friendly name
  129814. */
  129815. getSimpleName(): string;
  129816. /**
  129817. * Update the current camera state depending on the inputs that have been used this frame.
  129818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129819. */
  129820. checkInputs(): void;
  129821. }
  129822. }
  129823. declare module BABYLON {
  129824. /**
  129825. * Manage the mouse wheel inputs to control a follow camera.
  129826. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129827. */
  129828. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  129829. /**
  129830. * Defines the camera the input is attached to.
  129831. */
  129832. camera: FollowCamera;
  129833. /**
  129834. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  129835. */
  129836. axisControlRadius: boolean;
  129837. /**
  129838. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  129839. */
  129840. axisControlHeight: boolean;
  129841. /**
  129842. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  129843. */
  129844. axisControlRotation: boolean;
  129845. /**
  129846. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  129847. * relation to mouseWheel events.
  129848. */
  129849. wheelPrecision: number;
  129850. /**
  129851. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  129852. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  129853. */
  129854. wheelDeltaPercentage: number;
  129855. private _wheel;
  129856. private _observer;
  129857. /**
  129858. * Attach the input controls to a specific dom element to get the input from.
  129859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129860. */
  129861. attachControl(noPreventDefault?: boolean): void;
  129862. /**
  129863. * Detach the current controls from the specified dom element.
  129864. */
  129865. detachControl(): void;
  129866. /**
  129867. * Gets the class name of the current intput.
  129868. * @returns the class name
  129869. */
  129870. getClassName(): string;
  129871. /**
  129872. * Get the friendly name associated with the input class.
  129873. * @returns the input friendly name
  129874. */
  129875. getSimpleName(): string;
  129876. }
  129877. }
  129878. declare module BABYLON {
  129879. /**
  129880. * Manage the pointers inputs to control an follow camera.
  129881. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129882. */
  129883. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  129884. /**
  129885. * Defines the camera the input is attached to.
  129886. */
  129887. camera: FollowCamera;
  129888. /**
  129889. * Gets the class name of the current input.
  129890. * @returns the class name
  129891. */
  129892. getClassName(): string;
  129893. /**
  129894. * Defines the pointer angular sensibility along the X axis or how fast is
  129895. * the camera rotating.
  129896. * A negative number will reverse the axis direction.
  129897. */
  129898. angularSensibilityX: number;
  129899. /**
  129900. * Defines the pointer angular sensibility along the Y axis or how fast is
  129901. * the camera rotating.
  129902. * A negative number will reverse the axis direction.
  129903. */
  129904. angularSensibilityY: number;
  129905. /**
  129906. * Defines the pointer pinch precision or how fast is the camera zooming.
  129907. * A negative number will reverse the axis direction.
  129908. */
  129909. pinchPrecision: number;
  129910. /**
  129911. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  129912. * from 0.
  129913. * It defines the percentage of current camera.radius to use as delta when
  129914. * pinch zoom is used.
  129915. */
  129916. pinchDeltaPercentage: number;
  129917. /**
  129918. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  129919. */
  129920. axisXControlRadius: boolean;
  129921. /**
  129922. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  129923. */
  129924. axisXControlHeight: boolean;
  129925. /**
  129926. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  129927. */
  129928. axisXControlRotation: boolean;
  129929. /**
  129930. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  129931. */
  129932. axisYControlRadius: boolean;
  129933. /**
  129934. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  129935. */
  129936. axisYControlHeight: boolean;
  129937. /**
  129938. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  129939. */
  129940. axisYControlRotation: boolean;
  129941. /**
  129942. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  129943. */
  129944. axisPinchControlRadius: boolean;
  129945. /**
  129946. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  129947. */
  129948. axisPinchControlHeight: boolean;
  129949. /**
  129950. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  129951. */
  129952. axisPinchControlRotation: boolean;
  129953. /**
  129954. * Log error messages if basic misconfiguration has occurred.
  129955. */
  129956. warningEnable: boolean;
  129957. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  129958. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  129959. private _warningCounter;
  129960. private _warning;
  129961. }
  129962. }
  129963. declare module BABYLON {
  129964. /**
  129965. * Default Inputs manager for the FollowCamera.
  129966. * It groups all the default supported inputs for ease of use.
  129967. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129968. */
  129969. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  129970. /**
  129971. * Instantiates a new FollowCameraInputsManager.
  129972. * @param camera Defines the camera the inputs belong to
  129973. */
  129974. constructor(camera: FollowCamera);
  129975. /**
  129976. * Add keyboard input support to the input manager.
  129977. * @returns the current input manager
  129978. */
  129979. addKeyboard(): FollowCameraInputsManager;
  129980. /**
  129981. * Add mouse wheel input support to the input manager.
  129982. * @returns the current input manager
  129983. */
  129984. addMouseWheel(): FollowCameraInputsManager;
  129985. /**
  129986. * Add pointers input support to the input manager.
  129987. * @returns the current input manager
  129988. */
  129989. addPointers(): FollowCameraInputsManager;
  129990. /**
  129991. * Add orientation input support to the input manager.
  129992. * @returns the current input manager
  129993. */
  129994. addVRDeviceOrientation(): FollowCameraInputsManager;
  129995. }
  129996. }
  129997. declare module BABYLON {
  129998. /**
  129999. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  130000. * an arc rotate version arcFollowCamera are available.
  130001. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  130002. */
  130003. export class FollowCamera extends TargetCamera {
  130004. /**
  130005. * Distance the follow camera should follow an object at
  130006. */
  130007. radius: number;
  130008. /**
  130009. * Minimum allowed distance of the camera to the axis of rotation
  130010. * (The camera can not get closer).
  130011. * This can help limiting how the Camera is able to move in the scene.
  130012. */
  130013. lowerRadiusLimit: Nullable<number>;
  130014. /**
  130015. * Maximum allowed distance of the camera to the axis of rotation
  130016. * (The camera can not get further).
  130017. * This can help limiting how the Camera is able to move in the scene.
  130018. */
  130019. upperRadiusLimit: Nullable<number>;
  130020. /**
  130021. * Define a rotation offset between the camera and the object it follows
  130022. */
  130023. rotationOffset: number;
  130024. /**
  130025. * Minimum allowed angle to camera position relative to target object.
  130026. * This can help limiting how the Camera is able to move in the scene.
  130027. */
  130028. lowerRotationOffsetLimit: Nullable<number>;
  130029. /**
  130030. * Maximum allowed angle to camera position relative to target object.
  130031. * This can help limiting how the Camera is able to move in the scene.
  130032. */
  130033. upperRotationOffsetLimit: Nullable<number>;
  130034. /**
  130035. * Define a height offset between the camera and the object it follows.
  130036. * It can help following an object from the top (like a car chaing a plane)
  130037. */
  130038. heightOffset: number;
  130039. /**
  130040. * Minimum allowed height of camera position relative to target object.
  130041. * This can help limiting how the Camera is able to move in the scene.
  130042. */
  130043. lowerHeightOffsetLimit: Nullable<number>;
  130044. /**
  130045. * Maximum allowed height of camera position relative to target object.
  130046. * This can help limiting how the Camera is able to move in the scene.
  130047. */
  130048. upperHeightOffsetLimit: Nullable<number>;
  130049. /**
  130050. * Define how fast the camera can accelerate to follow it s target.
  130051. */
  130052. cameraAcceleration: number;
  130053. /**
  130054. * Define the speed limit of the camera following an object.
  130055. */
  130056. maxCameraSpeed: number;
  130057. /**
  130058. * Define the target of the camera.
  130059. */
  130060. lockedTarget: Nullable<AbstractMesh>;
  130061. /**
  130062. * Defines the input associated with the camera.
  130063. */
  130064. inputs: FollowCameraInputsManager;
  130065. /**
  130066. * Instantiates the follow camera.
  130067. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  130068. * @param name Define the name of the camera in the scene
  130069. * @param position Define the position of the camera
  130070. * @param scene Define the scene the camera belong to
  130071. * @param lockedTarget Define the target of the camera
  130072. */
  130073. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  130074. private _follow;
  130075. /**
  130076. * Attach the input controls to a specific dom element to get the input from.
  130077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  130078. */
  130079. attachControl(noPreventDefault?: boolean): void;
  130080. /**
  130081. * Detach the current controls from the specified dom element.
  130082. */
  130083. detachControl(): void;
  130084. /** @hidden */
  130085. _checkInputs(): void;
  130086. private _checkLimits;
  130087. /**
  130088. * Gets the camera class name.
  130089. * @returns the class name
  130090. */
  130091. getClassName(): string;
  130092. }
  130093. /**
  130094. * Arc Rotate version of the follow camera.
  130095. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  130096. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  130097. */
  130098. export class ArcFollowCamera extends TargetCamera {
  130099. /** The longitudinal angle of the camera */
  130100. alpha: number;
  130101. /** The latitudinal angle of the camera */
  130102. beta: number;
  130103. /** The radius of the camera from its target */
  130104. radius: number;
  130105. private _cartesianCoordinates;
  130106. /** Define the camera target (the mesh it should follow) */
  130107. private _meshTarget;
  130108. /**
  130109. * Instantiates a new ArcFollowCamera
  130110. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  130111. * @param name Define the name of the camera
  130112. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  130113. * @param beta Define the rotation angle of the camera around the elevation axis
  130114. * @param radius Define the radius of the camera from its target point
  130115. * @param target Define the target of the camera
  130116. * @param scene Define the scene the camera belongs to
  130117. */
  130118. constructor(name: string,
  130119. /** The longitudinal angle of the camera */
  130120. alpha: number,
  130121. /** The latitudinal angle of the camera */
  130122. beta: number,
  130123. /** The radius of the camera from its target */
  130124. radius: number,
  130125. /** Define the camera target (the mesh it should follow) */
  130126. target: Nullable<AbstractMesh>, scene: Scene);
  130127. private _follow;
  130128. /** @hidden */
  130129. _checkInputs(): void;
  130130. /**
  130131. * Returns the class name of the object.
  130132. * It is mostly used internally for serialization purposes.
  130133. */
  130134. getClassName(): string;
  130135. }
  130136. }
  130137. declare module BABYLON {
  130138. /**
  130139. * Manage the keyboard inputs to control the movement of a follow camera.
  130140. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130141. */
  130142. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  130143. /**
  130144. * Defines the camera the input is attached to.
  130145. */
  130146. camera: FollowCamera;
  130147. /**
  130148. * Defines the list of key codes associated with the up action (increase heightOffset)
  130149. */
  130150. keysHeightOffsetIncr: number[];
  130151. /**
  130152. * Defines the list of key codes associated with the down action (decrease heightOffset)
  130153. */
  130154. keysHeightOffsetDecr: number[];
  130155. /**
  130156. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  130157. */
  130158. keysHeightOffsetModifierAlt: boolean;
  130159. /**
  130160. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  130161. */
  130162. keysHeightOffsetModifierCtrl: boolean;
  130163. /**
  130164. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  130165. */
  130166. keysHeightOffsetModifierShift: boolean;
  130167. /**
  130168. * Defines the list of key codes associated with the left action (increase rotationOffset)
  130169. */
  130170. keysRotationOffsetIncr: number[];
  130171. /**
  130172. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  130173. */
  130174. keysRotationOffsetDecr: number[];
  130175. /**
  130176. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  130177. */
  130178. keysRotationOffsetModifierAlt: boolean;
  130179. /**
  130180. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  130181. */
  130182. keysRotationOffsetModifierCtrl: boolean;
  130183. /**
  130184. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  130185. */
  130186. keysRotationOffsetModifierShift: boolean;
  130187. /**
  130188. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  130189. */
  130190. keysRadiusIncr: number[];
  130191. /**
  130192. * Defines the list of key codes associated with the zoom-out action (increase radius)
  130193. */
  130194. keysRadiusDecr: number[];
  130195. /**
  130196. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  130197. */
  130198. keysRadiusModifierAlt: boolean;
  130199. /**
  130200. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  130201. */
  130202. keysRadiusModifierCtrl: boolean;
  130203. /**
  130204. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  130205. */
  130206. keysRadiusModifierShift: boolean;
  130207. /**
  130208. * Defines the rate of change of heightOffset.
  130209. */
  130210. heightSensibility: number;
  130211. /**
  130212. * Defines the rate of change of rotationOffset.
  130213. */
  130214. rotationSensibility: number;
  130215. /**
  130216. * Defines the rate of change of radius.
  130217. */
  130218. radiusSensibility: number;
  130219. private _keys;
  130220. private _ctrlPressed;
  130221. private _altPressed;
  130222. private _shiftPressed;
  130223. private _onCanvasBlurObserver;
  130224. private _onKeyboardObserver;
  130225. private _engine;
  130226. private _scene;
  130227. /**
  130228. * Attach the input controls to a specific dom element to get the input from.
  130229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  130230. */
  130231. attachControl(noPreventDefault?: boolean): void;
  130232. /**
  130233. * Detach the current controls from the specified dom element.
  130234. */
  130235. detachControl(): void;
  130236. /**
  130237. * Update the current camera state depending on the inputs that have been used this frame.
  130238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130239. */
  130240. checkInputs(): void;
  130241. /**
  130242. * Gets the class name of the current input.
  130243. * @returns the class name
  130244. */
  130245. getClassName(): string;
  130246. /**
  130247. * Get the friendly name associated with the input class.
  130248. * @returns the input friendly name
  130249. */
  130250. getSimpleName(): string;
  130251. /**
  130252. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130253. * allow modification of the heightOffset value.
  130254. */
  130255. private _modifierHeightOffset;
  130256. /**
  130257. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130258. * allow modification of the rotationOffset value.
  130259. */
  130260. private _modifierRotationOffset;
  130261. /**
  130262. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130263. * allow modification of the radius value.
  130264. */
  130265. private _modifierRadius;
  130266. }
  130267. }
  130268. declare module BABYLON {
  130269. interface FreeCameraInputsManager {
  130270. /**
  130271. * @hidden
  130272. */
  130273. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  130274. /**
  130275. * Add orientation input support to the input manager.
  130276. * @returns the current input manager
  130277. */
  130278. addDeviceOrientation(): FreeCameraInputsManager;
  130279. }
  130280. /**
  130281. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  130282. * Screen rotation is taken into account.
  130283. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130284. */
  130285. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  130286. private _camera;
  130287. private _screenOrientationAngle;
  130288. private _constantTranform;
  130289. private _screenQuaternion;
  130290. private _alpha;
  130291. private _beta;
  130292. private _gamma;
  130293. /**
  130294. * Can be used to detect if a device orientation sensor is available on a device
  130295. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  130296. * @returns a promise that will resolve on orientation change
  130297. */
  130298. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  130299. /**
  130300. * @hidden
  130301. */
  130302. _onDeviceOrientationChangedObservable: Observable<void>;
  130303. /**
  130304. * Instantiates a new input
  130305. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130306. */
  130307. constructor();
  130308. /**
  130309. * Define the camera controlled by the input.
  130310. */
  130311. get camera(): FreeCamera;
  130312. set camera(camera: FreeCamera);
  130313. /**
  130314. * Attach the input controls to a specific dom element to get the input from.
  130315. */
  130316. attachControl(): void;
  130317. private _orientationChanged;
  130318. private _deviceOrientation;
  130319. /**
  130320. * Detach the current controls from the specified dom element.
  130321. */
  130322. detachControl(): void;
  130323. /**
  130324. * Update the current camera state depending on the inputs that have been used this frame.
  130325. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130326. */
  130327. checkInputs(): void;
  130328. /**
  130329. * Gets the class name of the current intput.
  130330. * @returns the class name
  130331. */
  130332. getClassName(): string;
  130333. /**
  130334. * Get the friendly name associated with the input class.
  130335. * @returns the input friendly name
  130336. */
  130337. getSimpleName(): string;
  130338. }
  130339. }
  130340. declare module BABYLON {
  130341. /**
  130342. * Manage the gamepad inputs to control a free camera.
  130343. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130344. */
  130345. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  130346. /**
  130347. * Define the camera the input is attached to.
  130348. */
  130349. camera: FreeCamera;
  130350. /**
  130351. * Define the Gamepad controlling the input
  130352. */
  130353. gamepad: Nullable<Gamepad>;
  130354. /**
  130355. * Defines the gamepad rotation sensiblity.
  130356. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  130357. */
  130358. gamepadAngularSensibility: number;
  130359. /**
  130360. * Defines the gamepad move sensiblity.
  130361. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  130362. */
  130363. gamepadMoveSensibility: number;
  130364. private _yAxisScale;
  130365. /**
  130366. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  130367. */
  130368. get invertYAxis(): boolean;
  130369. set invertYAxis(value: boolean);
  130370. private _onGamepadConnectedObserver;
  130371. private _onGamepadDisconnectedObserver;
  130372. private _cameraTransform;
  130373. private _deltaTransform;
  130374. private _vector3;
  130375. private _vector2;
  130376. /**
  130377. * Attach the input controls to a specific dom element to get the input from.
  130378. */
  130379. attachControl(): void;
  130380. /**
  130381. * Detach the current controls from the specified dom element.
  130382. */
  130383. detachControl(): void;
  130384. /**
  130385. * Update the current camera state depending on the inputs that have been used this frame.
  130386. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130387. */
  130388. checkInputs(): void;
  130389. /**
  130390. * Gets the class name of the current intput.
  130391. * @returns the class name
  130392. */
  130393. getClassName(): string;
  130394. /**
  130395. * Get the friendly name associated with the input class.
  130396. * @returns the input friendly name
  130397. */
  130398. getSimpleName(): string;
  130399. }
  130400. }
  130401. declare module BABYLON {
  130402. /**
  130403. * Defines the potential axis of a Joystick
  130404. */
  130405. export enum JoystickAxis {
  130406. /** X axis */
  130407. X = 0,
  130408. /** Y axis */
  130409. Y = 1,
  130410. /** Z axis */
  130411. Z = 2
  130412. }
  130413. /**
  130414. * Represents the different customization options available
  130415. * for VirtualJoystick
  130416. */
  130417. interface VirtualJoystickCustomizations {
  130418. /**
  130419. * Size of the joystick's puck
  130420. */
  130421. puckSize: number;
  130422. /**
  130423. * Size of the joystick's container
  130424. */
  130425. containerSize: number;
  130426. /**
  130427. * Color of the joystick && puck
  130428. */
  130429. color: string;
  130430. /**
  130431. * Image URL for the joystick's puck
  130432. */
  130433. puckImage?: string;
  130434. /**
  130435. * Image URL for the joystick's container
  130436. */
  130437. containerImage?: string;
  130438. /**
  130439. * Defines the unmoving position of the joystick container
  130440. */
  130441. position?: {
  130442. x: number;
  130443. y: number;
  130444. };
  130445. /**
  130446. * Defines whether or not the joystick container is always visible
  130447. */
  130448. alwaysVisible: boolean;
  130449. /**
  130450. * Defines whether or not to limit the movement of the puck to the joystick's container
  130451. */
  130452. limitToContainer: boolean;
  130453. }
  130454. /**
  130455. * Class used to define virtual joystick (used in touch mode)
  130456. */
  130457. export class VirtualJoystick {
  130458. /**
  130459. * Gets or sets a boolean indicating that left and right values must be inverted
  130460. */
  130461. reverseLeftRight: boolean;
  130462. /**
  130463. * Gets or sets a boolean indicating that up and down values must be inverted
  130464. */
  130465. reverseUpDown: boolean;
  130466. /**
  130467. * Gets the offset value for the position (ie. the change of the position value)
  130468. */
  130469. deltaPosition: Vector3;
  130470. /**
  130471. * Gets a boolean indicating if the virtual joystick was pressed
  130472. */
  130473. pressed: boolean;
  130474. /**
  130475. * Canvas the virtual joystick will render onto, default z-index of this is 5
  130476. */
  130477. static Canvas: Nullable<HTMLCanvasElement>;
  130478. /**
  130479. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  130480. */
  130481. limitToContainer: boolean;
  130482. private static _globalJoystickIndex;
  130483. private static _alwaysVisibleSticks;
  130484. private static vjCanvasContext;
  130485. private static vjCanvasWidth;
  130486. private static vjCanvasHeight;
  130487. private static halfWidth;
  130488. private static _GetDefaultOptions;
  130489. private _action;
  130490. private _axisTargetedByLeftAndRight;
  130491. private _axisTargetedByUpAndDown;
  130492. private _joystickSensibility;
  130493. private _inversedSensibility;
  130494. private _joystickPointerID;
  130495. private _joystickColor;
  130496. private _joystickPointerPos;
  130497. private _joystickPreviousPointerPos;
  130498. private _joystickPointerStartPos;
  130499. private _deltaJoystickVector;
  130500. private _leftJoystick;
  130501. private _touches;
  130502. private _joystickPosition;
  130503. private _alwaysVisible;
  130504. private _puckImage;
  130505. private _containerImage;
  130506. private _joystickPuckSize;
  130507. private _joystickContainerSize;
  130508. private _clearPuckSize;
  130509. private _clearContainerSize;
  130510. private _clearPuckSizeOffset;
  130511. private _clearContainerSizeOffset;
  130512. private _onPointerDownHandlerRef;
  130513. private _onPointerMoveHandlerRef;
  130514. private _onPointerUpHandlerRef;
  130515. private _onResize;
  130516. /**
  130517. * Creates a new virtual joystick
  130518. * @param leftJoystick defines that the joystick is for left hand (false by default)
  130519. * @param customizations Defines the options we want to customize the VirtualJoystick
  130520. */
  130521. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  130522. /**
  130523. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  130524. * @param newJoystickSensibility defines the new sensibility
  130525. */
  130526. setJoystickSensibility(newJoystickSensibility: number): void;
  130527. private _onPointerDown;
  130528. private _onPointerMove;
  130529. private _onPointerUp;
  130530. /**
  130531. * Change the color of the virtual joystick
  130532. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  130533. */
  130534. setJoystickColor(newColor: string): void;
  130535. /**
  130536. * Size of the joystick's container
  130537. */
  130538. set containerSize(newSize: number);
  130539. get containerSize(): number;
  130540. /**
  130541. * Size of the joystick's puck
  130542. */
  130543. set puckSize(newSize: number);
  130544. get puckSize(): number;
  130545. /**
  130546. * Clears the set position of the joystick
  130547. */
  130548. clearPosition(): void;
  130549. /**
  130550. * Defines whether or not the joystick container is always visible
  130551. */
  130552. set alwaysVisible(value: boolean);
  130553. get alwaysVisible(): boolean;
  130554. /**
  130555. * Sets the constant position of the Joystick container
  130556. * @param x X axis coordinate
  130557. * @param y Y axis coordinate
  130558. */
  130559. setPosition(x: number, y: number): void;
  130560. /**
  130561. * Defines a callback to call when the joystick is touched
  130562. * @param action defines the callback
  130563. */
  130564. setActionOnTouch(action: () => any): void;
  130565. /**
  130566. * Defines which axis you'd like to control for left & right
  130567. * @param axis defines the axis to use
  130568. */
  130569. setAxisForLeftRight(axis: JoystickAxis): void;
  130570. /**
  130571. * Defines which axis you'd like to control for up & down
  130572. * @param axis defines the axis to use
  130573. */
  130574. setAxisForUpDown(axis: JoystickAxis): void;
  130575. /**
  130576. * Clears the canvas from the previous puck / container draw
  130577. */
  130578. private _clearPreviousDraw;
  130579. /**
  130580. * Loads `urlPath` to be used for the container's image
  130581. * @param urlPath defines the urlPath of an image to use
  130582. */
  130583. setContainerImage(urlPath: string): void;
  130584. /**
  130585. * Loads `urlPath` to be used for the puck's image
  130586. * @param urlPath defines the urlPath of an image to use
  130587. */
  130588. setPuckImage(urlPath: string): void;
  130589. /**
  130590. * Draws the Virtual Joystick's container
  130591. */
  130592. private _drawContainer;
  130593. /**
  130594. * Draws the Virtual Joystick's puck
  130595. */
  130596. private _drawPuck;
  130597. private _drawVirtualJoystick;
  130598. /**
  130599. * Release internal HTML canvas
  130600. */
  130601. releaseCanvas(): void;
  130602. }
  130603. }
  130604. declare module BABYLON {
  130605. interface FreeCameraInputsManager {
  130606. /**
  130607. * Add virtual joystick input support to the input manager.
  130608. * @returns the current input manager
  130609. */
  130610. addVirtualJoystick(): FreeCameraInputsManager;
  130611. }
  130612. /**
  130613. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  130614. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130615. */
  130616. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  130617. /**
  130618. * Defines the camera the input is attached to.
  130619. */
  130620. camera: FreeCamera;
  130621. private _leftjoystick;
  130622. private _rightjoystick;
  130623. /**
  130624. * Gets the left stick of the virtual joystick.
  130625. * @returns The virtual Joystick
  130626. */
  130627. getLeftJoystick(): VirtualJoystick;
  130628. /**
  130629. * Gets the right stick of the virtual joystick.
  130630. * @returns The virtual Joystick
  130631. */
  130632. getRightJoystick(): VirtualJoystick;
  130633. /**
  130634. * Update the current camera state depending on the inputs that have been used this frame.
  130635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130636. */
  130637. checkInputs(): void;
  130638. /**
  130639. * Attach the input controls to a specific dom element to get the input from.
  130640. */
  130641. attachControl(): void;
  130642. /**
  130643. * Detach the current controls from the specified dom element.
  130644. */
  130645. detachControl(): void;
  130646. /**
  130647. * Gets the class name of the current intput.
  130648. * @returns the class name
  130649. */
  130650. getClassName(): string;
  130651. /**
  130652. * Get the friendly name associated with the input class.
  130653. * @returns the input friendly name
  130654. */
  130655. getSimpleName(): string;
  130656. }
  130657. }
  130658. declare module BABYLON {
  130659. /**
  130660. * This represents a FPS type of camera controlled by touch.
  130661. * This is like a universal camera minus the Gamepad controls.
  130662. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130663. */
  130664. export class TouchCamera extends FreeCamera {
  130665. /**
  130666. * Defines the touch sensibility for rotation.
  130667. * The higher the faster.
  130668. */
  130669. get touchAngularSensibility(): number;
  130670. set touchAngularSensibility(value: number);
  130671. /**
  130672. * Defines the touch sensibility for move.
  130673. * The higher the faster.
  130674. */
  130675. get touchMoveSensibility(): number;
  130676. set touchMoveSensibility(value: number);
  130677. /**
  130678. * Instantiates a new touch camera.
  130679. * This represents a FPS type of camera controlled by touch.
  130680. * This is like a universal camera minus the Gamepad controls.
  130681. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130682. * @param name Define the name of the camera in the scene
  130683. * @param position Define the start position of the camera in the scene
  130684. * @param scene Define the scene the camera belongs to
  130685. */
  130686. constructor(name: string, position: Vector3, scene: Scene);
  130687. /**
  130688. * Gets the current object class name.
  130689. * @return the class name
  130690. */
  130691. getClassName(): string;
  130692. /** @hidden */
  130693. _setupInputs(): void;
  130694. }
  130695. }
  130696. declare module BABYLON {
  130697. /**
  130698. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  130699. * being tilted forward or back and left or right.
  130700. */
  130701. export class DeviceOrientationCamera extends FreeCamera {
  130702. private _initialQuaternion;
  130703. private _quaternionCache;
  130704. private _tmpDragQuaternion;
  130705. private _disablePointerInputWhenUsingDeviceOrientation;
  130706. /**
  130707. * Creates a new device orientation camera
  130708. * @param name The name of the camera
  130709. * @param position The start position camera
  130710. * @param scene The scene the camera belongs to
  130711. */
  130712. constructor(name: string, position: Vector3, scene: Scene);
  130713. /**
  130714. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  130715. */
  130716. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  130717. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  130718. private _dragFactor;
  130719. /**
  130720. * Enabled turning on the y axis when the orientation sensor is active
  130721. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  130722. */
  130723. enableHorizontalDragging(dragFactor?: number): void;
  130724. /**
  130725. * Gets the current instance class name ("DeviceOrientationCamera").
  130726. * This helps avoiding instanceof at run time.
  130727. * @returns the class name
  130728. */
  130729. getClassName(): string;
  130730. /**
  130731. * @hidden
  130732. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  130733. */
  130734. _checkInputs(): void;
  130735. /**
  130736. * Reset the camera to its default orientation on the specified axis only.
  130737. * @param axis The axis to reset
  130738. */
  130739. resetToCurrentRotation(axis?: Axis): void;
  130740. }
  130741. }
  130742. declare module BABYLON {
  130743. /**
  130744. * Defines supported buttons for XBox360 compatible gamepads
  130745. */
  130746. export enum Xbox360Button {
  130747. /** A */
  130748. A = 0,
  130749. /** B */
  130750. B = 1,
  130751. /** X */
  130752. X = 2,
  130753. /** Y */
  130754. Y = 3,
  130755. /** Left button */
  130756. LB = 4,
  130757. /** Right button */
  130758. RB = 5,
  130759. /** Back */
  130760. Back = 8,
  130761. /** Start */
  130762. Start = 9,
  130763. /** Left stick */
  130764. LeftStick = 10,
  130765. /** Right stick */
  130766. RightStick = 11
  130767. }
  130768. /** Defines values for XBox360 DPad */
  130769. export enum Xbox360Dpad {
  130770. /** Up */
  130771. Up = 12,
  130772. /** Down */
  130773. Down = 13,
  130774. /** Left */
  130775. Left = 14,
  130776. /** Right */
  130777. Right = 15
  130778. }
  130779. /**
  130780. * Defines a XBox360 gamepad
  130781. */
  130782. export class Xbox360Pad extends Gamepad {
  130783. private _leftTrigger;
  130784. private _rightTrigger;
  130785. private _onlefttriggerchanged;
  130786. private _onrighttriggerchanged;
  130787. private _onbuttondown;
  130788. private _onbuttonup;
  130789. private _ondpaddown;
  130790. private _ondpadup;
  130791. /** Observable raised when a button is pressed */
  130792. onButtonDownObservable: Observable<Xbox360Button>;
  130793. /** Observable raised when a button is released */
  130794. onButtonUpObservable: Observable<Xbox360Button>;
  130795. /** Observable raised when a pad is pressed */
  130796. onPadDownObservable: Observable<Xbox360Dpad>;
  130797. /** Observable raised when a pad is released */
  130798. onPadUpObservable: Observable<Xbox360Dpad>;
  130799. private _buttonA;
  130800. private _buttonB;
  130801. private _buttonX;
  130802. private _buttonY;
  130803. private _buttonBack;
  130804. private _buttonStart;
  130805. private _buttonLB;
  130806. private _buttonRB;
  130807. private _buttonLeftStick;
  130808. private _buttonRightStick;
  130809. private _dPadUp;
  130810. private _dPadDown;
  130811. private _dPadLeft;
  130812. private _dPadRight;
  130813. private _isXboxOnePad;
  130814. /**
  130815. * Creates a new XBox360 gamepad object
  130816. * @param id defines the id of this gamepad
  130817. * @param index defines its index
  130818. * @param gamepad defines the internal HTML gamepad object
  130819. * @param xboxOne defines if it is a XBox One gamepad
  130820. */
  130821. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  130822. /**
  130823. * Defines the callback to call when left trigger is pressed
  130824. * @param callback defines the callback to use
  130825. */
  130826. onlefttriggerchanged(callback: (value: number) => void): void;
  130827. /**
  130828. * Defines the callback to call when right trigger is pressed
  130829. * @param callback defines the callback to use
  130830. */
  130831. onrighttriggerchanged(callback: (value: number) => void): void;
  130832. /**
  130833. * Gets the left trigger value
  130834. */
  130835. get leftTrigger(): number;
  130836. /**
  130837. * Sets the left trigger value
  130838. */
  130839. set leftTrigger(newValue: number);
  130840. /**
  130841. * Gets the right trigger value
  130842. */
  130843. get rightTrigger(): number;
  130844. /**
  130845. * Sets the right trigger value
  130846. */
  130847. set rightTrigger(newValue: number);
  130848. /**
  130849. * Defines the callback to call when a button is pressed
  130850. * @param callback defines the callback to use
  130851. */
  130852. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  130853. /**
  130854. * Defines the callback to call when a button is released
  130855. * @param callback defines the callback to use
  130856. */
  130857. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  130858. /**
  130859. * Defines the callback to call when a pad is pressed
  130860. * @param callback defines the callback to use
  130861. */
  130862. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  130863. /**
  130864. * Defines the callback to call when a pad is released
  130865. * @param callback defines the callback to use
  130866. */
  130867. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  130868. private _setButtonValue;
  130869. private _setDPadValue;
  130870. /**
  130871. * Gets the value of the `A` button
  130872. */
  130873. get buttonA(): number;
  130874. /**
  130875. * Sets the value of the `A` button
  130876. */
  130877. set buttonA(value: number);
  130878. /**
  130879. * Gets the value of the `B` button
  130880. */
  130881. get buttonB(): number;
  130882. /**
  130883. * Sets the value of the `B` button
  130884. */
  130885. set buttonB(value: number);
  130886. /**
  130887. * Gets the value of the `X` button
  130888. */
  130889. get buttonX(): number;
  130890. /**
  130891. * Sets the value of the `X` button
  130892. */
  130893. set buttonX(value: number);
  130894. /**
  130895. * Gets the value of the `Y` button
  130896. */
  130897. get buttonY(): number;
  130898. /**
  130899. * Sets the value of the `Y` button
  130900. */
  130901. set buttonY(value: number);
  130902. /**
  130903. * Gets the value of the `Start` button
  130904. */
  130905. get buttonStart(): number;
  130906. /**
  130907. * Sets the value of the `Start` button
  130908. */
  130909. set buttonStart(value: number);
  130910. /**
  130911. * Gets the value of the `Back` button
  130912. */
  130913. get buttonBack(): number;
  130914. /**
  130915. * Sets the value of the `Back` button
  130916. */
  130917. set buttonBack(value: number);
  130918. /**
  130919. * Gets the value of the `Left` button
  130920. */
  130921. get buttonLB(): number;
  130922. /**
  130923. * Sets the value of the `Left` button
  130924. */
  130925. set buttonLB(value: number);
  130926. /**
  130927. * Gets the value of the `Right` button
  130928. */
  130929. get buttonRB(): number;
  130930. /**
  130931. * Sets the value of the `Right` button
  130932. */
  130933. set buttonRB(value: number);
  130934. /**
  130935. * Gets the value of the Left joystick
  130936. */
  130937. get buttonLeftStick(): number;
  130938. /**
  130939. * Sets the value of the Left joystick
  130940. */
  130941. set buttonLeftStick(value: number);
  130942. /**
  130943. * Gets the value of the Right joystick
  130944. */
  130945. get buttonRightStick(): number;
  130946. /**
  130947. * Sets the value of the Right joystick
  130948. */
  130949. set buttonRightStick(value: number);
  130950. /**
  130951. * Gets the value of D-pad up
  130952. */
  130953. get dPadUp(): number;
  130954. /**
  130955. * Sets the value of D-pad up
  130956. */
  130957. set dPadUp(value: number);
  130958. /**
  130959. * Gets the value of D-pad down
  130960. */
  130961. get dPadDown(): number;
  130962. /**
  130963. * Sets the value of D-pad down
  130964. */
  130965. set dPadDown(value: number);
  130966. /**
  130967. * Gets the value of D-pad left
  130968. */
  130969. get dPadLeft(): number;
  130970. /**
  130971. * Sets the value of D-pad left
  130972. */
  130973. set dPadLeft(value: number);
  130974. /**
  130975. * Gets the value of D-pad right
  130976. */
  130977. get dPadRight(): number;
  130978. /**
  130979. * Sets the value of D-pad right
  130980. */
  130981. set dPadRight(value: number);
  130982. /**
  130983. * Force the gamepad to synchronize with device values
  130984. */
  130985. update(): void;
  130986. /**
  130987. * Disposes the gamepad
  130988. */
  130989. dispose(): void;
  130990. }
  130991. }
  130992. declare module BABYLON {
  130993. /**
  130994. * Defines supported buttons for DualShock compatible gamepads
  130995. */
  130996. export enum DualShockButton {
  130997. /** Cross */
  130998. Cross = 0,
  130999. /** Circle */
  131000. Circle = 1,
  131001. /** Square */
  131002. Square = 2,
  131003. /** Triangle */
  131004. Triangle = 3,
  131005. /** L1 */
  131006. L1 = 4,
  131007. /** R1 */
  131008. R1 = 5,
  131009. /** Share */
  131010. Share = 8,
  131011. /** Options */
  131012. Options = 9,
  131013. /** Left stick */
  131014. LeftStick = 10,
  131015. /** Right stick */
  131016. RightStick = 11
  131017. }
  131018. /** Defines values for DualShock DPad */
  131019. export enum DualShockDpad {
  131020. /** Up */
  131021. Up = 12,
  131022. /** Down */
  131023. Down = 13,
  131024. /** Left */
  131025. Left = 14,
  131026. /** Right */
  131027. Right = 15
  131028. }
  131029. /**
  131030. * Defines a DualShock gamepad
  131031. */
  131032. export class DualShockPad extends Gamepad {
  131033. private _leftTrigger;
  131034. private _rightTrigger;
  131035. private _onlefttriggerchanged;
  131036. private _onrighttriggerchanged;
  131037. private _onbuttondown;
  131038. private _onbuttonup;
  131039. private _ondpaddown;
  131040. private _ondpadup;
  131041. /** Observable raised when a button is pressed */
  131042. onButtonDownObservable: Observable<DualShockButton>;
  131043. /** Observable raised when a button is released */
  131044. onButtonUpObservable: Observable<DualShockButton>;
  131045. /** Observable raised when a pad is pressed */
  131046. onPadDownObservable: Observable<DualShockDpad>;
  131047. /** Observable raised when a pad is released */
  131048. onPadUpObservable: Observable<DualShockDpad>;
  131049. private _buttonCross;
  131050. private _buttonCircle;
  131051. private _buttonSquare;
  131052. private _buttonTriangle;
  131053. private _buttonShare;
  131054. private _buttonOptions;
  131055. private _buttonL1;
  131056. private _buttonR1;
  131057. private _buttonLeftStick;
  131058. private _buttonRightStick;
  131059. private _dPadUp;
  131060. private _dPadDown;
  131061. private _dPadLeft;
  131062. private _dPadRight;
  131063. /**
  131064. * Creates a new DualShock gamepad object
  131065. * @param id defines the id of this gamepad
  131066. * @param index defines its index
  131067. * @param gamepad defines the internal HTML gamepad object
  131068. */
  131069. constructor(id: string, index: number, gamepad: any);
  131070. /**
  131071. * Defines the callback to call when left trigger is pressed
  131072. * @param callback defines the callback to use
  131073. */
  131074. onlefttriggerchanged(callback: (value: number) => void): void;
  131075. /**
  131076. * Defines the callback to call when right trigger is pressed
  131077. * @param callback defines the callback to use
  131078. */
  131079. onrighttriggerchanged(callback: (value: number) => void): void;
  131080. /**
  131081. * Gets the left trigger value
  131082. */
  131083. get leftTrigger(): number;
  131084. /**
  131085. * Sets the left trigger value
  131086. */
  131087. set leftTrigger(newValue: number);
  131088. /**
  131089. * Gets the right trigger value
  131090. */
  131091. get rightTrigger(): number;
  131092. /**
  131093. * Sets the right trigger value
  131094. */
  131095. set rightTrigger(newValue: number);
  131096. /**
  131097. * Defines the callback to call when a button is pressed
  131098. * @param callback defines the callback to use
  131099. */
  131100. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  131101. /**
  131102. * Defines the callback to call when a button is released
  131103. * @param callback defines the callback to use
  131104. */
  131105. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  131106. /**
  131107. * Defines the callback to call when a pad is pressed
  131108. * @param callback defines the callback to use
  131109. */
  131110. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  131111. /**
  131112. * Defines the callback to call when a pad is released
  131113. * @param callback defines the callback to use
  131114. */
  131115. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  131116. private _setButtonValue;
  131117. private _setDPadValue;
  131118. /**
  131119. * Gets the value of the `Cross` button
  131120. */
  131121. get buttonCross(): number;
  131122. /**
  131123. * Sets the value of the `Cross` button
  131124. */
  131125. set buttonCross(value: number);
  131126. /**
  131127. * Gets the value of the `Circle` button
  131128. */
  131129. get buttonCircle(): number;
  131130. /**
  131131. * Sets the value of the `Circle` button
  131132. */
  131133. set buttonCircle(value: number);
  131134. /**
  131135. * Gets the value of the `Square` button
  131136. */
  131137. get buttonSquare(): number;
  131138. /**
  131139. * Sets the value of the `Square` button
  131140. */
  131141. set buttonSquare(value: number);
  131142. /**
  131143. * Gets the value of the `Triangle` button
  131144. */
  131145. get buttonTriangle(): number;
  131146. /**
  131147. * Sets the value of the `Triangle` button
  131148. */
  131149. set buttonTriangle(value: number);
  131150. /**
  131151. * Gets the value of the `Options` button
  131152. */
  131153. get buttonOptions(): number;
  131154. /**
  131155. * Sets the value of the `Options` button
  131156. */
  131157. set buttonOptions(value: number);
  131158. /**
  131159. * Gets the value of the `Share` button
  131160. */
  131161. get buttonShare(): number;
  131162. /**
  131163. * Sets the value of the `Share` button
  131164. */
  131165. set buttonShare(value: number);
  131166. /**
  131167. * Gets the value of the `L1` button
  131168. */
  131169. get buttonL1(): number;
  131170. /**
  131171. * Sets the value of the `L1` button
  131172. */
  131173. set buttonL1(value: number);
  131174. /**
  131175. * Gets the value of the `R1` button
  131176. */
  131177. get buttonR1(): number;
  131178. /**
  131179. * Sets the value of the `R1` button
  131180. */
  131181. set buttonR1(value: number);
  131182. /**
  131183. * Gets the value of the Left joystick
  131184. */
  131185. get buttonLeftStick(): number;
  131186. /**
  131187. * Sets the value of the Left joystick
  131188. */
  131189. set buttonLeftStick(value: number);
  131190. /**
  131191. * Gets the value of the Right joystick
  131192. */
  131193. get buttonRightStick(): number;
  131194. /**
  131195. * Sets the value of the Right joystick
  131196. */
  131197. set buttonRightStick(value: number);
  131198. /**
  131199. * Gets the value of D-pad up
  131200. */
  131201. get dPadUp(): number;
  131202. /**
  131203. * Sets the value of D-pad up
  131204. */
  131205. set dPadUp(value: number);
  131206. /**
  131207. * Gets the value of D-pad down
  131208. */
  131209. get dPadDown(): number;
  131210. /**
  131211. * Sets the value of D-pad down
  131212. */
  131213. set dPadDown(value: number);
  131214. /**
  131215. * Gets the value of D-pad left
  131216. */
  131217. get dPadLeft(): number;
  131218. /**
  131219. * Sets the value of D-pad left
  131220. */
  131221. set dPadLeft(value: number);
  131222. /**
  131223. * Gets the value of D-pad right
  131224. */
  131225. get dPadRight(): number;
  131226. /**
  131227. * Sets the value of D-pad right
  131228. */
  131229. set dPadRight(value: number);
  131230. /**
  131231. * Force the gamepad to synchronize with device values
  131232. */
  131233. update(): void;
  131234. /**
  131235. * Disposes the gamepad
  131236. */
  131237. dispose(): void;
  131238. }
  131239. }
  131240. declare module BABYLON {
  131241. /**
  131242. * Manager for handling gamepads
  131243. */
  131244. export class GamepadManager {
  131245. private _scene?;
  131246. private _babylonGamepads;
  131247. private _oneGamepadConnected;
  131248. /** @hidden */
  131249. _isMonitoring: boolean;
  131250. private _gamepadEventSupported;
  131251. private _gamepadSupport?;
  131252. /**
  131253. * observable to be triggered when the gamepad controller has been connected
  131254. */
  131255. onGamepadConnectedObservable: Observable<Gamepad>;
  131256. /**
  131257. * observable to be triggered when the gamepad controller has been disconnected
  131258. */
  131259. onGamepadDisconnectedObservable: Observable<Gamepad>;
  131260. private _onGamepadConnectedEvent;
  131261. private _onGamepadDisconnectedEvent;
  131262. /**
  131263. * Initializes the gamepad manager
  131264. * @param _scene BabylonJS scene
  131265. */
  131266. constructor(_scene?: Scene | undefined);
  131267. /**
  131268. * The gamepads in the game pad manager
  131269. */
  131270. get gamepads(): Gamepad[];
  131271. /**
  131272. * Get the gamepad controllers based on type
  131273. * @param type The type of gamepad controller
  131274. * @returns Nullable gamepad
  131275. */
  131276. getGamepadByType(type?: number): Nullable<Gamepad>;
  131277. /**
  131278. * Disposes the gamepad manager
  131279. */
  131280. dispose(): void;
  131281. private _addNewGamepad;
  131282. private _startMonitoringGamepads;
  131283. private _stopMonitoringGamepads;
  131284. /** @hidden */
  131285. _checkGamepadsStatus(): void;
  131286. private _updateGamepadObjects;
  131287. }
  131288. }
  131289. declare module BABYLON {
  131290. interface Scene {
  131291. /** @hidden */
  131292. _gamepadManager: Nullable<GamepadManager>;
  131293. /**
  131294. * Gets the gamepad manager associated with the scene
  131295. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  131296. */
  131297. gamepadManager: GamepadManager;
  131298. }
  131299. /**
  131300. * Interface representing a free camera inputs manager
  131301. */
  131302. interface FreeCameraInputsManager {
  131303. /**
  131304. * Adds gamepad input support to the FreeCameraInputsManager.
  131305. * @returns the FreeCameraInputsManager
  131306. */
  131307. addGamepad(): FreeCameraInputsManager;
  131308. }
  131309. /**
  131310. * Interface representing an arc rotate camera inputs manager
  131311. */
  131312. interface ArcRotateCameraInputsManager {
  131313. /**
  131314. * Adds gamepad input support to the ArcRotateCamera InputManager.
  131315. * @returns the camera inputs manager
  131316. */
  131317. addGamepad(): ArcRotateCameraInputsManager;
  131318. }
  131319. /**
  131320. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  131321. */
  131322. export class GamepadSystemSceneComponent implements ISceneComponent {
  131323. /**
  131324. * The component name helpfull to identify the component in the list of scene components.
  131325. */
  131326. readonly name: string;
  131327. /**
  131328. * The scene the component belongs to.
  131329. */
  131330. scene: Scene;
  131331. /**
  131332. * Creates a new instance of the component for the given scene
  131333. * @param scene Defines the scene to register the component in
  131334. */
  131335. constructor(scene: Scene);
  131336. /**
  131337. * Registers the component in a given scene
  131338. */
  131339. register(): void;
  131340. /**
  131341. * Rebuilds the elements related to this component in case of
  131342. * context lost for instance.
  131343. */
  131344. rebuild(): void;
  131345. /**
  131346. * Disposes the component and the associated ressources
  131347. */
  131348. dispose(): void;
  131349. private _beforeCameraUpdate;
  131350. }
  131351. }
  131352. declare module BABYLON {
  131353. /**
  131354. * 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,
  131355. * which still works and will still be found in many Playgrounds.
  131356. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131357. */
  131358. export class UniversalCamera extends TouchCamera {
  131359. /**
  131360. * Defines the gamepad rotation sensiblity.
  131361. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  131362. */
  131363. get gamepadAngularSensibility(): number;
  131364. set gamepadAngularSensibility(value: number);
  131365. /**
  131366. * Defines the gamepad move sensiblity.
  131367. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  131368. */
  131369. get gamepadMoveSensibility(): number;
  131370. set gamepadMoveSensibility(value: number);
  131371. /**
  131372. * 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,
  131373. * which still works and will still be found in many Playgrounds.
  131374. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131375. * @param name Define the name of the camera in the scene
  131376. * @param position Define the start position of the camera in the scene
  131377. * @param scene Define the scene the camera belongs to
  131378. */
  131379. constructor(name: string, position: Vector3, scene: Scene);
  131380. /**
  131381. * Gets the current object class name.
  131382. * @return the class name
  131383. */
  131384. getClassName(): string;
  131385. }
  131386. }
  131387. declare module BABYLON {
  131388. /**
  131389. * This represents a FPS type of camera. This is only here for back compat purpose.
  131390. * Please use the UniversalCamera instead as both are identical.
  131391. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131392. */
  131393. export class GamepadCamera extends UniversalCamera {
  131394. /**
  131395. * Instantiates a new Gamepad Camera
  131396. * This represents a FPS type of camera. This is only here for back compat purpose.
  131397. * Please use the UniversalCamera instead as both are identical.
  131398. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131399. * @param name Define the name of the camera in the scene
  131400. * @param position Define the start position of the camera in the scene
  131401. * @param scene Define the scene the camera belongs to
  131402. */
  131403. constructor(name: string, position: Vector3, scene: Scene);
  131404. /**
  131405. * Gets the current object class name.
  131406. * @return the class name
  131407. */
  131408. getClassName(): string;
  131409. }
  131410. }
  131411. declare module BABYLON {
  131412. /** @hidden */
  131413. export var passPixelShader: {
  131414. name: string;
  131415. shader: string;
  131416. };
  131417. }
  131418. declare module BABYLON {
  131419. /** @hidden */
  131420. export var passCubePixelShader: {
  131421. name: string;
  131422. shader: string;
  131423. };
  131424. }
  131425. declare module BABYLON {
  131426. /**
  131427. * PassPostProcess which produces an output the same as it's input
  131428. */
  131429. export class PassPostProcess extends PostProcess {
  131430. /**
  131431. * Gets a string identifying the name of the class
  131432. * @returns "PassPostProcess" string
  131433. */
  131434. getClassName(): string;
  131435. /**
  131436. * Creates the PassPostProcess
  131437. * @param name The name of the effect.
  131438. * @param options The required width/height ratio to downsize to before computing the render pass.
  131439. * @param camera The camera to apply the render pass to.
  131440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131441. * @param engine The engine which the post process will be applied. (default: current engine)
  131442. * @param reusable If the post process can be reused on the same frame. (default: false)
  131443. * @param textureType The type of texture to be used when performing the post processing.
  131444. * @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)
  131445. */
  131446. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131447. /** @hidden */
  131448. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  131449. }
  131450. /**
  131451. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  131452. */
  131453. export class PassCubePostProcess extends PostProcess {
  131454. private _face;
  131455. /**
  131456. * Gets or sets the cube face to display.
  131457. * * 0 is +X
  131458. * * 1 is -X
  131459. * * 2 is +Y
  131460. * * 3 is -Y
  131461. * * 4 is +Z
  131462. * * 5 is -Z
  131463. */
  131464. get face(): number;
  131465. set face(value: number);
  131466. /**
  131467. * Gets a string identifying the name of the class
  131468. * @returns "PassCubePostProcess" string
  131469. */
  131470. getClassName(): string;
  131471. /**
  131472. * Creates the PassCubePostProcess
  131473. * @param name The name of the effect.
  131474. * @param options The required width/height ratio to downsize to before computing the render pass.
  131475. * @param camera The camera to apply the render pass to.
  131476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131477. * @param engine The engine which the post process will be applied. (default: current engine)
  131478. * @param reusable If the post process can be reused on the same frame. (default: false)
  131479. * @param textureType The type of texture to be used when performing the post processing.
  131480. * @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)
  131481. */
  131482. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131483. /** @hidden */
  131484. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  131485. }
  131486. }
  131487. declare module BABYLON {
  131488. /** @hidden */
  131489. export var anaglyphPixelShader: {
  131490. name: string;
  131491. shader: string;
  131492. };
  131493. }
  131494. declare module BABYLON {
  131495. /**
  131496. * Postprocess used to generate anaglyphic rendering
  131497. */
  131498. export class AnaglyphPostProcess extends PostProcess {
  131499. private _passedProcess;
  131500. /**
  131501. * Gets a string identifying the name of the class
  131502. * @returns "AnaglyphPostProcess" string
  131503. */
  131504. getClassName(): string;
  131505. /**
  131506. * Creates a new AnaglyphPostProcess
  131507. * @param name defines postprocess name
  131508. * @param options defines creation options or target ratio scale
  131509. * @param rigCameras defines cameras using this postprocess
  131510. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  131511. * @param engine defines hosting engine
  131512. * @param reusable defines if the postprocess will be reused multiple times per frame
  131513. */
  131514. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  131515. }
  131516. }
  131517. declare module BABYLON {
  131518. /**
  131519. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  131520. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131521. */
  131522. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  131523. /**
  131524. * Creates a new AnaglyphArcRotateCamera
  131525. * @param name defines camera name
  131526. * @param alpha defines alpha angle (in radians)
  131527. * @param beta defines beta angle (in radians)
  131528. * @param radius defines radius
  131529. * @param target defines camera target
  131530. * @param interaxialDistance defines distance between each color axis
  131531. * @param scene defines the hosting scene
  131532. */
  131533. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  131534. /**
  131535. * Gets camera class name
  131536. * @returns AnaglyphArcRotateCamera
  131537. */
  131538. getClassName(): string;
  131539. }
  131540. }
  131541. declare module BABYLON {
  131542. /**
  131543. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  131544. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131545. */
  131546. export class AnaglyphFreeCamera extends FreeCamera {
  131547. /**
  131548. * Creates a new AnaglyphFreeCamera
  131549. * @param name defines camera name
  131550. * @param position defines initial position
  131551. * @param interaxialDistance defines distance between each color axis
  131552. * @param scene defines the hosting scene
  131553. */
  131554. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131555. /**
  131556. * Gets camera class name
  131557. * @returns AnaglyphFreeCamera
  131558. */
  131559. getClassName(): string;
  131560. }
  131561. }
  131562. declare module BABYLON {
  131563. /**
  131564. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  131565. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131566. */
  131567. export class AnaglyphGamepadCamera extends GamepadCamera {
  131568. /**
  131569. * Creates a new AnaglyphGamepadCamera
  131570. * @param name defines camera name
  131571. * @param position defines initial position
  131572. * @param interaxialDistance defines distance between each color axis
  131573. * @param scene defines the hosting scene
  131574. */
  131575. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131576. /**
  131577. * Gets camera class name
  131578. * @returns AnaglyphGamepadCamera
  131579. */
  131580. getClassName(): string;
  131581. }
  131582. }
  131583. declare module BABYLON {
  131584. /**
  131585. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  131586. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131587. */
  131588. export class AnaglyphUniversalCamera extends UniversalCamera {
  131589. /**
  131590. * Creates a new AnaglyphUniversalCamera
  131591. * @param name defines camera name
  131592. * @param position defines initial position
  131593. * @param interaxialDistance defines distance between each color axis
  131594. * @param scene defines the hosting scene
  131595. */
  131596. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131597. /**
  131598. * Gets camera class name
  131599. * @returns AnaglyphUniversalCamera
  131600. */
  131601. getClassName(): string;
  131602. }
  131603. }
  131604. declare module BABYLON {
  131605. /**
  131606. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  131607. * @see https://doc.babylonjs.com/features/cameras
  131608. */
  131609. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  131610. /**
  131611. * Creates a new StereoscopicArcRotateCamera
  131612. * @param name defines camera name
  131613. * @param alpha defines alpha angle (in radians)
  131614. * @param beta defines beta angle (in radians)
  131615. * @param radius defines radius
  131616. * @param target defines camera target
  131617. * @param interaxialDistance defines distance between each color axis
  131618. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131619. * @param scene defines the hosting scene
  131620. */
  131621. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131622. /**
  131623. * Gets camera class name
  131624. * @returns StereoscopicArcRotateCamera
  131625. */
  131626. getClassName(): string;
  131627. }
  131628. }
  131629. declare module BABYLON {
  131630. /**
  131631. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  131632. * @see https://doc.babylonjs.com/features/cameras
  131633. */
  131634. export class StereoscopicFreeCamera extends FreeCamera {
  131635. /**
  131636. * Creates a new StereoscopicFreeCamera
  131637. * @param name defines camera name
  131638. * @param position defines initial position
  131639. * @param interaxialDistance defines distance between each color axis
  131640. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131641. * @param scene defines the hosting scene
  131642. */
  131643. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131644. /**
  131645. * Gets camera class name
  131646. * @returns StereoscopicFreeCamera
  131647. */
  131648. getClassName(): string;
  131649. }
  131650. }
  131651. declare module BABYLON {
  131652. /**
  131653. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  131654. * @see https://doc.babylonjs.com/features/cameras
  131655. */
  131656. export class StereoscopicGamepadCamera extends GamepadCamera {
  131657. /**
  131658. * Creates a new StereoscopicGamepadCamera
  131659. * @param name defines camera name
  131660. * @param position defines initial position
  131661. * @param interaxialDistance defines distance between each color axis
  131662. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131663. * @param scene defines the hosting scene
  131664. */
  131665. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131666. /**
  131667. * Gets camera class name
  131668. * @returns StereoscopicGamepadCamera
  131669. */
  131670. getClassName(): string;
  131671. }
  131672. }
  131673. declare module BABYLON {
  131674. /**
  131675. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  131676. * @see https://doc.babylonjs.com/features/cameras
  131677. */
  131678. export class StereoscopicUniversalCamera extends UniversalCamera {
  131679. /**
  131680. * Creates a new StereoscopicUniversalCamera
  131681. * @param name defines camera name
  131682. * @param position defines initial position
  131683. * @param interaxialDistance defines distance between each color axis
  131684. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131685. * @param scene defines the hosting scene
  131686. */
  131687. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131688. /**
  131689. * Gets camera class name
  131690. * @returns StereoscopicUniversalCamera
  131691. */
  131692. getClassName(): string;
  131693. }
  131694. }
  131695. declare module BABYLON {
  131696. /**
  131697. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  131698. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131699. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131700. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131701. */
  131702. export class VirtualJoysticksCamera extends FreeCamera {
  131703. /**
  131704. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  131705. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131706. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131707. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131708. * @param name Define the name of the camera in the scene
  131709. * @param position Define the start position of the camera in the scene
  131710. * @param scene Define the scene the camera belongs to
  131711. */
  131712. constructor(name: string, position: Vector3, scene: Scene);
  131713. /**
  131714. * Gets the current object class name.
  131715. * @return the class name
  131716. */
  131717. getClassName(): string;
  131718. }
  131719. }
  131720. declare module BABYLON {
  131721. /**
  131722. * This represents all the required metrics to create a VR camera.
  131723. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  131724. */
  131725. export class VRCameraMetrics {
  131726. /**
  131727. * Define the horizontal resolution off the screen.
  131728. */
  131729. hResolution: number;
  131730. /**
  131731. * Define the vertical resolution off the screen.
  131732. */
  131733. vResolution: number;
  131734. /**
  131735. * Define the horizontal screen size.
  131736. */
  131737. hScreenSize: number;
  131738. /**
  131739. * Define the vertical screen size.
  131740. */
  131741. vScreenSize: number;
  131742. /**
  131743. * Define the vertical screen center position.
  131744. */
  131745. vScreenCenter: number;
  131746. /**
  131747. * Define the distance of the eyes to the screen.
  131748. */
  131749. eyeToScreenDistance: number;
  131750. /**
  131751. * Define the distance between both lenses
  131752. */
  131753. lensSeparationDistance: number;
  131754. /**
  131755. * Define the distance between both viewer's eyes.
  131756. */
  131757. interpupillaryDistance: number;
  131758. /**
  131759. * Define the distortion factor of the VR postprocess.
  131760. * Please, touch with care.
  131761. */
  131762. distortionK: number[];
  131763. /**
  131764. * Define the chromatic aberration correction factors for the VR post process.
  131765. */
  131766. chromaAbCorrection: number[];
  131767. /**
  131768. * Define the scale factor of the post process.
  131769. * The smaller the better but the slower.
  131770. */
  131771. postProcessScaleFactor: number;
  131772. /**
  131773. * Define an offset for the lens center.
  131774. */
  131775. lensCenterOffset: number;
  131776. /**
  131777. * Define if the current vr camera should compensate the distortion of the lense or not.
  131778. */
  131779. compensateDistortion: boolean;
  131780. /**
  131781. * Defines if multiview should be enabled when rendering (Default: false)
  131782. */
  131783. multiviewEnabled: boolean;
  131784. /**
  131785. * Gets the rendering aspect ratio based on the provided resolutions.
  131786. */
  131787. get aspectRatio(): number;
  131788. /**
  131789. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  131790. */
  131791. get aspectRatioFov(): number;
  131792. /**
  131793. * @hidden
  131794. */
  131795. get leftHMatrix(): Matrix;
  131796. /**
  131797. * @hidden
  131798. */
  131799. get rightHMatrix(): Matrix;
  131800. /**
  131801. * @hidden
  131802. */
  131803. get leftPreViewMatrix(): Matrix;
  131804. /**
  131805. * @hidden
  131806. */
  131807. get rightPreViewMatrix(): Matrix;
  131808. /**
  131809. * Get the default VRMetrics based on the most generic setup.
  131810. * @returns the default vr metrics
  131811. */
  131812. static GetDefault(): VRCameraMetrics;
  131813. }
  131814. }
  131815. declare module BABYLON {
  131816. /** @hidden */
  131817. export var vrDistortionCorrectionPixelShader: {
  131818. name: string;
  131819. shader: string;
  131820. };
  131821. }
  131822. declare module BABYLON {
  131823. /**
  131824. * VRDistortionCorrectionPostProcess used for mobile VR
  131825. */
  131826. export class VRDistortionCorrectionPostProcess extends PostProcess {
  131827. private _isRightEye;
  131828. private _distortionFactors;
  131829. private _postProcessScaleFactor;
  131830. private _lensCenterOffset;
  131831. private _scaleIn;
  131832. private _scaleFactor;
  131833. private _lensCenter;
  131834. /**
  131835. * Gets a string identifying the name of the class
  131836. * @returns "VRDistortionCorrectionPostProcess" string
  131837. */
  131838. getClassName(): string;
  131839. /**
  131840. * Initializes the VRDistortionCorrectionPostProcess
  131841. * @param name The name of the effect.
  131842. * @param camera The camera to apply the render pass to.
  131843. * @param isRightEye If this is for the right eye distortion
  131844. * @param vrMetrics All the required metrics for the VR camera
  131845. */
  131846. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  131847. }
  131848. }
  131849. declare module BABYLON {
  131850. /**
  131851. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  131852. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131853. */
  131854. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  131855. /**
  131856. * Creates a new VRDeviceOrientationArcRotateCamera
  131857. * @param name defines camera name
  131858. * @param alpha defines the camera rotation along the logitudinal axis
  131859. * @param beta defines the camera rotation along the latitudinal axis
  131860. * @param radius defines the camera distance from its target
  131861. * @param target defines the camera target
  131862. * @param scene defines the scene the camera belongs to
  131863. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131864. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131865. */
  131866. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131867. /**
  131868. * Gets camera class name
  131869. * @returns VRDeviceOrientationArcRotateCamera
  131870. */
  131871. getClassName(): string;
  131872. }
  131873. }
  131874. declare module BABYLON {
  131875. /**
  131876. * Camera used to simulate VR rendering (based on FreeCamera)
  131877. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131878. */
  131879. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  131880. /**
  131881. * Creates a new VRDeviceOrientationFreeCamera
  131882. * @param name defines camera name
  131883. * @param position defines the start position of the camera
  131884. * @param scene defines the scene the camera belongs to
  131885. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131886. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131887. */
  131888. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131889. /**
  131890. * Gets camera class name
  131891. * @returns VRDeviceOrientationFreeCamera
  131892. */
  131893. getClassName(): string;
  131894. }
  131895. }
  131896. declare module BABYLON {
  131897. /**
  131898. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  131899. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131900. */
  131901. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  131902. /**
  131903. * Creates a new VRDeviceOrientationGamepadCamera
  131904. * @param name defines camera name
  131905. * @param position defines the start position of the camera
  131906. * @param scene defines the scene the camera belongs to
  131907. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131908. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131909. */
  131910. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131911. /**
  131912. * Gets camera class name
  131913. * @returns VRDeviceOrientationGamepadCamera
  131914. */
  131915. getClassName(): string;
  131916. }
  131917. }
  131918. declare module BABYLON {
  131919. /**
  131920. * A class extending Texture allowing drawing on a texture
  131921. * @see https://doc.babylonjs.com/how_to/dynamictexture
  131922. */
  131923. export class DynamicTexture extends Texture {
  131924. private _generateMipMaps;
  131925. private _canvas;
  131926. private _context;
  131927. /**
  131928. * Creates a DynamicTexture
  131929. * @param name defines the name of the texture
  131930. * @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
  131931. * @param scene defines the scene where you want the texture
  131932. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  131933. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131934. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  131935. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  131936. */
  131937. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  131938. /**
  131939. * Get the current class name of the texture useful for serialization or dynamic coding.
  131940. * @returns "DynamicTexture"
  131941. */
  131942. getClassName(): string;
  131943. /**
  131944. * Gets the current state of canRescale
  131945. */
  131946. get canRescale(): boolean;
  131947. private _recreate;
  131948. /**
  131949. * Scales the texture
  131950. * @param ratio the scale factor to apply to both width and height
  131951. */
  131952. scale(ratio: number): void;
  131953. /**
  131954. * Resizes the texture
  131955. * @param width the new width
  131956. * @param height the new height
  131957. */
  131958. scaleTo(width: number, height: number): void;
  131959. /**
  131960. * Gets the context of the canvas used by the texture
  131961. * @returns the canvas context of the dynamic texture
  131962. */
  131963. getContext(): CanvasRenderingContext2D;
  131964. /**
  131965. * Clears the texture
  131966. */
  131967. clear(): void;
  131968. /**
  131969. * Updates the texture
  131970. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131971. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  131972. */
  131973. update(invertY?: boolean, premulAlpha?: boolean): void;
  131974. /**
  131975. * Draws text onto the texture
  131976. * @param text defines the text to be drawn
  131977. * @param x defines the placement of the text from the left
  131978. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  131979. * @param font defines the font to be used with font-style, font-size, font-name
  131980. * @param color defines the color used for the text
  131981. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  131982. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131983. * @param update defines whether texture is immediately update (default is true)
  131984. */
  131985. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  131986. /**
  131987. * Clones the texture
  131988. * @returns the clone of the texture.
  131989. */
  131990. clone(): DynamicTexture;
  131991. /**
  131992. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  131993. * @returns a serialized dynamic texture object
  131994. */
  131995. serialize(): any;
  131996. private _IsCanvasElement;
  131997. /** @hidden */
  131998. _rebuild(): void;
  131999. }
  132000. }
  132001. declare module BABYLON {
  132002. /**
  132003. * Class containing static functions to help procedurally build meshes
  132004. */
  132005. export class GroundBuilder {
  132006. /**
  132007. * Creates a ground mesh
  132008. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  132009. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  132010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132011. * @param name defines the name of the mesh
  132012. * @param options defines the options used to create the mesh
  132013. * @param scene defines the hosting scene
  132014. * @returns the ground mesh
  132015. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  132016. */
  132017. static CreateGround(name: string, options: {
  132018. width?: number;
  132019. height?: number;
  132020. subdivisions?: number;
  132021. subdivisionsX?: number;
  132022. subdivisionsY?: number;
  132023. updatable?: boolean;
  132024. }, scene: any): Mesh;
  132025. /**
  132026. * Creates a tiled ground mesh
  132027. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  132028. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  132029. * * 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
  132030. * * 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
  132031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132032. * @param name defines the name of the mesh
  132033. * @param options defines the options used to create the mesh
  132034. * @param scene defines the hosting scene
  132035. * @returns the tiled ground mesh
  132036. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  132037. */
  132038. static CreateTiledGround(name: string, options: {
  132039. xmin: number;
  132040. zmin: number;
  132041. xmax: number;
  132042. zmax: number;
  132043. subdivisions?: {
  132044. w: number;
  132045. h: number;
  132046. };
  132047. precision?: {
  132048. w: number;
  132049. h: number;
  132050. };
  132051. updatable?: boolean;
  132052. }, scene?: Nullable<Scene>): Mesh;
  132053. /**
  132054. * Creates a ground mesh from a height map
  132055. * * The parameter `url` sets the URL of the height map image resource.
  132056. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  132057. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  132058. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  132059. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  132060. * * 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.
  132061. * * 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).
  132062. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  132063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132064. * @param name defines the name of the mesh
  132065. * @param url defines the url to the height map
  132066. * @param options defines the options used to create the mesh
  132067. * @param scene defines the hosting scene
  132068. * @returns the ground mesh
  132069. * @see https://doc.babylonjs.com/babylon101/height_map
  132070. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  132071. */
  132072. static CreateGroundFromHeightMap(name: string, url: string, options: {
  132073. width?: number;
  132074. height?: number;
  132075. subdivisions?: number;
  132076. minHeight?: number;
  132077. maxHeight?: number;
  132078. colorFilter?: Color3;
  132079. alphaFilter?: number;
  132080. updatable?: boolean;
  132081. onReady?: (mesh: GroundMesh) => void;
  132082. }, scene?: Nullable<Scene>): GroundMesh;
  132083. }
  132084. }
  132085. declare module BABYLON {
  132086. /**
  132087. * Class containing static functions to help procedurally build meshes
  132088. */
  132089. export class TorusBuilder {
  132090. /**
  132091. * Creates a torus mesh
  132092. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  132093. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  132094. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  132095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132098. * @param name defines the name of the mesh
  132099. * @param options defines the options used to create the mesh
  132100. * @param scene defines the hosting scene
  132101. * @returns the torus mesh
  132102. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  132103. */
  132104. static CreateTorus(name: string, options: {
  132105. diameter?: number;
  132106. thickness?: number;
  132107. tessellation?: number;
  132108. updatable?: boolean;
  132109. sideOrientation?: number;
  132110. frontUVs?: Vector4;
  132111. backUVs?: Vector4;
  132112. }, scene: any): Mesh;
  132113. }
  132114. }
  132115. declare module BABYLON {
  132116. /**
  132117. * Class containing static functions to help procedurally build meshes
  132118. */
  132119. export class CylinderBuilder {
  132120. /**
  132121. * Creates a cylinder or a cone mesh
  132122. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  132123. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  132124. * * 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.
  132125. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  132126. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  132127. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  132128. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  132129. * * 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).
  132130. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  132131. * * 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).
  132132. * * 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
  132133. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  132134. * * 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
  132135. * * 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.
  132136. * * If `enclose` is false, a ring surface is one element.
  132137. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  132138. * * 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
  132139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132142. * @param name defines the name of the mesh
  132143. * @param options defines the options used to create the mesh
  132144. * @param scene defines the hosting scene
  132145. * @returns the cylinder mesh
  132146. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  132147. */
  132148. static CreateCylinder(name: string, options: {
  132149. height?: number;
  132150. diameterTop?: number;
  132151. diameterBottom?: number;
  132152. diameter?: number;
  132153. tessellation?: number;
  132154. subdivisions?: number;
  132155. arc?: number;
  132156. faceColors?: Color4[];
  132157. faceUV?: Vector4[];
  132158. updatable?: boolean;
  132159. hasRings?: boolean;
  132160. enclose?: boolean;
  132161. cap?: number;
  132162. sideOrientation?: number;
  132163. frontUVs?: Vector4;
  132164. backUVs?: Vector4;
  132165. }, scene: any): Mesh;
  132166. }
  132167. }
  132168. declare module BABYLON {
  132169. /**
  132170. * States of the webXR experience
  132171. */
  132172. export enum WebXRState {
  132173. /**
  132174. * Transitioning to being in XR mode
  132175. */
  132176. ENTERING_XR = 0,
  132177. /**
  132178. * Transitioning to non XR mode
  132179. */
  132180. EXITING_XR = 1,
  132181. /**
  132182. * In XR mode and presenting
  132183. */
  132184. IN_XR = 2,
  132185. /**
  132186. * Not entered XR mode
  132187. */
  132188. NOT_IN_XR = 3
  132189. }
  132190. /**
  132191. * The state of the XR camera's tracking
  132192. */
  132193. export enum WebXRTrackingState {
  132194. /**
  132195. * No transformation received, device is not being tracked
  132196. */
  132197. NOT_TRACKING = 0,
  132198. /**
  132199. * Tracking lost - using emulated position
  132200. */
  132201. TRACKING_LOST = 1,
  132202. /**
  132203. * Transformation tracking works normally
  132204. */
  132205. TRACKING = 2
  132206. }
  132207. /**
  132208. * Abstraction of the XR render target
  132209. */
  132210. export interface WebXRRenderTarget extends IDisposable {
  132211. /**
  132212. * xrpresent context of the canvas which can be used to display/mirror xr content
  132213. */
  132214. canvasContext: WebGLRenderingContext;
  132215. /**
  132216. * xr layer for the canvas
  132217. */
  132218. xrLayer: Nullable<XRWebGLLayer>;
  132219. /**
  132220. * Initializes the xr layer for the session
  132221. * @param xrSession xr session
  132222. * @returns a promise that will resolve once the XR Layer has been created
  132223. */
  132224. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  132225. }
  132226. }
  132227. declare module BABYLON {
  132228. /**
  132229. * COnfiguration object for WebXR output canvas
  132230. */
  132231. export class WebXRManagedOutputCanvasOptions {
  132232. /**
  132233. * An optional canvas in case you wish to create it yourself and provide it here.
  132234. * If not provided, a new canvas will be created
  132235. */
  132236. canvasElement?: HTMLCanvasElement;
  132237. /**
  132238. * Options for this XR Layer output
  132239. */
  132240. canvasOptions?: XRWebGLLayerInit;
  132241. /**
  132242. * CSS styling for a newly created canvas (if not provided)
  132243. */
  132244. newCanvasCssStyle?: string;
  132245. /**
  132246. * Get the default values of the configuration object
  132247. * @param engine defines the engine to use (can be null)
  132248. * @returns default values of this configuration object
  132249. */
  132250. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  132251. }
  132252. /**
  132253. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  132254. */
  132255. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  132256. private _options;
  132257. private _canvas;
  132258. private _engine;
  132259. private _originalCanvasSize;
  132260. /**
  132261. * Rendering context of the canvas which can be used to display/mirror xr content
  132262. */
  132263. canvasContext: WebGLRenderingContext;
  132264. /**
  132265. * xr layer for the canvas
  132266. */
  132267. xrLayer: Nullable<XRWebGLLayer>;
  132268. /**
  132269. * Obseervers registered here will be triggered when the xr layer was initialized
  132270. */
  132271. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  132272. /**
  132273. * Initializes the canvas to be added/removed upon entering/exiting xr
  132274. * @param _xrSessionManager The XR Session manager
  132275. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  132276. */
  132277. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  132278. /**
  132279. * Disposes of the object
  132280. */
  132281. dispose(): void;
  132282. /**
  132283. * Initializes the xr layer for the session
  132284. * @param xrSession xr session
  132285. * @returns a promise that will resolve once the XR Layer has been created
  132286. */
  132287. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  132288. private _addCanvas;
  132289. private _removeCanvas;
  132290. private _setCanvasSize;
  132291. private _setManagedOutputCanvas;
  132292. }
  132293. }
  132294. declare module BABYLON {
  132295. /**
  132296. * Manages an XRSession to work with Babylon's engine
  132297. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  132298. */
  132299. export class WebXRSessionManager implements IDisposable {
  132300. /** The scene which the session should be created for */
  132301. scene: Scene;
  132302. private _referenceSpace;
  132303. private _rttProvider;
  132304. private _sessionEnded;
  132305. private _xrNavigator;
  132306. private baseLayer;
  132307. /**
  132308. * The base reference space from which the session started. good if you want to reset your
  132309. * reference space
  132310. */
  132311. baseReferenceSpace: XRReferenceSpace;
  132312. /**
  132313. * Current XR frame
  132314. */
  132315. currentFrame: Nullable<XRFrame>;
  132316. /** WebXR timestamp updated every frame */
  132317. currentTimestamp: number;
  132318. /**
  132319. * Used just in case of a failure to initialize an immersive session.
  132320. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  132321. */
  132322. defaultHeightCompensation: number;
  132323. /**
  132324. * Fires every time a new xrFrame arrives which can be used to update the camera
  132325. */
  132326. onXRFrameObservable: Observable<XRFrame>;
  132327. /**
  132328. * Fires when the reference space changed
  132329. */
  132330. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  132331. /**
  132332. * Fires when the xr session is ended either by the device or manually done
  132333. */
  132334. onXRSessionEnded: Observable<any>;
  132335. /**
  132336. * Fires when the xr session is ended either by the device or manually done
  132337. */
  132338. onXRSessionInit: Observable<XRSession>;
  132339. /**
  132340. * Underlying xr session
  132341. */
  132342. session: XRSession;
  132343. /**
  132344. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  132345. * or get the offset the player is currently at.
  132346. */
  132347. viewerReferenceSpace: XRReferenceSpace;
  132348. /**
  132349. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  132350. * @param scene The scene which the session should be created for
  132351. */
  132352. constructor(
  132353. /** The scene which the session should be created for */
  132354. scene: Scene);
  132355. /**
  132356. * The current reference space used in this session. This reference space can constantly change!
  132357. * It is mainly used to offset the camera's position.
  132358. */
  132359. get referenceSpace(): XRReferenceSpace;
  132360. /**
  132361. * Set a new reference space and triggers the observable
  132362. */
  132363. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  132364. /**
  132365. * Disposes of the session manager
  132366. */
  132367. dispose(): void;
  132368. /**
  132369. * Stops the xrSession and restores the render loop
  132370. * @returns Promise which resolves after it exits XR
  132371. */
  132372. exitXRAsync(): Promise<void>;
  132373. /**
  132374. * Gets the correct render target texture to be rendered this frame for this eye
  132375. * @param eye the eye for which to get the render target
  132376. * @returns the render target for the specified eye
  132377. */
  132378. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  132379. /**
  132380. * Creates a WebXRRenderTarget object for the XR session
  132381. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  132382. * @param options optional options to provide when creating a new render target
  132383. * @returns a WebXR render target to which the session can render
  132384. */
  132385. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  132386. /**
  132387. * Initializes the manager
  132388. * After initialization enterXR can be called to start an XR session
  132389. * @returns Promise which resolves after it is initialized
  132390. */
  132391. initializeAsync(): Promise<void>;
  132392. /**
  132393. * Initializes an xr session
  132394. * @param xrSessionMode mode to initialize
  132395. * @param xrSessionInit defines optional and required values to pass to the session builder
  132396. * @returns a promise which will resolve once the session has been initialized
  132397. */
  132398. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  132399. /**
  132400. * Checks if a session would be supported for the creation options specified
  132401. * @param sessionMode session mode to check if supported eg. immersive-vr
  132402. * @returns A Promise that resolves to true if supported and false if not
  132403. */
  132404. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132405. /**
  132406. * Resets the reference space to the one started the session
  132407. */
  132408. resetReferenceSpace(): void;
  132409. /**
  132410. * Starts rendering to the xr layer
  132411. */
  132412. runXRRenderLoop(): void;
  132413. /**
  132414. * Sets the reference space on the xr session
  132415. * @param referenceSpaceType space to set
  132416. * @returns a promise that will resolve once the reference space has been set
  132417. */
  132418. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132419. /**
  132420. * Updates the render state of the session
  132421. * @param state state to set
  132422. * @returns a promise that resolves once the render state has been updated
  132423. */
  132424. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  132425. /**
  132426. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  132427. * @param sessionMode defines the session to test
  132428. * @returns a promise with boolean as final value
  132429. */
  132430. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132431. private _createRenderTargetTexture;
  132432. }
  132433. }
  132434. declare module BABYLON {
  132435. /**
  132436. * WebXR Camera which holds the views for the xrSession
  132437. * @see https://doc.babylonjs.com/how_to/webxr_camera
  132438. */
  132439. export class WebXRCamera extends FreeCamera {
  132440. private _xrSessionManager;
  132441. private _firstFrame;
  132442. private _referenceQuaternion;
  132443. private _referencedPosition;
  132444. private _xrInvPositionCache;
  132445. private _xrInvQuaternionCache;
  132446. private _trackingState;
  132447. /**
  132448. * Observable raised before camera teleportation
  132449. */
  132450. onBeforeCameraTeleport: Observable<Vector3>;
  132451. /**
  132452. * Observable raised after camera teleportation
  132453. */
  132454. onAfterCameraTeleport: Observable<Vector3>;
  132455. /**
  132456. * Notifies when the camera's tracking state has changed.
  132457. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  132458. */
  132459. onTrackingStateChanged: Observable<WebXRTrackingState>;
  132460. /**
  132461. * Should position compensation execute on first frame.
  132462. * This is used when copying the position from a native (non XR) camera
  132463. */
  132464. compensateOnFirstFrame: boolean;
  132465. /**
  132466. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  132467. * @param name the name of the camera
  132468. * @param scene the scene to add the camera to
  132469. * @param _xrSessionManager a constructed xr session manager
  132470. */
  132471. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  132472. /**
  132473. * Get the current XR tracking state of the camera
  132474. */
  132475. get trackingState(): WebXRTrackingState;
  132476. private _setTrackingState;
  132477. /**
  132478. * Return the user's height, unrelated to the current ground.
  132479. * This will be the y position of this camera, when ground level is 0.
  132480. */
  132481. get realWorldHeight(): number;
  132482. /** @hidden */
  132483. _updateForDualEyeDebugging(): void;
  132484. /**
  132485. * Sets this camera's transformation based on a non-vr camera
  132486. * @param otherCamera the non-vr camera to copy the transformation from
  132487. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  132488. */
  132489. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  132490. /**
  132491. * Gets the current instance class name ("WebXRCamera").
  132492. * @returns the class name
  132493. */
  132494. getClassName(): string;
  132495. private _rotate180;
  132496. private _updateFromXRSession;
  132497. private _updateNumberOfRigCameras;
  132498. private _updateReferenceSpace;
  132499. private _updateReferenceSpaceOffset;
  132500. }
  132501. }
  132502. declare module BABYLON {
  132503. /**
  132504. * Defining the interface required for a (webxr) feature
  132505. */
  132506. export interface IWebXRFeature extends IDisposable {
  132507. /**
  132508. * Is this feature attached
  132509. */
  132510. attached: boolean;
  132511. /**
  132512. * Should auto-attach be disabled?
  132513. */
  132514. disableAutoAttach: boolean;
  132515. /**
  132516. * Attach the feature to the session
  132517. * Will usually be called by the features manager
  132518. *
  132519. * @param force should attachment be forced (even when already attached)
  132520. * @returns true if successful.
  132521. */
  132522. attach(force?: boolean): boolean;
  132523. /**
  132524. * Detach the feature from the session
  132525. * Will usually be called by the features manager
  132526. *
  132527. * @returns true if successful.
  132528. */
  132529. detach(): boolean;
  132530. /**
  132531. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132532. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132533. *
  132534. * @returns whether or not the feature is compatible in this environment
  132535. */
  132536. isCompatible(): boolean;
  132537. /**
  132538. * Was this feature disposed;
  132539. */
  132540. isDisposed: boolean;
  132541. /**
  132542. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  132543. */
  132544. xrNativeFeatureName?: string;
  132545. /**
  132546. * A list of (Babylon WebXR) features this feature depends on
  132547. */
  132548. dependsOn?: string[];
  132549. }
  132550. /**
  132551. * A list of the currently available features without referencing them
  132552. */
  132553. export class WebXRFeatureName {
  132554. /**
  132555. * The name of the anchor system feature
  132556. */
  132557. static readonly ANCHOR_SYSTEM: string;
  132558. /**
  132559. * The name of the background remover feature
  132560. */
  132561. static readonly BACKGROUND_REMOVER: string;
  132562. /**
  132563. * The name of the hit test feature
  132564. */
  132565. static readonly HIT_TEST: string;
  132566. /**
  132567. * physics impostors for xr controllers feature
  132568. */
  132569. static readonly PHYSICS_CONTROLLERS: string;
  132570. /**
  132571. * The name of the plane detection feature
  132572. */
  132573. static readonly PLANE_DETECTION: string;
  132574. /**
  132575. * The name of the pointer selection feature
  132576. */
  132577. static readonly POINTER_SELECTION: string;
  132578. /**
  132579. * The name of the teleportation feature
  132580. */
  132581. static readonly TELEPORTATION: string;
  132582. /**
  132583. * The name of the feature points feature.
  132584. */
  132585. static readonly FEATURE_POINTS: string;
  132586. /**
  132587. * The name of the hand tracking feature.
  132588. */
  132589. static readonly HAND_TRACKING: string;
  132590. }
  132591. /**
  132592. * Defining the constructor of a feature. Used to register the modules.
  132593. */
  132594. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  132595. /**
  132596. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  132597. * It is mainly used in AR sessions.
  132598. *
  132599. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  132600. */
  132601. export class WebXRFeaturesManager implements IDisposable {
  132602. private _xrSessionManager;
  132603. private static readonly _AvailableFeatures;
  132604. private _features;
  132605. /**
  132606. * constructs a new features manages.
  132607. *
  132608. * @param _xrSessionManager an instance of WebXRSessionManager
  132609. */
  132610. constructor(_xrSessionManager: WebXRSessionManager);
  132611. /**
  132612. * Used to register a module. After calling this function a developer can use this feature in the scene.
  132613. * Mainly used internally.
  132614. *
  132615. * @param featureName the name of the feature to register
  132616. * @param constructorFunction the function used to construct the module
  132617. * @param version the (babylon) version of the module
  132618. * @param stable is that a stable version of this module
  132619. */
  132620. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  132621. /**
  132622. * Returns a constructor of a specific feature.
  132623. *
  132624. * @param featureName the name of the feature to construct
  132625. * @param version the version of the feature to load
  132626. * @param xrSessionManager the xrSessionManager. Used to construct the module
  132627. * @param options optional options provided to the module.
  132628. * @returns a function that, when called, will return a new instance of this feature
  132629. */
  132630. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  132631. /**
  132632. * Can be used to return the list of features currently registered
  132633. *
  132634. * @returns an Array of available features
  132635. */
  132636. static GetAvailableFeatures(): string[];
  132637. /**
  132638. * Gets the versions available for a specific feature
  132639. * @param featureName the name of the feature
  132640. * @returns an array with the available versions
  132641. */
  132642. static GetAvailableVersions(featureName: string): string[];
  132643. /**
  132644. * Return the latest unstable version of this feature
  132645. * @param featureName the name of the feature to search
  132646. * @returns the version number. if not found will return -1
  132647. */
  132648. static GetLatestVersionOfFeature(featureName: string): number;
  132649. /**
  132650. * Return the latest stable version of this feature
  132651. * @param featureName the name of the feature to search
  132652. * @returns the version number. if not found will return -1
  132653. */
  132654. static GetStableVersionOfFeature(featureName: string): number;
  132655. /**
  132656. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  132657. * Can be used during a session to start a feature
  132658. * @param featureName the name of feature to attach
  132659. */
  132660. attachFeature(featureName: string): void;
  132661. /**
  132662. * Can be used inside a session or when the session ends to detach a specific feature
  132663. * @param featureName the name of the feature to detach
  132664. */
  132665. detachFeature(featureName: string): void;
  132666. /**
  132667. * Used to disable an already-enabled feature
  132668. * The feature will be disposed and will be recreated once enabled.
  132669. * @param featureName the feature to disable
  132670. * @returns true if disable was successful
  132671. */
  132672. disableFeature(featureName: string | {
  132673. Name: string;
  132674. }): boolean;
  132675. /**
  132676. * dispose this features manager
  132677. */
  132678. dispose(): void;
  132679. /**
  132680. * 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.
  132681. * 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.
  132682. *
  132683. * @param featureName the name of the feature to load or the class of the feature
  132684. * @param version optional version to load. if not provided the latest version will be enabled
  132685. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  132686. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  132687. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  132688. * @returns a new constructed feature or throws an error if feature not found.
  132689. */
  132690. enableFeature(featureName: string | {
  132691. Name: string;
  132692. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  132693. /**
  132694. * get the implementation of an enabled feature.
  132695. * @param featureName the name of the feature to load
  132696. * @returns the feature class, if found
  132697. */
  132698. getEnabledFeature(featureName: string): IWebXRFeature;
  132699. /**
  132700. * Get the list of enabled features
  132701. * @returns an array of enabled features
  132702. */
  132703. getEnabledFeatures(): string[];
  132704. /**
  132705. * This function will exten the session creation configuration object with enabled features.
  132706. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  132707. * according to the defined "required" variable, provided during enableFeature call
  132708. * @param xrSessionInit the xr Session init object to extend
  132709. *
  132710. * @returns an extended XRSessionInit object
  132711. */
  132712. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  132713. }
  132714. }
  132715. declare module BABYLON {
  132716. /**
  132717. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  132718. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  132719. */
  132720. export class WebXRExperienceHelper implements IDisposable {
  132721. private scene;
  132722. private _nonVRCamera;
  132723. private _originalSceneAutoClear;
  132724. private _supported;
  132725. /**
  132726. * Camera used to render xr content
  132727. */
  132728. camera: WebXRCamera;
  132729. /** A features manager for this xr session */
  132730. featuresManager: WebXRFeaturesManager;
  132731. /**
  132732. * Observers registered here will be triggered after the camera's initial transformation is set
  132733. * This can be used to set a different ground level or an extra rotation.
  132734. *
  132735. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  132736. * to the position set after this observable is done executing.
  132737. */
  132738. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  132739. /**
  132740. * Fires when the state of the experience helper has changed
  132741. */
  132742. onStateChangedObservable: Observable<WebXRState>;
  132743. /** Session manager used to keep track of xr session */
  132744. sessionManager: WebXRSessionManager;
  132745. /**
  132746. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  132747. */
  132748. state: WebXRState;
  132749. /**
  132750. * Creates a WebXRExperienceHelper
  132751. * @param scene The scene the helper should be created in
  132752. */
  132753. private constructor();
  132754. /**
  132755. * Creates the experience helper
  132756. * @param scene the scene to attach the experience helper to
  132757. * @returns a promise for the experience helper
  132758. */
  132759. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  132760. /**
  132761. * Disposes of the experience helper
  132762. */
  132763. dispose(): void;
  132764. /**
  132765. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  132766. * @param sessionMode options for the XR session
  132767. * @param referenceSpaceType frame of reference of the XR session
  132768. * @param renderTarget the output canvas that will be used to enter XR mode
  132769. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  132770. * @returns promise that resolves after xr mode has entered
  132771. */
  132772. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  132773. /**
  132774. * Exits XR mode and returns the scene to its original state
  132775. * @returns promise that resolves after xr mode has exited
  132776. */
  132777. exitXRAsync(): Promise<void>;
  132778. private _nonXRToXRCamera;
  132779. private _setState;
  132780. }
  132781. }
  132782. declare module BABYLON {
  132783. /**
  132784. * X-Y values for axes in WebXR
  132785. */
  132786. export interface IWebXRMotionControllerAxesValue {
  132787. /**
  132788. * The value of the x axis
  132789. */
  132790. x: number;
  132791. /**
  132792. * The value of the y-axis
  132793. */
  132794. y: number;
  132795. }
  132796. /**
  132797. * changed / previous values for the values of this component
  132798. */
  132799. export interface IWebXRMotionControllerComponentChangesValues<T> {
  132800. /**
  132801. * current (this frame) value
  132802. */
  132803. current: T;
  132804. /**
  132805. * previous (last change) value
  132806. */
  132807. previous: T;
  132808. }
  132809. /**
  132810. * Represents changes in the component between current frame and last values recorded
  132811. */
  132812. export interface IWebXRMotionControllerComponentChanges {
  132813. /**
  132814. * will be populated with previous and current values if axes changed
  132815. */
  132816. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  132817. /**
  132818. * will be populated with previous and current values if pressed changed
  132819. */
  132820. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132821. /**
  132822. * will be populated with previous and current values if touched changed
  132823. */
  132824. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132825. /**
  132826. * will be populated with previous and current values if value changed
  132827. */
  132828. value?: IWebXRMotionControllerComponentChangesValues<number>;
  132829. }
  132830. /**
  132831. * This class represents a single component (for example button or thumbstick) of a motion controller
  132832. */
  132833. export class WebXRControllerComponent implements IDisposable {
  132834. /**
  132835. * the id of this component
  132836. */
  132837. id: string;
  132838. /**
  132839. * the type of the component
  132840. */
  132841. type: MotionControllerComponentType;
  132842. private _buttonIndex;
  132843. private _axesIndices;
  132844. private _axes;
  132845. private _changes;
  132846. private _currentValue;
  132847. private _hasChanges;
  132848. private _pressed;
  132849. private _touched;
  132850. /**
  132851. * button component type
  132852. */
  132853. static BUTTON_TYPE: MotionControllerComponentType;
  132854. /**
  132855. * squeeze component type
  132856. */
  132857. static SQUEEZE_TYPE: MotionControllerComponentType;
  132858. /**
  132859. * Thumbstick component type
  132860. */
  132861. static THUMBSTICK_TYPE: MotionControllerComponentType;
  132862. /**
  132863. * Touchpad component type
  132864. */
  132865. static TOUCHPAD_TYPE: MotionControllerComponentType;
  132866. /**
  132867. * trigger component type
  132868. */
  132869. static TRIGGER_TYPE: MotionControllerComponentType;
  132870. /**
  132871. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  132872. * the axes data changes
  132873. */
  132874. onAxisValueChangedObservable: Observable<{
  132875. x: number;
  132876. y: number;
  132877. }>;
  132878. /**
  132879. * Observers registered here will be triggered when the state of a button changes
  132880. * State change is either pressed / touched / value
  132881. */
  132882. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  132883. /**
  132884. * Creates a new component for a motion controller.
  132885. * It is created by the motion controller itself
  132886. *
  132887. * @param id the id of this component
  132888. * @param type the type of the component
  132889. * @param _buttonIndex index in the buttons array of the gamepad
  132890. * @param _axesIndices indices of the values in the axes array of the gamepad
  132891. */
  132892. constructor(
  132893. /**
  132894. * the id of this component
  132895. */
  132896. id: string,
  132897. /**
  132898. * the type of the component
  132899. */
  132900. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  132901. /**
  132902. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  132903. */
  132904. get axes(): IWebXRMotionControllerAxesValue;
  132905. /**
  132906. * Get the changes. Elements will be populated only if they changed with their previous and current value
  132907. */
  132908. get changes(): IWebXRMotionControllerComponentChanges;
  132909. /**
  132910. * Return whether or not the component changed the last frame
  132911. */
  132912. get hasChanges(): boolean;
  132913. /**
  132914. * is the button currently pressed
  132915. */
  132916. get pressed(): boolean;
  132917. /**
  132918. * is the button currently touched
  132919. */
  132920. get touched(): boolean;
  132921. /**
  132922. * Get the current value of this component
  132923. */
  132924. get value(): number;
  132925. /**
  132926. * Dispose this component
  132927. */
  132928. dispose(): void;
  132929. /**
  132930. * Are there axes correlating to this component
  132931. * @return true is axes data is available
  132932. */
  132933. isAxes(): boolean;
  132934. /**
  132935. * Is this component a button (hence - pressable)
  132936. * @returns true if can be pressed
  132937. */
  132938. isButton(): boolean;
  132939. /**
  132940. * update this component using the gamepad object it is in. Called on every frame
  132941. * @param nativeController the native gamepad controller object
  132942. */
  132943. update(nativeController: IMinimalMotionControllerObject): void;
  132944. }
  132945. }
  132946. declare module BABYLON {
  132947. /**
  132948. * Type used for the success callback of ImportMesh
  132949. */
  132950. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  132951. /**
  132952. * Interface used for the result of ImportMeshAsync
  132953. */
  132954. export interface ISceneLoaderAsyncResult {
  132955. /**
  132956. * The array of loaded meshes
  132957. */
  132958. readonly meshes: AbstractMesh[];
  132959. /**
  132960. * The array of loaded particle systems
  132961. */
  132962. readonly particleSystems: IParticleSystem[];
  132963. /**
  132964. * The array of loaded skeletons
  132965. */
  132966. readonly skeletons: Skeleton[];
  132967. /**
  132968. * The array of loaded animation groups
  132969. */
  132970. readonly animationGroups: AnimationGroup[];
  132971. /**
  132972. * The array of loaded transform nodes
  132973. */
  132974. readonly transformNodes: TransformNode[];
  132975. /**
  132976. * The array of loaded geometries
  132977. */
  132978. readonly geometries: Geometry[];
  132979. /**
  132980. * The array of loaded lights
  132981. */
  132982. readonly lights: Light[];
  132983. }
  132984. /**
  132985. * Interface used to represent data loading progression
  132986. */
  132987. export interface ISceneLoaderProgressEvent {
  132988. /**
  132989. * Defines if data length to load can be evaluated
  132990. */
  132991. readonly lengthComputable: boolean;
  132992. /**
  132993. * Defines the loaded data length
  132994. */
  132995. readonly loaded: number;
  132996. /**
  132997. * Defines the data length to load
  132998. */
  132999. readonly total: number;
  133000. }
  133001. /**
  133002. * Interface used by SceneLoader plugins to define supported file extensions
  133003. */
  133004. export interface ISceneLoaderPluginExtensions {
  133005. /**
  133006. * Defines the list of supported extensions
  133007. */
  133008. [extension: string]: {
  133009. isBinary: boolean;
  133010. };
  133011. }
  133012. /**
  133013. * Interface used by SceneLoader plugin factory
  133014. */
  133015. export interface ISceneLoaderPluginFactory {
  133016. /**
  133017. * Defines the name of the factory
  133018. */
  133019. name: string;
  133020. /**
  133021. * Function called to create a new plugin
  133022. * @return the new plugin
  133023. */
  133024. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  133025. /**
  133026. * The callback that returns true if the data can be directly loaded.
  133027. * @param data string containing the file data
  133028. * @returns if the data can be loaded directly
  133029. */
  133030. canDirectLoad?(data: string): boolean;
  133031. }
  133032. /**
  133033. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  133034. */
  133035. export interface ISceneLoaderPluginBase {
  133036. /**
  133037. * The friendly name of this plugin.
  133038. */
  133039. name: string;
  133040. /**
  133041. * The file extensions supported by this plugin.
  133042. */
  133043. extensions: string | ISceneLoaderPluginExtensions;
  133044. /**
  133045. * The callback called when loading from a url.
  133046. * @param scene scene loading this url
  133047. * @param url url to load
  133048. * @param onSuccess callback called when the file successfully loads
  133049. * @param onProgress callback called while file is loading (if the server supports this mode)
  133050. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  133051. * @param onError callback called when the file fails to load
  133052. * @returns a file request object
  133053. */
  133054. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  133055. /**
  133056. * The callback called when loading from a file object.
  133057. * @param scene scene loading this file
  133058. * @param file defines the file to load
  133059. * @param onSuccess defines the callback to call when data is loaded
  133060. * @param onProgress defines the callback to call during loading process
  133061. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  133062. * @param onError defines the callback to call when an error occurs
  133063. * @returns a file request object
  133064. */
  133065. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  133066. /**
  133067. * The callback that returns true if the data can be directly loaded.
  133068. * @param data string containing the file data
  133069. * @returns if the data can be loaded directly
  133070. */
  133071. canDirectLoad?(data: string): boolean;
  133072. /**
  133073. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  133074. * @param scene scene loading this data
  133075. * @param data string containing the data
  133076. * @returns data to pass to the plugin
  133077. */
  133078. directLoad?(scene: Scene, data: string): any;
  133079. /**
  133080. * The callback that allows custom handling of the root url based on the response url.
  133081. * @param rootUrl the original root url
  133082. * @param responseURL the response url if available
  133083. * @returns the new root url
  133084. */
  133085. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  133086. }
  133087. /**
  133088. * Interface used to define a SceneLoader plugin
  133089. */
  133090. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  133091. /**
  133092. * Import meshes into a scene.
  133093. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133094. * @param scene The scene to import into
  133095. * @param data The data to import
  133096. * @param rootUrl The root url for scene and resources
  133097. * @param meshes The meshes array to import into
  133098. * @param particleSystems The particle systems array to import into
  133099. * @param skeletons The skeletons array to import into
  133100. * @param onError The callback when import fails
  133101. * @returns True if successful or false otherwise
  133102. */
  133103. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  133104. /**
  133105. * Load into a scene.
  133106. * @param scene The scene to load into
  133107. * @param data The data to import
  133108. * @param rootUrl The root url for scene and resources
  133109. * @param onError The callback when import fails
  133110. * @returns True if successful or false otherwise
  133111. */
  133112. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  133113. /**
  133114. * Load into an asset container.
  133115. * @param scene The scene to load into
  133116. * @param data The data to import
  133117. * @param rootUrl The root url for scene and resources
  133118. * @param onError The callback when import fails
  133119. * @returns The loaded asset container
  133120. */
  133121. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  133122. }
  133123. /**
  133124. * Interface used to define an async SceneLoader plugin
  133125. */
  133126. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  133127. /**
  133128. * Import meshes into a scene.
  133129. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133130. * @param scene The scene to import into
  133131. * @param data The data to import
  133132. * @param rootUrl The root url for scene and resources
  133133. * @param onProgress The callback when the load progresses
  133134. * @param fileName Defines the name of the file to load
  133135. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  133136. */
  133137. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  133138. /**
  133139. * Load into a scene.
  133140. * @param scene The scene to load into
  133141. * @param data The data to import
  133142. * @param rootUrl The root url for scene and resources
  133143. * @param onProgress The callback when the load progresses
  133144. * @param fileName Defines the name of the file to load
  133145. * @returns Nothing
  133146. */
  133147. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  133148. /**
  133149. * Load into an asset container.
  133150. * @param scene The scene to load into
  133151. * @param data The data to import
  133152. * @param rootUrl The root url for scene and resources
  133153. * @param onProgress The callback when the load progresses
  133154. * @param fileName Defines the name of the file to load
  133155. * @returns The loaded asset container
  133156. */
  133157. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  133158. }
  133159. /**
  133160. * Mode that determines how to handle old animation groups before loading new ones.
  133161. */
  133162. export enum SceneLoaderAnimationGroupLoadingMode {
  133163. /**
  133164. * Reset all old animations to initial state then dispose them.
  133165. */
  133166. Clean = 0,
  133167. /**
  133168. * Stop all old animations.
  133169. */
  133170. Stop = 1,
  133171. /**
  133172. * Restart old animations from first frame.
  133173. */
  133174. Sync = 2,
  133175. /**
  133176. * Old animations remains untouched.
  133177. */
  133178. NoSync = 3
  133179. }
  133180. /**
  133181. * Defines a plugin registered by the SceneLoader
  133182. */
  133183. interface IRegisteredPlugin {
  133184. /**
  133185. * Defines the plugin to use
  133186. */
  133187. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  133188. /**
  133189. * Defines if the plugin supports binary data
  133190. */
  133191. isBinary: boolean;
  133192. }
  133193. /**
  133194. * Class used to load scene from various file formats using registered plugins
  133195. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  133196. */
  133197. export class SceneLoader {
  133198. /**
  133199. * No logging while loading
  133200. */
  133201. static readonly NO_LOGGING: number;
  133202. /**
  133203. * Minimal logging while loading
  133204. */
  133205. static readonly MINIMAL_LOGGING: number;
  133206. /**
  133207. * Summary logging while loading
  133208. */
  133209. static readonly SUMMARY_LOGGING: number;
  133210. /**
  133211. * Detailled logging while loading
  133212. */
  133213. static readonly DETAILED_LOGGING: number;
  133214. /**
  133215. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  133216. */
  133217. static get ForceFullSceneLoadingForIncremental(): boolean;
  133218. static set ForceFullSceneLoadingForIncremental(value: boolean);
  133219. /**
  133220. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  133221. */
  133222. static get ShowLoadingScreen(): boolean;
  133223. static set ShowLoadingScreen(value: boolean);
  133224. /**
  133225. * Defines the current logging level (while loading the scene)
  133226. * @ignorenaming
  133227. */
  133228. static get loggingLevel(): number;
  133229. static set loggingLevel(value: number);
  133230. /**
  133231. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  133232. */
  133233. static get CleanBoneMatrixWeights(): boolean;
  133234. static set CleanBoneMatrixWeights(value: boolean);
  133235. /**
  133236. * Event raised when a plugin is used to load a scene
  133237. */
  133238. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  133239. private static _registeredPlugins;
  133240. private static _showingLoadingScreen;
  133241. /**
  133242. * Gets the default plugin (used to load Babylon files)
  133243. * @returns the .babylon plugin
  133244. */
  133245. static GetDefaultPlugin(): IRegisteredPlugin;
  133246. private static _GetPluginForExtension;
  133247. private static _GetPluginForDirectLoad;
  133248. private static _GetPluginForFilename;
  133249. private static _GetDirectLoad;
  133250. private static _LoadData;
  133251. private static _GetFileInfo;
  133252. /**
  133253. * Gets a plugin that can load the given extension
  133254. * @param extension defines the extension to load
  133255. * @returns a plugin or null if none works
  133256. */
  133257. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  133258. /**
  133259. * Gets a boolean indicating that the given extension can be loaded
  133260. * @param extension defines the extension to load
  133261. * @returns true if the extension is supported
  133262. */
  133263. static IsPluginForExtensionAvailable(extension: string): boolean;
  133264. /**
  133265. * Adds a new plugin to the list of registered plugins
  133266. * @param plugin defines the plugin to add
  133267. */
  133268. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  133269. /**
  133270. * Import meshes into a scene
  133271. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133272. * @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)
  133273. * @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)
  133274. * @param scene the instance of BABYLON.Scene to append to
  133275. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  133276. * @param onProgress a callback with a progress event for each file being loaded
  133277. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133278. * @param pluginExtension the extension used to determine the plugin
  133279. * @returns The loaded plugin
  133280. */
  133281. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  133282. /**
  133283. * Import meshes into a scene
  133284. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133285. * @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)
  133286. * @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)
  133287. * @param scene the instance of BABYLON.Scene to append to
  133288. * @param onProgress a callback with a progress event for each file being loaded
  133289. * @param pluginExtension the extension used to determine the plugin
  133290. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  133291. */
  133292. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  133293. /**
  133294. * Load a scene
  133295. * @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)
  133296. * @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)
  133297. * @param engine is the instance of BABYLON.Engine to use to create the scene
  133298. * @param onSuccess a callback with the scene when import succeeds
  133299. * @param onProgress a callback with a progress event for each file being loaded
  133300. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133301. * @param pluginExtension the extension used to determine the plugin
  133302. * @returns The loaded plugin
  133303. */
  133304. 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>;
  133305. /**
  133306. * Load a scene
  133307. * @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)
  133308. * @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)
  133309. * @param engine is the instance of BABYLON.Engine to use to create the scene
  133310. * @param onProgress a callback with a progress event for each file being loaded
  133311. * @param pluginExtension the extension used to determine the plugin
  133312. * @returns The loaded scene
  133313. */
  133314. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  133315. /**
  133316. * Append a scene
  133317. * @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)
  133318. * @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)
  133319. * @param scene is the instance of BABYLON.Scene to append to
  133320. * @param onSuccess a callback with the scene when import succeeds
  133321. * @param onProgress a callback with a progress event for each file being loaded
  133322. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133323. * @param pluginExtension the extension used to determine the plugin
  133324. * @returns The loaded plugin
  133325. */
  133326. 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>;
  133327. /**
  133328. * Append a scene
  133329. * @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)
  133330. * @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)
  133331. * @param scene is the instance of BABYLON.Scene to append to
  133332. * @param onProgress a callback with a progress event for each file being loaded
  133333. * @param pluginExtension the extension used to determine the plugin
  133334. * @returns The given scene
  133335. */
  133336. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  133337. /**
  133338. * Load a scene into an asset container
  133339. * @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)
  133340. * @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)
  133341. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133342. * @param onSuccess a callback with the scene when import succeeds
  133343. * @param onProgress a callback with a progress event for each file being loaded
  133344. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133345. * @param pluginExtension the extension used to determine the plugin
  133346. * @returns The loaded plugin
  133347. */
  133348. 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>;
  133349. /**
  133350. * Load a scene into an asset container
  133351. * @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)
  133352. * @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)
  133353. * @param scene is the instance of Scene to append to
  133354. * @param onProgress a callback with a progress event for each file being loaded
  133355. * @param pluginExtension the extension used to determine the plugin
  133356. * @returns The loaded asset container
  133357. */
  133358. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  133359. /**
  133360. * Import animations from a file into a scene
  133361. * @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)
  133362. * @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)
  133363. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133364. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133365. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133366. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133367. * @param onSuccess a callback with the scene when import succeeds
  133368. * @param onProgress a callback with a progress event for each file being loaded
  133369. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133370. * @param pluginExtension the extension used to determine the plugin
  133371. */
  133372. 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;
  133373. /**
  133374. * Import animations from a file into a scene
  133375. * @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)
  133376. * @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)
  133377. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133378. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133379. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133380. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133381. * @param onSuccess a callback with the scene when import succeeds
  133382. * @param onProgress a callback with a progress event for each file being loaded
  133383. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133384. * @param pluginExtension the extension used to determine the plugin
  133385. * @returns the updated scene with imported animations
  133386. */
  133387. 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>;
  133388. }
  133389. }
  133390. declare module BABYLON {
  133391. /**
  133392. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  133393. */
  133394. export type MotionControllerHandedness = "none" | "left" | "right";
  133395. /**
  133396. * The type of components available in motion controllers.
  133397. * This is not the name of the component.
  133398. */
  133399. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  133400. /**
  133401. * The state of a controller component
  133402. */
  133403. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  133404. /**
  133405. * The schema of motion controller layout.
  133406. * No object will be initialized using this interface
  133407. * This is used just to define the profile.
  133408. */
  133409. export interface IMotionControllerLayout {
  133410. /**
  133411. * Path to load the assets. Usually relative to the base path
  133412. */
  133413. assetPath: string;
  133414. /**
  133415. * Available components (unsorted)
  133416. */
  133417. components: {
  133418. /**
  133419. * A map of component Ids
  133420. */
  133421. [componentId: string]: {
  133422. /**
  133423. * The type of input the component outputs
  133424. */
  133425. type: MotionControllerComponentType;
  133426. /**
  133427. * The indices of this component in the gamepad object
  133428. */
  133429. gamepadIndices: {
  133430. /**
  133431. * Index of button
  133432. */
  133433. button?: number;
  133434. /**
  133435. * If available, index of x-axis
  133436. */
  133437. xAxis?: number;
  133438. /**
  133439. * If available, index of y-axis
  133440. */
  133441. yAxis?: number;
  133442. };
  133443. /**
  133444. * The mesh's root node name
  133445. */
  133446. rootNodeName: string;
  133447. /**
  133448. * Animation definitions for this model
  133449. */
  133450. visualResponses: {
  133451. [stateKey: string]: {
  133452. /**
  133453. * What property will be animated
  133454. */
  133455. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  133456. /**
  133457. * What states influence this visual response
  133458. */
  133459. states: MotionControllerComponentStateType[];
  133460. /**
  133461. * Type of animation - movement or visibility
  133462. */
  133463. valueNodeProperty: "transform" | "visibility";
  133464. /**
  133465. * Base node name to move. Its position will be calculated according to the min and max nodes
  133466. */
  133467. valueNodeName?: string;
  133468. /**
  133469. * Minimum movement node
  133470. */
  133471. minNodeName?: string;
  133472. /**
  133473. * Max movement node
  133474. */
  133475. maxNodeName?: string;
  133476. };
  133477. };
  133478. /**
  133479. * If touch enabled, what is the name of node to display user feedback
  133480. */
  133481. touchPointNodeName?: string;
  133482. };
  133483. };
  133484. /**
  133485. * Is it xr standard mapping or not
  133486. */
  133487. gamepadMapping: "" | "xr-standard";
  133488. /**
  133489. * Base root node of this entire model
  133490. */
  133491. rootNodeName: string;
  133492. /**
  133493. * Defines the main button component id
  133494. */
  133495. selectComponentId: string;
  133496. }
  133497. /**
  133498. * A definition for the layout map in the input profile
  133499. */
  133500. export interface IMotionControllerLayoutMap {
  133501. /**
  133502. * Layouts with handedness type as a key
  133503. */
  133504. [handedness: string]: IMotionControllerLayout;
  133505. }
  133506. /**
  133507. * The XR Input profile schema
  133508. * Profiles can be found here:
  133509. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  133510. */
  133511. export interface IMotionControllerProfile {
  133512. /**
  133513. * fallback profiles for this profileId
  133514. */
  133515. fallbackProfileIds: string[];
  133516. /**
  133517. * The layout map, with handedness as key
  133518. */
  133519. layouts: IMotionControllerLayoutMap;
  133520. /**
  133521. * The id of this profile
  133522. * correlates to the profile(s) in the xrInput.profiles array
  133523. */
  133524. profileId: string;
  133525. }
  133526. /**
  133527. * A helper-interface for the 3 meshes needed for controller button animation
  133528. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  133529. */
  133530. export interface IMotionControllerButtonMeshMap {
  133531. /**
  133532. * the mesh that defines the pressed value mesh position.
  133533. * This is used to find the max-position of this button
  133534. */
  133535. pressedMesh: AbstractMesh;
  133536. /**
  133537. * the mesh that defines the unpressed value mesh position.
  133538. * This is used to find the min (or initial) position of this button
  133539. */
  133540. unpressedMesh: AbstractMesh;
  133541. /**
  133542. * The mesh that will be changed when value changes
  133543. */
  133544. valueMesh: AbstractMesh;
  133545. }
  133546. /**
  133547. * A helper-interface for the 3 meshes needed for controller axis animation.
  133548. * This will be expanded when touchpad animations are fully supported
  133549. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  133550. */
  133551. export interface IMotionControllerMeshMap {
  133552. /**
  133553. * the mesh that defines the maximum value mesh position.
  133554. */
  133555. maxMesh?: AbstractMesh;
  133556. /**
  133557. * the mesh that defines the minimum value mesh position.
  133558. */
  133559. minMesh?: AbstractMesh;
  133560. /**
  133561. * The mesh that will be changed when axis value changes
  133562. */
  133563. valueMesh?: AbstractMesh;
  133564. }
  133565. /**
  133566. * The elements needed for change-detection of the gamepad objects in motion controllers
  133567. */
  133568. export interface IMinimalMotionControllerObject {
  133569. /**
  133570. * Available axes of this controller
  133571. */
  133572. axes: number[];
  133573. /**
  133574. * An array of available buttons
  133575. */
  133576. buttons: Array<{
  133577. /**
  133578. * Value of the button/trigger
  133579. */
  133580. value: number;
  133581. /**
  133582. * If the button/trigger is currently touched
  133583. */
  133584. touched: boolean;
  133585. /**
  133586. * If the button/trigger is currently pressed
  133587. */
  133588. pressed: boolean;
  133589. }>;
  133590. /**
  133591. * EXPERIMENTAL haptic support.
  133592. */
  133593. hapticActuators?: Array<{
  133594. pulse: (value: number, duration: number) => Promise<boolean>;
  133595. }>;
  133596. }
  133597. /**
  133598. * An Abstract Motion controller
  133599. * This class receives an xrInput and a profile layout and uses those to initialize the components
  133600. * Each component has an observable to check for changes in value and state
  133601. */
  133602. export abstract class WebXRAbstractMotionController implements IDisposable {
  133603. protected scene: Scene;
  133604. protected layout: IMotionControllerLayout;
  133605. /**
  133606. * The gamepad object correlating to this controller
  133607. */
  133608. gamepadObject: IMinimalMotionControllerObject;
  133609. /**
  133610. * handedness (left/right/none) of this controller
  133611. */
  133612. handedness: MotionControllerHandedness;
  133613. private _initComponent;
  133614. private _modelReady;
  133615. /**
  133616. * A map of components (WebXRControllerComponent) in this motion controller
  133617. * Components have a ComponentType and can also have both button and axis definitions
  133618. */
  133619. readonly components: {
  133620. [id: string]: WebXRControllerComponent;
  133621. };
  133622. /**
  133623. * Disable the model's animation. Can be set at any time.
  133624. */
  133625. disableAnimation: boolean;
  133626. /**
  133627. * Observers registered here will be triggered when the model of this controller is done loading
  133628. */
  133629. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  133630. /**
  133631. * The profile id of this motion controller
  133632. */
  133633. abstract profileId: string;
  133634. /**
  133635. * The root mesh of the model. It is null if the model was not yet initialized
  133636. */
  133637. rootMesh: Nullable<AbstractMesh>;
  133638. /**
  133639. * constructs a new abstract motion controller
  133640. * @param scene the scene to which the model of the controller will be added
  133641. * @param layout The profile layout to load
  133642. * @param gamepadObject The gamepad object correlating to this controller
  133643. * @param handedness handedness (left/right/none) of this controller
  133644. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  133645. */
  133646. constructor(scene: Scene, layout: IMotionControllerLayout,
  133647. /**
  133648. * The gamepad object correlating to this controller
  133649. */
  133650. gamepadObject: IMinimalMotionControllerObject,
  133651. /**
  133652. * handedness (left/right/none) of this controller
  133653. */
  133654. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  133655. /**
  133656. * Dispose this controller, the model mesh and all its components
  133657. */
  133658. dispose(): void;
  133659. /**
  133660. * Returns all components of specific type
  133661. * @param type the type to search for
  133662. * @return an array of components with this type
  133663. */
  133664. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  133665. /**
  133666. * get a component based an its component id as defined in layout.components
  133667. * @param id the id of the component
  133668. * @returns the component correlates to the id or undefined if not found
  133669. */
  133670. getComponent(id: string): WebXRControllerComponent;
  133671. /**
  133672. * Get the list of components available in this motion controller
  133673. * @returns an array of strings correlating to available components
  133674. */
  133675. getComponentIds(): string[];
  133676. /**
  133677. * Get the first component of specific type
  133678. * @param type type of component to find
  133679. * @return a controller component or null if not found
  133680. */
  133681. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  133682. /**
  133683. * Get the main (Select) component of this controller as defined in the layout
  133684. * @returns the main component of this controller
  133685. */
  133686. getMainComponent(): WebXRControllerComponent;
  133687. /**
  133688. * Loads the model correlating to this controller
  133689. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  133690. * @returns A promise fulfilled with the result of the model loading
  133691. */
  133692. loadModel(): Promise<boolean>;
  133693. /**
  133694. * Update this model using the current XRFrame
  133695. * @param xrFrame the current xr frame to use and update the model
  133696. */
  133697. updateFromXRFrame(xrFrame: XRFrame): void;
  133698. /**
  133699. * Backwards compatibility due to a deeply-integrated typo
  133700. */
  133701. get handness(): XREye;
  133702. /**
  133703. * Pulse (vibrate) this controller
  133704. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  133705. * Consecutive calls to this function will cancel the last pulse call
  133706. *
  133707. * @param value the strength of the pulse in 0.0...1.0 range
  133708. * @param duration Duration of the pulse in milliseconds
  133709. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  133710. * @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
  133711. */
  133712. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  133713. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133714. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133715. /**
  133716. * Moves the axis on the controller mesh based on its current state
  133717. * @param axis the index of the axis
  133718. * @param axisValue the value of the axis which determines the meshes new position
  133719. * @hidden
  133720. */
  133721. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  133722. /**
  133723. * Update the model itself with the current frame data
  133724. * @param xrFrame the frame to use for updating the model mesh
  133725. */
  133726. protected updateModel(xrFrame: XRFrame): void;
  133727. /**
  133728. * Get the filename and path for this controller's model
  133729. * @returns a map of filename and path
  133730. */
  133731. protected abstract _getFilenameAndPath(): {
  133732. filename: string;
  133733. path: string;
  133734. };
  133735. /**
  133736. * This function is called before the mesh is loaded. It checks for loading constraints.
  133737. * For example, this function can check if the GLB loader is available
  133738. * If this function returns false, the generic controller will be loaded instead
  133739. * @returns Is the client ready to load the mesh
  133740. */
  133741. protected abstract _getModelLoadingConstraints(): boolean;
  133742. /**
  133743. * This function will be called after the model was successfully loaded and can be used
  133744. * for mesh transformations before it is available for the user
  133745. * @param meshes the loaded meshes
  133746. */
  133747. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  133748. /**
  133749. * Set the root mesh for this controller. Important for the WebXR controller class
  133750. * @param meshes the loaded meshes
  133751. */
  133752. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  133753. /**
  133754. * A function executed each frame that updates the mesh (if needed)
  133755. * @param xrFrame the current xrFrame
  133756. */
  133757. protected abstract _updateModel(xrFrame: XRFrame): void;
  133758. private _getGenericFilenameAndPath;
  133759. private _getGenericParentMesh;
  133760. }
  133761. }
  133762. declare module BABYLON {
  133763. /**
  133764. * A generic trigger-only motion controller for WebXR
  133765. */
  133766. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  133767. /**
  133768. * Static version of the profile id of this controller
  133769. */
  133770. static ProfileId: string;
  133771. profileId: string;
  133772. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  133773. protected _getFilenameAndPath(): {
  133774. filename: string;
  133775. path: string;
  133776. };
  133777. protected _getModelLoadingConstraints(): boolean;
  133778. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  133779. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133780. protected _updateModel(): void;
  133781. }
  133782. }
  133783. declare module BABYLON {
  133784. /**
  133785. * Class containing static functions to help procedurally build meshes
  133786. */
  133787. export class SphereBuilder {
  133788. /**
  133789. * Creates a sphere mesh
  133790. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133791. * * 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`)
  133792. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133793. * * 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
  133794. * * 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)
  133795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133798. * @param name defines the name of the mesh
  133799. * @param options defines the options used to create the mesh
  133800. * @param scene defines the hosting scene
  133801. * @returns the sphere mesh
  133802. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133803. */
  133804. static CreateSphere(name: string, options: {
  133805. segments?: number;
  133806. diameter?: number;
  133807. diameterX?: number;
  133808. diameterY?: number;
  133809. diameterZ?: number;
  133810. arc?: number;
  133811. slice?: number;
  133812. sideOrientation?: number;
  133813. frontUVs?: Vector4;
  133814. backUVs?: Vector4;
  133815. updatable?: boolean;
  133816. }, scene?: Nullable<Scene>): Mesh;
  133817. }
  133818. }
  133819. declare module BABYLON {
  133820. /**
  133821. * A profiled motion controller has its profile loaded from an online repository.
  133822. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  133823. */
  133824. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  133825. private _repositoryUrl;
  133826. private _buttonMeshMapping;
  133827. private _touchDots;
  133828. /**
  133829. * The profile ID of this controller. Will be populated when the controller initializes.
  133830. */
  133831. profileId: string;
  133832. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  133833. dispose(): void;
  133834. protected _getFilenameAndPath(): {
  133835. filename: string;
  133836. path: string;
  133837. };
  133838. protected _getModelLoadingConstraints(): boolean;
  133839. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  133840. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133841. protected _updateModel(_xrFrame: XRFrame): void;
  133842. }
  133843. }
  133844. declare module BABYLON {
  133845. /**
  133846. * A construction function type to create a new controller based on an xrInput object
  133847. */
  133848. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  133849. /**
  133850. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  133851. *
  133852. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  133853. * it should be replaced with auto-loaded controllers.
  133854. *
  133855. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  133856. */
  133857. export class WebXRMotionControllerManager {
  133858. private static _AvailableControllers;
  133859. private static _Fallbacks;
  133860. private static _ProfileLoadingPromises;
  133861. private static _ProfilesList;
  133862. /**
  133863. * The base URL of the online controller repository. Can be changed at any time.
  133864. */
  133865. static BaseRepositoryUrl: string;
  133866. /**
  133867. * Which repository gets priority - local or online
  133868. */
  133869. static PrioritizeOnlineRepository: boolean;
  133870. /**
  133871. * Use the online repository, or use only locally-defined controllers
  133872. */
  133873. static UseOnlineRepository: boolean;
  133874. /**
  133875. * Clear the cache used for profile loading and reload when requested again
  133876. */
  133877. static ClearProfilesCache(): void;
  133878. /**
  133879. * Register the default fallbacks.
  133880. * This function is called automatically when this file is imported.
  133881. */
  133882. static DefaultFallbacks(): void;
  133883. /**
  133884. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  133885. * @param profileId the profile to which a fallback needs to be found
  133886. * @return an array with corresponding fallback profiles
  133887. */
  133888. static FindFallbackWithProfileId(profileId: string): string[];
  133889. /**
  133890. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  133891. * The order of search:
  133892. *
  133893. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  133894. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  133895. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  133896. * 4) return the generic trigger controller if none were found
  133897. *
  133898. * @param xrInput the xrInput to which a new controller is initialized
  133899. * @param scene the scene to which the model will be added
  133900. * @param forceProfile force a certain profile for this controller
  133901. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  133902. */
  133903. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  133904. /**
  133905. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  133906. *
  133907. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  133908. *
  133909. * @param type the profile type to register
  133910. * @param constructFunction the function to be called when loading this profile
  133911. */
  133912. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  133913. /**
  133914. * Register a fallback to a specific profile.
  133915. * @param profileId the profileId that will receive the fallbacks
  133916. * @param fallbacks A list of fallback profiles
  133917. */
  133918. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  133919. /**
  133920. * Will update the list of profiles available in the repository
  133921. * @return a promise that resolves to a map of profiles available online
  133922. */
  133923. static UpdateProfilesList(): Promise<{
  133924. [profile: string]: string;
  133925. }>;
  133926. private static _LoadProfileFromRepository;
  133927. private static _LoadProfilesFromAvailableControllers;
  133928. }
  133929. }
  133930. declare module BABYLON {
  133931. /**
  133932. * Configuration options for the WebXR controller creation
  133933. */
  133934. export interface IWebXRControllerOptions {
  133935. /**
  133936. * Should the controller mesh be animated when a user interacts with it
  133937. * The pressed buttons / thumbstick and touchpad animations will be disabled
  133938. */
  133939. disableMotionControllerAnimation?: boolean;
  133940. /**
  133941. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  133942. */
  133943. doNotLoadControllerMesh?: boolean;
  133944. /**
  133945. * Force a specific controller type for this controller.
  133946. * This can be used when creating your own profile or when testing different controllers
  133947. */
  133948. forceControllerProfile?: string;
  133949. /**
  133950. * Defines a rendering group ID for meshes that will be loaded.
  133951. * This is for the default controllers only.
  133952. */
  133953. renderingGroupId?: number;
  133954. }
  133955. /**
  133956. * Represents an XR controller
  133957. */
  133958. export class WebXRInputSource {
  133959. private _scene;
  133960. /** The underlying input source for the controller */
  133961. inputSource: XRInputSource;
  133962. private _options;
  133963. private _tmpVector;
  133964. private _uniqueId;
  133965. private _disposed;
  133966. /**
  133967. * 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
  133968. */
  133969. grip?: AbstractMesh;
  133970. /**
  133971. * If available, this is the gamepad object related to this controller.
  133972. * Using this object it is possible to get click events and trackpad changes of the
  133973. * webxr controller that is currently being used.
  133974. */
  133975. motionController?: WebXRAbstractMotionController;
  133976. /**
  133977. * Event that fires when the controller is removed/disposed.
  133978. * The object provided as event data is this controller, after associated assets were disposed.
  133979. * uniqueId is still available.
  133980. */
  133981. onDisposeObservable: Observable<WebXRInputSource>;
  133982. /**
  133983. * Will be triggered when the mesh associated with the motion controller is done loading.
  133984. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  133985. * A shortened version of controller -> motion controller -> on mesh loaded.
  133986. */
  133987. onMeshLoadedObservable: Observable<AbstractMesh>;
  133988. /**
  133989. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  133990. */
  133991. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  133992. /**
  133993. * Pointer which can be used to select objects or attach a visible laser to
  133994. */
  133995. pointer: AbstractMesh;
  133996. /**
  133997. * Creates the input source object
  133998. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  133999. * @param _scene the scene which the controller should be associated to
  134000. * @param inputSource the underlying input source for the controller
  134001. * @param _options options for this controller creation
  134002. */
  134003. constructor(_scene: Scene,
  134004. /** The underlying input source for the controller */
  134005. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  134006. /**
  134007. * Get this controllers unique id
  134008. */
  134009. get uniqueId(): string;
  134010. /**
  134011. * Disposes of the object
  134012. */
  134013. dispose(): void;
  134014. /**
  134015. * Gets a world space ray coming from the pointer or grip
  134016. * @param result the resulting ray
  134017. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  134018. */
  134019. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  134020. /**
  134021. * Updates the controller pose based on the given XRFrame
  134022. * @param xrFrame xr frame to update the pose with
  134023. * @param referenceSpace reference space to use
  134024. */
  134025. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  134026. }
  134027. }
  134028. declare module BABYLON {
  134029. /**
  134030. * The schema for initialization options of the XR Input class
  134031. */
  134032. export interface IWebXRInputOptions {
  134033. /**
  134034. * If set to true no model will be automatically loaded
  134035. */
  134036. doNotLoadControllerMeshes?: boolean;
  134037. /**
  134038. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  134039. * If not found, the xr input profile data will be used.
  134040. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  134041. */
  134042. forceInputProfile?: string;
  134043. /**
  134044. * Do not send a request to the controller repository to load the profile.
  134045. *
  134046. * Instead, use the controllers available in babylon itself.
  134047. */
  134048. disableOnlineControllerRepository?: boolean;
  134049. /**
  134050. * A custom URL for the controllers repository
  134051. */
  134052. customControllersRepositoryURL?: string;
  134053. /**
  134054. * Should the controller model's components not move according to the user input
  134055. */
  134056. disableControllerAnimation?: boolean;
  134057. /**
  134058. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  134059. */
  134060. controllerOptions?: IWebXRControllerOptions;
  134061. }
  134062. /**
  134063. * XR input used to track XR inputs such as controllers/rays
  134064. */
  134065. export class WebXRInput implements IDisposable {
  134066. /**
  134067. * the xr session manager for this session
  134068. */
  134069. xrSessionManager: WebXRSessionManager;
  134070. /**
  134071. * the WebXR camera for this session. Mainly used for teleportation
  134072. */
  134073. xrCamera: WebXRCamera;
  134074. private readonly options;
  134075. /**
  134076. * XR controllers being tracked
  134077. */
  134078. controllers: Array<WebXRInputSource>;
  134079. private _frameObserver;
  134080. private _sessionEndedObserver;
  134081. private _sessionInitObserver;
  134082. /**
  134083. * Event when a controller has been connected/added
  134084. */
  134085. onControllerAddedObservable: Observable<WebXRInputSource>;
  134086. /**
  134087. * Event when a controller has been removed/disconnected
  134088. */
  134089. onControllerRemovedObservable: Observable<WebXRInputSource>;
  134090. /**
  134091. * Initializes the WebXRInput
  134092. * @param xrSessionManager the xr session manager for this session
  134093. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  134094. * @param options = initialization options for this xr input
  134095. */
  134096. constructor(
  134097. /**
  134098. * the xr session manager for this session
  134099. */
  134100. xrSessionManager: WebXRSessionManager,
  134101. /**
  134102. * the WebXR camera for this session. Mainly used for teleportation
  134103. */
  134104. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  134105. private _onInputSourcesChange;
  134106. private _addAndRemoveControllers;
  134107. /**
  134108. * Disposes of the object
  134109. */
  134110. dispose(): void;
  134111. }
  134112. }
  134113. declare module BABYLON {
  134114. /**
  134115. * This is the base class for all WebXR features.
  134116. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  134117. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  134118. */
  134119. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  134120. protected _xrSessionManager: WebXRSessionManager;
  134121. private _attached;
  134122. private _removeOnDetach;
  134123. /**
  134124. * Is this feature disposed?
  134125. */
  134126. isDisposed: boolean;
  134127. /**
  134128. * Should auto-attach be disabled?
  134129. */
  134130. disableAutoAttach: boolean;
  134131. /**
  134132. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  134133. */
  134134. xrNativeFeatureName: string;
  134135. /**
  134136. * Construct a new (abstract) WebXR feature
  134137. * @param _xrSessionManager the xr session manager for this feature
  134138. */
  134139. constructor(_xrSessionManager: WebXRSessionManager);
  134140. /**
  134141. * Is this feature attached
  134142. */
  134143. get attached(): boolean;
  134144. /**
  134145. * attach this feature
  134146. *
  134147. * @param force should attachment be forced (even when already attached)
  134148. * @returns true if successful, false is failed or already attached
  134149. */
  134150. attach(force?: boolean): boolean;
  134151. /**
  134152. * detach this feature.
  134153. *
  134154. * @returns true if successful, false if failed or already detached
  134155. */
  134156. detach(): boolean;
  134157. /**
  134158. * Dispose this feature and all of the resources attached
  134159. */
  134160. dispose(): void;
  134161. /**
  134162. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  134163. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  134164. *
  134165. * @returns whether or not the feature is compatible in this environment
  134166. */
  134167. isCompatible(): boolean;
  134168. /**
  134169. * This is used to register callbacks that will automatically be removed when detach is called.
  134170. * @param observable the observable to which the observer will be attached
  134171. * @param callback the callback to register
  134172. */
  134173. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  134174. /**
  134175. * Code in this function will be executed on each xrFrame received from the browser.
  134176. * This function will not execute after the feature is detached.
  134177. * @param _xrFrame the current frame
  134178. */
  134179. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  134180. }
  134181. }
  134182. declare module BABYLON {
  134183. /**
  134184. * Renders a layer on top of an existing scene
  134185. */
  134186. export class UtilityLayerRenderer implements IDisposable {
  134187. /** the original scene that will be rendered on top of */
  134188. originalScene: Scene;
  134189. private _pointerCaptures;
  134190. private _lastPointerEvents;
  134191. private static _DefaultUtilityLayer;
  134192. private static _DefaultKeepDepthUtilityLayer;
  134193. private _sharedGizmoLight;
  134194. private _renderCamera;
  134195. /**
  134196. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  134197. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  134198. * @returns the camera that is used when rendering the utility layer
  134199. */
  134200. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  134201. /**
  134202. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  134203. * @param cam the camera that should be used when rendering the utility layer
  134204. */
  134205. setRenderCamera(cam: Nullable<Camera>): void;
  134206. /**
  134207. * @hidden
  134208. * Light which used by gizmos to get light shading
  134209. */
  134210. _getSharedGizmoLight(): HemisphericLight;
  134211. /**
  134212. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  134213. */
  134214. pickUtilitySceneFirst: boolean;
  134215. /**
  134216. * 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)
  134217. */
  134218. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  134219. /**
  134220. * 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)
  134221. */
  134222. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  134223. /**
  134224. * The scene that is rendered on top of the original scene
  134225. */
  134226. utilityLayerScene: Scene;
  134227. /**
  134228. * If the utility layer should automatically be rendered on top of existing scene
  134229. */
  134230. shouldRender: boolean;
  134231. /**
  134232. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  134233. */
  134234. onlyCheckPointerDownEvents: boolean;
  134235. /**
  134236. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  134237. */
  134238. processAllEvents: boolean;
  134239. /**
  134240. * Observable raised when the pointer move from the utility layer scene to the main scene
  134241. */
  134242. onPointerOutObservable: Observable<number>;
  134243. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  134244. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  134245. private _afterRenderObserver;
  134246. private _sceneDisposeObserver;
  134247. private _originalPointerObserver;
  134248. /**
  134249. * Instantiates a UtilityLayerRenderer
  134250. * @param originalScene the original scene that will be rendered on top of
  134251. * @param handleEvents boolean indicating if the utility layer should handle events
  134252. */
  134253. constructor(
  134254. /** the original scene that will be rendered on top of */
  134255. originalScene: Scene, handleEvents?: boolean);
  134256. private _notifyObservers;
  134257. /**
  134258. * Renders the utility layers scene on top of the original scene
  134259. */
  134260. render(): void;
  134261. /**
  134262. * Disposes of the renderer
  134263. */
  134264. dispose(): void;
  134265. private _updateCamera;
  134266. }
  134267. }
  134268. declare module BABYLON {
  134269. /**
  134270. * Options interface for the pointer selection module
  134271. */
  134272. export interface IWebXRControllerPointerSelectionOptions {
  134273. /**
  134274. * if provided, this scene will be used to render meshes.
  134275. */
  134276. customUtilityLayerScene?: Scene;
  134277. /**
  134278. * 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)
  134279. * If not disabled, the last picked point will be used to execute a pointer up event
  134280. * If disabled, pointer up event will be triggered right after the pointer down event.
  134281. * Used in screen and gaze target ray mode only
  134282. */
  134283. disablePointerUpOnTouchOut: boolean;
  134284. /**
  134285. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  134286. */
  134287. forceGazeMode: boolean;
  134288. /**
  134289. * 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
  134290. * to start a new countdown to the pointer down event.
  134291. * Defaults to 1.
  134292. */
  134293. gazeModePointerMovedFactor?: number;
  134294. /**
  134295. * Different button type to use instead of the main component
  134296. */
  134297. overrideButtonId?: string;
  134298. /**
  134299. * use this rendering group id for the meshes (optional)
  134300. */
  134301. renderingGroupId?: number;
  134302. /**
  134303. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  134304. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  134305. * 3000 means 3 seconds between pointing at something and selecting it
  134306. */
  134307. timeToSelect?: number;
  134308. /**
  134309. * Should meshes created here be added to a utility layer or the main scene
  134310. */
  134311. useUtilityLayer?: boolean;
  134312. /**
  134313. * Optional WebXR camera to be used for gaze selection
  134314. */
  134315. gazeCamera?: WebXRCamera;
  134316. /**
  134317. * the xr input to use with this pointer selection
  134318. */
  134319. xrInput: WebXRInput;
  134320. /**
  134321. * Should the scene pointerX and pointerY update be disabled
  134322. * This is required for fullscreen AR GUI, but might slow down other experiences.
  134323. * Disable in VR, if not needed.
  134324. * The first rig camera (left eye) will be used to calculate the projection
  134325. */
  134326. disableScenePointerVectorUpdate: boolean;
  134327. /**
  134328. * Enable pointer selection on all controllers instead of switching between them
  134329. */
  134330. enablePointerSelectionOnAllControllers?: boolean;
  134331. /**
  134332. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  134333. * If switch is enabled, it will still allow the user to switch between the different controllers
  134334. */
  134335. preferredHandedness?: XRHandedness;
  134336. /**
  134337. * Disable switching the pointer selection from one controller to the other.
  134338. * 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
  134339. */
  134340. disableSwitchOnClick?: boolean;
  134341. /**
  134342. * The maximum distance of the pointer selection feature. Defaults to 100.
  134343. */
  134344. maxPointerDistance?: number;
  134345. }
  134346. /**
  134347. * A module that will enable pointer selection for motion controllers of XR Input Sources
  134348. */
  134349. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  134350. private readonly _options;
  134351. private static _idCounter;
  134352. private _attachController;
  134353. private _controllers;
  134354. private _scene;
  134355. private _tmpVectorForPickCompare;
  134356. private _attachedController;
  134357. /**
  134358. * The module's name
  134359. */
  134360. static readonly Name: string;
  134361. /**
  134362. * The (Babylon) version of this module.
  134363. * This is an integer representing the implementation version.
  134364. * This number does not correspond to the WebXR specs version
  134365. */
  134366. static readonly Version: number;
  134367. /**
  134368. * Disable lighting on the laser pointer (so it will always be visible)
  134369. */
  134370. disablePointerLighting: boolean;
  134371. /**
  134372. * Disable lighting on the selection mesh (so it will always be visible)
  134373. */
  134374. disableSelectionMeshLighting: boolean;
  134375. /**
  134376. * Should the laser pointer be displayed
  134377. */
  134378. displayLaserPointer: boolean;
  134379. /**
  134380. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  134381. */
  134382. displaySelectionMesh: boolean;
  134383. /**
  134384. * This color will be set to the laser pointer when selection is triggered
  134385. */
  134386. laserPointerPickedColor: Color3;
  134387. /**
  134388. * Default color of the laser pointer
  134389. */
  134390. laserPointerDefaultColor: Color3;
  134391. /**
  134392. * default color of the selection ring
  134393. */
  134394. selectionMeshDefaultColor: Color3;
  134395. /**
  134396. * This color will be applied to the selection ring when selection is triggered
  134397. */
  134398. selectionMeshPickedColor: Color3;
  134399. /**
  134400. * Optional filter to be used for ray selection. This predicate shares behavior with
  134401. * scene.pointerMovePredicate which takes priority if it is also assigned.
  134402. */
  134403. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134404. /**
  134405. * constructs a new background remover module
  134406. * @param _xrSessionManager the session manager for this module
  134407. * @param _options read-only options to be used in this module
  134408. */
  134409. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  134410. /**
  134411. * attach this feature
  134412. * Will usually be called by the features manager
  134413. *
  134414. * @returns true if successful.
  134415. */
  134416. attach(): boolean;
  134417. /**
  134418. * detach this feature.
  134419. * Will usually be called by the features manager
  134420. *
  134421. * @returns true if successful.
  134422. */
  134423. detach(): boolean;
  134424. /**
  134425. * Will get the mesh under a specific pointer.
  134426. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  134427. * @param controllerId the controllerId to check
  134428. * @returns The mesh under pointer or null if no mesh is under the pointer
  134429. */
  134430. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  134431. /**
  134432. * Get the xr controller that correlates to the pointer id in the pointer event
  134433. *
  134434. * @param id the pointer id to search for
  134435. * @returns the controller that correlates to this id or null if not found
  134436. */
  134437. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  134438. private _identityMatrix;
  134439. private _screenCoordinatesRef;
  134440. private _viewportRef;
  134441. protected _onXRFrame(_xrFrame: XRFrame): void;
  134442. private _attachGazeMode;
  134443. private _attachScreenRayMode;
  134444. private _attachTrackedPointerRayMode;
  134445. private _convertNormalToDirectionOfRay;
  134446. private _detachController;
  134447. private _generateNewMeshPair;
  134448. private _pickingMoved;
  134449. private _updatePointerDistance;
  134450. /** @hidden */
  134451. get lasterPointerDefaultColor(): Color3;
  134452. }
  134453. }
  134454. declare module BABYLON {
  134455. /**
  134456. * Button which can be used to enter a different mode of XR
  134457. */
  134458. export class WebXREnterExitUIButton {
  134459. /** button element */
  134460. element: HTMLElement;
  134461. /** XR initialization options for the button */
  134462. sessionMode: XRSessionMode;
  134463. /** Reference space type */
  134464. referenceSpaceType: XRReferenceSpaceType;
  134465. /**
  134466. * Creates a WebXREnterExitUIButton
  134467. * @param element button element
  134468. * @param sessionMode XR initialization session mode
  134469. * @param referenceSpaceType the type of reference space to be used
  134470. */
  134471. constructor(
  134472. /** button element */
  134473. element: HTMLElement,
  134474. /** XR initialization options for the button */
  134475. sessionMode: XRSessionMode,
  134476. /** Reference space type */
  134477. referenceSpaceType: XRReferenceSpaceType);
  134478. /**
  134479. * Extendable function which can be used to update the button's visuals when the state changes
  134480. * @param activeButton the current active button in the UI
  134481. */
  134482. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  134483. }
  134484. /**
  134485. * Options to create the webXR UI
  134486. */
  134487. export class WebXREnterExitUIOptions {
  134488. /**
  134489. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  134490. */
  134491. customButtons?: Array<WebXREnterExitUIButton>;
  134492. /**
  134493. * A reference space type to use when creating the default button.
  134494. * Default is local-floor
  134495. */
  134496. referenceSpaceType?: XRReferenceSpaceType;
  134497. /**
  134498. * Context to enter xr with
  134499. */
  134500. renderTarget?: Nullable<WebXRRenderTarget>;
  134501. /**
  134502. * A session mode to use when creating the default button.
  134503. * Default is immersive-vr
  134504. */
  134505. sessionMode?: XRSessionMode;
  134506. /**
  134507. * A list of optional features to init the session with
  134508. */
  134509. optionalFeatures?: string[];
  134510. /**
  134511. * A list of optional features to init the session with
  134512. */
  134513. requiredFeatures?: string[];
  134514. /**
  134515. * If defined, this function will be executed if the UI encounters an error when entering XR
  134516. */
  134517. onError?: (error: any) => void;
  134518. }
  134519. /**
  134520. * UI to allow the user to enter/exit XR mode
  134521. */
  134522. export class WebXREnterExitUI implements IDisposable {
  134523. private scene;
  134524. /** version of the options passed to this UI */
  134525. options: WebXREnterExitUIOptions;
  134526. private _activeButton;
  134527. private _buttons;
  134528. /**
  134529. * The HTML Div Element to which buttons are added.
  134530. */
  134531. readonly overlay: HTMLDivElement;
  134532. /**
  134533. * Fired every time the active button is changed.
  134534. *
  134535. * When xr is entered via a button that launches xr that button will be the callback parameter
  134536. *
  134537. * When exiting xr the callback parameter will be null)
  134538. */
  134539. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  134540. /**
  134541. *
  134542. * @param scene babylon scene object to use
  134543. * @param options (read-only) version of the options passed to this UI
  134544. */
  134545. private constructor();
  134546. /**
  134547. * Creates UI to allow the user to enter/exit XR mode
  134548. * @param scene the scene to add the ui to
  134549. * @param helper the xr experience helper to enter/exit xr with
  134550. * @param options options to configure the UI
  134551. * @returns the created ui
  134552. */
  134553. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  134554. /**
  134555. * Disposes of the XR UI component
  134556. */
  134557. dispose(): void;
  134558. private _updateButtons;
  134559. }
  134560. }
  134561. declare module BABYLON {
  134562. /**
  134563. * Class containing static functions to help procedurally build meshes
  134564. */
  134565. export class LinesBuilder {
  134566. /**
  134567. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134568. * * 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
  134569. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134570. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134571. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134572. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134573. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134574. * * 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
  134575. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134577. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134578. * @param name defines the name of the new line system
  134579. * @param options defines the options used to create the line system
  134580. * @param scene defines the hosting scene
  134581. * @returns a new line system mesh
  134582. */
  134583. static CreateLineSystem(name: string, options: {
  134584. lines: Vector3[][];
  134585. updatable?: boolean;
  134586. instance?: Nullable<LinesMesh>;
  134587. colors?: Nullable<Color4[][]>;
  134588. useVertexAlpha?: boolean;
  134589. }, scene: Nullable<Scene>): LinesMesh;
  134590. /**
  134591. * Creates a line mesh
  134592. * 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
  134593. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134594. * * The parameter `points` is an array successive Vector3
  134595. * * 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
  134596. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134597. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134598. * * When updating an instance, remember that only point positions can change, not the number of points
  134599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134601. * @param name defines the name of the new line system
  134602. * @param options defines the options used to create the line system
  134603. * @param scene defines the hosting scene
  134604. * @returns a new line mesh
  134605. */
  134606. static CreateLines(name: string, options: {
  134607. points: Vector3[];
  134608. updatable?: boolean;
  134609. instance?: Nullable<LinesMesh>;
  134610. colors?: Color4[];
  134611. useVertexAlpha?: boolean;
  134612. }, scene?: Nullable<Scene>): LinesMesh;
  134613. /**
  134614. * Creates a dashed line mesh
  134615. * * 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
  134616. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134617. * * The parameter `points` is an array successive Vector3
  134618. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134619. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134620. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134621. * * 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
  134622. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134623. * * When updating an instance, remember that only point positions can change, not the number of points
  134624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134625. * @param name defines the name of the mesh
  134626. * @param options defines the options used to create the mesh
  134627. * @param scene defines the hosting scene
  134628. * @returns the dashed line mesh
  134629. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134630. */
  134631. static CreateDashedLines(name: string, options: {
  134632. points: Vector3[];
  134633. dashSize?: number;
  134634. gapSize?: number;
  134635. dashNb?: number;
  134636. updatable?: boolean;
  134637. instance?: LinesMesh;
  134638. useVertexAlpha?: boolean;
  134639. }, scene?: Nullable<Scene>): LinesMesh;
  134640. }
  134641. }
  134642. declare module BABYLON {
  134643. /**
  134644. * Construction options for a timer
  134645. */
  134646. export interface ITimerOptions<T> {
  134647. /**
  134648. * Time-to-end
  134649. */
  134650. timeout: number;
  134651. /**
  134652. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  134653. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  134654. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  134655. */
  134656. contextObservable: Observable<T>;
  134657. /**
  134658. * Optional parameters when adding an observer to the observable
  134659. */
  134660. observableParameters?: {
  134661. mask?: number;
  134662. insertFirst?: boolean;
  134663. scope?: any;
  134664. };
  134665. /**
  134666. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  134667. */
  134668. breakCondition?: (data?: ITimerData<T>) => boolean;
  134669. /**
  134670. * Will be triggered when the time condition has met
  134671. */
  134672. onEnded?: (data: ITimerData<any>) => void;
  134673. /**
  134674. * Will be triggered when the break condition has met (prematurely ended)
  134675. */
  134676. onAborted?: (data: ITimerData<any>) => void;
  134677. /**
  134678. * Optional function to execute on each tick (or count)
  134679. */
  134680. onTick?: (data: ITimerData<any>) => void;
  134681. }
  134682. /**
  134683. * An interface defining the data sent by the timer
  134684. */
  134685. export interface ITimerData<T> {
  134686. /**
  134687. * When did it start
  134688. */
  134689. startTime: number;
  134690. /**
  134691. * Time now
  134692. */
  134693. currentTime: number;
  134694. /**
  134695. * Time passed since started
  134696. */
  134697. deltaTime: number;
  134698. /**
  134699. * How much is completed, in [0.0...1.0].
  134700. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  134701. */
  134702. completeRate: number;
  134703. /**
  134704. * What the registered observable sent in the last count
  134705. */
  134706. payload: T;
  134707. }
  134708. /**
  134709. * The current state of the timer
  134710. */
  134711. export enum TimerState {
  134712. /**
  134713. * Timer initialized, not yet started
  134714. */
  134715. INIT = 0,
  134716. /**
  134717. * Timer started and counting
  134718. */
  134719. STARTED = 1,
  134720. /**
  134721. * Timer ended (whether aborted or time reached)
  134722. */
  134723. ENDED = 2
  134724. }
  134725. /**
  134726. * A simple version of the timer. Will take options and start the timer immediately after calling it
  134727. *
  134728. * @param options options with which to initialize this timer
  134729. */
  134730. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  134731. /**
  134732. * An advanced implementation of a timer class
  134733. */
  134734. export class AdvancedTimer<T = any> implements IDisposable {
  134735. /**
  134736. * Will notify each time the timer calculates the remaining time
  134737. */
  134738. onEachCountObservable: Observable<ITimerData<T>>;
  134739. /**
  134740. * Will trigger when the timer was aborted due to the break condition
  134741. */
  134742. onTimerAbortedObservable: Observable<ITimerData<T>>;
  134743. /**
  134744. * Will trigger when the timer ended successfully
  134745. */
  134746. onTimerEndedObservable: Observable<ITimerData<T>>;
  134747. /**
  134748. * Will trigger when the timer state has changed
  134749. */
  134750. onStateChangedObservable: Observable<TimerState>;
  134751. private _observer;
  134752. private _contextObservable;
  134753. private _observableParameters;
  134754. private _startTime;
  134755. private _timer;
  134756. private _state;
  134757. private _breakCondition;
  134758. private _timeToEnd;
  134759. private _breakOnNextTick;
  134760. /**
  134761. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  134762. * @param options construction options for this advanced timer
  134763. */
  134764. constructor(options: ITimerOptions<T>);
  134765. /**
  134766. * set a breaking condition for this timer. Default is to never break during count
  134767. * @param predicate the new break condition. Returns true to break, false otherwise
  134768. */
  134769. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  134770. /**
  134771. * Reset ALL associated observables in this advanced timer
  134772. */
  134773. clearObservables(): void;
  134774. /**
  134775. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  134776. *
  134777. * @param timeToEnd how much time to measure until timer ended
  134778. */
  134779. start(timeToEnd?: number): void;
  134780. /**
  134781. * Will force a stop on the next tick.
  134782. */
  134783. stop(): void;
  134784. /**
  134785. * Dispose this timer, clearing all resources
  134786. */
  134787. dispose(): void;
  134788. private _setState;
  134789. private _tick;
  134790. private _stop;
  134791. }
  134792. }
  134793. declare module BABYLON {
  134794. /**
  134795. * The options container for the teleportation module
  134796. */
  134797. export interface IWebXRTeleportationOptions {
  134798. /**
  134799. * if provided, this scene will be used to render meshes.
  134800. */
  134801. customUtilityLayerScene?: Scene;
  134802. /**
  134803. * Values to configure the default target mesh
  134804. */
  134805. defaultTargetMeshOptions?: {
  134806. /**
  134807. * Fill color of the teleportation area
  134808. */
  134809. teleportationFillColor?: string;
  134810. /**
  134811. * Border color for the teleportation area
  134812. */
  134813. teleportationBorderColor?: string;
  134814. /**
  134815. * Disable the mesh's animation sequence
  134816. */
  134817. disableAnimation?: boolean;
  134818. /**
  134819. * Disable lighting on the material or the ring and arrow
  134820. */
  134821. disableLighting?: boolean;
  134822. /**
  134823. * Override the default material of the torus and arrow
  134824. */
  134825. torusArrowMaterial?: Material;
  134826. };
  134827. /**
  134828. * A list of meshes to use as floor meshes.
  134829. * Meshes can be added and removed after initializing the feature using the
  134830. * addFloorMesh and removeFloorMesh functions
  134831. * If empty, rotation will still work
  134832. */
  134833. floorMeshes?: AbstractMesh[];
  134834. /**
  134835. * use this rendering group id for the meshes (optional)
  134836. */
  134837. renderingGroupId?: number;
  134838. /**
  134839. * Should teleportation move only to snap points
  134840. */
  134841. snapPointsOnly?: boolean;
  134842. /**
  134843. * An array of points to which the teleportation will snap to.
  134844. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  134845. */
  134846. snapPositions?: Vector3[];
  134847. /**
  134848. * How close should the teleportation ray be in order to snap to position.
  134849. * Default to 0.8 units (meters)
  134850. */
  134851. snapToPositionRadius?: number;
  134852. /**
  134853. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  134854. * If you want to support rotation, make sure your mesh has a direction indicator.
  134855. *
  134856. * When left untouched, the default mesh will be initialized.
  134857. */
  134858. teleportationTargetMesh?: AbstractMesh;
  134859. /**
  134860. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  134861. */
  134862. timeToTeleport?: number;
  134863. /**
  134864. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  134865. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  134866. */
  134867. useMainComponentOnly?: boolean;
  134868. /**
  134869. * Should meshes created here be added to a utility layer or the main scene
  134870. */
  134871. useUtilityLayer?: boolean;
  134872. /**
  134873. * Babylon XR Input class for controller
  134874. */
  134875. xrInput: WebXRInput;
  134876. /**
  134877. * Meshes that the teleportation ray cannot go through
  134878. */
  134879. pickBlockerMeshes?: AbstractMesh[];
  134880. /**
  134881. * Should teleport work only on a specific hand?
  134882. */
  134883. forceHandedness?: XRHandedness;
  134884. /**
  134885. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  134886. */
  134887. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  134888. }
  134889. /**
  134890. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  134891. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  134892. * the input of the attached controllers.
  134893. */
  134894. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  134895. private _options;
  134896. private _controllers;
  134897. private _currentTeleportationControllerId;
  134898. private _floorMeshes;
  134899. private _quadraticBezierCurve;
  134900. private _selectionFeature;
  134901. private _snapToPositions;
  134902. private _snappedToPoint;
  134903. private _teleportationRingMaterial?;
  134904. private _tmpRay;
  134905. private _tmpVector;
  134906. private _tmpQuaternion;
  134907. /**
  134908. * The module's name
  134909. */
  134910. static readonly Name: string;
  134911. /**
  134912. * The (Babylon) version of this module.
  134913. * This is an integer representing the implementation version.
  134914. * This number does not correspond to the webxr specs version
  134915. */
  134916. static readonly Version: number;
  134917. /**
  134918. * Is movement backwards enabled
  134919. */
  134920. backwardsMovementEnabled: boolean;
  134921. /**
  134922. * Distance to travel when moving backwards
  134923. */
  134924. backwardsTeleportationDistance: number;
  134925. /**
  134926. * The distance from the user to the inspection point in the direction of the controller
  134927. * A higher number will allow the user to move further
  134928. * defaults to 5 (meters, in xr units)
  134929. */
  134930. parabolicCheckRadius: number;
  134931. /**
  134932. * Should the module support parabolic ray on top of direct ray
  134933. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  134934. * Very helpful when moving between floors / different heights
  134935. */
  134936. parabolicRayEnabled: boolean;
  134937. /**
  134938. * The second type of ray - straight line.
  134939. * Should it be enabled or should the parabolic line be the only one.
  134940. */
  134941. straightRayEnabled: boolean;
  134942. /**
  134943. * How much rotation should be applied when rotating right and left
  134944. */
  134945. rotationAngle: number;
  134946. private _rotationEnabled;
  134947. /**
  134948. * Is rotation enabled when moving forward?
  134949. * Disabling this feature will prevent the user from deciding the direction when teleporting
  134950. */
  134951. get rotationEnabled(): boolean;
  134952. /**
  134953. * Sets wether rotation is enabled or not
  134954. * @param enabled is rotation enabled when teleportation is shown
  134955. */
  134956. set rotationEnabled(enabled: boolean);
  134957. /**
  134958. * Exposes the currently set teleportation target mesh.
  134959. */
  134960. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  134961. /**
  134962. * constructs a new anchor system
  134963. * @param _xrSessionManager an instance of WebXRSessionManager
  134964. * @param _options configuration object for this feature
  134965. */
  134966. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  134967. /**
  134968. * Get the snapPointsOnly flag
  134969. */
  134970. get snapPointsOnly(): boolean;
  134971. /**
  134972. * Sets the snapPointsOnly flag
  134973. * @param snapToPoints should teleportation be exclusively to snap points
  134974. */
  134975. set snapPointsOnly(snapToPoints: boolean);
  134976. /**
  134977. * Add a new mesh to the floor meshes array
  134978. * @param mesh the mesh to use as floor mesh
  134979. */
  134980. addFloorMesh(mesh: AbstractMesh): void;
  134981. /**
  134982. * Add a new snap-to point to fix teleportation to this position
  134983. * @param newSnapPoint The new Snap-To point
  134984. */
  134985. addSnapPoint(newSnapPoint: Vector3): void;
  134986. attach(): boolean;
  134987. detach(): boolean;
  134988. dispose(): void;
  134989. /**
  134990. * Remove a mesh from the floor meshes array
  134991. * @param mesh the mesh to remove
  134992. */
  134993. removeFloorMesh(mesh: AbstractMesh): void;
  134994. /**
  134995. * Remove a mesh from the floor meshes array using its name
  134996. * @param name the mesh name to remove
  134997. */
  134998. removeFloorMeshByName(name: string): void;
  134999. /**
  135000. * 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
  135001. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  135002. * @returns was the point found and removed or not
  135003. */
  135004. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  135005. /**
  135006. * This function sets a selection feature that will be disabled when
  135007. * the forward ray is shown and will be reattached when hidden.
  135008. * This is used to remove the selection rays when moving.
  135009. * @param selectionFeature the feature to disable when forward movement is enabled
  135010. */
  135011. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  135012. protected _onXRFrame(_xrFrame: XRFrame): void;
  135013. private _attachController;
  135014. private _createDefaultTargetMesh;
  135015. private _detachController;
  135016. private _findClosestSnapPointWithRadius;
  135017. private _setTargetMeshPosition;
  135018. private _setTargetMeshVisibility;
  135019. private _showParabolicPath;
  135020. private _teleportForward;
  135021. }
  135022. }
  135023. declare module BABYLON {
  135024. /**
  135025. * Options for the default xr helper
  135026. */
  135027. export class WebXRDefaultExperienceOptions {
  135028. /**
  135029. * Enable or disable default UI to enter XR
  135030. */
  135031. disableDefaultUI?: boolean;
  135032. /**
  135033. * Should teleportation not initialize. defaults to false.
  135034. */
  135035. disableTeleportation?: boolean;
  135036. /**
  135037. * Floor meshes that will be used for teleport
  135038. */
  135039. floorMeshes?: Array<AbstractMesh>;
  135040. /**
  135041. * If set to true, the first frame will not be used to reset position
  135042. * The first frame is mainly used when copying transformation from the old camera
  135043. * Mainly used in AR
  135044. */
  135045. ignoreNativeCameraTransformation?: boolean;
  135046. /**
  135047. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  135048. */
  135049. inputOptions?: IWebXRInputOptions;
  135050. /**
  135051. * optional configuration for the output canvas
  135052. */
  135053. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  135054. /**
  135055. * optional UI options. This can be used among other to change session mode and reference space type
  135056. */
  135057. uiOptions?: WebXREnterExitUIOptions;
  135058. /**
  135059. * When loading teleportation and pointer select, use stable versions instead of latest.
  135060. */
  135061. useStablePlugins?: boolean;
  135062. /**
  135063. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  135064. */
  135065. renderingGroupId?: number;
  135066. /**
  135067. * A list of optional features to init the session with
  135068. * If set to true, all features we support will be added
  135069. */
  135070. optionalFeatures?: boolean | string[];
  135071. }
  135072. /**
  135073. * Default experience which provides a similar setup to the previous webVRExperience
  135074. */
  135075. export class WebXRDefaultExperience {
  135076. /**
  135077. * Base experience
  135078. */
  135079. baseExperience: WebXRExperienceHelper;
  135080. /**
  135081. * Enables ui for entering/exiting xr
  135082. */
  135083. enterExitUI: WebXREnterExitUI;
  135084. /**
  135085. * Input experience extension
  135086. */
  135087. input: WebXRInput;
  135088. /**
  135089. * Enables laser pointer and selection
  135090. */
  135091. pointerSelection: WebXRControllerPointerSelection;
  135092. /**
  135093. * Default target xr should render to
  135094. */
  135095. renderTarget: WebXRRenderTarget;
  135096. /**
  135097. * Enables teleportation
  135098. */
  135099. teleportation: WebXRMotionControllerTeleportation;
  135100. private constructor();
  135101. /**
  135102. * Creates the default xr experience
  135103. * @param scene scene
  135104. * @param options options for basic configuration
  135105. * @returns resulting WebXRDefaultExperience
  135106. */
  135107. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  135108. /**
  135109. * DIsposes of the experience helper
  135110. */
  135111. dispose(): void;
  135112. }
  135113. }
  135114. declare module BABYLON {
  135115. /**
  135116. * Options to modify the vr teleportation behavior.
  135117. */
  135118. export interface VRTeleportationOptions {
  135119. /**
  135120. * The name of the mesh which should be used as the teleportation floor. (default: null)
  135121. */
  135122. floorMeshName?: string;
  135123. /**
  135124. * A list of meshes to be used as the teleportation floor. (default: empty)
  135125. */
  135126. floorMeshes?: Mesh[];
  135127. /**
  135128. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  135129. */
  135130. teleportationMode?: number;
  135131. /**
  135132. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  135133. */
  135134. teleportationTime?: number;
  135135. /**
  135136. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  135137. */
  135138. teleportationSpeed?: number;
  135139. /**
  135140. * The easing function used in the animation or null for Linear. (default CircleEase)
  135141. */
  135142. easingFunction?: EasingFunction;
  135143. }
  135144. /**
  135145. * Options to modify the vr experience helper's behavior.
  135146. */
  135147. export interface VRExperienceHelperOptions extends WebVROptions {
  135148. /**
  135149. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  135150. */
  135151. createDeviceOrientationCamera?: boolean;
  135152. /**
  135153. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  135154. */
  135155. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  135156. /**
  135157. * Uses the main button on the controller to toggle the laser casted. (default: true)
  135158. */
  135159. laserToggle?: boolean;
  135160. /**
  135161. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  135162. */
  135163. floorMeshes?: Mesh[];
  135164. /**
  135165. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  135166. */
  135167. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  135168. /**
  135169. * Defines if WebXR should be used instead of WebVR (if available)
  135170. */
  135171. useXR?: boolean;
  135172. }
  135173. /**
  135174. * Event containing information after VR has been entered
  135175. */
  135176. export class OnAfterEnteringVRObservableEvent {
  135177. /**
  135178. * If entering vr was successful
  135179. */
  135180. success: boolean;
  135181. }
  135182. /**
  135183. * Helps to quickly add VR support to an existing scene.
  135184. * See https://doc.babylonjs.com/how_to/webvr_helper
  135185. */
  135186. export class VRExperienceHelper {
  135187. /** Options to modify the vr experience helper's behavior. */
  135188. webVROptions: VRExperienceHelperOptions;
  135189. private _scene;
  135190. private _position;
  135191. private _btnVR;
  135192. private _btnVRDisplayed;
  135193. private _webVRsupported;
  135194. private _webVRready;
  135195. private _webVRrequesting;
  135196. private _webVRpresenting;
  135197. private _hasEnteredVR;
  135198. private _fullscreenVRpresenting;
  135199. private _inputElement;
  135200. private _webVRCamera;
  135201. private _vrDeviceOrientationCamera;
  135202. private _deviceOrientationCamera;
  135203. private _existingCamera;
  135204. private _onKeyDown;
  135205. private _onVrDisplayPresentChange;
  135206. private _onVRDisplayChanged;
  135207. private _onVRRequestPresentStart;
  135208. private _onVRRequestPresentComplete;
  135209. /**
  135210. * 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)
  135211. */
  135212. enableGazeEvenWhenNoPointerLock: boolean;
  135213. /**
  135214. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  135215. */
  135216. exitVROnDoubleTap: boolean;
  135217. /**
  135218. * Observable raised right before entering VR.
  135219. */
  135220. onEnteringVRObservable: Observable<VRExperienceHelper>;
  135221. /**
  135222. * Observable raised when entering VR has completed.
  135223. */
  135224. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  135225. /**
  135226. * Observable raised when exiting VR.
  135227. */
  135228. onExitingVRObservable: Observable<VRExperienceHelper>;
  135229. /**
  135230. * Observable raised when controller mesh is loaded.
  135231. */
  135232. onControllerMeshLoadedObservable: Observable<WebVRController>;
  135233. /** Return this.onEnteringVRObservable
  135234. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  135235. */
  135236. get onEnteringVR(): Observable<VRExperienceHelper>;
  135237. /** Return this.onExitingVRObservable
  135238. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  135239. */
  135240. get onExitingVR(): Observable<VRExperienceHelper>;
  135241. /** Return this.onControllerMeshLoadedObservable
  135242. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  135243. */
  135244. get onControllerMeshLoaded(): Observable<WebVRController>;
  135245. private _rayLength;
  135246. private _useCustomVRButton;
  135247. private _teleportationRequested;
  135248. private _teleportActive;
  135249. private _floorMeshName;
  135250. private _floorMeshesCollection;
  135251. private _teleportationMode;
  135252. private _teleportationTime;
  135253. private _teleportationSpeed;
  135254. private _teleportationEasing;
  135255. private _rotationAllowed;
  135256. private _teleportBackwardsVector;
  135257. private _teleportationTarget;
  135258. private _isDefaultTeleportationTarget;
  135259. private _postProcessMove;
  135260. private _teleportationFillColor;
  135261. private _teleportationBorderColor;
  135262. private _rotationAngle;
  135263. private _haloCenter;
  135264. private _cameraGazer;
  135265. private _padSensibilityUp;
  135266. private _padSensibilityDown;
  135267. private _leftController;
  135268. private _rightController;
  135269. private _gazeColor;
  135270. private _laserColor;
  135271. private _pickedLaserColor;
  135272. private _pickedGazeColor;
  135273. /**
  135274. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  135275. */
  135276. onNewMeshSelected: Observable<AbstractMesh>;
  135277. /**
  135278. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  135279. * This observable will provide the mesh and the controller used to select the mesh
  135280. */
  135281. onMeshSelectedWithController: Observable<{
  135282. mesh: AbstractMesh;
  135283. controller: WebVRController;
  135284. }>;
  135285. /**
  135286. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  135287. */
  135288. onNewMeshPicked: Observable<PickingInfo>;
  135289. private _circleEase;
  135290. /**
  135291. * Observable raised before camera teleportation
  135292. */
  135293. onBeforeCameraTeleport: Observable<Vector3>;
  135294. /**
  135295. * Observable raised after camera teleportation
  135296. */
  135297. onAfterCameraTeleport: Observable<Vector3>;
  135298. /**
  135299. * Observable raised when current selected mesh gets unselected
  135300. */
  135301. onSelectedMeshUnselected: Observable<AbstractMesh>;
  135302. private _raySelectionPredicate;
  135303. /**
  135304. * To be optionaly changed by user to define custom ray selection
  135305. */
  135306. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  135307. /**
  135308. * To be optionaly changed by user to define custom selection logic (after ray selection)
  135309. */
  135310. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135311. /**
  135312. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  135313. */
  135314. teleportationEnabled: boolean;
  135315. private _defaultHeight;
  135316. private _teleportationInitialized;
  135317. private _interactionsEnabled;
  135318. private _interactionsRequested;
  135319. private _displayGaze;
  135320. private _displayLaserPointer;
  135321. /**
  135322. * The mesh used to display where the user is going to teleport.
  135323. */
  135324. get teleportationTarget(): Mesh;
  135325. /**
  135326. * Sets the mesh to be used to display where the user is going to teleport.
  135327. */
  135328. set teleportationTarget(value: Mesh);
  135329. /**
  135330. * 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
  135331. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  135332. * See https://doc.babylonjs.com/resources/baking_transformations
  135333. */
  135334. get gazeTrackerMesh(): Mesh;
  135335. set gazeTrackerMesh(value: Mesh);
  135336. /**
  135337. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  135338. */
  135339. updateGazeTrackerScale: boolean;
  135340. /**
  135341. * If the gaze trackers color should be updated when selecting meshes
  135342. */
  135343. updateGazeTrackerColor: boolean;
  135344. /**
  135345. * If the controller laser color should be updated when selecting meshes
  135346. */
  135347. updateControllerLaserColor: boolean;
  135348. /**
  135349. * The gaze tracking mesh corresponding to the left controller
  135350. */
  135351. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  135352. /**
  135353. * The gaze tracking mesh corresponding to the right controller
  135354. */
  135355. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  135356. /**
  135357. * If the ray of the gaze should be displayed.
  135358. */
  135359. get displayGaze(): boolean;
  135360. /**
  135361. * Sets if the ray of the gaze should be displayed.
  135362. */
  135363. set displayGaze(value: boolean);
  135364. /**
  135365. * If the ray of the LaserPointer should be displayed.
  135366. */
  135367. get displayLaserPointer(): boolean;
  135368. /**
  135369. * Sets if the ray of the LaserPointer should be displayed.
  135370. */
  135371. set displayLaserPointer(value: boolean);
  135372. /**
  135373. * The deviceOrientationCamera used as the camera when not in VR.
  135374. */
  135375. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  135376. /**
  135377. * Based on the current WebVR support, returns the current VR camera used.
  135378. */
  135379. get currentVRCamera(): Nullable<Camera>;
  135380. /**
  135381. * The webVRCamera which is used when in VR.
  135382. */
  135383. get webVRCamera(): WebVRFreeCamera;
  135384. /**
  135385. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  135386. */
  135387. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  135388. /**
  135389. * The html button that is used to trigger entering into VR.
  135390. */
  135391. get vrButton(): Nullable<HTMLButtonElement>;
  135392. private get _teleportationRequestInitiated();
  135393. /**
  135394. * Defines whether or not Pointer lock should be requested when switching to
  135395. * full screen.
  135396. */
  135397. requestPointerLockOnFullScreen: boolean;
  135398. /**
  135399. * If asking to force XR, this will be populated with the default xr experience
  135400. */
  135401. xr: WebXRDefaultExperience;
  135402. /**
  135403. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  135404. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  135405. */
  135406. xrTestDone: boolean;
  135407. /**
  135408. * Instantiates a VRExperienceHelper.
  135409. * Helps to quickly add VR support to an existing scene.
  135410. * @param scene The scene the VRExperienceHelper belongs to.
  135411. * @param webVROptions Options to modify the vr experience helper's behavior.
  135412. */
  135413. constructor(scene: Scene,
  135414. /** Options to modify the vr experience helper's behavior. */
  135415. webVROptions?: VRExperienceHelperOptions);
  135416. private completeVRInit;
  135417. private _onDefaultMeshLoaded;
  135418. private _onResize;
  135419. private _onFullscreenChange;
  135420. /**
  135421. * Gets a value indicating if we are currently in VR mode.
  135422. */
  135423. get isInVRMode(): boolean;
  135424. private onVrDisplayPresentChange;
  135425. private onVRDisplayChanged;
  135426. private moveButtonToBottomRight;
  135427. private displayVRButton;
  135428. private updateButtonVisibility;
  135429. private _cachedAngularSensibility;
  135430. /**
  135431. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  135432. * Otherwise, will use the fullscreen API.
  135433. */
  135434. enterVR(): void;
  135435. /**
  135436. * Attempt to exit VR, or fullscreen.
  135437. */
  135438. exitVR(): void;
  135439. /**
  135440. * The position of the vr experience helper.
  135441. */
  135442. get position(): Vector3;
  135443. /**
  135444. * Sets the position of the vr experience helper.
  135445. */
  135446. set position(value: Vector3);
  135447. /**
  135448. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  135449. */
  135450. enableInteractions(): void;
  135451. private get _noControllerIsActive();
  135452. private beforeRender;
  135453. private _isTeleportationFloor;
  135454. /**
  135455. * Adds a floor mesh to be used for teleportation.
  135456. * @param floorMesh the mesh to be used for teleportation.
  135457. */
  135458. addFloorMesh(floorMesh: Mesh): void;
  135459. /**
  135460. * Removes a floor mesh from being used for teleportation.
  135461. * @param floorMesh the mesh to be removed.
  135462. */
  135463. removeFloorMesh(floorMesh: Mesh): void;
  135464. /**
  135465. * Enables interactions and teleportation using the VR controllers and gaze.
  135466. * @param vrTeleportationOptions options to modify teleportation behavior.
  135467. */
  135468. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  135469. private _onNewGamepadConnected;
  135470. private _tryEnableInteractionOnController;
  135471. private _onNewGamepadDisconnected;
  135472. private _enableInteractionOnController;
  135473. private _checkTeleportWithRay;
  135474. private _checkRotate;
  135475. private _checkTeleportBackwards;
  135476. private _enableTeleportationOnController;
  135477. private _createTeleportationCircles;
  135478. private _displayTeleportationTarget;
  135479. private _hideTeleportationTarget;
  135480. private _rotateCamera;
  135481. private _moveTeleportationSelectorTo;
  135482. private _workingVector;
  135483. private _workingQuaternion;
  135484. private _workingMatrix;
  135485. /**
  135486. * Time Constant Teleportation Mode
  135487. */
  135488. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  135489. /**
  135490. * Speed Constant Teleportation Mode
  135491. */
  135492. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  135493. /**
  135494. * Teleports the users feet to the desired location
  135495. * @param location The location where the user's feet should be placed
  135496. */
  135497. teleportCamera(location: Vector3): void;
  135498. private _convertNormalToDirectionOfRay;
  135499. private _castRayAndSelectObject;
  135500. private _notifySelectedMeshUnselected;
  135501. /**
  135502. * Permanently set new colors for the laser pointer
  135503. * @param color the new laser color
  135504. * @param pickedColor the new laser color when picked mesh detected
  135505. */
  135506. setLaserColor(color: Color3, pickedColor?: Color3): void;
  135507. /**
  135508. * Set lighting enabled / disabled on the laser pointer of both controllers
  135509. * @param enabled should the lighting be enabled on the laser pointer
  135510. */
  135511. setLaserLightingState(enabled?: boolean): void;
  135512. /**
  135513. * Permanently set new colors for the gaze pointer
  135514. * @param color the new gaze color
  135515. * @param pickedColor the new gaze color when picked mesh detected
  135516. */
  135517. setGazeColor(color: Color3, pickedColor?: Color3): void;
  135518. /**
  135519. * Sets the color of the laser ray from the vr controllers.
  135520. * @param color new color for the ray.
  135521. */
  135522. changeLaserColor(color: Color3): void;
  135523. /**
  135524. * Sets the color of the ray from the vr headsets gaze.
  135525. * @param color new color for the ray.
  135526. */
  135527. changeGazeColor(color: Color3): void;
  135528. /**
  135529. * Exits VR and disposes of the vr experience helper
  135530. */
  135531. dispose(): void;
  135532. /**
  135533. * Gets the name of the VRExperienceHelper class
  135534. * @returns "VRExperienceHelper"
  135535. */
  135536. getClassName(): string;
  135537. }
  135538. }
  135539. declare module BABYLON {
  135540. /**
  135541. * Contains an array of blocks representing the octree
  135542. */
  135543. export interface IOctreeContainer<T> {
  135544. /**
  135545. * Blocks within the octree
  135546. */
  135547. blocks: Array<OctreeBlock<T>>;
  135548. }
  135549. /**
  135550. * Class used to store a cell in an octree
  135551. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135552. */
  135553. export class OctreeBlock<T> {
  135554. /**
  135555. * Gets the content of the current block
  135556. */
  135557. entries: T[];
  135558. /**
  135559. * Gets the list of block children
  135560. */
  135561. blocks: Array<OctreeBlock<T>>;
  135562. private _depth;
  135563. private _maxDepth;
  135564. private _capacity;
  135565. private _minPoint;
  135566. private _maxPoint;
  135567. private _boundingVectors;
  135568. private _creationFunc;
  135569. /**
  135570. * Creates a new block
  135571. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  135572. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  135573. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135574. * @param depth defines the current depth of this block in the octree
  135575. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  135576. * @param creationFunc defines a callback to call when an element is added to the block
  135577. */
  135578. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  135579. /**
  135580. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135581. */
  135582. get capacity(): number;
  135583. /**
  135584. * Gets the minimum vector (in world space) of the block's bounding box
  135585. */
  135586. get minPoint(): Vector3;
  135587. /**
  135588. * Gets the maximum vector (in world space) of the block's bounding box
  135589. */
  135590. get maxPoint(): Vector3;
  135591. /**
  135592. * Add a new element to this block
  135593. * @param entry defines the element to add
  135594. */
  135595. addEntry(entry: T): void;
  135596. /**
  135597. * Remove an element from this block
  135598. * @param entry defines the element to remove
  135599. */
  135600. removeEntry(entry: T): void;
  135601. /**
  135602. * Add an array of elements to this block
  135603. * @param entries defines the array of elements to add
  135604. */
  135605. addEntries(entries: T[]): void;
  135606. /**
  135607. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  135608. * @param frustumPlanes defines the frustum planes to test
  135609. * @param selection defines the array to store current content if selection is positive
  135610. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135611. */
  135612. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135613. /**
  135614. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  135615. * @param sphereCenter defines the bounding sphere center
  135616. * @param sphereRadius defines the bounding sphere radius
  135617. * @param selection defines the array to store current content if selection is positive
  135618. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135619. */
  135620. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135621. /**
  135622. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  135623. * @param ray defines the ray to test with
  135624. * @param selection defines the array to store current content if selection is positive
  135625. */
  135626. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  135627. /**
  135628. * Subdivide the content into child blocks (this block will then be empty)
  135629. */
  135630. createInnerBlocks(): void;
  135631. /**
  135632. * @hidden
  135633. */
  135634. 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;
  135635. }
  135636. }
  135637. declare module BABYLON {
  135638. /**
  135639. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  135640. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135641. */
  135642. export class Octree<T> {
  135643. /** 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.) */
  135644. maxDepth: number;
  135645. /**
  135646. * Blocks within the octree containing objects
  135647. */
  135648. blocks: Array<OctreeBlock<T>>;
  135649. /**
  135650. * Content stored in the octree
  135651. */
  135652. dynamicContent: T[];
  135653. private _maxBlockCapacity;
  135654. private _selectionContent;
  135655. private _creationFunc;
  135656. /**
  135657. * Creates a octree
  135658. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135659. * @param creationFunc function to be used to instatiate the octree
  135660. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  135661. * @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.)
  135662. */
  135663. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  135664. /** 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.) */
  135665. maxDepth?: number);
  135666. /**
  135667. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  135668. * @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);
  135669. * @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);
  135670. * @param entries meshes to be added to the octree blocks
  135671. */
  135672. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  135673. /**
  135674. * Adds a mesh to the octree
  135675. * @param entry Mesh to add to the octree
  135676. */
  135677. addMesh(entry: T): void;
  135678. /**
  135679. * Remove an element from the octree
  135680. * @param entry defines the element to remove
  135681. */
  135682. removeMesh(entry: T): void;
  135683. /**
  135684. * Selects an array of meshes within the frustum
  135685. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  135686. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  135687. * @returns array of meshes within the frustum
  135688. */
  135689. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  135690. /**
  135691. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  135692. * @param sphereCenter defines the bounding sphere center
  135693. * @param sphereRadius defines the bounding sphere radius
  135694. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135695. * @returns an array of objects that intersect the sphere
  135696. */
  135697. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  135698. /**
  135699. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  135700. * @param ray defines the ray to test with
  135701. * @returns array of intersected objects
  135702. */
  135703. intersectsRay(ray: Ray): SmartArray<T>;
  135704. /**
  135705. * Adds a mesh into the octree block if it intersects the block
  135706. */
  135707. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  135708. /**
  135709. * Adds a submesh into the octree block if it intersects the block
  135710. */
  135711. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  135712. }
  135713. }
  135714. declare module BABYLON {
  135715. interface Scene {
  135716. /**
  135717. * @hidden
  135718. * Backing Filed
  135719. */
  135720. _selectionOctree: Octree<AbstractMesh>;
  135721. /**
  135722. * Gets the octree used to boost mesh selection (picking)
  135723. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135724. */
  135725. selectionOctree: Octree<AbstractMesh>;
  135726. /**
  135727. * Creates or updates the octree used to boost selection (picking)
  135728. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135729. * @param maxCapacity defines the maximum capacity per leaf
  135730. * @param maxDepth defines the maximum depth of the octree
  135731. * @returns an octree of AbstractMesh
  135732. */
  135733. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  135734. }
  135735. interface AbstractMesh {
  135736. /**
  135737. * @hidden
  135738. * Backing Field
  135739. */
  135740. _submeshesOctree: Octree<SubMesh>;
  135741. /**
  135742. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  135743. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  135744. * @param maxCapacity defines the maximum size of each block (64 by default)
  135745. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  135746. * @returns the new octree
  135747. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  135748. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135749. */
  135750. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  135751. }
  135752. /**
  135753. * Defines the octree scene component responsible to manage any octrees
  135754. * in a given scene.
  135755. */
  135756. export class OctreeSceneComponent {
  135757. /**
  135758. * The component name help to identify the component in the list of scene components.
  135759. */
  135760. readonly name: string;
  135761. /**
  135762. * The scene the component belongs to.
  135763. */
  135764. scene: Scene;
  135765. /**
  135766. * Indicates if the meshes have been checked to make sure they are isEnabled()
  135767. */
  135768. readonly checksIsEnabled: boolean;
  135769. /**
  135770. * Creates a new instance of the component for the given scene
  135771. * @param scene Defines the scene to register the component in
  135772. */
  135773. constructor(scene: Scene);
  135774. /**
  135775. * Registers the component in a given scene
  135776. */
  135777. register(): void;
  135778. /**
  135779. * Return the list of active meshes
  135780. * @returns the list of active meshes
  135781. */
  135782. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  135783. /**
  135784. * Return the list of active sub meshes
  135785. * @param mesh The mesh to get the candidates sub meshes from
  135786. * @returns the list of active sub meshes
  135787. */
  135788. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  135789. private _tempRay;
  135790. /**
  135791. * Return the list of sub meshes intersecting with a given local ray
  135792. * @param mesh defines the mesh to find the submesh for
  135793. * @param localRay defines the ray in local space
  135794. * @returns the list of intersecting sub meshes
  135795. */
  135796. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  135797. /**
  135798. * Return the list of sub meshes colliding with a collider
  135799. * @param mesh defines the mesh to find the submesh for
  135800. * @param collider defines the collider to evaluate the collision against
  135801. * @returns the list of colliding sub meshes
  135802. */
  135803. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  135804. /**
  135805. * Rebuilds the elements related to this component in case of
  135806. * context lost for instance.
  135807. */
  135808. rebuild(): void;
  135809. /**
  135810. * Disposes the component and the associated ressources.
  135811. */
  135812. dispose(): void;
  135813. }
  135814. }
  135815. declare module BABYLON {
  135816. /**
  135817. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  135818. */
  135819. export interface GizmoAxisCache {
  135820. /** Mesh used to runder the Gizmo */
  135821. gizmoMeshes: Mesh[];
  135822. /** Mesh used to detect user interaction with Gizmo */
  135823. colliderMeshes: Mesh[];
  135824. /** Material used to inicate color of gizmo mesh */
  135825. material: StandardMaterial;
  135826. /** Material used to inicate hover state of the Gizmo */
  135827. hoverMaterial: StandardMaterial;
  135828. /** Material used to inicate disabled state of the Gizmo */
  135829. disableMaterial: StandardMaterial;
  135830. /** Used to indicate Active state of the Gizmo */
  135831. active: boolean;
  135832. }
  135833. /**
  135834. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  135835. */
  135836. export class Gizmo implements IDisposable {
  135837. /** The utility layer the gizmo will be added to */
  135838. gizmoLayer: UtilityLayerRenderer;
  135839. /**
  135840. * The root mesh of the gizmo
  135841. */
  135842. _rootMesh: Mesh;
  135843. private _attachedMesh;
  135844. private _attachedNode;
  135845. /**
  135846. * Ratio for the scale of the gizmo (Default: 1)
  135847. */
  135848. protected _scaleRatio: number;
  135849. /**
  135850. * boolean updated by pointermove when a gizmo mesh is hovered
  135851. */
  135852. protected _isHovered: boolean;
  135853. /**
  135854. * Ratio for the scale of the gizmo (Default: 1)
  135855. */
  135856. set scaleRatio(value: number);
  135857. get scaleRatio(): number;
  135858. /**
  135859. * True when the mouse pointer is hovered a gizmo mesh
  135860. */
  135861. get isHovered(): boolean;
  135862. /**
  135863. * If a custom mesh has been set (Default: false)
  135864. */
  135865. protected _customMeshSet: boolean;
  135866. /**
  135867. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  135868. * * When set, interactions will be enabled
  135869. */
  135870. get attachedMesh(): Nullable<AbstractMesh>;
  135871. set attachedMesh(value: Nullable<AbstractMesh>);
  135872. /**
  135873. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  135874. * * When set, interactions will be enabled
  135875. */
  135876. get attachedNode(): Nullable<Node>;
  135877. set attachedNode(value: Nullable<Node>);
  135878. /**
  135879. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  135880. * @param mesh The mesh to replace the default mesh of the gizmo
  135881. */
  135882. setCustomMesh(mesh: Mesh): void;
  135883. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  135884. /**
  135885. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  135886. */
  135887. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135888. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135889. /**
  135890. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  135891. */
  135892. updateGizmoPositionToMatchAttachedMesh: boolean;
  135893. /**
  135894. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  135895. */
  135896. updateScale: boolean;
  135897. protected _interactionsEnabled: boolean;
  135898. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135899. private _beforeRenderObserver;
  135900. private _tempQuaternion;
  135901. private _tempVector;
  135902. private _tempVector2;
  135903. private _tempMatrix1;
  135904. private _tempMatrix2;
  135905. private _rightHandtoLeftHandMatrix;
  135906. /**
  135907. * Creates a gizmo
  135908. * @param gizmoLayer The utility layer the gizmo will be added to
  135909. */
  135910. constructor(
  135911. /** The utility layer the gizmo will be added to */
  135912. gizmoLayer?: UtilityLayerRenderer);
  135913. /**
  135914. * Updates the gizmo to match the attached mesh's position/rotation
  135915. */
  135916. protected _update(): void;
  135917. /**
  135918. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  135919. * @param value Node, TransformNode or mesh
  135920. */
  135921. protected _matrixChanged(): void;
  135922. /**
  135923. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  135924. * @param gizmoLayer The utility layer the gizmo will be added to
  135925. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  135926. * @returns {Observer<PointerInfo>} pointerObserver
  135927. */
  135928. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  135929. /**
  135930. * Disposes of the gizmo
  135931. */
  135932. dispose(): void;
  135933. }
  135934. }
  135935. declare module BABYLON {
  135936. /**
  135937. * Single plane drag gizmo
  135938. */
  135939. export class PlaneDragGizmo extends Gizmo {
  135940. /**
  135941. * Drag behavior responsible for the gizmos dragging interactions
  135942. */
  135943. dragBehavior: PointerDragBehavior;
  135944. private _pointerObserver;
  135945. /**
  135946. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135947. */
  135948. snapDistance: number;
  135949. /**
  135950. * Event that fires each time the gizmo snaps to a new location.
  135951. * * snapDistance is the the change in distance
  135952. */
  135953. onSnapObservable: Observable<{
  135954. snapDistance: number;
  135955. }>;
  135956. private _gizmoMesh;
  135957. private _coloredMaterial;
  135958. private _hoverMaterial;
  135959. private _disableMaterial;
  135960. private _isEnabled;
  135961. private _parent;
  135962. private _dragging;
  135963. /** @hidden */
  135964. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  135965. /**
  135966. * Creates a PlaneDragGizmo
  135967. * @param gizmoLayer The utility layer the gizmo will be added to
  135968. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  135969. * @param color The color of the gizmo
  135970. */
  135971. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  135972. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135973. /**
  135974. * If the gizmo is enabled
  135975. */
  135976. set isEnabled(value: boolean);
  135977. get isEnabled(): boolean;
  135978. /**
  135979. * Disposes of the gizmo
  135980. */
  135981. dispose(): void;
  135982. }
  135983. }
  135984. declare module BABYLON {
  135985. /**
  135986. * Single plane rotation gizmo
  135987. */
  135988. export class PlaneRotationGizmo extends Gizmo {
  135989. /**
  135990. * Drag behavior responsible for the gizmos dragging interactions
  135991. */
  135992. dragBehavior: PointerDragBehavior;
  135993. private _pointerObserver;
  135994. /**
  135995. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  135996. */
  135997. snapDistance: number;
  135998. /**
  135999. * Event that fires each time the gizmo snaps to a new location.
  136000. * * snapDistance is the the change in distance
  136001. */
  136002. onSnapObservable: Observable<{
  136003. snapDistance: number;
  136004. }>;
  136005. private _isEnabled;
  136006. private _parent;
  136007. private _coloredMaterial;
  136008. private _hoverMaterial;
  136009. private _disableMaterial;
  136010. private _gizmoMesh;
  136011. private _rotationCircle;
  136012. private _dragging;
  136013. private static _CircleConstants;
  136014. /**
  136015. * Creates a PlaneRotationGizmo
  136016. * @param gizmoLayer The utility layer the gizmo will be added to
  136017. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  136018. * @param color The color of the gizmo
  136019. * @param tessellation Amount of tessellation to be used when creating rotation circles
  136020. * @param useEulerRotation Use and update Euler angle instead of quaternion
  136021. * @param thickness display gizmo axis thickness
  136022. */
  136023. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  136024. /** Create Geometry for Gizmo */
  136025. private _createGizmoMesh;
  136026. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136027. private setupRotationCircle;
  136028. private updateRotationPath;
  136029. private updateRotationCircle;
  136030. /**
  136031. * If the gizmo is enabled
  136032. */
  136033. set isEnabled(value: boolean);
  136034. get isEnabled(): boolean;
  136035. /**
  136036. * Disposes of the gizmo
  136037. */
  136038. dispose(): void;
  136039. }
  136040. }
  136041. declare module BABYLON {
  136042. /**
  136043. * Gizmo that enables rotating a mesh along 3 axis
  136044. */
  136045. export class RotationGizmo extends Gizmo {
  136046. /**
  136047. * Internal gizmo used for interactions on the x axis
  136048. */
  136049. xGizmo: PlaneRotationGizmo;
  136050. /**
  136051. * Internal gizmo used for interactions on the y axis
  136052. */
  136053. yGizmo: PlaneRotationGizmo;
  136054. /**
  136055. * Internal gizmo used for interactions on the z axis
  136056. */
  136057. zGizmo: PlaneRotationGizmo;
  136058. /** Fires an event when any of it's sub gizmos are dragged */
  136059. onDragStartObservable: Observable<unknown>;
  136060. /** Fires an event when any of it's sub gizmos are released from dragging */
  136061. onDragEndObservable: Observable<unknown>;
  136062. private _meshAttached;
  136063. private _nodeAttached;
  136064. private _observables;
  136065. /** Node Caching for quick lookup */
  136066. private _gizmoAxisCache;
  136067. get attachedMesh(): Nullable<AbstractMesh>;
  136068. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136069. get attachedNode(): Nullable<Node>;
  136070. set attachedNode(node: Nullable<Node>);
  136071. protected _checkBillboardTransform(): void;
  136072. /**
  136073. * True when the mouse pointer is hovering a gizmo mesh
  136074. */
  136075. get isHovered(): boolean;
  136076. /**
  136077. * Creates a RotationGizmo
  136078. * @param gizmoLayer The utility layer the gizmo will be added to
  136079. * @param tessellation Amount of tessellation to be used when creating rotation circles
  136080. * @param useEulerRotation Use and update Euler angle instead of quaternion
  136081. * @param thickness display gizmo axis thickness
  136082. */
  136083. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  136084. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136085. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136086. /**
  136087. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136088. */
  136089. set snapDistance(value: number);
  136090. get snapDistance(): number;
  136091. /**
  136092. * Ratio for the scale of the gizmo (Default: 1)
  136093. */
  136094. set scaleRatio(value: number);
  136095. get scaleRatio(): number;
  136096. /**
  136097. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136098. * @param mesh Axis gizmo mesh
  136099. * @param cache Gizmo axis definition used for reactive gizmo UI
  136100. */
  136101. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136102. /**
  136103. * Disposes of the gizmo
  136104. */
  136105. dispose(): void;
  136106. /**
  136107. * CustomMeshes are not supported by this gizmo
  136108. * @param mesh The mesh to replace the default mesh of the gizmo
  136109. */
  136110. setCustomMesh(mesh: Mesh): void;
  136111. }
  136112. }
  136113. declare module BABYLON {
  136114. /**
  136115. * Class containing static functions to help procedurally build meshes
  136116. */
  136117. export class PolyhedronBuilder {
  136118. /**
  136119. * Creates a polyhedron mesh
  136120. * * 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
  136121. * * The parameter `size` (positive float, default 1) sets the polygon size
  136122. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136123. * * 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`
  136124. * * 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
  136125. * * 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)`)
  136126. * * 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
  136127. * * 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
  136128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136131. * @param name defines the name of the mesh
  136132. * @param options defines the options used to create the mesh
  136133. * @param scene defines the hosting scene
  136134. * @returns the polyhedron mesh
  136135. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136136. */
  136137. static CreatePolyhedron(name: string, options: {
  136138. type?: number;
  136139. size?: number;
  136140. sizeX?: number;
  136141. sizeY?: number;
  136142. sizeZ?: number;
  136143. custom?: any;
  136144. faceUV?: Vector4[];
  136145. faceColors?: Color4[];
  136146. flat?: boolean;
  136147. updatable?: boolean;
  136148. sideOrientation?: number;
  136149. frontUVs?: Vector4;
  136150. backUVs?: Vector4;
  136151. }, scene?: Nullable<Scene>): Mesh;
  136152. }
  136153. }
  136154. declare module BABYLON {
  136155. /**
  136156. * Class containing static functions to help procedurally build meshes
  136157. */
  136158. export class BoxBuilder {
  136159. /**
  136160. * Creates a box mesh
  136161. * * The parameter `size` sets the size (float) of each box side (default 1)
  136162. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  136163. * * 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)
  136164. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136168. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  136169. * @param name defines the name of the mesh
  136170. * @param options defines the options used to create the mesh
  136171. * @param scene defines the hosting scene
  136172. * @returns the box mesh
  136173. */
  136174. static CreateBox(name: string, options: {
  136175. size?: number;
  136176. width?: number;
  136177. height?: number;
  136178. depth?: number;
  136179. faceUV?: Vector4[];
  136180. faceColors?: Color4[];
  136181. sideOrientation?: number;
  136182. frontUVs?: Vector4;
  136183. backUVs?: Vector4;
  136184. wrap?: boolean;
  136185. topBaseAt?: number;
  136186. bottomBaseAt?: number;
  136187. updatable?: boolean;
  136188. }, scene?: Nullable<Scene>): Mesh;
  136189. }
  136190. }
  136191. declare module BABYLON {
  136192. /**
  136193. * Single axis scale gizmo
  136194. */
  136195. export class AxisScaleGizmo extends Gizmo {
  136196. /**
  136197. * Drag behavior responsible for the gizmos dragging interactions
  136198. */
  136199. dragBehavior: PointerDragBehavior;
  136200. private _pointerObserver;
  136201. /**
  136202. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136203. */
  136204. snapDistance: number;
  136205. /**
  136206. * Event that fires each time the gizmo snaps to a new location.
  136207. * * snapDistance is the the change in distance
  136208. */
  136209. onSnapObservable: Observable<{
  136210. snapDistance: number;
  136211. }>;
  136212. /**
  136213. * If the scaling operation should be done on all axis (default: false)
  136214. */
  136215. uniformScaling: boolean;
  136216. /**
  136217. * Custom sensitivity value for the drag strength
  136218. */
  136219. sensitivity: number;
  136220. private _isEnabled;
  136221. private _parent;
  136222. private _gizmoMesh;
  136223. private _coloredMaterial;
  136224. private _hoverMaterial;
  136225. private _disableMaterial;
  136226. private _dragging;
  136227. private _tmpVector;
  136228. private _tmpMatrix;
  136229. private _tmpMatrix2;
  136230. /**
  136231. * Creates an AxisScaleGizmo
  136232. * @param gizmoLayer The utility layer the gizmo will be added to
  136233. * @param dragAxis The axis which the gizmo will be able to scale on
  136234. * @param color The color of the gizmo
  136235. * @param thickness display gizmo axis thickness
  136236. */
  136237. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  136238. /** Create Geometry for Gizmo */
  136239. private _createGizmoMesh;
  136240. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136241. /**
  136242. * If the gizmo is enabled
  136243. */
  136244. set isEnabled(value: boolean);
  136245. get isEnabled(): boolean;
  136246. /**
  136247. * Disposes of the gizmo
  136248. */
  136249. dispose(): void;
  136250. /**
  136251. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  136252. * @param mesh The mesh to replace the default mesh of the gizmo
  136253. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  136254. */
  136255. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  136256. }
  136257. }
  136258. declare module BABYLON {
  136259. /**
  136260. * Gizmo that enables scaling a mesh along 3 axis
  136261. */
  136262. export class ScaleGizmo extends Gizmo {
  136263. /**
  136264. * Internal gizmo used for interactions on the x axis
  136265. */
  136266. xGizmo: AxisScaleGizmo;
  136267. /**
  136268. * Internal gizmo used for interactions on the y axis
  136269. */
  136270. yGizmo: AxisScaleGizmo;
  136271. /**
  136272. * Internal gizmo used for interactions on the z axis
  136273. */
  136274. zGizmo: AxisScaleGizmo;
  136275. /**
  136276. * Internal gizmo used to scale all axis equally
  136277. */
  136278. uniformScaleGizmo: AxisScaleGizmo;
  136279. private _meshAttached;
  136280. private _nodeAttached;
  136281. private _snapDistance;
  136282. private _uniformScalingMesh;
  136283. private _octahedron;
  136284. private _sensitivity;
  136285. private _coloredMaterial;
  136286. private _hoverMaterial;
  136287. private _disableMaterial;
  136288. private _observables;
  136289. /** Node Caching for quick lookup */
  136290. private _gizmoAxisCache;
  136291. /** Fires an event when any of it's sub gizmos are dragged */
  136292. onDragStartObservable: Observable<unknown>;
  136293. /** Fires an event when any of it's sub gizmos are released from dragging */
  136294. onDragEndObservable: Observable<unknown>;
  136295. get attachedMesh(): Nullable<AbstractMesh>;
  136296. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136297. get attachedNode(): Nullable<Node>;
  136298. set attachedNode(node: Nullable<Node>);
  136299. /**
  136300. * True when the mouse pointer is hovering a gizmo mesh
  136301. */
  136302. get isHovered(): boolean;
  136303. /**
  136304. * Creates a ScaleGizmo
  136305. * @param gizmoLayer The utility layer the gizmo will be added to
  136306. * @param thickness display gizmo axis thickness
  136307. */
  136308. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136309. /** Create Geometry for Gizmo */
  136310. private _createUniformScaleMesh;
  136311. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136312. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136313. /**
  136314. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136315. */
  136316. set snapDistance(value: number);
  136317. get snapDistance(): number;
  136318. /**
  136319. * Ratio for the scale of the gizmo (Default: 1)
  136320. */
  136321. set scaleRatio(value: number);
  136322. get scaleRatio(): number;
  136323. /**
  136324. * Sensitivity factor for dragging (Default: 1)
  136325. */
  136326. set sensitivity(value: number);
  136327. get sensitivity(): number;
  136328. /**
  136329. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136330. * @param mesh Axis gizmo mesh
  136331. * @param cache Gizmo axis definition used for reactive gizmo UI
  136332. */
  136333. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136334. /**
  136335. * Disposes of the gizmo
  136336. */
  136337. dispose(): void;
  136338. }
  136339. }
  136340. declare module BABYLON {
  136341. /**
  136342. * Bounding box gizmo
  136343. */
  136344. export class BoundingBoxGizmo extends Gizmo {
  136345. private _lineBoundingBox;
  136346. private _rotateSpheresParent;
  136347. private _scaleBoxesParent;
  136348. private _boundingDimensions;
  136349. private _renderObserver;
  136350. private _pointerObserver;
  136351. private _scaleDragSpeed;
  136352. private _tmpQuaternion;
  136353. private _tmpVector;
  136354. private _tmpRotationMatrix;
  136355. /**
  136356. * 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)
  136357. */
  136358. ignoreChildren: boolean;
  136359. /**
  136360. * 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)
  136361. */
  136362. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  136363. /**
  136364. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  136365. */
  136366. rotationSphereSize: number;
  136367. /**
  136368. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  136369. */
  136370. scaleBoxSize: number;
  136371. /**
  136372. * 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)
  136373. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  136374. */
  136375. fixedDragMeshScreenSize: boolean;
  136376. /**
  136377. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  136378. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  136379. */
  136380. fixedDragMeshBoundsSize: boolean;
  136381. /**
  136382. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  136383. */
  136384. fixedDragMeshScreenSizeDistanceFactor: number;
  136385. /**
  136386. * Fired when a rotation sphere or scale box is dragged
  136387. */
  136388. onDragStartObservable: Observable<{}>;
  136389. /**
  136390. * Fired when a scale box is dragged
  136391. */
  136392. onScaleBoxDragObservable: Observable<{}>;
  136393. /**
  136394. * Fired when a scale box drag is ended
  136395. */
  136396. onScaleBoxDragEndObservable: Observable<{}>;
  136397. /**
  136398. * Fired when a rotation sphere is dragged
  136399. */
  136400. onRotationSphereDragObservable: Observable<{}>;
  136401. /**
  136402. * Fired when a rotation sphere drag is ended
  136403. */
  136404. onRotationSphereDragEndObservable: Observable<{}>;
  136405. /**
  136406. * 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)
  136407. */
  136408. scalePivot: Nullable<Vector3>;
  136409. /**
  136410. * Mesh used as a pivot to rotate the attached node
  136411. */
  136412. private _anchorMesh;
  136413. private _existingMeshScale;
  136414. private _dragMesh;
  136415. private pointerDragBehavior;
  136416. private coloredMaterial;
  136417. private hoverColoredMaterial;
  136418. /**
  136419. * Sets the color of the bounding box gizmo
  136420. * @param color the color to set
  136421. */
  136422. setColor(color: Color3): void;
  136423. /**
  136424. * Creates an BoundingBoxGizmo
  136425. * @param gizmoLayer The utility layer the gizmo will be added to
  136426. * @param color The color of the gizmo
  136427. */
  136428. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  136429. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  136430. private _selectNode;
  136431. /**
  136432. * Updates the bounding box information for the Gizmo
  136433. */
  136434. updateBoundingBox(): void;
  136435. private _updateRotationSpheres;
  136436. private _updateScaleBoxes;
  136437. /**
  136438. * Enables rotation on the specified axis and disables rotation on the others
  136439. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  136440. */
  136441. setEnabledRotationAxis(axis: string): void;
  136442. /**
  136443. * Enables/disables scaling
  136444. * @param enable if scaling should be enabled
  136445. * @param homogeneousScaling defines if scaling should only be homogeneous
  136446. */
  136447. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  136448. private _updateDummy;
  136449. /**
  136450. * Enables a pointer drag behavior on the bounding box of the gizmo
  136451. */
  136452. enableDragBehavior(): void;
  136453. /**
  136454. * Disposes of the gizmo
  136455. */
  136456. dispose(): void;
  136457. /**
  136458. * 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)
  136459. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  136460. * @returns the bounding box mesh with the passed in mesh as a child
  136461. */
  136462. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  136463. /**
  136464. * CustomMeshes are not supported by this gizmo
  136465. * @param mesh The mesh to replace the default mesh of the gizmo
  136466. */
  136467. setCustomMesh(mesh: Mesh): void;
  136468. }
  136469. }
  136470. declare module BABYLON {
  136471. /**
  136472. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  136473. */
  136474. export class GizmoManager implements IDisposable {
  136475. private scene;
  136476. /**
  136477. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  136478. */
  136479. gizmos: {
  136480. positionGizmo: Nullable<PositionGizmo>;
  136481. rotationGizmo: Nullable<RotationGizmo>;
  136482. scaleGizmo: Nullable<ScaleGizmo>;
  136483. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  136484. };
  136485. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  136486. clearGizmoOnEmptyPointerEvent: boolean;
  136487. /** Fires an event when the manager is attached to a mesh */
  136488. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  136489. /** Fires an event when the manager is attached to a node */
  136490. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  136491. private _gizmosEnabled;
  136492. private _pointerObservers;
  136493. private _attachedMesh;
  136494. private _attachedNode;
  136495. private _boundingBoxColor;
  136496. private _defaultUtilityLayer;
  136497. private _defaultKeepDepthUtilityLayer;
  136498. private _thickness;
  136499. /** Node Caching for quick lookup */
  136500. private _gizmoAxisCache;
  136501. /**
  136502. * When bounding box gizmo is enabled, this can be used to track drag/end events
  136503. */
  136504. boundingBoxDragBehavior: SixDofDragBehavior;
  136505. /**
  136506. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  136507. */
  136508. attachableMeshes: Nullable<Array<AbstractMesh>>;
  136509. /**
  136510. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  136511. */
  136512. attachableNodes: Nullable<Array<Node>>;
  136513. /**
  136514. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  136515. */
  136516. usePointerToAttachGizmos: boolean;
  136517. /**
  136518. * Utility layer that the bounding box gizmo belongs to
  136519. */
  136520. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  136521. /**
  136522. * Utility layer that all gizmos besides bounding box belong to
  136523. */
  136524. get utilityLayer(): UtilityLayerRenderer;
  136525. /**
  136526. * True when the mouse pointer is hovering a gizmo mesh
  136527. */
  136528. get isHovered(): boolean;
  136529. /**
  136530. * Instatiates a gizmo manager
  136531. * @param scene the scene to overlay the gizmos on top of
  136532. * @param thickness display gizmo axis thickness
  136533. * @param utilityLayer the layer where gizmos are rendered
  136534. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  136535. */
  136536. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  136537. /**
  136538. * Subscribes to pointer down events, for attaching and detaching mesh
  136539. * @param scene The sceme layer the observer will be added to
  136540. */
  136541. private _attachToMeshPointerObserver;
  136542. /**
  136543. * Attaches a set of gizmos to the specified mesh
  136544. * @param mesh The mesh the gizmo's should be attached to
  136545. */
  136546. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136547. /**
  136548. * Attaches a set of gizmos to the specified node
  136549. * @param node The node the gizmo's should be attached to
  136550. */
  136551. attachToNode(node: Nullable<Node>): void;
  136552. /**
  136553. * If the position gizmo is enabled
  136554. */
  136555. set positionGizmoEnabled(value: boolean);
  136556. get positionGizmoEnabled(): boolean;
  136557. /**
  136558. * If the rotation gizmo is enabled
  136559. */
  136560. set rotationGizmoEnabled(value: boolean);
  136561. get rotationGizmoEnabled(): boolean;
  136562. /**
  136563. * If the scale gizmo is enabled
  136564. */
  136565. set scaleGizmoEnabled(value: boolean);
  136566. get scaleGizmoEnabled(): boolean;
  136567. /**
  136568. * If the boundingBox gizmo is enabled
  136569. */
  136570. set boundingBoxGizmoEnabled(value: boolean);
  136571. get boundingBoxGizmoEnabled(): boolean;
  136572. /**
  136573. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136574. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  136575. */
  136576. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  136577. /**
  136578. * Disposes of the gizmo manager
  136579. */
  136580. dispose(): void;
  136581. }
  136582. }
  136583. declare module BABYLON {
  136584. /**
  136585. * Gizmo that enables dragging a mesh along 3 axis
  136586. */
  136587. export class PositionGizmo extends Gizmo {
  136588. /**
  136589. * Internal gizmo used for interactions on the x axis
  136590. */
  136591. xGizmo: AxisDragGizmo;
  136592. /**
  136593. * Internal gizmo used for interactions on the y axis
  136594. */
  136595. yGizmo: AxisDragGizmo;
  136596. /**
  136597. * Internal gizmo used for interactions on the z axis
  136598. */
  136599. zGizmo: AxisDragGizmo;
  136600. /**
  136601. * Internal gizmo used for interactions on the yz plane
  136602. */
  136603. xPlaneGizmo: PlaneDragGizmo;
  136604. /**
  136605. * Internal gizmo used for interactions on the xz plane
  136606. */
  136607. yPlaneGizmo: PlaneDragGizmo;
  136608. /**
  136609. * Internal gizmo used for interactions on the xy plane
  136610. */
  136611. zPlaneGizmo: PlaneDragGizmo;
  136612. /**
  136613. * private variables
  136614. */
  136615. private _meshAttached;
  136616. private _nodeAttached;
  136617. private _snapDistance;
  136618. private _observables;
  136619. /** Node Caching for quick lookup */
  136620. private _gizmoAxisCache;
  136621. /** Fires an event when any of it's sub gizmos are dragged */
  136622. onDragStartObservable: Observable<unknown>;
  136623. /** Fires an event when any of it's sub gizmos are released from dragging */
  136624. onDragEndObservable: Observable<unknown>;
  136625. /**
  136626. * If set to true, planar drag is enabled
  136627. */
  136628. private _planarGizmoEnabled;
  136629. get attachedMesh(): Nullable<AbstractMesh>;
  136630. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136631. get attachedNode(): Nullable<Node>;
  136632. set attachedNode(node: Nullable<Node>);
  136633. /**
  136634. * True when the mouse pointer is hovering a gizmo mesh
  136635. */
  136636. get isHovered(): boolean;
  136637. /**
  136638. * Creates a PositionGizmo
  136639. * @param gizmoLayer The utility layer the gizmo will be added to
  136640. @param thickness display gizmo axis thickness
  136641. */
  136642. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136643. /**
  136644. * If the planar drag gizmo is enabled
  136645. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  136646. */
  136647. set planarGizmoEnabled(value: boolean);
  136648. get planarGizmoEnabled(): boolean;
  136649. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136650. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136651. /**
  136652. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136653. */
  136654. set snapDistance(value: number);
  136655. get snapDistance(): number;
  136656. /**
  136657. * Ratio for the scale of the gizmo (Default: 1)
  136658. */
  136659. set scaleRatio(value: number);
  136660. get scaleRatio(): number;
  136661. /**
  136662. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136663. * @param mesh Axis gizmo mesh
  136664. * @param cache Gizmo axis definition used for reactive gizmo UI
  136665. */
  136666. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136667. /**
  136668. * Disposes of the gizmo
  136669. */
  136670. dispose(): void;
  136671. /**
  136672. * CustomMeshes are not supported by this gizmo
  136673. * @param mesh The mesh to replace the default mesh of the gizmo
  136674. */
  136675. setCustomMesh(mesh: Mesh): void;
  136676. }
  136677. }
  136678. declare module BABYLON {
  136679. /**
  136680. * Single axis drag gizmo
  136681. */
  136682. export class AxisDragGizmo extends Gizmo {
  136683. /**
  136684. * Drag behavior responsible for the gizmos dragging interactions
  136685. */
  136686. dragBehavior: PointerDragBehavior;
  136687. private _pointerObserver;
  136688. /**
  136689. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136690. */
  136691. snapDistance: number;
  136692. /**
  136693. * Event that fires each time the gizmo snaps to a new location.
  136694. * * snapDistance is the the change in distance
  136695. */
  136696. onSnapObservable: Observable<{
  136697. snapDistance: number;
  136698. }>;
  136699. private _isEnabled;
  136700. private _parent;
  136701. private _gizmoMesh;
  136702. private _coloredMaterial;
  136703. private _hoverMaterial;
  136704. private _disableMaterial;
  136705. private _dragging;
  136706. /** @hidden */
  136707. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  136708. /** @hidden */
  136709. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  136710. /**
  136711. * Creates an AxisDragGizmo
  136712. * @param gizmoLayer The utility layer the gizmo will be added to
  136713. * @param dragAxis The axis which the gizmo will be able to drag on
  136714. * @param color The color of the gizmo
  136715. * @param thickness display gizmo axis thickness
  136716. */
  136717. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  136718. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136719. /**
  136720. * If the gizmo is enabled
  136721. */
  136722. set isEnabled(value: boolean);
  136723. get isEnabled(): boolean;
  136724. /**
  136725. * Disposes of the gizmo
  136726. */
  136727. dispose(): void;
  136728. }
  136729. }
  136730. declare module BABYLON.Debug {
  136731. /**
  136732. * The Axes viewer will show 3 axes in a specific point in space
  136733. */
  136734. export class AxesViewer {
  136735. private _xAxis;
  136736. private _yAxis;
  136737. private _zAxis;
  136738. private _scaleLinesFactor;
  136739. private _instanced;
  136740. /**
  136741. * Gets the hosting scene
  136742. */
  136743. scene: Nullable<Scene>;
  136744. /**
  136745. * Gets or sets a number used to scale line length
  136746. */
  136747. scaleLines: number;
  136748. /** Gets the node hierarchy used to render x-axis */
  136749. get xAxis(): TransformNode;
  136750. /** Gets the node hierarchy used to render y-axis */
  136751. get yAxis(): TransformNode;
  136752. /** Gets the node hierarchy used to render z-axis */
  136753. get zAxis(): TransformNode;
  136754. /**
  136755. * Creates a new AxesViewer
  136756. * @param scene defines the hosting scene
  136757. * @param scaleLines defines a number used to scale line length (1 by default)
  136758. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  136759. * @param xAxis defines the node hierarchy used to render the x-axis
  136760. * @param yAxis defines the node hierarchy used to render the y-axis
  136761. * @param zAxis defines the node hierarchy used to render the z-axis
  136762. */
  136763. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  136764. /**
  136765. * Force the viewer to update
  136766. * @param position defines the position of the viewer
  136767. * @param xaxis defines the x axis of the viewer
  136768. * @param yaxis defines the y axis of the viewer
  136769. * @param zaxis defines the z axis of the viewer
  136770. */
  136771. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  136772. /**
  136773. * Creates an instance of this axes viewer.
  136774. * @returns a new axes viewer with instanced meshes
  136775. */
  136776. createInstance(): AxesViewer;
  136777. /** Releases resources */
  136778. dispose(): void;
  136779. private static _SetRenderingGroupId;
  136780. }
  136781. }
  136782. declare module BABYLON.Debug {
  136783. /**
  136784. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  136785. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  136786. */
  136787. export class BoneAxesViewer extends AxesViewer {
  136788. /**
  136789. * Gets or sets the target mesh where to display the axes viewer
  136790. */
  136791. mesh: Nullable<Mesh>;
  136792. /**
  136793. * Gets or sets the target bone where to display the axes viewer
  136794. */
  136795. bone: Nullable<Bone>;
  136796. /** Gets current position */
  136797. pos: Vector3;
  136798. /** Gets direction of X axis */
  136799. xaxis: Vector3;
  136800. /** Gets direction of Y axis */
  136801. yaxis: Vector3;
  136802. /** Gets direction of Z axis */
  136803. zaxis: Vector3;
  136804. /**
  136805. * Creates a new BoneAxesViewer
  136806. * @param scene defines the hosting scene
  136807. * @param bone defines the target bone
  136808. * @param mesh defines the target mesh
  136809. * @param scaleLines defines a scaling factor for line length (1 by default)
  136810. */
  136811. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  136812. /**
  136813. * Force the viewer to update
  136814. */
  136815. update(): void;
  136816. /** Releases resources */
  136817. dispose(): void;
  136818. }
  136819. }
  136820. declare module BABYLON {
  136821. /**
  136822. * Interface used to define scene explorer extensibility option
  136823. */
  136824. export interface IExplorerExtensibilityOption {
  136825. /**
  136826. * Define the option label
  136827. */
  136828. label: string;
  136829. /**
  136830. * Defines the action to execute on click
  136831. */
  136832. action: (entity: any) => void;
  136833. }
  136834. /**
  136835. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  136836. */
  136837. export interface IExplorerExtensibilityGroup {
  136838. /**
  136839. * Defines a predicate to test if a given type mut be extended
  136840. */
  136841. predicate: (entity: any) => boolean;
  136842. /**
  136843. * Gets the list of options added to a type
  136844. */
  136845. entries: IExplorerExtensibilityOption[];
  136846. }
  136847. /**
  136848. * Interface used to define the options to use to create the Inspector
  136849. */
  136850. export interface IInspectorOptions {
  136851. /**
  136852. * Display in overlay mode (default: false)
  136853. */
  136854. overlay?: boolean;
  136855. /**
  136856. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  136857. */
  136858. globalRoot?: HTMLElement;
  136859. /**
  136860. * Display the Scene explorer
  136861. */
  136862. showExplorer?: boolean;
  136863. /**
  136864. * Display the property inspector
  136865. */
  136866. showInspector?: boolean;
  136867. /**
  136868. * Display in embed mode (both panes on the right)
  136869. */
  136870. embedMode?: boolean;
  136871. /**
  136872. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  136873. */
  136874. handleResize?: boolean;
  136875. /**
  136876. * Allow the panes to popup (default: true)
  136877. */
  136878. enablePopup?: boolean;
  136879. /**
  136880. * Allow the panes to be closed by users (default: true)
  136881. */
  136882. enableClose?: boolean;
  136883. /**
  136884. * Optional list of extensibility entries
  136885. */
  136886. explorerExtensibility?: IExplorerExtensibilityGroup[];
  136887. /**
  136888. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  136889. */
  136890. inspectorURL?: string;
  136891. /**
  136892. * Optional initial tab (default to DebugLayerTab.Properties)
  136893. */
  136894. initialTab?: DebugLayerTab;
  136895. }
  136896. interface Scene {
  136897. /**
  136898. * @hidden
  136899. * Backing field
  136900. */
  136901. _debugLayer: DebugLayer;
  136902. /**
  136903. * Gets the debug layer (aka Inspector) associated with the scene
  136904. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136905. */
  136906. debugLayer: DebugLayer;
  136907. }
  136908. /**
  136909. * Enum of inspector action tab
  136910. */
  136911. export enum DebugLayerTab {
  136912. /**
  136913. * Properties tag (default)
  136914. */
  136915. Properties = 0,
  136916. /**
  136917. * Debug tab
  136918. */
  136919. Debug = 1,
  136920. /**
  136921. * Statistics tab
  136922. */
  136923. Statistics = 2,
  136924. /**
  136925. * Tools tab
  136926. */
  136927. Tools = 3,
  136928. /**
  136929. * Settings tab
  136930. */
  136931. Settings = 4
  136932. }
  136933. /**
  136934. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136935. * what is happening in your scene
  136936. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136937. */
  136938. export class DebugLayer {
  136939. /**
  136940. * Define the url to get the inspector script from.
  136941. * By default it uses the babylonjs CDN.
  136942. * @ignoreNaming
  136943. */
  136944. static InspectorURL: string;
  136945. private _scene;
  136946. private BJSINSPECTOR;
  136947. private _onPropertyChangedObservable?;
  136948. /**
  136949. * Observable triggered when a property is changed through the inspector.
  136950. */
  136951. get onPropertyChangedObservable(): any;
  136952. /**
  136953. * Instantiates a new debug layer.
  136954. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136955. * what is happening in your scene
  136956. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136957. * @param scene Defines the scene to inspect
  136958. */
  136959. constructor(scene: Scene);
  136960. /** Creates the inspector window. */
  136961. private _createInspector;
  136962. /**
  136963. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  136964. * @param entity defines the entity to select
  136965. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  136966. */
  136967. select(entity: any, lineContainerTitles?: string | string[]): void;
  136968. /** Get the inspector from bundle or global */
  136969. private _getGlobalInspector;
  136970. /**
  136971. * Get if the inspector is visible or not.
  136972. * @returns true if visible otherwise, false
  136973. */
  136974. isVisible(): boolean;
  136975. /**
  136976. * Hide the inspector and close its window.
  136977. */
  136978. hide(): void;
  136979. /**
  136980. * Update the scene in the inspector
  136981. */
  136982. setAsActiveScene(): void;
  136983. /**
  136984. * Launch the debugLayer.
  136985. * @param config Define the configuration of the inspector
  136986. * @return a promise fulfilled when the debug layer is visible
  136987. */
  136988. show(config?: IInspectorOptions): Promise<DebugLayer>;
  136989. }
  136990. }
  136991. declare module BABYLON.Debug {
  136992. /**
  136993. * Used to show the physics impostor around the specific mesh
  136994. */
  136995. export class PhysicsViewer {
  136996. /** @hidden */
  136997. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  136998. /** @hidden */
  136999. protected _meshes: Array<Nullable<AbstractMesh>>;
  137000. /** @hidden */
  137001. protected _scene: Nullable<Scene>;
  137002. /** @hidden */
  137003. protected _numMeshes: number;
  137004. /** @hidden */
  137005. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  137006. private _renderFunction;
  137007. private _utilityLayer;
  137008. private _debugBoxMesh;
  137009. private _debugSphereMesh;
  137010. private _debugCylinderMesh;
  137011. private _debugMaterial;
  137012. private _debugMeshMeshes;
  137013. /**
  137014. * Creates a new PhysicsViewer
  137015. * @param scene defines the hosting scene
  137016. */
  137017. constructor(scene: Scene);
  137018. /** @hidden */
  137019. protected _updateDebugMeshes(): void;
  137020. /**
  137021. * Renders a specified physic impostor
  137022. * @param impostor defines the impostor to render
  137023. * @param targetMesh defines the mesh represented by the impostor
  137024. * @returns the new debug mesh used to render the impostor
  137025. */
  137026. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  137027. /**
  137028. * Hides a specified physic impostor
  137029. * @param impostor defines the impostor to hide
  137030. */
  137031. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  137032. private _getDebugMaterial;
  137033. private _getDebugBoxMesh;
  137034. private _getDebugSphereMesh;
  137035. private _getDebugCylinderMesh;
  137036. private _getDebugMeshMesh;
  137037. private _getDebugMesh;
  137038. /** Releases all resources */
  137039. dispose(): void;
  137040. }
  137041. }
  137042. declare module BABYLON {
  137043. /**
  137044. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  137045. * in order to better appreciate the issue one might have.
  137046. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  137047. */
  137048. export class RayHelper {
  137049. /**
  137050. * Defines the ray we are currently tryin to visualize.
  137051. */
  137052. ray: Nullable<Ray>;
  137053. private _renderPoints;
  137054. private _renderLine;
  137055. private _renderFunction;
  137056. private _scene;
  137057. private _onAfterRenderObserver;
  137058. private _onAfterStepObserver;
  137059. private _attachedToMesh;
  137060. private _meshSpaceDirection;
  137061. private _meshSpaceOrigin;
  137062. /**
  137063. * Helper function to create a colored helper in a scene in one line.
  137064. * @param ray Defines the ray we are currently tryin to visualize
  137065. * @param scene Defines the scene the ray is used in
  137066. * @param color Defines the color we want to see the ray in
  137067. * @returns The newly created ray helper.
  137068. */
  137069. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  137070. /**
  137071. * Instantiate a new ray helper.
  137072. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  137073. * in order to better appreciate the issue one might have.
  137074. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  137075. * @param ray Defines the ray we are currently tryin to visualize
  137076. */
  137077. constructor(ray: Ray);
  137078. /**
  137079. * Shows the ray we are willing to debug.
  137080. * @param scene Defines the scene the ray needs to be rendered in
  137081. * @param color Defines the color the ray needs to be rendered in
  137082. */
  137083. show(scene: Scene, color?: Color3): void;
  137084. /**
  137085. * Hides the ray we are debugging.
  137086. */
  137087. hide(): void;
  137088. private _render;
  137089. /**
  137090. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  137091. * @param mesh Defines the mesh we want the helper attached to
  137092. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  137093. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  137094. * @param length Defines the length of the ray
  137095. */
  137096. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  137097. /**
  137098. * Detach the ray helper from the mesh it has previously been attached to.
  137099. */
  137100. detachFromMesh(): void;
  137101. private _updateToMesh;
  137102. /**
  137103. * Dispose the helper and release its associated resources.
  137104. */
  137105. dispose(): void;
  137106. }
  137107. }
  137108. declare module BABYLON {
  137109. /**
  137110. * Defines the options associated with the creation of a SkeletonViewer.
  137111. */
  137112. export interface ISkeletonViewerOptions {
  137113. /** Should the system pause animations before building the Viewer? */
  137114. pauseAnimations: boolean;
  137115. /** Should the system return the skeleton to rest before building? */
  137116. returnToRest: boolean;
  137117. /** public Display Mode of the Viewer */
  137118. displayMode: number;
  137119. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  137120. displayOptions: ISkeletonViewerDisplayOptions;
  137121. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  137122. computeBonesUsingShaders: boolean;
  137123. /** Flag ignore non weighted bones */
  137124. useAllBones: boolean;
  137125. }
  137126. /**
  137127. * Defines how to display the various bone meshes for the viewer.
  137128. */
  137129. export interface ISkeletonViewerDisplayOptions {
  137130. /** How far down to start tapering the bone spurs */
  137131. midStep?: number;
  137132. /** How big is the midStep? */
  137133. midStepFactor?: number;
  137134. /** Base for the Sphere Size */
  137135. sphereBaseSize?: number;
  137136. /** The ratio of the sphere to the longest bone in units */
  137137. sphereScaleUnit?: number;
  137138. /** Ratio for the Sphere Size */
  137139. sphereFactor?: number;
  137140. /** Whether a spur should attach its far end to the child bone position */
  137141. spurFollowsChild?: boolean;
  137142. /** Whether to show local axes or not */
  137143. showLocalAxes?: boolean;
  137144. /** Length of each local axis */
  137145. localAxesSize?: number;
  137146. }
  137147. /**
  137148. * Defines the constructor options for the BoneWeight Shader.
  137149. */
  137150. export interface IBoneWeightShaderOptions {
  137151. /** Skeleton to Map */
  137152. skeleton: Skeleton;
  137153. /** Colors for Uninfluenced bones */
  137154. colorBase?: Color3;
  137155. /** Colors for 0.0-0.25 Weight bones */
  137156. colorZero?: Color3;
  137157. /** Color for 0.25-0.5 Weight Influence */
  137158. colorQuarter?: Color3;
  137159. /** Color for 0.5-0.75 Weight Influence */
  137160. colorHalf?: Color3;
  137161. /** Color for 0.75-1 Weight Influence */
  137162. colorFull?: Color3;
  137163. /** Color for Zero Weight Influence */
  137164. targetBoneIndex?: number;
  137165. }
  137166. /**
  137167. * Simple structure of the gradient steps for the Color Map.
  137168. */
  137169. export interface ISkeletonMapShaderColorMapKnot {
  137170. /** Color of the Knot */
  137171. color: Color3;
  137172. /** Location of the Knot */
  137173. location: number;
  137174. }
  137175. /**
  137176. * Defines the constructor options for the SkeletonMap Shader.
  137177. */
  137178. export interface ISkeletonMapShaderOptions {
  137179. /** Skeleton to Map */
  137180. skeleton: Skeleton;
  137181. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  137182. colorMap?: ISkeletonMapShaderColorMapKnot[];
  137183. }
  137184. }
  137185. declare module BABYLON {
  137186. /**
  137187. * Class containing static functions to help procedurally build meshes
  137188. */
  137189. export class RibbonBuilder {
  137190. /**
  137191. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137192. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137193. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137194. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137195. * * 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
  137196. * * 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
  137197. * * 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
  137198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137200. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137201. * * 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
  137202. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137203. * * 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
  137204. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137206. * @param name defines the name of the mesh
  137207. * @param options defines the options used to create the mesh
  137208. * @param scene defines the hosting scene
  137209. * @returns the ribbon mesh
  137210. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137211. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137212. */
  137213. static CreateRibbon(name: string, options: {
  137214. pathArray: Vector3[][];
  137215. closeArray?: boolean;
  137216. closePath?: boolean;
  137217. offset?: number;
  137218. updatable?: boolean;
  137219. sideOrientation?: number;
  137220. frontUVs?: Vector4;
  137221. backUVs?: Vector4;
  137222. instance?: Mesh;
  137223. invertUV?: boolean;
  137224. uvs?: Vector2[];
  137225. colors?: Color4[];
  137226. }, scene?: Nullable<Scene>): Mesh;
  137227. }
  137228. }
  137229. declare module BABYLON {
  137230. /**
  137231. * Class containing static functions to help procedurally build meshes
  137232. */
  137233. export class ShapeBuilder {
  137234. /**
  137235. * 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.
  137236. * * 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.
  137237. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137238. * * 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.
  137239. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137240. * * 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
  137241. * * 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
  137242. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137244. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137245. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137246. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137247. * @param name defines the name of the mesh
  137248. * @param options defines the options used to create the mesh
  137249. * @param scene defines the hosting scene
  137250. * @returns the extruded shape mesh
  137251. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137253. */
  137254. static ExtrudeShape(name: string, options: {
  137255. shape: Vector3[];
  137256. path: Vector3[];
  137257. scale?: number;
  137258. rotation?: number;
  137259. cap?: number;
  137260. updatable?: boolean;
  137261. sideOrientation?: number;
  137262. frontUVs?: Vector4;
  137263. backUVs?: Vector4;
  137264. instance?: Mesh;
  137265. invertUV?: boolean;
  137266. }, scene?: Nullable<Scene>): Mesh;
  137267. /**
  137268. * Creates an custom extruded shape mesh.
  137269. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137270. * * 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.
  137271. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137272. * * 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
  137273. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137274. * * 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
  137275. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137276. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137277. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137278. * * 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
  137279. * * 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
  137280. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137283. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137285. * @param name defines the name of the mesh
  137286. * @param options defines the options used to create the mesh
  137287. * @param scene defines the hosting scene
  137288. * @returns the custom extruded shape mesh
  137289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137290. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137292. */
  137293. static ExtrudeShapeCustom(name: string, options: {
  137294. shape: Vector3[];
  137295. path: Vector3[];
  137296. scaleFunction?: any;
  137297. rotationFunction?: any;
  137298. ribbonCloseArray?: boolean;
  137299. ribbonClosePath?: boolean;
  137300. cap?: number;
  137301. updatable?: boolean;
  137302. sideOrientation?: number;
  137303. frontUVs?: Vector4;
  137304. backUVs?: Vector4;
  137305. instance?: Mesh;
  137306. invertUV?: boolean;
  137307. }, scene?: Nullable<Scene>): Mesh;
  137308. private static _ExtrudeShapeGeneric;
  137309. }
  137310. }
  137311. declare module BABYLON.Debug {
  137312. /**
  137313. * Class used to render a debug view of a given skeleton
  137314. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  137315. */
  137316. export class SkeletonViewer {
  137317. /** defines the skeleton to render */
  137318. skeleton: Skeleton;
  137319. /** defines the mesh attached to the skeleton */
  137320. mesh: AbstractMesh;
  137321. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  137322. autoUpdateBonesMatrices: boolean;
  137323. /** defines the rendering group id to use with the viewer */
  137324. renderingGroupId: number;
  137325. /** is the options for the viewer */
  137326. options: Partial<ISkeletonViewerOptions>;
  137327. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  137328. static readonly DISPLAY_LINES: number;
  137329. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  137330. static readonly DISPLAY_SPHERES: number;
  137331. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  137332. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  137333. /** public static method to create a BoneWeight Shader
  137334. * @param options The constructor options
  137335. * @param scene The scene that the shader is scoped to
  137336. * @returns The created ShaderMaterial
  137337. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  137338. */
  137339. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  137340. /** public static method to create a BoneWeight Shader
  137341. * @param options The constructor options
  137342. * @param scene The scene that the shader is scoped to
  137343. * @returns The created ShaderMaterial
  137344. */
  137345. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  137346. /** private static method to create a BoneWeight Shader
  137347. * @param size The size of the buffer to create (usually the bone count)
  137348. * @param colorMap The gradient data to generate
  137349. * @param scene The scene that the shader is scoped to
  137350. * @returns an Array of floats from the color gradient values
  137351. */
  137352. private static _CreateBoneMapColorBuffer;
  137353. /** If SkeletonViewer scene scope. */
  137354. private _scene;
  137355. /** Gets or sets the color used to render the skeleton */
  137356. color: Color3;
  137357. /** Array of the points of the skeleton fo the line view. */
  137358. private _debugLines;
  137359. /** The SkeletonViewers Mesh. */
  137360. private _debugMesh;
  137361. /** The local axes Meshes. */
  137362. private _localAxes;
  137363. /** If SkeletonViewer is enabled. */
  137364. private _isEnabled;
  137365. /** If SkeletonViewer is ready. */
  137366. private _ready;
  137367. /** SkeletonViewer render observable. */
  137368. private _obs;
  137369. /** The Utility Layer to render the gizmos in. */
  137370. private _utilityLayer;
  137371. private _boneIndices;
  137372. /** Gets the Scene. */
  137373. get scene(): Scene;
  137374. /** Gets the utilityLayer. */
  137375. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  137376. /** Checks Ready Status. */
  137377. get isReady(): Boolean;
  137378. /** Sets Ready Status. */
  137379. set ready(value: boolean);
  137380. /** Gets the debugMesh */
  137381. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  137382. /** Sets the debugMesh */
  137383. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  137384. /** Gets the displayMode */
  137385. get displayMode(): number;
  137386. /** Sets the displayMode */
  137387. set displayMode(value: number);
  137388. /**
  137389. * Creates a new SkeletonViewer
  137390. * @param skeleton defines the skeleton to render
  137391. * @param mesh defines the mesh attached to the skeleton
  137392. * @param scene defines the hosting scene
  137393. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  137394. * @param renderingGroupId defines the rendering group id to use with the viewer
  137395. * @param options All of the extra constructor options for the SkeletonViewer
  137396. */
  137397. constructor(
  137398. /** defines the skeleton to render */
  137399. skeleton: Skeleton,
  137400. /** defines the mesh attached to the skeleton */
  137401. mesh: AbstractMesh,
  137402. /** The Scene scope*/
  137403. scene: Scene,
  137404. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  137405. autoUpdateBonesMatrices?: boolean,
  137406. /** defines the rendering group id to use with the viewer */
  137407. renderingGroupId?: number,
  137408. /** is the options for the viewer */
  137409. options?: Partial<ISkeletonViewerOptions>);
  137410. /** The Dynamic bindings for the update functions */
  137411. private _bindObs;
  137412. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  137413. update(): void;
  137414. /** Gets or sets a boolean indicating if the viewer is enabled */
  137415. set isEnabled(value: boolean);
  137416. get isEnabled(): boolean;
  137417. private _getBonePosition;
  137418. private _getLinesForBonesWithLength;
  137419. private _getLinesForBonesNoLength;
  137420. /** function to revert the mesh and scene back to the initial state. */
  137421. private _revert;
  137422. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  137423. private _getAbsoluteBindPoseToRef;
  137424. /** function to build and bind sphere joint points and spur bone representations. */
  137425. private _buildSpheresAndSpurs;
  137426. private _buildLocalAxes;
  137427. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  137428. private _displayLinesUpdate;
  137429. /** Changes the displayMode of the skeleton viewer
  137430. * @param mode The displayMode numerical value
  137431. */
  137432. changeDisplayMode(mode: number): void;
  137433. /** Sets a display option of the skeleton viewer
  137434. *
  137435. * | Option | Type | Default | Description |
  137436. * | ---------------- | ------- | ------- | ----------- |
  137437. * | 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`. |
  137438. * | 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`. |
  137439. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  137440. * | 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`. |
  137441. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  137442. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  137443. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  137444. *
  137445. * @param option String of the option name
  137446. * @param value The numerical option value
  137447. */
  137448. changeDisplayOptions(option: string, value: number): void;
  137449. /** Release associated resources */
  137450. dispose(): void;
  137451. }
  137452. }
  137453. declare module BABYLON {
  137454. /**
  137455. * Enum for Device Types
  137456. */
  137457. export enum DeviceType {
  137458. /** Generic */
  137459. Generic = 0,
  137460. /** Keyboard */
  137461. Keyboard = 1,
  137462. /** Mouse */
  137463. Mouse = 2,
  137464. /** Touch Pointers */
  137465. Touch = 3,
  137466. /** PS4 Dual Shock */
  137467. DualShock = 4,
  137468. /** Xbox */
  137469. Xbox = 5,
  137470. /** Switch Controller */
  137471. Switch = 6
  137472. }
  137473. /**
  137474. * Enum for All Pointers (Touch/Mouse)
  137475. */
  137476. export enum PointerInput {
  137477. /** Horizontal Axis */
  137478. Horizontal = 0,
  137479. /** Vertical Axis */
  137480. Vertical = 1,
  137481. /** Left Click or Touch */
  137482. LeftClick = 2,
  137483. /** Middle Click */
  137484. MiddleClick = 3,
  137485. /** Right Click */
  137486. RightClick = 4,
  137487. /** Browser Back */
  137488. BrowserBack = 5,
  137489. /** Browser Forward */
  137490. BrowserForward = 6
  137491. }
  137492. /**
  137493. * Enum for Dual Shock Gamepad
  137494. */
  137495. export enum DualShockInput {
  137496. /** Cross */
  137497. Cross = 0,
  137498. /** Circle */
  137499. Circle = 1,
  137500. /** Square */
  137501. Square = 2,
  137502. /** Triangle */
  137503. Triangle = 3,
  137504. /** L1 */
  137505. L1 = 4,
  137506. /** R1 */
  137507. R1 = 5,
  137508. /** L2 */
  137509. L2 = 6,
  137510. /** R2 */
  137511. R2 = 7,
  137512. /** Share */
  137513. Share = 8,
  137514. /** Options */
  137515. Options = 9,
  137516. /** L3 */
  137517. L3 = 10,
  137518. /** R3 */
  137519. R3 = 11,
  137520. /** DPadUp */
  137521. DPadUp = 12,
  137522. /** DPadDown */
  137523. DPadDown = 13,
  137524. /** DPadLeft */
  137525. DPadLeft = 14,
  137526. /** DRight */
  137527. DPadRight = 15,
  137528. /** Home */
  137529. Home = 16,
  137530. /** TouchPad */
  137531. TouchPad = 17,
  137532. /** LStickXAxis */
  137533. LStickXAxis = 18,
  137534. /** LStickYAxis */
  137535. LStickYAxis = 19,
  137536. /** RStickXAxis */
  137537. RStickXAxis = 20,
  137538. /** RStickYAxis */
  137539. RStickYAxis = 21
  137540. }
  137541. /**
  137542. * Enum for Xbox Gamepad
  137543. */
  137544. export enum XboxInput {
  137545. /** A */
  137546. A = 0,
  137547. /** B */
  137548. B = 1,
  137549. /** X */
  137550. X = 2,
  137551. /** Y */
  137552. Y = 3,
  137553. /** LB */
  137554. LB = 4,
  137555. /** RB */
  137556. RB = 5,
  137557. /** LT */
  137558. LT = 6,
  137559. /** RT */
  137560. RT = 7,
  137561. /** Back */
  137562. Back = 8,
  137563. /** Start */
  137564. Start = 9,
  137565. /** LS */
  137566. LS = 10,
  137567. /** RS */
  137568. RS = 11,
  137569. /** DPadUp */
  137570. DPadUp = 12,
  137571. /** DPadDown */
  137572. DPadDown = 13,
  137573. /** DPadLeft */
  137574. DPadLeft = 14,
  137575. /** DRight */
  137576. DPadRight = 15,
  137577. /** Home */
  137578. Home = 16,
  137579. /** LStickXAxis */
  137580. LStickXAxis = 17,
  137581. /** LStickYAxis */
  137582. LStickYAxis = 18,
  137583. /** RStickXAxis */
  137584. RStickXAxis = 19,
  137585. /** RStickYAxis */
  137586. RStickYAxis = 20
  137587. }
  137588. /**
  137589. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  137590. */
  137591. export enum SwitchInput {
  137592. /** B */
  137593. B = 0,
  137594. /** A */
  137595. A = 1,
  137596. /** Y */
  137597. Y = 2,
  137598. /** X */
  137599. X = 3,
  137600. /** L */
  137601. L = 4,
  137602. /** R */
  137603. R = 5,
  137604. /** ZL */
  137605. ZL = 6,
  137606. /** ZR */
  137607. ZR = 7,
  137608. /** Minus */
  137609. Minus = 8,
  137610. /** Plus */
  137611. Plus = 9,
  137612. /** LS */
  137613. LS = 10,
  137614. /** RS */
  137615. RS = 11,
  137616. /** DPadUp */
  137617. DPadUp = 12,
  137618. /** DPadDown */
  137619. DPadDown = 13,
  137620. /** DPadLeft */
  137621. DPadLeft = 14,
  137622. /** DRight */
  137623. DPadRight = 15,
  137624. /** Home */
  137625. Home = 16,
  137626. /** Capture */
  137627. Capture = 17,
  137628. /** LStickXAxis */
  137629. LStickXAxis = 18,
  137630. /** LStickYAxis */
  137631. LStickYAxis = 19,
  137632. /** RStickXAxis */
  137633. RStickXAxis = 20,
  137634. /** RStickYAxis */
  137635. RStickYAxis = 21
  137636. }
  137637. }
  137638. declare module BABYLON {
  137639. /**
  137640. * This class will take all inputs from Keyboard, Pointer, and
  137641. * any Gamepads and provide a polling system that all devices
  137642. * will use. This class assumes that there will only be one
  137643. * pointer device and one keyboard.
  137644. */
  137645. export class DeviceInputSystem implements IDisposable {
  137646. /**
  137647. * Returns onDeviceConnected callback property
  137648. * @returns Callback with function to execute when a device is connected
  137649. */
  137650. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  137651. /**
  137652. * Sets callback function when a device is connected and executes against all connected devices
  137653. * @param callback Function to execute when a device is connected
  137654. */
  137655. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  137656. /**
  137657. * Callback to be triggered when a device is disconnected
  137658. */
  137659. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  137660. /**
  137661. * Callback to be triggered when event driven input is updated
  137662. */
  137663. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  137664. private _inputs;
  137665. private _gamepads;
  137666. private _keyboardActive;
  137667. private _pointerActive;
  137668. private _elementToAttachTo;
  137669. private _keyboardDownEvent;
  137670. private _keyboardUpEvent;
  137671. private _pointerMoveEvent;
  137672. private _pointerDownEvent;
  137673. private _pointerUpEvent;
  137674. private _gamepadConnectedEvent;
  137675. private _gamepadDisconnectedEvent;
  137676. private _onDeviceConnected;
  137677. private static _MAX_KEYCODES;
  137678. private static _MAX_POINTER_INPUTS;
  137679. private constructor();
  137680. /**
  137681. * Creates a new DeviceInputSystem instance
  137682. * @param engine Engine to pull input element from
  137683. * @returns The new instance
  137684. */
  137685. static Create(engine: Engine): DeviceInputSystem;
  137686. /**
  137687. * Checks for current device input value, given an id and input index
  137688. * @param deviceName Id of connected device
  137689. * @param inputIndex Index of device input
  137690. * @returns Current value of input
  137691. */
  137692. /**
  137693. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  137694. * @param deviceType Enum specifiying device type
  137695. * @param deviceSlot "Slot" or index that device is referenced in
  137696. * @param inputIndex Id of input to be checked
  137697. * @returns Current value of input
  137698. */
  137699. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  137700. /**
  137701. * Dispose of all the eventlisteners
  137702. */
  137703. dispose(): void;
  137704. /**
  137705. * Checks for existing connections to devices and register them, if necessary
  137706. * Currently handles gamepads and mouse
  137707. */
  137708. private _checkForConnectedDevices;
  137709. /**
  137710. * Add a gamepad to the DeviceInputSystem
  137711. * @param gamepad A single DOM Gamepad object
  137712. */
  137713. private _addGamePad;
  137714. /**
  137715. * Add pointer device to DeviceInputSystem
  137716. * @param deviceType Type of Pointer to add
  137717. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  137718. * @param currentX Current X at point of adding
  137719. * @param currentY Current Y at point of adding
  137720. */
  137721. private _addPointerDevice;
  137722. /**
  137723. * Add device and inputs to device array
  137724. * @param deviceType Enum specifiying device type
  137725. * @param deviceSlot "Slot" or index that device is referenced in
  137726. * @param numberOfInputs Number of input entries to create for given device
  137727. */
  137728. private _registerDevice;
  137729. /**
  137730. * Given a specific device name, remove that device from the device map
  137731. * @param deviceType Enum specifiying device type
  137732. * @param deviceSlot "Slot" or index that device is referenced in
  137733. */
  137734. private _unregisterDevice;
  137735. /**
  137736. * Handle all actions that come from keyboard interaction
  137737. */
  137738. private _handleKeyActions;
  137739. /**
  137740. * Handle all actions that come from pointer interaction
  137741. */
  137742. private _handlePointerActions;
  137743. /**
  137744. * Handle all actions that come from gamepad interaction
  137745. */
  137746. private _handleGamepadActions;
  137747. /**
  137748. * Update all non-event based devices with each frame
  137749. * @param deviceType Enum specifiying device type
  137750. * @param deviceSlot "Slot" or index that device is referenced in
  137751. * @param inputIndex Id of input to be checked
  137752. */
  137753. private _updateDevice;
  137754. /**
  137755. * Gets DeviceType from the device name
  137756. * @param deviceName Name of Device from DeviceInputSystem
  137757. * @returns DeviceType enum value
  137758. */
  137759. private _getGamepadDeviceType;
  137760. }
  137761. }
  137762. declare module BABYLON {
  137763. /**
  137764. * Type to handle enforcement of inputs
  137765. */
  137766. 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;
  137767. }
  137768. declare module BABYLON {
  137769. /**
  137770. * Class that handles all input for a specific device
  137771. */
  137772. export class DeviceSource<T extends DeviceType> {
  137773. /** Type of device */
  137774. readonly deviceType: DeviceType;
  137775. /** "Slot" or index that device is referenced in */
  137776. readonly deviceSlot: number;
  137777. /**
  137778. * Observable to handle device input changes per device
  137779. */
  137780. readonly onInputChangedObservable: Observable<{
  137781. inputIndex: DeviceInput<T>;
  137782. previousState: Nullable<number>;
  137783. currentState: Nullable<number>;
  137784. }>;
  137785. private readonly _deviceInputSystem;
  137786. /**
  137787. * Default Constructor
  137788. * @param deviceInputSystem Reference to DeviceInputSystem
  137789. * @param deviceType Type of device
  137790. * @param deviceSlot "Slot" or index that device is referenced in
  137791. */
  137792. constructor(deviceInputSystem: DeviceInputSystem,
  137793. /** Type of device */
  137794. deviceType: DeviceType,
  137795. /** "Slot" or index that device is referenced in */
  137796. deviceSlot?: number);
  137797. /**
  137798. * Get input for specific input
  137799. * @param inputIndex index of specific input on device
  137800. * @returns Input value from DeviceInputSystem
  137801. */
  137802. getInput(inputIndex: DeviceInput<T>): number;
  137803. }
  137804. /**
  137805. * Class to keep track of devices
  137806. */
  137807. export class DeviceSourceManager implements IDisposable {
  137808. /**
  137809. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  137810. */
  137811. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  137812. /**
  137813. * Observable to be triggered when after a device is disconnected
  137814. */
  137815. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  137816. private readonly _devices;
  137817. private readonly _firstDevice;
  137818. private readonly _deviceInputSystem;
  137819. /**
  137820. * Default Constructor
  137821. * @param engine engine to pull input element from
  137822. */
  137823. constructor(engine: Engine);
  137824. /**
  137825. * Gets a DeviceSource, given a type and slot
  137826. * @param deviceType Enum specifying device type
  137827. * @param deviceSlot "Slot" or index that device is referenced in
  137828. * @returns DeviceSource object
  137829. */
  137830. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  137831. /**
  137832. * Gets an array of DeviceSource objects for a given device type
  137833. * @param deviceType Enum specifying device type
  137834. * @returns Array of DeviceSource objects
  137835. */
  137836. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  137837. /**
  137838. * Returns a read-only list of all available devices
  137839. * @returns Read-only array with active devices
  137840. */
  137841. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  137842. /**
  137843. * Dispose of DeviceInputSystem and other parts
  137844. */
  137845. dispose(): void;
  137846. /**
  137847. * Function to add device name to device list
  137848. * @param deviceType Enum specifying device type
  137849. * @param deviceSlot "Slot" or index that device is referenced in
  137850. */
  137851. private _addDevice;
  137852. /**
  137853. * Function to remove device name to device list
  137854. * @param deviceType Enum specifying device type
  137855. * @param deviceSlot "Slot" or index that device is referenced in
  137856. */
  137857. private _removeDevice;
  137858. /**
  137859. * Updates array storing first connected device of each type
  137860. * @param type Type of Device
  137861. */
  137862. private _updateFirstDevices;
  137863. }
  137864. }
  137865. declare module BABYLON {
  137866. /**
  137867. * Options to create the null engine
  137868. */
  137869. export class NullEngineOptions {
  137870. /**
  137871. * Render width (Default: 512)
  137872. */
  137873. renderWidth: number;
  137874. /**
  137875. * Render height (Default: 256)
  137876. */
  137877. renderHeight: number;
  137878. /**
  137879. * Texture size (Default: 512)
  137880. */
  137881. textureSize: number;
  137882. /**
  137883. * If delta time between frames should be constant
  137884. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137885. */
  137886. deterministicLockstep: boolean;
  137887. /**
  137888. * Maximum about of steps between frames (Default: 4)
  137889. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137890. */
  137891. lockstepMaxSteps: number;
  137892. /**
  137893. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  137894. */
  137895. useHighPrecisionMatrix?: boolean;
  137896. }
  137897. /**
  137898. * The null engine class provides support for headless version of babylon.js.
  137899. * This can be used in server side scenario or for testing purposes
  137900. */
  137901. export class NullEngine extends Engine {
  137902. private _options;
  137903. /**
  137904. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  137905. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137906. * @returns true if engine is in deterministic lock step mode
  137907. */
  137908. isDeterministicLockStep(): boolean;
  137909. /**
  137910. * Gets the max steps when engine is running in deterministic lock step
  137911. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137912. * @returns the max steps
  137913. */
  137914. getLockstepMaxSteps(): number;
  137915. /**
  137916. * Gets the current hardware scaling level.
  137917. * By default the hardware scaling level is computed from the window device ratio.
  137918. * 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.
  137919. * @returns a number indicating the current hardware scaling level
  137920. */
  137921. getHardwareScalingLevel(): number;
  137922. constructor(options?: NullEngineOptions);
  137923. /**
  137924. * Creates a vertex buffer
  137925. * @param vertices the data for the vertex buffer
  137926. * @returns the new WebGL static buffer
  137927. */
  137928. createVertexBuffer(vertices: FloatArray): DataBuffer;
  137929. /**
  137930. * Creates a new index buffer
  137931. * @param indices defines the content of the index buffer
  137932. * @param updatable defines if the index buffer must be updatable
  137933. * @returns a new webGL buffer
  137934. */
  137935. createIndexBuffer(indices: IndicesArray): DataBuffer;
  137936. /**
  137937. * Clear the current render buffer or the current render target (if any is set up)
  137938. * @param color defines the color to use
  137939. * @param backBuffer defines if the back buffer must be cleared
  137940. * @param depth defines if the depth buffer must be cleared
  137941. * @param stencil defines if the stencil buffer must be cleared
  137942. */
  137943. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  137944. /**
  137945. * Gets the current render width
  137946. * @param useScreen defines if screen size must be used (or the current render target if any)
  137947. * @returns a number defining the current render width
  137948. */
  137949. getRenderWidth(useScreen?: boolean): number;
  137950. /**
  137951. * Gets the current render height
  137952. * @param useScreen defines if screen size must be used (or the current render target if any)
  137953. * @returns a number defining the current render height
  137954. */
  137955. getRenderHeight(useScreen?: boolean): number;
  137956. /**
  137957. * Set the WebGL's viewport
  137958. * @param viewport defines the viewport element to be used
  137959. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  137960. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  137961. */
  137962. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  137963. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  137964. /**
  137965. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  137966. * @param pipelineContext defines the pipeline context to use
  137967. * @param uniformsNames defines the list of uniform names
  137968. * @returns an array of webGL uniform locations
  137969. */
  137970. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  137971. /**
  137972. * Gets the lsit of active attributes for a given webGL program
  137973. * @param pipelineContext defines the pipeline context to use
  137974. * @param attributesNames defines the list of attribute names to get
  137975. * @returns an array of indices indicating the offset of each attribute
  137976. */
  137977. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  137978. /**
  137979. * Binds an effect to the webGL context
  137980. * @param effect defines the effect to bind
  137981. */
  137982. bindSamplers(effect: Effect): void;
  137983. /**
  137984. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  137985. * @param effect defines the effect to activate
  137986. */
  137987. enableEffect(effect: Effect): void;
  137988. /**
  137989. * Set various states to the webGL context
  137990. * @param culling defines backface culling state
  137991. * @param zOffset defines the value to apply to zOffset (0 by default)
  137992. * @param force defines if states must be applied even if cache is up to date
  137993. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  137994. */
  137995. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  137996. /**
  137997. * Set the value of an uniform to an array of int32
  137998. * @param uniform defines the webGL uniform location where to store the value
  137999. * @param array defines the array of int32 to store
  138000. * @returns true if value was set
  138001. */
  138002. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138003. /**
  138004. * Set the value of an uniform to an array of int32 (stored as vec2)
  138005. * @param uniform defines the webGL uniform location where to store the value
  138006. * @param array defines the array of int32 to store
  138007. * @returns true if value was set
  138008. */
  138009. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138010. /**
  138011. * Set the value of an uniform to an array of int32 (stored as vec3)
  138012. * @param uniform defines the webGL uniform location where to store the value
  138013. * @param array defines the array of int32 to store
  138014. * @returns true if value was set
  138015. */
  138016. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138017. /**
  138018. * Set the value of an uniform to an array of int32 (stored as vec4)
  138019. * @param uniform defines the webGL uniform location where to store the value
  138020. * @param array defines the array of int32 to store
  138021. * @returns true if value was set
  138022. */
  138023. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138024. /**
  138025. * Set the value of an uniform to an array of float32
  138026. * @param uniform defines the webGL uniform location where to store the value
  138027. * @param array defines the array of float32 to store
  138028. * @returns true if value was set
  138029. */
  138030. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138031. /**
  138032. * Set the value of an uniform to an array of float32 (stored as vec2)
  138033. * @param uniform defines the webGL uniform location where to store the value
  138034. * @param array defines the array of float32 to store
  138035. * @returns true if value was set
  138036. */
  138037. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138038. /**
  138039. * Set the value of an uniform to an array of float32 (stored as vec3)
  138040. * @param uniform defines the webGL uniform location where to store the value
  138041. * @param array defines the array of float32 to store
  138042. * @returns true if value was set
  138043. */
  138044. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138045. /**
  138046. * Set the value of an uniform to an array of float32 (stored as vec4)
  138047. * @param uniform defines the webGL uniform location where to store the value
  138048. * @param array defines the array of float32 to store
  138049. * @returns true if value was set
  138050. */
  138051. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138052. /**
  138053. * Set the value of an uniform to an array of number
  138054. * @param uniform defines the webGL uniform location where to store the value
  138055. * @param array defines the array of number to store
  138056. * @returns true if value was set
  138057. */
  138058. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  138059. /**
  138060. * Set the value of an uniform to an array of number (stored as vec2)
  138061. * @param uniform defines the webGL uniform location where to store the value
  138062. * @param array defines the array of number to store
  138063. * @returns true if value was set
  138064. */
  138065. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  138066. /**
  138067. * Set the value of an uniform to an array of number (stored as vec3)
  138068. * @param uniform defines the webGL uniform location where to store the value
  138069. * @param array defines the array of number to store
  138070. * @returns true if value was set
  138071. */
  138072. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  138073. /**
  138074. * Set the value of an uniform to an array of number (stored as vec4)
  138075. * @param uniform defines the webGL uniform location where to store the value
  138076. * @param array defines the array of number to store
  138077. * @returns true if value was set
  138078. */
  138079. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  138080. /**
  138081. * Set the value of an uniform to an array of float32 (stored as matrices)
  138082. * @param uniform defines the webGL uniform location where to store the value
  138083. * @param matrices defines the array of float32 to store
  138084. * @returns true if value was set
  138085. */
  138086. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  138087. /**
  138088. * Set the value of an uniform to a matrix (3x3)
  138089. * @param uniform defines the webGL uniform location where to store the value
  138090. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  138091. * @returns true if value was set
  138092. */
  138093. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138094. /**
  138095. * Set the value of an uniform to a matrix (2x2)
  138096. * @param uniform defines the webGL uniform location where to store the value
  138097. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  138098. * @returns true if value was set
  138099. */
  138100. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138101. /**
  138102. * Set the value of an uniform to a number (float)
  138103. * @param uniform defines the webGL uniform location where to store the value
  138104. * @param value defines the float number to store
  138105. * @returns true if value was set
  138106. */
  138107. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  138108. /**
  138109. * Set the value of an uniform to a vec2
  138110. * @param uniform defines the webGL uniform location where to store the value
  138111. * @param x defines the 1st component of the value
  138112. * @param y defines the 2nd component of the value
  138113. * @returns true if value was set
  138114. */
  138115. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  138116. /**
  138117. * Set the value of an uniform to a vec3
  138118. * @param uniform defines the webGL uniform location where to store the value
  138119. * @param x defines the 1st component of the value
  138120. * @param y defines the 2nd component of the value
  138121. * @param z defines the 3rd component of the value
  138122. * @returns true if value was set
  138123. */
  138124. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  138125. /**
  138126. * Set the value of an uniform to a boolean
  138127. * @param uniform defines the webGL uniform location where to store the value
  138128. * @param bool defines the boolean to store
  138129. * @returns true if value was set
  138130. */
  138131. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  138132. /**
  138133. * Set the value of an uniform to a vec4
  138134. * @param uniform defines the webGL uniform location where to store the value
  138135. * @param x defines the 1st component of the value
  138136. * @param y defines the 2nd component of the value
  138137. * @param z defines the 3rd component of the value
  138138. * @param w defines the 4th component of the value
  138139. * @returns true if value was set
  138140. */
  138141. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  138142. /**
  138143. * Sets the current alpha mode
  138144. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  138145. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  138146. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138147. */
  138148. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  138149. /**
  138150. * Bind webGl buffers directly to the webGL context
  138151. * @param vertexBuffers defines the vertex buffer to bind
  138152. * @param indexBuffer defines the index buffer to bind
  138153. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  138154. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  138155. * @param effect defines the effect associated with the vertex buffer
  138156. */
  138157. bindBuffers(vertexBuffers: {
  138158. [key: string]: VertexBuffer;
  138159. }, indexBuffer: DataBuffer, effect: Effect): void;
  138160. /**
  138161. * Force the entire cache to be cleared
  138162. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  138163. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  138164. */
  138165. wipeCaches(bruteForce?: boolean): void;
  138166. /**
  138167. * Send a draw order
  138168. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  138169. * @param indexStart defines the starting index
  138170. * @param indexCount defines the number of index to draw
  138171. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138172. */
  138173. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  138174. /**
  138175. * Draw a list of indexed primitives
  138176. * @param fillMode defines the primitive to use
  138177. * @param indexStart defines the starting index
  138178. * @param indexCount defines the number of index to draw
  138179. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138180. */
  138181. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  138182. /**
  138183. * Draw a list of unindexed primitives
  138184. * @param fillMode defines the primitive to use
  138185. * @param verticesStart defines the index of first vertex to draw
  138186. * @param verticesCount defines the count of vertices to draw
  138187. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138188. */
  138189. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  138190. /** @hidden */
  138191. _createTexture(): WebGLTexture;
  138192. /** @hidden */
  138193. _releaseTexture(texture: InternalTexture): void;
  138194. /**
  138195. * Usually called from Texture.ts.
  138196. * Passed information to create a WebGLTexture
  138197. * @param urlArg defines a value which contains one of the following:
  138198. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  138199. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  138200. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  138201. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  138202. * @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)
  138203. * @param scene needed for loading to the correct scene
  138204. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  138205. * @param onLoad optional callback to be called upon successful completion
  138206. * @param onError optional callback to be called upon failure
  138207. * @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
  138208. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  138209. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  138210. * @param forcedExtension defines the extension to use to pick the right loader
  138211. * @param mimeType defines an optional mime type
  138212. * @returns a InternalTexture for assignment back into BABYLON.Texture
  138213. */
  138214. 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;
  138215. /**
  138216. * Creates a new render target texture
  138217. * @param size defines the size of the texture
  138218. * @param options defines the options used to create the texture
  138219. * @returns a new render target texture stored in an InternalTexture
  138220. */
  138221. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  138222. /**
  138223. * Update the sampling mode of a given texture
  138224. * @param samplingMode defines the required sampling mode
  138225. * @param texture defines the texture to update
  138226. */
  138227. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  138228. /**
  138229. * Binds the frame buffer to the specified texture.
  138230. * @param texture The texture to render to or null for the default canvas
  138231. * @param faceIndex The face of the texture to render to in case of cube texture
  138232. * @param requiredWidth The width of the target to render to
  138233. * @param requiredHeight The height of the target to render to
  138234. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  138235. * @param lodLevel defines le lod level to bind to the frame buffer
  138236. */
  138237. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  138238. /**
  138239. * Unbind the current render target texture from the webGL context
  138240. * @param texture defines the render target texture to unbind
  138241. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  138242. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  138243. */
  138244. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  138245. /**
  138246. * Creates a dynamic vertex buffer
  138247. * @param vertices the data for the dynamic vertex buffer
  138248. * @returns the new WebGL dynamic buffer
  138249. */
  138250. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  138251. /**
  138252. * Update the content of a dynamic texture
  138253. * @param texture defines the texture to update
  138254. * @param canvas defines the canvas containing the source
  138255. * @param invertY defines if data must be stored with Y axis inverted
  138256. * @param premulAlpha defines if alpha is stored as premultiplied
  138257. * @param format defines the format of the data
  138258. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  138259. */
  138260. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  138261. /**
  138262. * Gets a boolean indicating if all created effects are ready
  138263. * @returns true if all effects are ready
  138264. */
  138265. areAllEffectsReady(): boolean;
  138266. /**
  138267. * @hidden
  138268. * Get the current error code of the webGL context
  138269. * @returns the error code
  138270. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  138271. */
  138272. getError(): number;
  138273. /** @hidden */
  138274. _getUnpackAlignement(): number;
  138275. /** @hidden */
  138276. _unpackFlipY(value: boolean): void;
  138277. /**
  138278. * Update a dynamic index buffer
  138279. * @param indexBuffer defines the target index buffer
  138280. * @param indices defines the data to update
  138281. * @param offset defines the offset in the target index buffer where update should start
  138282. */
  138283. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  138284. /**
  138285. * Updates a dynamic vertex buffer.
  138286. * @param vertexBuffer the vertex buffer to update
  138287. * @param vertices the data used to update the vertex buffer
  138288. * @param byteOffset the byte offset of the data (optional)
  138289. * @param byteLength the byte length of the data (optional)
  138290. */
  138291. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  138292. /** @hidden */
  138293. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  138294. /** @hidden */
  138295. _bindTexture(channel: number, texture: InternalTexture): void;
  138296. protected _deleteBuffer(buffer: WebGLBuffer): void;
  138297. /**
  138298. * 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
  138299. */
  138300. releaseEffects(): void;
  138301. displayLoadingUI(): void;
  138302. hideLoadingUI(): void;
  138303. /** @hidden */
  138304. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138305. /** @hidden */
  138306. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138307. /** @hidden */
  138308. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138309. /** @hidden */
  138310. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138311. }
  138312. }
  138313. declare module BABYLON {
  138314. /**
  138315. * @hidden
  138316. **/
  138317. export class _TimeToken {
  138318. _startTimeQuery: Nullable<WebGLQuery>;
  138319. _endTimeQuery: Nullable<WebGLQuery>;
  138320. _timeElapsedQuery: Nullable<WebGLQuery>;
  138321. _timeElapsedQueryEnded: boolean;
  138322. }
  138323. }
  138324. declare module BABYLON {
  138325. /** @hidden */
  138326. export class _OcclusionDataStorage {
  138327. /** @hidden */
  138328. occlusionInternalRetryCounter: number;
  138329. /** @hidden */
  138330. isOcclusionQueryInProgress: boolean;
  138331. /** @hidden */
  138332. isOccluded: boolean;
  138333. /** @hidden */
  138334. occlusionRetryCount: number;
  138335. /** @hidden */
  138336. occlusionType: number;
  138337. /** @hidden */
  138338. occlusionQueryAlgorithmType: number;
  138339. }
  138340. interface Engine {
  138341. /**
  138342. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  138343. * @return the new query
  138344. */
  138345. createQuery(): WebGLQuery;
  138346. /**
  138347. * Delete and release a webGL query
  138348. * @param query defines the query to delete
  138349. * @return the current engine
  138350. */
  138351. deleteQuery(query: WebGLQuery): Engine;
  138352. /**
  138353. * Check if a given query has resolved and got its value
  138354. * @param query defines the query to check
  138355. * @returns true if the query got its value
  138356. */
  138357. isQueryResultAvailable(query: WebGLQuery): boolean;
  138358. /**
  138359. * Gets the value of a given query
  138360. * @param query defines the query to check
  138361. * @returns the value of the query
  138362. */
  138363. getQueryResult(query: WebGLQuery): number;
  138364. /**
  138365. * Initiates an occlusion query
  138366. * @param algorithmType defines the algorithm to use
  138367. * @param query defines the query to use
  138368. * @returns the current engine
  138369. * @see https://doc.babylonjs.com/features/occlusionquery
  138370. */
  138371. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  138372. /**
  138373. * Ends an occlusion query
  138374. * @see https://doc.babylonjs.com/features/occlusionquery
  138375. * @param algorithmType defines the algorithm to use
  138376. * @returns the current engine
  138377. */
  138378. endOcclusionQuery(algorithmType: number): Engine;
  138379. /**
  138380. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  138381. * Please note that only one query can be issued at a time
  138382. * @returns a time token used to track the time span
  138383. */
  138384. startTimeQuery(): Nullable<_TimeToken>;
  138385. /**
  138386. * Ends a time query
  138387. * @param token defines the token used to measure the time span
  138388. * @returns the time spent (in ns)
  138389. */
  138390. endTimeQuery(token: _TimeToken): int;
  138391. /** @hidden */
  138392. _currentNonTimestampToken: Nullable<_TimeToken>;
  138393. /** @hidden */
  138394. _createTimeQuery(): WebGLQuery;
  138395. /** @hidden */
  138396. _deleteTimeQuery(query: WebGLQuery): void;
  138397. /** @hidden */
  138398. _getGlAlgorithmType(algorithmType: number): number;
  138399. /** @hidden */
  138400. _getTimeQueryResult(query: WebGLQuery): any;
  138401. /** @hidden */
  138402. _getTimeQueryAvailability(query: WebGLQuery): any;
  138403. }
  138404. interface AbstractMesh {
  138405. /**
  138406. * Backing filed
  138407. * @hidden
  138408. */
  138409. __occlusionDataStorage: _OcclusionDataStorage;
  138410. /**
  138411. * Access property
  138412. * @hidden
  138413. */
  138414. _occlusionDataStorage: _OcclusionDataStorage;
  138415. /**
  138416. * 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.
  138417. * The default value is -1 which means don't break the query and wait till the result
  138418. * @see https://doc.babylonjs.com/features/occlusionquery
  138419. */
  138420. occlusionRetryCount: number;
  138421. /**
  138422. * 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:
  138423. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  138424. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  138425. * * 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.
  138426. * @see https://doc.babylonjs.com/features/occlusionquery
  138427. */
  138428. occlusionType: number;
  138429. /**
  138430. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  138431. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  138432. * * 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.
  138433. * @see https://doc.babylonjs.com/features/occlusionquery
  138434. */
  138435. occlusionQueryAlgorithmType: number;
  138436. /**
  138437. * 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
  138438. * @see https://doc.babylonjs.com/features/occlusionquery
  138439. */
  138440. isOccluded: boolean;
  138441. /**
  138442. * Flag to check the progress status of the query
  138443. * @see https://doc.babylonjs.com/features/occlusionquery
  138444. */
  138445. isOcclusionQueryInProgress: boolean;
  138446. }
  138447. }
  138448. declare module BABYLON {
  138449. /** @hidden */
  138450. export var _forceTransformFeedbackToBundle: boolean;
  138451. interface Engine {
  138452. /**
  138453. * Creates a webGL transform feedback object
  138454. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  138455. * @returns the webGL transform feedback object
  138456. */
  138457. createTransformFeedback(): WebGLTransformFeedback;
  138458. /**
  138459. * Delete a webGL transform feedback object
  138460. * @param value defines the webGL transform feedback object to delete
  138461. */
  138462. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  138463. /**
  138464. * Bind a webGL transform feedback object to the webgl context
  138465. * @param value defines the webGL transform feedback object to bind
  138466. */
  138467. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  138468. /**
  138469. * Begins a transform feedback operation
  138470. * @param usePoints defines if points or triangles must be used
  138471. */
  138472. beginTransformFeedback(usePoints: boolean): void;
  138473. /**
  138474. * Ends a transform feedback operation
  138475. */
  138476. endTransformFeedback(): void;
  138477. /**
  138478. * Specify the varyings to use with transform feedback
  138479. * @param program defines the associated webGL program
  138480. * @param value defines the list of strings representing the varying names
  138481. */
  138482. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  138483. /**
  138484. * Bind a webGL buffer for a transform feedback operation
  138485. * @param value defines the webGL buffer to bind
  138486. */
  138487. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  138488. }
  138489. }
  138490. declare module BABYLON {
  138491. /**
  138492. * Class used to define an additional view for the engine
  138493. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138494. */
  138495. export class EngineView {
  138496. /** Defines the canvas where to render the view */
  138497. target: HTMLCanvasElement;
  138498. /** Defines an optional camera used to render the view (will use active camera else) */
  138499. camera?: Camera;
  138500. }
  138501. interface Engine {
  138502. /**
  138503. * Gets or sets the HTML element to use for attaching events
  138504. */
  138505. inputElement: Nullable<HTMLElement>;
  138506. /**
  138507. * Gets the current engine view
  138508. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138509. */
  138510. activeView: Nullable<EngineView>;
  138511. /** Gets or sets the list of views */
  138512. views: EngineView[];
  138513. /**
  138514. * Register a new child canvas
  138515. * @param canvas defines the canvas to register
  138516. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  138517. * @returns the associated view
  138518. */
  138519. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  138520. /**
  138521. * Remove a registered child canvas
  138522. * @param canvas defines the canvas to remove
  138523. * @returns the current engine
  138524. */
  138525. unRegisterView(canvas: HTMLCanvasElement): Engine;
  138526. }
  138527. }
  138528. declare module BABYLON {
  138529. interface Engine {
  138530. /** @hidden */
  138531. _excludedCompressedTextures: string[];
  138532. /** @hidden */
  138533. _textureFormatInUse: string;
  138534. /**
  138535. * Gets the list of texture formats supported
  138536. */
  138537. readonly texturesSupported: Array<string>;
  138538. /**
  138539. * Gets the texture format in use
  138540. */
  138541. readonly textureFormatInUse: Nullable<string>;
  138542. /**
  138543. * Set the compressed texture extensions or file names to skip.
  138544. *
  138545. * @param skippedFiles defines the list of those texture files you want to skip
  138546. * Example: [".dds", ".env", "myfile.png"]
  138547. */
  138548. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  138549. /**
  138550. * Set the compressed texture format to use, based on the formats you have, and the formats
  138551. * supported by the hardware / browser.
  138552. *
  138553. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  138554. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  138555. * to API arguments needed to compressed textures. This puts the burden on the container
  138556. * generator to house the arcane code for determining these for current & future formats.
  138557. *
  138558. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138559. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138560. *
  138561. * Note: The result of this call is not taken into account when a texture is base64.
  138562. *
  138563. * @param formatsAvailable defines the list of those format families you have created
  138564. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  138565. *
  138566. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  138567. * @returns The extension selected.
  138568. */
  138569. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  138570. }
  138571. }
  138572. declare module BABYLON {
  138573. /** @hidden */
  138574. export var rgbdEncodePixelShader: {
  138575. name: string;
  138576. shader: string;
  138577. };
  138578. }
  138579. declare module BABYLON {
  138580. /**
  138581. * Raw texture data and descriptor sufficient for WebGL texture upload
  138582. */
  138583. export interface EnvironmentTextureInfo {
  138584. /**
  138585. * Version of the environment map
  138586. */
  138587. version: number;
  138588. /**
  138589. * Width of image
  138590. */
  138591. width: number;
  138592. /**
  138593. * Irradiance information stored in the file.
  138594. */
  138595. irradiance: any;
  138596. /**
  138597. * Specular information stored in the file.
  138598. */
  138599. specular: any;
  138600. }
  138601. /**
  138602. * Defines One Image in the file. It requires only the position in the file
  138603. * as well as the length.
  138604. */
  138605. interface BufferImageData {
  138606. /**
  138607. * Length of the image data.
  138608. */
  138609. length: number;
  138610. /**
  138611. * Position of the data from the null terminator delimiting the end of the JSON.
  138612. */
  138613. position: number;
  138614. }
  138615. /**
  138616. * Defines the specular data enclosed in the file.
  138617. * This corresponds to the version 1 of the data.
  138618. */
  138619. export interface EnvironmentTextureSpecularInfoV1 {
  138620. /**
  138621. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  138622. */
  138623. specularDataPosition?: number;
  138624. /**
  138625. * This contains all the images data needed to reconstruct the cubemap.
  138626. */
  138627. mipmaps: Array<BufferImageData>;
  138628. /**
  138629. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  138630. */
  138631. lodGenerationScale: number;
  138632. }
  138633. /**
  138634. * Sets of helpers addressing the serialization and deserialization of environment texture
  138635. * stored in a BabylonJS env file.
  138636. * Those files are usually stored as .env files.
  138637. */
  138638. export class EnvironmentTextureTools {
  138639. /**
  138640. * Magic number identifying the env file.
  138641. */
  138642. private static _MagicBytes;
  138643. /**
  138644. * Gets the environment info from an env file.
  138645. * @param data The array buffer containing the .env bytes.
  138646. * @returns the environment file info (the json header) if successfully parsed.
  138647. */
  138648. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  138649. /**
  138650. * Creates an environment texture from a loaded cube texture.
  138651. * @param texture defines the cube texture to convert in env file
  138652. * @return a promise containing the environment data if succesfull.
  138653. */
  138654. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  138655. /**
  138656. * Creates a JSON representation of the spherical data.
  138657. * @param texture defines the texture containing the polynomials
  138658. * @return the JSON representation of the spherical info
  138659. */
  138660. private static _CreateEnvTextureIrradiance;
  138661. /**
  138662. * Creates the ArrayBufferViews used for initializing environment texture image data.
  138663. * @param data the image data
  138664. * @param info parameters that determine what views will be created for accessing the underlying buffer
  138665. * @return the views described by info providing access to the underlying buffer
  138666. */
  138667. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  138668. /**
  138669. * Uploads the texture info contained in the env file to the GPU.
  138670. * @param texture defines the internal texture to upload to
  138671. * @param data defines the data to load
  138672. * @param info defines the texture info retrieved through the GetEnvInfo method
  138673. * @returns a promise
  138674. */
  138675. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  138676. private static _OnImageReadyAsync;
  138677. /**
  138678. * Uploads the levels of image data to the GPU.
  138679. * @param texture defines the internal texture to upload to
  138680. * @param imageData defines the array buffer views of image data [mipmap][face]
  138681. * @returns a promise
  138682. */
  138683. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  138684. /**
  138685. * Uploads spherical polynomials information to the texture.
  138686. * @param texture defines the texture we are trying to upload the information to
  138687. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  138688. */
  138689. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  138690. /** @hidden */
  138691. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138692. }
  138693. }
  138694. declare module BABYLON {
  138695. /**
  138696. * Class used to inline functions in shader code
  138697. */
  138698. export class ShaderCodeInliner {
  138699. private static readonly _RegexpFindFunctionNameAndType;
  138700. private _sourceCode;
  138701. private _functionDescr;
  138702. private _numMaxIterations;
  138703. /** Gets or sets the token used to mark the functions to inline */
  138704. inlineToken: string;
  138705. /** Gets or sets the debug mode */
  138706. debug: boolean;
  138707. /** Gets the code after the inlining process */
  138708. get code(): string;
  138709. /**
  138710. * Initializes the inliner
  138711. * @param sourceCode shader code source to inline
  138712. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  138713. */
  138714. constructor(sourceCode: string, numMaxIterations?: number);
  138715. /**
  138716. * Start the processing of the shader code
  138717. */
  138718. processCode(): void;
  138719. private _collectFunctions;
  138720. private _processInlining;
  138721. private _extractBetweenMarkers;
  138722. private _skipWhitespaces;
  138723. private _removeComments;
  138724. private _replaceFunctionCallsByCode;
  138725. private _findBackward;
  138726. private _escapeRegExp;
  138727. private _replaceNames;
  138728. }
  138729. }
  138730. declare module BABYLON {
  138731. /**
  138732. * Container for accessors for natively-stored mesh data buffers.
  138733. */
  138734. class NativeDataBuffer extends DataBuffer {
  138735. /**
  138736. * Accessor value used to identify/retrieve a natively-stored index buffer.
  138737. */
  138738. nativeIndexBuffer?: any;
  138739. /**
  138740. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  138741. */
  138742. nativeVertexBuffer?: any;
  138743. }
  138744. /** @hidden */
  138745. class NativeTexture extends InternalTexture {
  138746. getInternalTexture(): InternalTexture;
  138747. getViewCount(): number;
  138748. }
  138749. /** @hidden */
  138750. export class NativeEngine extends Engine {
  138751. private readonly _native;
  138752. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  138753. private readonly INVALID_HANDLE;
  138754. private _boundBuffersVertexArray;
  138755. private _currentDepthTest;
  138756. getHardwareScalingLevel(): number;
  138757. constructor();
  138758. dispose(): void;
  138759. /**
  138760. * Can be used to override the current requestAnimationFrame requester.
  138761. * @hidden
  138762. */
  138763. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  138764. /**
  138765. * Override default engine behavior.
  138766. * @param color
  138767. * @param backBuffer
  138768. * @param depth
  138769. * @param stencil
  138770. */
  138771. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  138772. /**
  138773. * Gets host document
  138774. * @returns the host document object
  138775. */
  138776. getHostDocument(): Nullable<Document>;
  138777. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  138778. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  138779. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  138780. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  138781. [key: string]: VertexBuffer;
  138782. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138783. bindBuffers(vertexBuffers: {
  138784. [key: string]: VertexBuffer;
  138785. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138786. recordVertexArrayObject(vertexBuffers: {
  138787. [key: string]: VertexBuffer;
  138788. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  138789. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138790. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138791. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  138792. /**
  138793. * Draw a list of indexed primitives
  138794. * @param fillMode defines the primitive to use
  138795. * @param indexStart defines the starting index
  138796. * @param indexCount defines the number of index to draw
  138797. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138798. */
  138799. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  138800. /**
  138801. * Draw a list of unindexed primitives
  138802. * @param fillMode defines the primitive to use
  138803. * @param verticesStart defines the index of first vertex to draw
  138804. * @param verticesCount defines the count of vertices to draw
  138805. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138806. */
  138807. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  138808. createPipelineContext(): IPipelineContext;
  138809. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  138810. /** @hidden */
  138811. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  138812. /** @hidden */
  138813. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  138814. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138815. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138816. protected _setProgram(program: WebGLProgram): void;
  138817. _releaseEffect(effect: Effect): void;
  138818. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  138819. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  138820. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  138821. bindSamplers(effect: Effect): void;
  138822. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  138823. getRenderWidth(useScreen?: boolean): number;
  138824. getRenderHeight(useScreen?: boolean): number;
  138825. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  138826. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  138827. /**
  138828. * Set the z offset to apply to current rendering
  138829. * @param value defines the offset to apply
  138830. */
  138831. setZOffset(value: number): void;
  138832. /**
  138833. * Gets the current value of the zOffset
  138834. * @returns the current zOffset state
  138835. */
  138836. getZOffset(): number;
  138837. /**
  138838. * Enable or disable depth buffering
  138839. * @param enable defines the state to set
  138840. */
  138841. setDepthBuffer(enable: boolean): void;
  138842. /**
  138843. * Gets a boolean indicating if depth writing is enabled
  138844. * @returns the current depth writing state
  138845. */
  138846. getDepthWrite(): boolean;
  138847. setDepthFunctionToGreater(): void;
  138848. setDepthFunctionToGreaterOrEqual(): void;
  138849. setDepthFunctionToLess(): void;
  138850. setDepthFunctionToLessOrEqual(): void;
  138851. /**
  138852. * Enable or disable depth writing
  138853. * @param enable defines the state to set
  138854. */
  138855. setDepthWrite(enable: boolean): void;
  138856. /**
  138857. * Enable or disable color writing
  138858. * @param enable defines the state to set
  138859. */
  138860. setColorWrite(enable: boolean): void;
  138861. /**
  138862. * Gets a boolean indicating if color writing is enabled
  138863. * @returns the current color writing state
  138864. */
  138865. getColorWrite(): boolean;
  138866. /**
  138867. * Sets alpha constants used by some alpha blending modes
  138868. * @param r defines the red component
  138869. * @param g defines the green component
  138870. * @param b defines the blue component
  138871. * @param a defines the alpha component
  138872. */
  138873. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  138874. /**
  138875. * Sets the current alpha mode
  138876. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  138877. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  138878. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138879. */
  138880. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  138881. /**
  138882. * Gets the current alpha mode
  138883. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138884. * @returns the current alpha mode
  138885. */
  138886. getAlphaMode(): number;
  138887. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  138888. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138889. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138890. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138891. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138892. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138893. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138894. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138895. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138896. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  138897. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  138898. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  138899. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  138900. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  138901. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138902. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138903. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  138904. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  138905. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  138906. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  138907. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  138908. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  138909. wipeCaches(bruteForce?: boolean): void;
  138910. _createTexture(): WebGLTexture;
  138911. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  138912. /**
  138913. * Update the content of a dynamic texture
  138914. * @param texture defines the texture to update
  138915. * @param canvas defines the canvas containing the source
  138916. * @param invertY defines if data must be stored with Y axis inverted
  138917. * @param premulAlpha defines if alpha is stored as premultiplied
  138918. * @param format defines the format of the data
  138919. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  138920. */
  138921. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  138922. /**
  138923. * Usually called from Texture.ts.
  138924. * Passed information to create a WebGLTexture
  138925. * @param url defines a value which contains one of the following:
  138926. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  138927. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  138928. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  138929. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  138930. * @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)
  138931. * @param scene needed for loading to the correct scene
  138932. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  138933. * @param onLoad optional callback to be called upon successful completion
  138934. * @param onError optional callback to be called upon failure
  138935. * @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
  138936. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  138937. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  138938. * @param forcedExtension defines the extension to use to pick the right loader
  138939. * @param mimeType defines an optional mime type
  138940. * @param loaderOptions options to be passed to the loader
  138941. * @returns a InternalTexture for assignment back into BABYLON.Texture
  138942. */
  138943. 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;
  138944. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  138945. _releaseFramebufferObjects(texture: InternalTexture): void;
  138946. /**
  138947. * Creates a cube texture
  138948. * @param rootUrl defines the url where the files to load is located
  138949. * @param scene defines the current scene
  138950. * @param files defines the list of files to load (1 per face)
  138951. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  138952. * @param onLoad defines an optional callback raised when the texture is loaded
  138953. * @param onError defines an optional callback raised if there is an issue to load the texture
  138954. * @param format defines the format of the data
  138955. * @param forcedExtension defines the extension to use to pick the right loader
  138956. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  138957. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138958. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138959. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  138960. * @returns the cube texture as an InternalTexture
  138961. */
  138962. 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;
  138963. createRenderTargetTexture(size: number | {
  138964. width: number;
  138965. height: number;
  138966. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  138967. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  138968. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  138969. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  138970. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  138971. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  138972. /**
  138973. * Updates a dynamic vertex buffer.
  138974. * @param vertexBuffer the vertex buffer to update
  138975. * @param data the data used to update the vertex buffer
  138976. * @param byteOffset the byte offset of the data (optional)
  138977. * @param byteLength the byte length of the data (optional)
  138978. */
  138979. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  138980. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  138981. private _updateAnisotropicLevel;
  138982. private _getAddressMode;
  138983. /** @hidden */
  138984. _bindTexture(channel: number, texture: InternalTexture): void;
  138985. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  138986. releaseEffects(): void;
  138987. /** @hidden */
  138988. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138989. /** @hidden */
  138990. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138991. /** @hidden */
  138992. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138993. /** @hidden */
  138994. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138995. private _getNativeSamplingMode;
  138996. private _getNativeTextureFormat;
  138997. private _getNativeAlphaMode;
  138998. private _getNativeAttribType;
  138999. }
  139000. }
  139001. declare module BABYLON {
  139002. /**
  139003. * Gather the list of clipboard event types as constants.
  139004. */
  139005. export class ClipboardEventTypes {
  139006. /**
  139007. * The clipboard event is fired when a copy command is active (pressed).
  139008. */
  139009. static readonly COPY: number;
  139010. /**
  139011. * The clipboard event is fired when a cut command is active (pressed).
  139012. */
  139013. static readonly CUT: number;
  139014. /**
  139015. * The clipboard event is fired when a paste command is active (pressed).
  139016. */
  139017. static readonly PASTE: number;
  139018. }
  139019. /**
  139020. * This class is used to store clipboard related info for the onClipboardObservable event.
  139021. */
  139022. export class ClipboardInfo {
  139023. /**
  139024. * Defines the type of event (BABYLON.ClipboardEventTypes)
  139025. */
  139026. type: number;
  139027. /**
  139028. * Defines the related dom event
  139029. */
  139030. event: ClipboardEvent;
  139031. /**
  139032. *Creates an instance of ClipboardInfo.
  139033. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  139034. * @param event Defines the related dom event
  139035. */
  139036. constructor(
  139037. /**
  139038. * Defines the type of event (BABYLON.ClipboardEventTypes)
  139039. */
  139040. type: number,
  139041. /**
  139042. * Defines the related dom event
  139043. */
  139044. event: ClipboardEvent);
  139045. /**
  139046. * Get the clipboard event's type from the keycode.
  139047. * @param keyCode Defines the keyCode for the current keyboard event.
  139048. * @return {number}
  139049. */
  139050. static GetTypeFromCharacter(keyCode: number): number;
  139051. }
  139052. }
  139053. declare module BABYLON {
  139054. /**
  139055. * Google Daydream controller
  139056. */
  139057. export class DaydreamController extends WebVRController {
  139058. /**
  139059. * Base Url for the controller model.
  139060. */
  139061. static MODEL_BASE_URL: string;
  139062. /**
  139063. * File name for the controller model.
  139064. */
  139065. static MODEL_FILENAME: string;
  139066. /**
  139067. * Gamepad Id prefix used to identify Daydream Controller.
  139068. */
  139069. static readonly GAMEPAD_ID_PREFIX: string;
  139070. /**
  139071. * Creates a new DaydreamController from a gamepad
  139072. * @param vrGamepad the gamepad that the controller should be created from
  139073. */
  139074. constructor(vrGamepad: any);
  139075. /**
  139076. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139077. * @param scene scene in which to add meshes
  139078. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139079. */
  139080. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139081. /**
  139082. * Called once for each button that changed state since the last frame
  139083. * @param buttonIdx Which button index changed
  139084. * @param state New state of the button
  139085. * @param changes Which properties on the state changed since last frame
  139086. */
  139087. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139088. }
  139089. }
  139090. declare module BABYLON {
  139091. /**
  139092. * Gear VR Controller
  139093. */
  139094. export class GearVRController extends WebVRController {
  139095. /**
  139096. * Base Url for the controller model.
  139097. */
  139098. static MODEL_BASE_URL: string;
  139099. /**
  139100. * File name for the controller model.
  139101. */
  139102. static MODEL_FILENAME: string;
  139103. /**
  139104. * Gamepad Id prefix used to identify this controller.
  139105. */
  139106. static readonly GAMEPAD_ID_PREFIX: string;
  139107. private readonly _buttonIndexToObservableNameMap;
  139108. /**
  139109. * Creates a new GearVRController from a gamepad
  139110. * @param vrGamepad the gamepad that the controller should be created from
  139111. */
  139112. constructor(vrGamepad: any);
  139113. /**
  139114. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139115. * @param scene scene in which to add meshes
  139116. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139117. */
  139118. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139119. /**
  139120. * Called once for each button that changed state since the last frame
  139121. * @param buttonIdx Which button index changed
  139122. * @param state New state of the button
  139123. * @param changes Which properties on the state changed since last frame
  139124. */
  139125. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139126. }
  139127. }
  139128. declare module BABYLON {
  139129. /**
  139130. * Generic Controller
  139131. */
  139132. export class GenericController extends WebVRController {
  139133. /**
  139134. * Base Url for the controller model.
  139135. */
  139136. static readonly MODEL_BASE_URL: string;
  139137. /**
  139138. * File name for the controller model.
  139139. */
  139140. static readonly MODEL_FILENAME: string;
  139141. /**
  139142. * Creates a new GenericController from a gamepad
  139143. * @param vrGamepad the gamepad that the controller should be created from
  139144. */
  139145. constructor(vrGamepad: any);
  139146. /**
  139147. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139148. * @param scene scene in which to add meshes
  139149. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139150. */
  139151. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139152. /**
  139153. * Called once for each button that changed state since the last frame
  139154. * @param buttonIdx Which button index changed
  139155. * @param state New state of the button
  139156. * @param changes Which properties on the state changed since last frame
  139157. */
  139158. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139159. }
  139160. }
  139161. declare module BABYLON {
  139162. /**
  139163. * Oculus Touch Controller
  139164. */
  139165. export class OculusTouchController extends WebVRController {
  139166. /**
  139167. * Base Url for the controller model.
  139168. */
  139169. static MODEL_BASE_URL: string;
  139170. /**
  139171. * File name for the left controller model.
  139172. */
  139173. static MODEL_LEFT_FILENAME: string;
  139174. /**
  139175. * File name for the right controller model.
  139176. */
  139177. static MODEL_RIGHT_FILENAME: string;
  139178. /**
  139179. * Base Url for the Quest controller model.
  139180. */
  139181. static QUEST_MODEL_BASE_URL: string;
  139182. /**
  139183. * @hidden
  139184. * If the controllers are running on a device that needs the updated Quest controller models
  139185. */
  139186. static _IsQuest: boolean;
  139187. /**
  139188. * Fired when the secondary trigger on this controller is modified
  139189. */
  139190. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  139191. /**
  139192. * Fired when the thumb rest on this controller is modified
  139193. */
  139194. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  139195. /**
  139196. * Creates a new OculusTouchController from a gamepad
  139197. * @param vrGamepad the gamepad that the controller should be created from
  139198. */
  139199. constructor(vrGamepad: any);
  139200. /**
  139201. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139202. * @param scene scene in which to add meshes
  139203. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139204. */
  139205. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139206. /**
  139207. * Fired when the A button on this controller is modified
  139208. */
  139209. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139210. /**
  139211. * Fired when the B button on this controller is modified
  139212. */
  139213. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139214. /**
  139215. * Fired when the X button on this controller is modified
  139216. */
  139217. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139218. /**
  139219. * Fired when the Y button on this controller is modified
  139220. */
  139221. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139222. /**
  139223. * Called once for each button that changed state since the last frame
  139224. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  139225. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  139226. * 2) secondary trigger (same)
  139227. * 3) A (right) X (left), touch, pressed = value
  139228. * 4) B / Y
  139229. * 5) thumb rest
  139230. * @param buttonIdx Which button index changed
  139231. * @param state New state of the button
  139232. * @param changes Which properties on the state changed since last frame
  139233. */
  139234. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139235. }
  139236. }
  139237. declare module BABYLON {
  139238. /**
  139239. * Vive Controller
  139240. */
  139241. export class ViveController extends WebVRController {
  139242. /**
  139243. * Base Url for the controller model.
  139244. */
  139245. static MODEL_BASE_URL: string;
  139246. /**
  139247. * File name for the controller model.
  139248. */
  139249. static MODEL_FILENAME: string;
  139250. /**
  139251. * Creates a new ViveController from a gamepad
  139252. * @param vrGamepad the gamepad that the controller should be created from
  139253. */
  139254. constructor(vrGamepad: any);
  139255. /**
  139256. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139257. * @param scene scene in which to add meshes
  139258. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139259. */
  139260. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139261. /**
  139262. * Fired when the left button on this controller is modified
  139263. */
  139264. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139265. /**
  139266. * Fired when the right button on this controller is modified
  139267. */
  139268. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139269. /**
  139270. * Fired when the menu button on this controller is modified
  139271. */
  139272. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139273. /**
  139274. * Called once for each button that changed state since the last frame
  139275. * Vive mapping:
  139276. * 0: touchpad
  139277. * 1: trigger
  139278. * 2: left AND right buttons
  139279. * 3: menu button
  139280. * @param buttonIdx Which button index changed
  139281. * @param state New state of the button
  139282. * @param changes Which properties on the state changed since last frame
  139283. */
  139284. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139285. }
  139286. }
  139287. declare module BABYLON {
  139288. /**
  139289. * Defines the WindowsMotionController object that the state of the windows motion controller
  139290. */
  139291. export class WindowsMotionController extends WebVRController {
  139292. /**
  139293. * The base url used to load the left and right controller models
  139294. */
  139295. static MODEL_BASE_URL: string;
  139296. /**
  139297. * The name of the left controller model file
  139298. */
  139299. static MODEL_LEFT_FILENAME: string;
  139300. /**
  139301. * The name of the right controller model file
  139302. */
  139303. static MODEL_RIGHT_FILENAME: string;
  139304. /**
  139305. * The controller name prefix for this controller type
  139306. */
  139307. static readonly GAMEPAD_ID_PREFIX: string;
  139308. /**
  139309. * The controller id pattern for this controller type
  139310. */
  139311. private static readonly GAMEPAD_ID_PATTERN;
  139312. private _loadedMeshInfo;
  139313. protected readonly _mapping: {
  139314. buttons: string[];
  139315. buttonMeshNames: {
  139316. trigger: string;
  139317. menu: string;
  139318. grip: string;
  139319. thumbstick: string;
  139320. trackpad: string;
  139321. };
  139322. buttonObservableNames: {
  139323. trigger: string;
  139324. menu: string;
  139325. grip: string;
  139326. thumbstick: string;
  139327. trackpad: string;
  139328. };
  139329. axisMeshNames: string[];
  139330. pointingPoseMeshName: string;
  139331. };
  139332. /**
  139333. * Fired when the trackpad on this controller is clicked
  139334. */
  139335. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139336. /**
  139337. * Fired when the trackpad on this controller is modified
  139338. */
  139339. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139340. /**
  139341. * The current x and y values of this controller's trackpad
  139342. */
  139343. trackpad: StickValues;
  139344. /**
  139345. * Creates a new WindowsMotionController from a gamepad
  139346. * @param vrGamepad the gamepad that the controller should be created from
  139347. */
  139348. constructor(vrGamepad: any);
  139349. /**
  139350. * Fired when the trigger on this controller is modified
  139351. */
  139352. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139353. /**
  139354. * Fired when the menu button on this controller is modified
  139355. */
  139356. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139357. /**
  139358. * Fired when the grip button on this controller is modified
  139359. */
  139360. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139361. /**
  139362. * Fired when the thumbstick button on this controller is modified
  139363. */
  139364. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139365. /**
  139366. * Fired when the touchpad button on this controller is modified
  139367. */
  139368. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139369. /**
  139370. * Fired when the touchpad values on this controller are modified
  139371. */
  139372. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  139373. protected _updateTrackpad(): void;
  139374. /**
  139375. * Called once per frame by the engine.
  139376. */
  139377. update(): void;
  139378. /**
  139379. * Called once for each button that changed state since the last frame
  139380. * @param buttonIdx Which button index changed
  139381. * @param state New state of the button
  139382. * @param changes Which properties on the state changed since last frame
  139383. */
  139384. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139385. /**
  139386. * Moves the buttons on the controller mesh based on their current state
  139387. * @param buttonName the name of the button to move
  139388. * @param buttonValue the value of the button which determines the buttons new position
  139389. */
  139390. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  139391. /**
  139392. * Moves the axis on the controller mesh based on its current state
  139393. * @param axis the index of the axis
  139394. * @param axisValue the value of the axis which determines the meshes new position
  139395. * @hidden
  139396. */
  139397. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  139398. /**
  139399. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139400. * @param scene scene in which to add meshes
  139401. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139402. */
  139403. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  139404. /**
  139405. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  139406. * can be transformed by button presses and axes values, based on this._mapping.
  139407. *
  139408. * @param scene scene in which the meshes exist
  139409. * @param meshes list of meshes that make up the controller model to process
  139410. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  139411. */
  139412. private processModel;
  139413. private createMeshInfo;
  139414. /**
  139415. * Gets the ray of the controller in the direction the controller is pointing
  139416. * @param length the length the resulting ray should be
  139417. * @returns a ray in the direction the controller is pointing
  139418. */
  139419. getForwardRay(length?: number): Ray;
  139420. /**
  139421. * Disposes of the controller
  139422. */
  139423. dispose(): void;
  139424. }
  139425. /**
  139426. * This class represents a new windows motion controller in XR.
  139427. */
  139428. export class XRWindowsMotionController extends WindowsMotionController {
  139429. /**
  139430. * Changing the original WIndowsMotionController mapping to fir the new mapping
  139431. */
  139432. protected readonly _mapping: {
  139433. buttons: string[];
  139434. buttonMeshNames: {
  139435. trigger: string;
  139436. menu: string;
  139437. grip: string;
  139438. thumbstick: string;
  139439. trackpad: string;
  139440. };
  139441. buttonObservableNames: {
  139442. trigger: string;
  139443. menu: string;
  139444. grip: string;
  139445. thumbstick: string;
  139446. trackpad: string;
  139447. };
  139448. axisMeshNames: string[];
  139449. pointingPoseMeshName: string;
  139450. };
  139451. /**
  139452. * Construct a new XR-Based windows motion controller
  139453. *
  139454. * @param gamepadInfo the gamepad object from the browser
  139455. */
  139456. constructor(gamepadInfo: any);
  139457. /**
  139458. * holds the thumbstick values (X,Y)
  139459. */
  139460. thumbstickValues: StickValues;
  139461. /**
  139462. * Fired when the thumbstick on this controller is clicked
  139463. */
  139464. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  139465. /**
  139466. * Fired when the thumbstick on this controller is modified
  139467. */
  139468. onThumbstickValuesChangedObservable: Observable<StickValues>;
  139469. /**
  139470. * Fired when the touchpad button on this controller is modified
  139471. */
  139472. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139473. /**
  139474. * Fired when the touchpad values on this controller are modified
  139475. */
  139476. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139477. /**
  139478. * Fired when the thumbstick button on this controller is modified
  139479. * here to prevent breaking changes
  139480. */
  139481. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139482. /**
  139483. * updating the thumbstick(!) and not the trackpad.
  139484. * This is named this way due to the difference between WebVR and XR and to avoid
  139485. * changing the parent class.
  139486. */
  139487. protected _updateTrackpad(): void;
  139488. /**
  139489. * Disposes the class with joy
  139490. */
  139491. dispose(): void;
  139492. }
  139493. }
  139494. declare module BABYLON {
  139495. /**
  139496. * A directional light is defined by a direction (what a surprise!).
  139497. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  139498. * 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.
  139499. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139500. */
  139501. export class DirectionalLight extends ShadowLight {
  139502. private _shadowFrustumSize;
  139503. /**
  139504. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  139505. */
  139506. get shadowFrustumSize(): number;
  139507. /**
  139508. * Specifies a fix frustum size for the shadow generation.
  139509. */
  139510. set shadowFrustumSize(value: number);
  139511. private _shadowOrthoScale;
  139512. /**
  139513. * Gets the shadow projection scale against the optimal computed one.
  139514. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139515. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139516. */
  139517. get shadowOrthoScale(): number;
  139518. /**
  139519. * Sets the shadow projection scale against the optimal computed one.
  139520. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139521. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139522. */
  139523. set shadowOrthoScale(value: number);
  139524. /**
  139525. * Automatically compute the projection matrix to best fit (including all the casters)
  139526. * on each frame.
  139527. */
  139528. autoUpdateExtends: boolean;
  139529. /**
  139530. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  139531. * on each frame. autoUpdateExtends must be set to true for this to work
  139532. */
  139533. autoCalcShadowZBounds: boolean;
  139534. private _orthoLeft;
  139535. private _orthoRight;
  139536. private _orthoTop;
  139537. private _orthoBottom;
  139538. /**
  139539. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  139540. * The directional light is emitted from everywhere in the given direction.
  139541. * It can cast shadows.
  139542. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139543. * @param name The friendly name of the light
  139544. * @param direction The direction of the light
  139545. * @param scene The scene the light belongs to
  139546. */
  139547. constructor(name: string, direction: Vector3, scene: Scene);
  139548. /**
  139549. * Returns the string "DirectionalLight".
  139550. * @return The class name
  139551. */
  139552. getClassName(): string;
  139553. /**
  139554. * Returns the integer 1.
  139555. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139556. */
  139557. getTypeID(): number;
  139558. /**
  139559. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  139560. * Returns the DirectionalLight Shadow projection matrix.
  139561. */
  139562. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139563. /**
  139564. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  139565. * Returns the DirectionalLight Shadow projection matrix.
  139566. */
  139567. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  139568. /**
  139569. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  139570. * Returns the DirectionalLight Shadow projection matrix.
  139571. */
  139572. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139573. protected _buildUniformLayout(): void;
  139574. /**
  139575. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  139576. * @param effect The effect to update
  139577. * @param lightIndex The index of the light in the effect to update
  139578. * @returns The directional light
  139579. */
  139580. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  139581. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  139582. /**
  139583. * Gets the minZ used for shadow according to both the scene and the light.
  139584. *
  139585. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139586. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139587. * @param activeCamera The camera we are returning the min for
  139588. * @returns the depth min z
  139589. */
  139590. getDepthMinZ(activeCamera: Camera): number;
  139591. /**
  139592. * Gets the maxZ used for shadow according to both the scene and the light.
  139593. *
  139594. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139595. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139596. * @param activeCamera The camera we are returning the max for
  139597. * @returns the depth max z
  139598. */
  139599. getDepthMaxZ(activeCamera: Camera): number;
  139600. /**
  139601. * Prepares the list of defines specific to the light type.
  139602. * @param defines the list of defines
  139603. * @param lightIndex defines the index of the light for the effect
  139604. */
  139605. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139606. }
  139607. }
  139608. declare module BABYLON {
  139609. /**
  139610. * Class containing static functions to help procedurally build meshes
  139611. */
  139612. export class HemisphereBuilder {
  139613. /**
  139614. * Creates a hemisphere mesh
  139615. * @param name defines the name of the mesh
  139616. * @param options defines the options used to create the mesh
  139617. * @param scene defines the hosting scene
  139618. * @returns the hemisphere mesh
  139619. */
  139620. static CreateHemisphere(name: string, options: {
  139621. segments?: number;
  139622. diameter?: number;
  139623. sideOrientation?: number;
  139624. }, scene: any): Mesh;
  139625. }
  139626. }
  139627. declare module BABYLON {
  139628. /**
  139629. * A spot light is defined by a position, a direction, an angle, and an exponent.
  139630. * These values define a cone of light starting from the position, emitting toward the direction.
  139631. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  139632. * and the exponent defines the speed of the decay of the light with distance (reach).
  139633. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139634. */
  139635. export class SpotLight extends ShadowLight {
  139636. private _angle;
  139637. private _innerAngle;
  139638. private _cosHalfAngle;
  139639. private _lightAngleScale;
  139640. private _lightAngleOffset;
  139641. /**
  139642. * Gets the cone angle of the spot light in Radians.
  139643. */
  139644. get angle(): number;
  139645. /**
  139646. * Sets the cone angle of the spot light in Radians.
  139647. */
  139648. set angle(value: number);
  139649. /**
  139650. * Only used in gltf falloff mode, this defines the angle where
  139651. * the directional falloff will start before cutting at angle which could be seen
  139652. * as outer angle.
  139653. */
  139654. get innerAngle(): number;
  139655. /**
  139656. * Only used in gltf falloff mode, this defines the angle where
  139657. * the directional falloff will start before cutting at angle which could be seen
  139658. * as outer angle.
  139659. */
  139660. set innerAngle(value: number);
  139661. private _shadowAngleScale;
  139662. /**
  139663. * Allows scaling the angle of the light for shadow generation only.
  139664. */
  139665. get shadowAngleScale(): number;
  139666. /**
  139667. * Allows scaling the angle of the light for shadow generation only.
  139668. */
  139669. set shadowAngleScale(value: number);
  139670. /**
  139671. * The light decay speed with the distance from the emission spot.
  139672. */
  139673. exponent: number;
  139674. private _projectionTextureMatrix;
  139675. /**
  139676. * Allows reading the projecton texture
  139677. */
  139678. get projectionTextureMatrix(): Matrix;
  139679. protected _projectionTextureLightNear: number;
  139680. /**
  139681. * Gets the near clip of the Spotlight for texture projection.
  139682. */
  139683. get projectionTextureLightNear(): number;
  139684. /**
  139685. * Sets the near clip of the Spotlight for texture projection.
  139686. */
  139687. set projectionTextureLightNear(value: number);
  139688. protected _projectionTextureLightFar: number;
  139689. /**
  139690. * Gets the far clip of the Spotlight for texture projection.
  139691. */
  139692. get projectionTextureLightFar(): number;
  139693. /**
  139694. * Sets the far clip of the Spotlight for texture projection.
  139695. */
  139696. set projectionTextureLightFar(value: number);
  139697. protected _projectionTextureUpDirection: Vector3;
  139698. /**
  139699. * Gets the Up vector of the Spotlight for texture projection.
  139700. */
  139701. get projectionTextureUpDirection(): Vector3;
  139702. /**
  139703. * Sets the Up vector of the Spotlight for texture projection.
  139704. */
  139705. set projectionTextureUpDirection(value: Vector3);
  139706. private _projectionTexture;
  139707. /**
  139708. * Gets the projection texture of the light.
  139709. */
  139710. get projectionTexture(): Nullable<BaseTexture>;
  139711. /**
  139712. * Sets the projection texture of the light.
  139713. */
  139714. set projectionTexture(value: Nullable<BaseTexture>);
  139715. private static _IsProceduralTexture;
  139716. private static _IsTexture;
  139717. private _projectionTextureViewLightDirty;
  139718. private _projectionTextureProjectionLightDirty;
  139719. private _projectionTextureDirty;
  139720. private _projectionTextureViewTargetVector;
  139721. private _projectionTextureViewLightMatrix;
  139722. private _projectionTextureProjectionLightMatrix;
  139723. private _projectionTextureScalingMatrix;
  139724. /**
  139725. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  139726. * It can cast shadows.
  139727. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139728. * @param name The light friendly name
  139729. * @param position The position of the spot light in the scene
  139730. * @param direction The direction of the light in the scene
  139731. * @param angle The cone angle of the light in Radians
  139732. * @param exponent The light decay speed with the distance from the emission spot
  139733. * @param scene The scene the lights belongs to
  139734. */
  139735. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  139736. /**
  139737. * Returns the string "SpotLight".
  139738. * @returns the class name
  139739. */
  139740. getClassName(): string;
  139741. /**
  139742. * Returns the integer 2.
  139743. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139744. */
  139745. getTypeID(): number;
  139746. /**
  139747. * Overrides the direction setter to recompute the projection texture view light Matrix.
  139748. */
  139749. protected _setDirection(value: Vector3): void;
  139750. /**
  139751. * Overrides the position setter to recompute the projection texture view light Matrix.
  139752. */
  139753. protected _setPosition(value: Vector3): void;
  139754. /**
  139755. * 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.
  139756. * Returns the SpotLight.
  139757. */
  139758. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139759. protected _computeProjectionTextureViewLightMatrix(): void;
  139760. protected _computeProjectionTextureProjectionLightMatrix(): void;
  139761. /**
  139762. * Main function for light texture projection matrix computing.
  139763. */
  139764. protected _computeProjectionTextureMatrix(): void;
  139765. protected _buildUniformLayout(): void;
  139766. private _computeAngleValues;
  139767. /**
  139768. * Sets the passed Effect "effect" with the Light textures.
  139769. * @param effect The effect to update
  139770. * @param lightIndex The index of the light in the effect to update
  139771. * @returns The light
  139772. */
  139773. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  139774. /**
  139775. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  139776. * @param effect The effect to update
  139777. * @param lightIndex The index of the light in the effect to update
  139778. * @returns The spot light
  139779. */
  139780. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  139781. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139782. /**
  139783. * Disposes the light and the associated resources.
  139784. */
  139785. dispose(): void;
  139786. /**
  139787. * Prepares the list of defines specific to the light type.
  139788. * @param defines the list of defines
  139789. * @param lightIndex defines the index of the light for the effect
  139790. */
  139791. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139792. }
  139793. }
  139794. declare module BABYLON {
  139795. /**
  139796. * Gizmo that enables viewing a light
  139797. */
  139798. export class LightGizmo extends Gizmo {
  139799. private _lightMesh;
  139800. private _material;
  139801. private _cachedPosition;
  139802. private _cachedForward;
  139803. private _attachedMeshParent;
  139804. private _pointerObserver;
  139805. /**
  139806. * Event that fires each time the gizmo is clicked
  139807. */
  139808. onClickedObservable: Observable<Light>;
  139809. /**
  139810. * Creates a LightGizmo
  139811. * @param gizmoLayer The utility layer the gizmo will be added to
  139812. */
  139813. constructor(gizmoLayer?: UtilityLayerRenderer);
  139814. private _light;
  139815. /**
  139816. * The light that the gizmo is attached to
  139817. */
  139818. set light(light: Nullable<Light>);
  139819. get light(): Nullable<Light>;
  139820. /**
  139821. * Gets the material used to render the light gizmo
  139822. */
  139823. get material(): StandardMaterial;
  139824. /**
  139825. * @hidden
  139826. * Updates the gizmo to match the attached mesh's position/rotation
  139827. */
  139828. protected _update(): void;
  139829. private static _Scale;
  139830. /**
  139831. * Creates the lines for a light mesh
  139832. */
  139833. private static _CreateLightLines;
  139834. /**
  139835. * Disposes of the light gizmo
  139836. */
  139837. dispose(): void;
  139838. private static _CreateHemisphericLightMesh;
  139839. private static _CreatePointLightMesh;
  139840. private static _CreateSpotLightMesh;
  139841. private static _CreateDirectionalLightMesh;
  139842. }
  139843. }
  139844. declare module BABYLON {
  139845. /**
  139846. * Gizmo that enables viewing a camera
  139847. */
  139848. export class CameraGizmo extends Gizmo {
  139849. private _cameraMesh;
  139850. private _cameraLinesMesh;
  139851. private _material;
  139852. private _pointerObserver;
  139853. /**
  139854. * Event that fires each time the gizmo is clicked
  139855. */
  139856. onClickedObservable: Observable<Camera>;
  139857. /**
  139858. * Creates a CameraGizmo
  139859. * @param gizmoLayer The utility layer the gizmo will be added to
  139860. */
  139861. constructor(gizmoLayer?: UtilityLayerRenderer);
  139862. private _camera;
  139863. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  139864. get displayFrustum(): boolean;
  139865. set displayFrustum(value: boolean);
  139866. /**
  139867. * The camera that the gizmo is attached to
  139868. */
  139869. set camera(camera: Nullable<Camera>);
  139870. get camera(): Nullable<Camera>;
  139871. /**
  139872. * Gets the material used to render the camera gizmo
  139873. */
  139874. get material(): StandardMaterial;
  139875. /**
  139876. * @hidden
  139877. * Updates the gizmo to match the attached mesh's position/rotation
  139878. */
  139879. protected _update(): void;
  139880. private static _Scale;
  139881. private _invProjection;
  139882. /**
  139883. * Disposes of the camera gizmo
  139884. */
  139885. dispose(): void;
  139886. private static _CreateCameraMesh;
  139887. private static _CreateCameraFrustum;
  139888. }
  139889. }
  139890. declare module BABYLON {
  139891. /** @hidden */
  139892. export var backgroundFragmentDeclaration: {
  139893. name: string;
  139894. shader: string;
  139895. };
  139896. }
  139897. declare module BABYLON {
  139898. /** @hidden */
  139899. export var backgroundUboDeclaration: {
  139900. name: string;
  139901. shader: string;
  139902. };
  139903. }
  139904. declare module BABYLON {
  139905. /** @hidden */
  139906. export var backgroundPixelShader: {
  139907. name: string;
  139908. shader: string;
  139909. };
  139910. }
  139911. declare module BABYLON {
  139912. /** @hidden */
  139913. export var backgroundVertexDeclaration: {
  139914. name: string;
  139915. shader: string;
  139916. };
  139917. }
  139918. declare module BABYLON {
  139919. /** @hidden */
  139920. export var backgroundVertexShader: {
  139921. name: string;
  139922. shader: string;
  139923. };
  139924. }
  139925. declare module BABYLON {
  139926. /**
  139927. * Background material used to create an efficient environement around your scene.
  139928. */
  139929. export class BackgroundMaterial extends PushMaterial {
  139930. /**
  139931. * Standard reflectance value at parallel view angle.
  139932. */
  139933. static StandardReflectance0: number;
  139934. /**
  139935. * Standard reflectance value at grazing angle.
  139936. */
  139937. static StandardReflectance90: number;
  139938. protected _primaryColor: Color3;
  139939. /**
  139940. * Key light Color (multiply against the environement texture)
  139941. */
  139942. primaryColor: Color3;
  139943. protected __perceptualColor: Nullable<Color3>;
  139944. /**
  139945. * Experimental Internal Use Only.
  139946. *
  139947. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  139948. * This acts as a helper to set the primary color to a more "human friendly" value.
  139949. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  139950. * output color as close as possible from the chosen value.
  139951. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  139952. * part of lighting setup.)
  139953. */
  139954. get _perceptualColor(): Nullable<Color3>;
  139955. set _perceptualColor(value: Nullable<Color3>);
  139956. protected _primaryColorShadowLevel: float;
  139957. /**
  139958. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  139959. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  139960. */
  139961. get primaryColorShadowLevel(): float;
  139962. set primaryColorShadowLevel(value: float);
  139963. protected _primaryColorHighlightLevel: float;
  139964. /**
  139965. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  139966. * The primary color is used at the level chosen to define what the white area would look.
  139967. */
  139968. get primaryColorHighlightLevel(): float;
  139969. set primaryColorHighlightLevel(value: float);
  139970. protected _reflectionTexture: Nullable<BaseTexture>;
  139971. /**
  139972. * Reflection Texture used in the material.
  139973. * Should be author in a specific way for the best result (refer to the documentation).
  139974. */
  139975. reflectionTexture: Nullable<BaseTexture>;
  139976. protected _reflectionBlur: float;
  139977. /**
  139978. * Reflection Texture level of blur.
  139979. *
  139980. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  139981. * texture twice.
  139982. */
  139983. reflectionBlur: float;
  139984. protected _diffuseTexture: Nullable<BaseTexture>;
  139985. /**
  139986. * Diffuse Texture used in the material.
  139987. * Should be author in a specific way for the best result (refer to the documentation).
  139988. */
  139989. diffuseTexture: Nullable<BaseTexture>;
  139990. protected _shadowLights: Nullable<IShadowLight[]>;
  139991. /**
  139992. * Specify the list of lights casting shadow on the material.
  139993. * All scene shadow lights will be included if null.
  139994. */
  139995. shadowLights: Nullable<IShadowLight[]>;
  139996. protected _shadowLevel: float;
  139997. /**
  139998. * Helps adjusting the shadow to a softer level if required.
  139999. * 0 means black shadows and 1 means no shadows.
  140000. */
  140001. shadowLevel: float;
  140002. protected _sceneCenter: Vector3;
  140003. /**
  140004. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  140005. * It is usually zero but might be interesting to modify according to your setup.
  140006. */
  140007. sceneCenter: Vector3;
  140008. protected _opacityFresnel: boolean;
  140009. /**
  140010. * This helps specifying that the material is falling off to the sky box at grazing angle.
  140011. * This helps ensuring a nice transition when the camera goes under the ground.
  140012. */
  140013. opacityFresnel: boolean;
  140014. protected _reflectionFresnel: boolean;
  140015. /**
  140016. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  140017. * This helps adding a mirror texture on the ground.
  140018. */
  140019. reflectionFresnel: boolean;
  140020. protected _reflectionFalloffDistance: number;
  140021. /**
  140022. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  140023. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  140024. */
  140025. reflectionFalloffDistance: number;
  140026. protected _reflectionAmount: number;
  140027. /**
  140028. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  140029. */
  140030. reflectionAmount: number;
  140031. protected _reflectionReflectance0: number;
  140032. /**
  140033. * This specifies the weight of the reflection at grazing angle.
  140034. */
  140035. reflectionReflectance0: number;
  140036. protected _reflectionReflectance90: number;
  140037. /**
  140038. * This specifies the weight of the reflection at a perpendicular point of view.
  140039. */
  140040. reflectionReflectance90: number;
  140041. /**
  140042. * Sets the reflection reflectance fresnel values according to the default standard
  140043. * empirically know to work well :-)
  140044. */
  140045. set reflectionStandardFresnelWeight(value: number);
  140046. protected _useRGBColor: boolean;
  140047. /**
  140048. * Helps to directly use the maps channels instead of their level.
  140049. */
  140050. useRGBColor: boolean;
  140051. protected _enableNoise: boolean;
  140052. /**
  140053. * This helps reducing the banding effect that could occur on the background.
  140054. */
  140055. enableNoise: boolean;
  140056. /**
  140057. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  140058. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  140059. * Recommended to be keep at 1.0 except for special cases.
  140060. */
  140061. get fovMultiplier(): number;
  140062. set fovMultiplier(value: number);
  140063. private _fovMultiplier;
  140064. /**
  140065. * Enable the FOV adjustment feature controlled by fovMultiplier.
  140066. */
  140067. useEquirectangularFOV: boolean;
  140068. private _maxSimultaneousLights;
  140069. /**
  140070. * Number of Simultaneous lights allowed on the material.
  140071. */
  140072. maxSimultaneousLights: int;
  140073. private _shadowOnly;
  140074. /**
  140075. * Make the material only render shadows
  140076. */
  140077. shadowOnly: boolean;
  140078. /**
  140079. * Default configuration related to image processing available in the Background Material.
  140080. */
  140081. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  140082. /**
  140083. * Keep track of the image processing observer to allow dispose and replace.
  140084. */
  140085. private _imageProcessingObserver;
  140086. /**
  140087. * Attaches a new image processing configuration to the PBR Material.
  140088. * @param configuration (if null the scene configuration will be use)
  140089. */
  140090. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  140091. /**
  140092. * Gets the image processing configuration used either in this material.
  140093. */
  140094. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  140095. /**
  140096. * Sets the Default image processing configuration used either in the this material.
  140097. *
  140098. * If sets to null, the scene one is in use.
  140099. */
  140100. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  140101. /**
  140102. * Gets wether the color curves effect is enabled.
  140103. */
  140104. get cameraColorCurvesEnabled(): boolean;
  140105. /**
  140106. * Sets wether the color curves effect is enabled.
  140107. */
  140108. set cameraColorCurvesEnabled(value: boolean);
  140109. /**
  140110. * Gets wether the color grading effect is enabled.
  140111. */
  140112. get cameraColorGradingEnabled(): boolean;
  140113. /**
  140114. * Gets wether the color grading effect is enabled.
  140115. */
  140116. set cameraColorGradingEnabled(value: boolean);
  140117. /**
  140118. * Gets wether tonemapping is enabled or not.
  140119. */
  140120. get cameraToneMappingEnabled(): boolean;
  140121. /**
  140122. * Sets wether tonemapping is enabled or not
  140123. */
  140124. set cameraToneMappingEnabled(value: boolean);
  140125. /**
  140126. * The camera exposure used on this material.
  140127. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  140128. * This corresponds to a photographic exposure.
  140129. */
  140130. get cameraExposure(): float;
  140131. /**
  140132. * The camera exposure used on this material.
  140133. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  140134. * This corresponds to a photographic exposure.
  140135. */
  140136. set cameraExposure(value: float);
  140137. /**
  140138. * Gets The camera contrast used on this material.
  140139. */
  140140. get cameraContrast(): float;
  140141. /**
  140142. * Sets The camera contrast used on this material.
  140143. */
  140144. set cameraContrast(value: float);
  140145. /**
  140146. * Gets the Color Grading 2D Lookup Texture.
  140147. */
  140148. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  140149. /**
  140150. * Sets the Color Grading 2D Lookup Texture.
  140151. */
  140152. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  140153. /**
  140154. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  140155. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  140156. * 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;
  140157. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  140158. */
  140159. get cameraColorCurves(): Nullable<ColorCurves>;
  140160. /**
  140161. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  140162. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  140163. * 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;
  140164. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  140165. */
  140166. set cameraColorCurves(value: Nullable<ColorCurves>);
  140167. /**
  140168. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  140169. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  140170. */
  140171. switchToBGR: boolean;
  140172. private _renderTargets;
  140173. private _reflectionControls;
  140174. private _white;
  140175. private _primaryShadowColor;
  140176. private _primaryHighlightColor;
  140177. /**
  140178. * Instantiates a Background Material in the given scene
  140179. * @param name The friendly name of the material
  140180. * @param scene The scene to add the material to
  140181. */
  140182. constructor(name: string, scene: Scene);
  140183. /**
  140184. * Gets a boolean indicating that current material needs to register RTT
  140185. */
  140186. get hasRenderTargetTextures(): boolean;
  140187. /**
  140188. * The entire material has been created in order to prevent overdraw.
  140189. * @returns false
  140190. */
  140191. needAlphaTesting(): boolean;
  140192. /**
  140193. * The entire material has been created in order to prevent overdraw.
  140194. * @returns true if blending is enable
  140195. */
  140196. needAlphaBlending(): boolean;
  140197. /**
  140198. * Checks wether the material is ready to be rendered for a given mesh.
  140199. * @param mesh The mesh to render
  140200. * @param subMesh The submesh to check against
  140201. * @param useInstances Specify wether or not the material is used with instances
  140202. * @returns true if all the dependencies are ready (Textures, Effects...)
  140203. */
  140204. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  140205. /**
  140206. * Compute the primary color according to the chosen perceptual color.
  140207. */
  140208. private _computePrimaryColorFromPerceptualColor;
  140209. /**
  140210. * Compute the highlights and shadow colors according to their chosen levels.
  140211. */
  140212. private _computePrimaryColors;
  140213. /**
  140214. * Build the uniform buffer used in the material.
  140215. */
  140216. buildUniformLayout(): void;
  140217. /**
  140218. * Unbind the material.
  140219. */
  140220. unbind(): void;
  140221. /**
  140222. * Bind only the world matrix to the material.
  140223. * @param world The world matrix to bind.
  140224. */
  140225. bindOnlyWorldMatrix(world: Matrix): void;
  140226. /**
  140227. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  140228. * @param world The world matrix to bind.
  140229. * @param subMesh The submesh to bind for.
  140230. */
  140231. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  140232. /**
  140233. * Checks to see if a texture is used in the material.
  140234. * @param texture - Base texture to use.
  140235. * @returns - Boolean specifying if a texture is used in the material.
  140236. */
  140237. hasTexture(texture: BaseTexture): boolean;
  140238. /**
  140239. * Dispose the material.
  140240. * @param forceDisposeEffect Force disposal of the associated effect.
  140241. * @param forceDisposeTextures Force disposal of the associated textures.
  140242. */
  140243. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  140244. /**
  140245. * Clones the material.
  140246. * @param name The cloned name.
  140247. * @returns The cloned material.
  140248. */
  140249. clone(name: string): BackgroundMaterial;
  140250. /**
  140251. * Serializes the current material to its JSON representation.
  140252. * @returns The JSON representation.
  140253. */
  140254. serialize(): any;
  140255. /**
  140256. * Gets the class name of the material
  140257. * @returns "BackgroundMaterial"
  140258. */
  140259. getClassName(): string;
  140260. /**
  140261. * Parse a JSON input to create back a background material.
  140262. * @param source The JSON data to parse
  140263. * @param scene The scene to create the parsed material in
  140264. * @param rootUrl The root url of the assets the material depends upon
  140265. * @returns the instantiated BackgroundMaterial.
  140266. */
  140267. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  140268. }
  140269. }
  140270. declare module BABYLON {
  140271. /**
  140272. * Represents the different options available during the creation of
  140273. * a Environment helper.
  140274. *
  140275. * This can control the default ground, skybox and image processing setup of your scene.
  140276. */
  140277. export interface IEnvironmentHelperOptions {
  140278. /**
  140279. * Specifies whether or not to create a ground.
  140280. * True by default.
  140281. */
  140282. createGround: boolean;
  140283. /**
  140284. * Specifies the ground size.
  140285. * 15 by default.
  140286. */
  140287. groundSize: number;
  140288. /**
  140289. * The texture used on the ground for the main color.
  140290. * Comes from the BabylonJS CDN by default.
  140291. *
  140292. * Remarks: Can be either a texture or a url.
  140293. */
  140294. groundTexture: string | BaseTexture;
  140295. /**
  140296. * The color mixed in the ground texture by default.
  140297. * BabylonJS clearColor by default.
  140298. */
  140299. groundColor: Color3;
  140300. /**
  140301. * Specifies the ground opacity.
  140302. * 1 by default.
  140303. */
  140304. groundOpacity: number;
  140305. /**
  140306. * Enables the ground to receive shadows.
  140307. * True by default.
  140308. */
  140309. enableGroundShadow: boolean;
  140310. /**
  140311. * Helps preventing the shadow to be fully black on the ground.
  140312. * 0.5 by default.
  140313. */
  140314. groundShadowLevel: number;
  140315. /**
  140316. * Creates a mirror texture attach to the ground.
  140317. * false by default.
  140318. */
  140319. enableGroundMirror: boolean;
  140320. /**
  140321. * Specifies the ground mirror size ratio.
  140322. * 0.3 by default as the default kernel is 64.
  140323. */
  140324. groundMirrorSizeRatio: number;
  140325. /**
  140326. * Specifies the ground mirror blur kernel size.
  140327. * 64 by default.
  140328. */
  140329. groundMirrorBlurKernel: number;
  140330. /**
  140331. * Specifies the ground mirror visibility amount.
  140332. * 1 by default
  140333. */
  140334. groundMirrorAmount: number;
  140335. /**
  140336. * Specifies the ground mirror reflectance weight.
  140337. * This uses the standard weight of the background material to setup the fresnel effect
  140338. * of the mirror.
  140339. * 1 by default.
  140340. */
  140341. groundMirrorFresnelWeight: number;
  140342. /**
  140343. * Specifies the ground mirror Falloff distance.
  140344. * This can helps reducing the size of the reflection.
  140345. * 0 by Default.
  140346. */
  140347. groundMirrorFallOffDistance: number;
  140348. /**
  140349. * Specifies the ground mirror texture type.
  140350. * Unsigned Int by Default.
  140351. */
  140352. groundMirrorTextureType: number;
  140353. /**
  140354. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  140355. * the shown objects.
  140356. */
  140357. groundYBias: number;
  140358. /**
  140359. * Specifies whether or not to create a skybox.
  140360. * True by default.
  140361. */
  140362. createSkybox: boolean;
  140363. /**
  140364. * Specifies the skybox size.
  140365. * 20 by default.
  140366. */
  140367. skyboxSize: number;
  140368. /**
  140369. * The texture used on the skybox for the main color.
  140370. * Comes from the BabylonJS CDN by default.
  140371. *
  140372. * Remarks: Can be either a texture or a url.
  140373. */
  140374. skyboxTexture: string | BaseTexture;
  140375. /**
  140376. * The color mixed in the skybox texture by default.
  140377. * BabylonJS clearColor by default.
  140378. */
  140379. skyboxColor: Color3;
  140380. /**
  140381. * The background rotation around the Y axis of the scene.
  140382. * This helps aligning the key lights of your scene with the background.
  140383. * 0 by default.
  140384. */
  140385. backgroundYRotation: number;
  140386. /**
  140387. * Compute automatically the size of the elements to best fit with the scene.
  140388. */
  140389. sizeAuto: boolean;
  140390. /**
  140391. * Default position of the rootMesh if autoSize is not true.
  140392. */
  140393. rootPosition: Vector3;
  140394. /**
  140395. * Sets up the image processing in the scene.
  140396. * true by default.
  140397. */
  140398. setupImageProcessing: boolean;
  140399. /**
  140400. * The texture used as your environment texture in the scene.
  140401. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  140402. *
  140403. * Remarks: Can be either a texture or a url.
  140404. */
  140405. environmentTexture: string | BaseTexture;
  140406. /**
  140407. * The value of the exposure to apply to the scene.
  140408. * 0.6 by default if setupImageProcessing is true.
  140409. */
  140410. cameraExposure: number;
  140411. /**
  140412. * The value of the contrast to apply to the scene.
  140413. * 1.6 by default if setupImageProcessing is true.
  140414. */
  140415. cameraContrast: number;
  140416. /**
  140417. * Specifies whether or not tonemapping should be enabled in the scene.
  140418. * true by default if setupImageProcessing is true.
  140419. */
  140420. toneMappingEnabled: boolean;
  140421. }
  140422. /**
  140423. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  140424. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  140425. * It also helps with the default setup of your imageProcessing configuration.
  140426. */
  140427. export class EnvironmentHelper {
  140428. /**
  140429. * Default ground texture URL.
  140430. */
  140431. private static _groundTextureCDNUrl;
  140432. /**
  140433. * Default skybox texture URL.
  140434. */
  140435. private static _skyboxTextureCDNUrl;
  140436. /**
  140437. * Default environment texture URL.
  140438. */
  140439. private static _environmentTextureCDNUrl;
  140440. /**
  140441. * Creates the default options for the helper.
  140442. */
  140443. private static _getDefaultOptions;
  140444. private _rootMesh;
  140445. /**
  140446. * Gets the root mesh created by the helper.
  140447. */
  140448. get rootMesh(): Mesh;
  140449. private _skybox;
  140450. /**
  140451. * Gets the skybox created by the helper.
  140452. */
  140453. get skybox(): Nullable<Mesh>;
  140454. private _skyboxTexture;
  140455. /**
  140456. * Gets the skybox texture created by the helper.
  140457. */
  140458. get skyboxTexture(): Nullable<BaseTexture>;
  140459. private _skyboxMaterial;
  140460. /**
  140461. * Gets the skybox material created by the helper.
  140462. */
  140463. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  140464. private _ground;
  140465. /**
  140466. * Gets the ground mesh created by the helper.
  140467. */
  140468. get ground(): Nullable<Mesh>;
  140469. private _groundTexture;
  140470. /**
  140471. * Gets the ground texture created by the helper.
  140472. */
  140473. get groundTexture(): Nullable<BaseTexture>;
  140474. private _groundMirror;
  140475. /**
  140476. * Gets the ground mirror created by the helper.
  140477. */
  140478. get groundMirror(): Nullable<MirrorTexture>;
  140479. /**
  140480. * Gets the ground mirror render list to helps pushing the meshes
  140481. * you wish in the ground reflection.
  140482. */
  140483. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  140484. private _groundMaterial;
  140485. /**
  140486. * Gets the ground material created by the helper.
  140487. */
  140488. get groundMaterial(): Nullable<BackgroundMaterial>;
  140489. /**
  140490. * Stores the creation options.
  140491. */
  140492. private readonly _scene;
  140493. private _options;
  140494. /**
  140495. * This observable will be notified with any error during the creation of the environment,
  140496. * mainly texture creation errors.
  140497. */
  140498. onErrorObservable: Observable<{
  140499. message?: string;
  140500. exception?: any;
  140501. }>;
  140502. /**
  140503. * constructor
  140504. * @param options Defines the options we want to customize the helper
  140505. * @param scene The scene to add the material to
  140506. */
  140507. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  140508. /**
  140509. * Updates the background according to the new options
  140510. * @param options
  140511. */
  140512. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  140513. /**
  140514. * Sets the primary color of all the available elements.
  140515. * @param color the main color to affect to the ground and the background
  140516. */
  140517. setMainColor(color: Color3): void;
  140518. /**
  140519. * Setup the image processing according to the specified options.
  140520. */
  140521. private _setupImageProcessing;
  140522. /**
  140523. * Setup the environment texture according to the specified options.
  140524. */
  140525. private _setupEnvironmentTexture;
  140526. /**
  140527. * Setup the background according to the specified options.
  140528. */
  140529. private _setupBackground;
  140530. /**
  140531. * Get the scene sizes according to the setup.
  140532. */
  140533. private _getSceneSize;
  140534. /**
  140535. * Setup the ground according to the specified options.
  140536. */
  140537. private _setupGround;
  140538. /**
  140539. * Setup the ground material according to the specified options.
  140540. */
  140541. private _setupGroundMaterial;
  140542. /**
  140543. * Setup the ground diffuse texture according to the specified options.
  140544. */
  140545. private _setupGroundDiffuseTexture;
  140546. /**
  140547. * Setup the ground mirror texture according to the specified options.
  140548. */
  140549. private _setupGroundMirrorTexture;
  140550. /**
  140551. * Setup the ground to receive the mirror texture.
  140552. */
  140553. private _setupMirrorInGroundMaterial;
  140554. /**
  140555. * Setup the skybox according to the specified options.
  140556. */
  140557. private _setupSkybox;
  140558. /**
  140559. * Setup the skybox material according to the specified options.
  140560. */
  140561. private _setupSkyboxMaterial;
  140562. /**
  140563. * Setup the skybox reflection texture according to the specified options.
  140564. */
  140565. private _setupSkyboxReflectionTexture;
  140566. private _errorHandler;
  140567. /**
  140568. * Dispose all the elements created by the Helper.
  140569. */
  140570. dispose(): void;
  140571. }
  140572. }
  140573. declare module BABYLON {
  140574. /**
  140575. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  140576. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  140577. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140578. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140579. */
  140580. export abstract class TextureDome<T extends Texture> extends TransformNode {
  140581. protected onError: Nullable<(message?: string, exception?: any) => void>;
  140582. /**
  140583. * Define the source as a Monoscopic panoramic 360/180.
  140584. */
  140585. static readonly MODE_MONOSCOPIC: number;
  140586. /**
  140587. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  140588. */
  140589. static readonly MODE_TOPBOTTOM: number;
  140590. /**
  140591. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  140592. */
  140593. static readonly MODE_SIDEBYSIDE: number;
  140594. private _halfDome;
  140595. private _crossEye;
  140596. protected _useDirectMapping: boolean;
  140597. /**
  140598. * The texture being displayed on the sphere
  140599. */
  140600. protected _texture: T;
  140601. /**
  140602. * Gets the texture being displayed on the sphere
  140603. */
  140604. get texture(): T;
  140605. /**
  140606. * Sets the texture being displayed on the sphere
  140607. */
  140608. set texture(newTexture: T);
  140609. /**
  140610. * The skybox material
  140611. */
  140612. protected _material: BackgroundMaterial;
  140613. /**
  140614. * The surface used for the dome
  140615. */
  140616. protected _mesh: Mesh;
  140617. /**
  140618. * Gets the mesh used for the dome.
  140619. */
  140620. get mesh(): Mesh;
  140621. /**
  140622. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  140623. */
  140624. private _halfDomeMask;
  140625. /**
  140626. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  140627. * Also see the options.resolution property.
  140628. */
  140629. get fovMultiplier(): number;
  140630. set fovMultiplier(value: number);
  140631. protected _textureMode: number;
  140632. /**
  140633. * Gets or set the current texture mode for the texture. It can be:
  140634. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140635. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140636. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140637. */
  140638. get textureMode(): number;
  140639. /**
  140640. * Sets the current texture mode for the texture. It can be:
  140641. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140642. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140643. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140644. */
  140645. set textureMode(value: number);
  140646. /**
  140647. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  140648. */
  140649. get halfDome(): boolean;
  140650. /**
  140651. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  140652. */
  140653. set halfDome(enabled: boolean);
  140654. /**
  140655. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  140656. */
  140657. set crossEye(enabled: boolean);
  140658. /**
  140659. * Is it a cross-eye texture?
  140660. */
  140661. get crossEye(): boolean;
  140662. /**
  140663. * The background material of this dome.
  140664. */
  140665. get material(): BackgroundMaterial;
  140666. /**
  140667. * Oberserver used in Stereoscopic VR Mode.
  140668. */
  140669. private _onBeforeCameraRenderObserver;
  140670. /**
  140671. * Observable raised when an error occured while loading the 360 image
  140672. */
  140673. onLoadErrorObservable: Observable<string>;
  140674. /**
  140675. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  140676. * @param name Element's name, child elements will append suffixes for their own names.
  140677. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  140678. * @param options An object containing optional or exposed sub element properties
  140679. */
  140680. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  140681. resolution?: number;
  140682. clickToPlay?: boolean;
  140683. autoPlay?: boolean;
  140684. loop?: boolean;
  140685. size?: number;
  140686. poster?: string;
  140687. faceForward?: boolean;
  140688. useDirectMapping?: boolean;
  140689. halfDomeMode?: boolean;
  140690. crossEyeMode?: boolean;
  140691. generateMipMaps?: boolean;
  140692. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  140693. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  140694. protected _changeTextureMode(value: number): void;
  140695. /**
  140696. * Releases resources associated with this node.
  140697. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  140698. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  140699. */
  140700. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  140701. }
  140702. }
  140703. declare module BABYLON {
  140704. /**
  140705. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  140706. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  140707. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140708. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140709. */
  140710. export class PhotoDome extends TextureDome<Texture> {
  140711. /**
  140712. * Define the image as a Monoscopic panoramic 360 image.
  140713. */
  140714. static readonly MODE_MONOSCOPIC: number;
  140715. /**
  140716. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  140717. */
  140718. static readonly MODE_TOPBOTTOM: number;
  140719. /**
  140720. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  140721. */
  140722. static readonly MODE_SIDEBYSIDE: number;
  140723. /**
  140724. * Gets or sets the texture being displayed on the sphere
  140725. */
  140726. get photoTexture(): Texture;
  140727. /**
  140728. * sets the texture being displayed on the sphere
  140729. */
  140730. set photoTexture(value: Texture);
  140731. /**
  140732. * Gets the current video mode for the video. It can be:
  140733. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140734. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140735. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140736. */
  140737. get imageMode(): number;
  140738. /**
  140739. * Sets the current video mode for the video. It can be:
  140740. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140741. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140742. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140743. */
  140744. set imageMode(value: number);
  140745. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  140746. }
  140747. }
  140748. declare module BABYLON {
  140749. /**
  140750. * Direct draw surface info
  140751. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  140752. */
  140753. export interface DDSInfo {
  140754. /**
  140755. * Width of the texture
  140756. */
  140757. width: number;
  140758. /**
  140759. * Width of the texture
  140760. */
  140761. height: number;
  140762. /**
  140763. * Number of Mipmaps for the texture
  140764. * @see https://en.wikipedia.org/wiki/Mipmap
  140765. */
  140766. mipmapCount: number;
  140767. /**
  140768. * If the textures format is a known fourCC format
  140769. * @see https://www.fourcc.org/
  140770. */
  140771. isFourCC: boolean;
  140772. /**
  140773. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  140774. */
  140775. isRGB: boolean;
  140776. /**
  140777. * If the texture is a lumincance format
  140778. */
  140779. isLuminance: boolean;
  140780. /**
  140781. * If this is a cube texture
  140782. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  140783. */
  140784. isCube: boolean;
  140785. /**
  140786. * If the texture is a compressed format eg. FOURCC_DXT1
  140787. */
  140788. isCompressed: boolean;
  140789. /**
  140790. * The dxgiFormat of the texture
  140791. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  140792. */
  140793. dxgiFormat: number;
  140794. /**
  140795. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  140796. */
  140797. textureType: number;
  140798. /**
  140799. * Sphericle polynomial created for the dds texture
  140800. */
  140801. sphericalPolynomial?: SphericalPolynomial;
  140802. }
  140803. /**
  140804. * Class used to provide DDS decompression tools
  140805. */
  140806. export class DDSTools {
  140807. /**
  140808. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  140809. */
  140810. static StoreLODInAlphaChannel: boolean;
  140811. /**
  140812. * Gets DDS information from an array buffer
  140813. * @param data defines the array buffer view to read data from
  140814. * @returns the DDS information
  140815. */
  140816. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  140817. private static _FloatView;
  140818. private static _Int32View;
  140819. private static _ToHalfFloat;
  140820. private static _FromHalfFloat;
  140821. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  140822. private static _GetHalfFloatRGBAArrayBuffer;
  140823. private static _GetFloatRGBAArrayBuffer;
  140824. private static _GetFloatAsUIntRGBAArrayBuffer;
  140825. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  140826. private static _GetRGBAArrayBuffer;
  140827. private static _ExtractLongWordOrder;
  140828. private static _GetRGBArrayBuffer;
  140829. private static _GetLuminanceArrayBuffer;
  140830. /**
  140831. * Uploads DDS Levels to a Babylon Texture
  140832. * @hidden
  140833. */
  140834. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  140835. }
  140836. interface ThinEngine {
  140837. /**
  140838. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  140839. * @param rootUrl defines the url where the file to load is located
  140840. * @param scene defines the current scene
  140841. * @param lodScale defines scale to apply to the mip map selection
  140842. * @param lodOffset defines offset to apply to the mip map selection
  140843. * @param onLoad defines an optional callback raised when the texture is loaded
  140844. * @param onError defines an optional callback raised if there is an issue to load the texture
  140845. * @param format defines the format of the data
  140846. * @param forcedExtension defines the extension to use to pick the right loader
  140847. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  140848. * @returns the cube texture as an InternalTexture
  140849. */
  140850. 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;
  140851. }
  140852. }
  140853. declare module BABYLON {
  140854. /**
  140855. * Implementation of the DDS Texture Loader.
  140856. * @hidden
  140857. */
  140858. export class _DDSTextureLoader implements IInternalTextureLoader {
  140859. /**
  140860. * Defines wether the loader supports cascade loading the different faces.
  140861. */
  140862. readonly supportCascades: boolean;
  140863. /**
  140864. * This returns if the loader support the current file information.
  140865. * @param extension defines the file extension of the file being loaded
  140866. * @returns true if the loader can load the specified file
  140867. */
  140868. canLoad(extension: string): boolean;
  140869. /**
  140870. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140871. * @param data contains the texture data
  140872. * @param texture defines the BabylonJS internal texture
  140873. * @param createPolynomials will be true if polynomials have been requested
  140874. * @param onLoad defines the callback to trigger once the texture is ready
  140875. * @param onError defines the callback to trigger in case of error
  140876. */
  140877. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140878. /**
  140879. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140880. * @param data contains the texture data
  140881. * @param texture defines the BabylonJS internal texture
  140882. * @param callback defines the method to call once ready to upload
  140883. */
  140884. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140885. }
  140886. }
  140887. declare module BABYLON {
  140888. /**
  140889. * Implementation of the ENV Texture Loader.
  140890. * @hidden
  140891. */
  140892. export class _ENVTextureLoader implements IInternalTextureLoader {
  140893. /**
  140894. * Defines wether the loader supports cascade loading the different faces.
  140895. */
  140896. readonly supportCascades: boolean;
  140897. /**
  140898. * This returns if the loader support the current file information.
  140899. * @param extension defines the file extension of the file being loaded
  140900. * @returns true if the loader can load the specified file
  140901. */
  140902. canLoad(extension: string): boolean;
  140903. /**
  140904. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140905. * @param data contains the texture data
  140906. * @param texture defines the BabylonJS internal texture
  140907. * @param createPolynomials will be true if polynomials have been requested
  140908. * @param onLoad defines the callback to trigger once the texture is ready
  140909. * @param onError defines the callback to trigger in case of error
  140910. */
  140911. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140912. /**
  140913. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140914. * @param data contains the texture data
  140915. * @param texture defines the BabylonJS internal texture
  140916. * @param callback defines the method to call once ready to upload
  140917. */
  140918. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140919. }
  140920. }
  140921. declare module BABYLON {
  140922. /**
  140923. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  140924. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  140925. */
  140926. export class KhronosTextureContainer {
  140927. /** contents of the KTX container file */
  140928. data: ArrayBufferView;
  140929. private static HEADER_LEN;
  140930. private static COMPRESSED_2D;
  140931. private static COMPRESSED_3D;
  140932. private static TEX_2D;
  140933. private static TEX_3D;
  140934. /**
  140935. * Gets the openGL type
  140936. */
  140937. glType: number;
  140938. /**
  140939. * Gets the openGL type size
  140940. */
  140941. glTypeSize: number;
  140942. /**
  140943. * Gets the openGL format
  140944. */
  140945. glFormat: number;
  140946. /**
  140947. * Gets the openGL internal format
  140948. */
  140949. glInternalFormat: number;
  140950. /**
  140951. * Gets the base internal format
  140952. */
  140953. glBaseInternalFormat: number;
  140954. /**
  140955. * Gets image width in pixel
  140956. */
  140957. pixelWidth: number;
  140958. /**
  140959. * Gets image height in pixel
  140960. */
  140961. pixelHeight: number;
  140962. /**
  140963. * Gets image depth in pixels
  140964. */
  140965. pixelDepth: number;
  140966. /**
  140967. * Gets the number of array elements
  140968. */
  140969. numberOfArrayElements: number;
  140970. /**
  140971. * Gets the number of faces
  140972. */
  140973. numberOfFaces: number;
  140974. /**
  140975. * Gets the number of mipmap levels
  140976. */
  140977. numberOfMipmapLevels: number;
  140978. /**
  140979. * Gets the bytes of key value data
  140980. */
  140981. bytesOfKeyValueData: number;
  140982. /**
  140983. * Gets the load type
  140984. */
  140985. loadType: number;
  140986. /**
  140987. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  140988. */
  140989. isInvalid: boolean;
  140990. /**
  140991. * Creates a new KhronosTextureContainer
  140992. * @param data contents of the KTX container file
  140993. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  140994. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  140995. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  140996. */
  140997. constructor(
  140998. /** contents of the KTX container file */
  140999. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  141000. /**
  141001. * Uploads KTX content to a Babylon Texture.
  141002. * It is assumed that the texture has already been created & is currently bound
  141003. * @hidden
  141004. */
  141005. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  141006. private _upload2DCompressedLevels;
  141007. /**
  141008. * Checks if the given data starts with a KTX file identifier.
  141009. * @param data the data to check
  141010. * @returns true if the data is a KTX file or false otherwise
  141011. */
  141012. static IsValid(data: ArrayBufferView): boolean;
  141013. }
  141014. }
  141015. declare module BABYLON {
  141016. /**
  141017. * Helper class to push actions to a pool of workers.
  141018. */
  141019. export class WorkerPool implements IDisposable {
  141020. private _workerInfos;
  141021. private _pendingActions;
  141022. /**
  141023. * Constructor
  141024. * @param workers Array of workers to use for actions
  141025. */
  141026. constructor(workers: Array<Worker>);
  141027. /**
  141028. * Terminates all workers and clears any pending actions.
  141029. */
  141030. dispose(): void;
  141031. /**
  141032. * Pushes an action to the worker pool. If all the workers are active, the action will be
  141033. * pended until a worker has completed its action.
  141034. * @param action The action to perform. Call onComplete when the action is complete.
  141035. */
  141036. push(action: (worker: Worker, onComplete: () => void) => void): void;
  141037. private _execute;
  141038. }
  141039. }
  141040. declare module BABYLON {
  141041. /**
  141042. * Class for loading KTX2 files
  141043. */
  141044. export class KhronosTextureContainer2 {
  141045. private static _WorkerPoolPromise?;
  141046. private static _Initialized;
  141047. private static _Ktx2Decoder;
  141048. /**
  141049. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  141050. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  141051. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  141052. * Urls you can change:
  141053. * URLConfig.jsDecoderModule
  141054. * URLConfig.wasmUASTCToASTC
  141055. * URLConfig.wasmUASTCToBC7
  141056. * URLConfig.wasmUASTCToRGBA_UNORM
  141057. * URLConfig.wasmUASTCToRGBA_SRGB
  141058. * URLConfig.jsMSCTranscoder
  141059. * URLConfig.wasmMSCTranscoder
  141060. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  141061. */
  141062. static URLConfig: {
  141063. jsDecoderModule: string;
  141064. wasmUASTCToASTC: null;
  141065. wasmUASTCToBC7: null;
  141066. wasmUASTCToRGBA_UNORM: null;
  141067. wasmUASTCToRGBA_SRGB: null;
  141068. jsMSCTranscoder: null;
  141069. wasmMSCTranscoder: null;
  141070. };
  141071. /**
  141072. * Default number of workers used to handle data decoding
  141073. */
  141074. static DefaultNumWorkers: number;
  141075. private static GetDefaultNumWorkers;
  141076. private _engine;
  141077. private static _CreateWorkerPool;
  141078. /**
  141079. * Constructor
  141080. * @param engine The engine to use
  141081. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  141082. */
  141083. constructor(engine: ThinEngine, numWorkers?: number);
  141084. /** @hidden */
  141085. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  141086. /**
  141087. * Stop all async operations and release resources.
  141088. */
  141089. dispose(): void;
  141090. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  141091. /**
  141092. * Checks if the given data starts with a KTX2 file identifier.
  141093. * @param data the data to check
  141094. * @returns true if the data is a KTX2 file or false otherwise
  141095. */
  141096. static IsValid(data: ArrayBufferView): boolean;
  141097. }
  141098. }
  141099. declare module BABYLON {
  141100. /**
  141101. * Implementation of the KTX Texture Loader.
  141102. * @hidden
  141103. */
  141104. export class _KTXTextureLoader implements IInternalTextureLoader {
  141105. /**
  141106. * Defines wether the loader supports cascade loading the different faces.
  141107. */
  141108. readonly supportCascades: boolean;
  141109. /**
  141110. * This returns if the loader support the current file information.
  141111. * @param extension defines the file extension of the file being loaded
  141112. * @param mimeType defines the optional mime type of the file being loaded
  141113. * @returns true if the loader can load the specified file
  141114. */
  141115. canLoad(extension: string, mimeType?: string): boolean;
  141116. /**
  141117. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141118. * @param data contains the texture data
  141119. * @param texture defines the BabylonJS internal texture
  141120. * @param createPolynomials will be true if polynomials have been requested
  141121. * @param onLoad defines the callback to trigger once the texture is ready
  141122. * @param onError defines the callback to trigger in case of error
  141123. */
  141124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141125. /**
  141126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141127. * @param data contains the texture data
  141128. * @param texture defines the BabylonJS internal texture
  141129. * @param callback defines the method to call once ready to upload
  141130. */
  141131. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  141132. }
  141133. }
  141134. declare module BABYLON {
  141135. /** @hidden */
  141136. export var _forceSceneHelpersToBundle: boolean;
  141137. interface Scene {
  141138. /**
  141139. * Creates a default light for the scene.
  141140. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  141141. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  141142. */
  141143. createDefaultLight(replace?: boolean): void;
  141144. /**
  141145. * Creates a default camera for the scene.
  141146. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  141147. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  141148. * @param replace has default false, when true replaces the active camera in the scene
  141149. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  141150. */
  141151. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  141152. /**
  141153. * Creates a default camera and a default light.
  141154. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  141155. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  141156. * @param replace has the default false, when true replaces the active camera/light in the scene
  141157. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  141158. */
  141159. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  141160. /**
  141161. * Creates a new sky box
  141162. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  141163. * @param environmentTexture defines the texture to use as environment texture
  141164. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  141165. * @param scale defines the overall scale of the skybox
  141166. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  141167. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  141168. * @returns a new mesh holding the sky box
  141169. */
  141170. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  141171. /**
  141172. * Creates a new environment
  141173. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  141174. * @param options defines the options you can use to configure the environment
  141175. * @returns the new EnvironmentHelper
  141176. */
  141177. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  141178. /**
  141179. * Creates a new VREXperienceHelper
  141180. * @see https://doc.babylonjs.com/how_to/webvr_helper
  141181. * @param webVROptions defines the options used to create the new VREXperienceHelper
  141182. * @returns a new VREXperienceHelper
  141183. */
  141184. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  141185. /**
  141186. * Creates a new WebXRDefaultExperience
  141187. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  141188. * @param options experience options
  141189. * @returns a promise for a new WebXRDefaultExperience
  141190. */
  141191. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  141192. }
  141193. }
  141194. declare module BABYLON {
  141195. /**
  141196. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  141197. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  141198. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  141199. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  141200. */
  141201. export class VideoDome extends TextureDome<VideoTexture> {
  141202. /**
  141203. * Define the video source as a Monoscopic panoramic 360 video.
  141204. */
  141205. static readonly MODE_MONOSCOPIC: number;
  141206. /**
  141207. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  141208. */
  141209. static readonly MODE_TOPBOTTOM: number;
  141210. /**
  141211. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  141212. */
  141213. static readonly MODE_SIDEBYSIDE: number;
  141214. /**
  141215. * Get the video texture associated with this video dome
  141216. */
  141217. get videoTexture(): VideoTexture;
  141218. /**
  141219. * Get the video mode of this dome
  141220. */
  141221. get videoMode(): number;
  141222. /**
  141223. * Set the video mode of this dome.
  141224. * @see textureMode
  141225. */
  141226. set videoMode(value: number);
  141227. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  141228. }
  141229. }
  141230. declare module BABYLON {
  141231. /**
  141232. * This class can be used to get instrumentation data from a Babylon engine
  141233. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  141234. */
  141235. export class EngineInstrumentation implements IDisposable {
  141236. /**
  141237. * Define the instrumented engine.
  141238. */
  141239. engine: Engine;
  141240. private _captureGPUFrameTime;
  141241. private _gpuFrameTimeToken;
  141242. private _gpuFrameTime;
  141243. private _captureShaderCompilationTime;
  141244. private _shaderCompilationTime;
  141245. private _onBeginFrameObserver;
  141246. private _onEndFrameObserver;
  141247. private _onBeforeShaderCompilationObserver;
  141248. private _onAfterShaderCompilationObserver;
  141249. /**
  141250. * Gets the perf counter used for GPU frame time
  141251. */
  141252. get gpuFrameTimeCounter(): PerfCounter;
  141253. /**
  141254. * Gets the GPU frame time capture status
  141255. */
  141256. get captureGPUFrameTime(): boolean;
  141257. /**
  141258. * Enable or disable the GPU frame time capture
  141259. */
  141260. set captureGPUFrameTime(value: boolean);
  141261. /**
  141262. * Gets the perf counter used for shader compilation time
  141263. */
  141264. get shaderCompilationTimeCounter(): PerfCounter;
  141265. /**
  141266. * Gets the shader compilation time capture status
  141267. */
  141268. get captureShaderCompilationTime(): boolean;
  141269. /**
  141270. * Enable or disable the shader compilation time capture
  141271. */
  141272. set captureShaderCompilationTime(value: boolean);
  141273. /**
  141274. * Instantiates a new engine instrumentation.
  141275. * This class can be used to get instrumentation data from a Babylon engine
  141276. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  141277. * @param engine Defines the engine to instrument
  141278. */
  141279. constructor(
  141280. /**
  141281. * Define the instrumented engine.
  141282. */
  141283. engine: Engine);
  141284. /**
  141285. * Dispose and release associated resources.
  141286. */
  141287. dispose(): void;
  141288. }
  141289. }
  141290. declare module BABYLON {
  141291. /**
  141292. * This class can be used to get instrumentation data from a Babylon engine
  141293. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  141294. */
  141295. export class SceneInstrumentation implements IDisposable {
  141296. /**
  141297. * Defines the scene to instrument
  141298. */
  141299. scene: Scene;
  141300. private _captureActiveMeshesEvaluationTime;
  141301. private _activeMeshesEvaluationTime;
  141302. private _captureRenderTargetsRenderTime;
  141303. private _renderTargetsRenderTime;
  141304. private _captureFrameTime;
  141305. private _frameTime;
  141306. private _captureRenderTime;
  141307. private _renderTime;
  141308. private _captureInterFrameTime;
  141309. private _interFrameTime;
  141310. private _captureParticlesRenderTime;
  141311. private _particlesRenderTime;
  141312. private _captureSpritesRenderTime;
  141313. private _spritesRenderTime;
  141314. private _capturePhysicsTime;
  141315. private _physicsTime;
  141316. private _captureAnimationsTime;
  141317. private _animationsTime;
  141318. private _captureCameraRenderTime;
  141319. private _cameraRenderTime;
  141320. private _onBeforeActiveMeshesEvaluationObserver;
  141321. private _onAfterActiveMeshesEvaluationObserver;
  141322. private _onBeforeRenderTargetsRenderObserver;
  141323. private _onAfterRenderTargetsRenderObserver;
  141324. private _onAfterRenderObserver;
  141325. private _onBeforeDrawPhaseObserver;
  141326. private _onAfterDrawPhaseObserver;
  141327. private _onBeforeAnimationsObserver;
  141328. private _onBeforeParticlesRenderingObserver;
  141329. private _onAfterParticlesRenderingObserver;
  141330. private _onBeforeSpritesRenderingObserver;
  141331. private _onAfterSpritesRenderingObserver;
  141332. private _onBeforePhysicsObserver;
  141333. private _onAfterPhysicsObserver;
  141334. private _onAfterAnimationsObserver;
  141335. private _onBeforeCameraRenderObserver;
  141336. private _onAfterCameraRenderObserver;
  141337. /**
  141338. * Gets the perf counter used for active meshes evaluation time
  141339. */
  141340. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  141341. /**
  141342. * Gets the active meshes evaluation time capture status
  141343. */
  141344. get captureActiveMeshesEvaluationTime(): boolean;
  141345. /**
  141346. * Enable or disable the active meshes evaluation time capture
  141347. */
  141348. set captureActiveMeshesEvaluationTime(value: boolean);
  141349. /**
  141350. * Gets the perf counter used for render targets render time
  141351. */
  141352. get renderTargetsRenderTimeCounter(): PerfCounter;
  141353. /**
  141354. * Gets the render targets render time capture status
  141355. */
  141356. get captureRenderTargetsRenderTime(): boolean;
  141357. /**
  141358. * Enable or disable the render targets render time capture
  141359. */
  141360. set captureRenderTargetsRenderTime(value: boolean);
  141361. /**
  141362. * Gets the perf counter used for particles render time
  141363. */
  141364. get particlesRenderTimeCounter(): PerfCounter;
  141365. /**
  141366. * Gets the particles render time capture status
  141367. */
  141368. get captureParticlesRenderTime(): boolean;
  141369. /**
  141370. * Enable or disable the particles render time capture
  141371. */
  141372. set captureParticlesRenderTime(value: boolean);
  141373. /**
  141374. * Gets the perf counter used for sprites render time
  141375. */
  141376. get spritesRenderTimeCounter(): PerfCounter;
  141377. /**
  141378. * Gets the sprites render time capture status
  141379. */
  141380. get captureSpritesRenderTime(): boolean;
  141381. /**
  141382. * Enable or disable the sprites render time capture
  141383. */
  141384. set captureSpritesRenderTime(value: boolean);
  141385. /**
  141386. * Gets the perf counter used for physics time
  141387. */
  141388. get physicsTimeCounter(): PerfCounter;
  141389. /**
  141390. * Gets the physics time capture status
  141391. */
  141392. get capturePhysicsTime(): boolean;
  141393. /**
  141394. * Enable or disable the physics time capture
  141395. */
  141396. set capturePhysicsTime(value: boolean);
  141397. /**
  141398. * Gets the perf counter used for animations time
  141399. */
  141400. get animationsTimeCounter(): PerfCounter;
  141401. /**
  141402. * Gets the animations time capture status
  141403. */
  141404. get captureAnimationsTime(): boolean;
  141405. /**
  141406. * Enable or disable the animations time capture
  141407. */
  141408. set captureAnimationsTime(value: boolean);
  141409. /**
  141410. * Gets the perf counter used for frame time capture
  141411. */
  141412. get frameTimeCounter(): PerfCounter;
  141413. /**
  141414. * Gets the frame time capture status
  141415. */
  141416. get captureFrameTime(): boolean;
  141417. /**
  141418. * Enable or disable the frame time capture
  141419. */
  141420. set captureFrameTime(value: boolean);
  141421. /**
  141422. * Gets the perf counter used for inter-frames time capture
  141423. */
  141424. get interFrameTimeCounter(): PerfCounter;
  141425. /**
  141426. * Gets the inter-frames time capture status
  141427. */
  141428. get captureInterFrameTime(): boolean;
  141429. /**
  141430. * Enable or disable the inter-frames time capture
  141431. */
  141432. set captureInterFrameTime(value: boolean);
  141433. /**
  141434. * Gets the perf counter used for render time capture
  141435. */
  141436. get renderTimeCounter(): PerfCounter;
  141437. /**
  141438. * Gets the render time capture status
  141439. */
  141440. get captureRenderTime(): boolean;
  141441. /**
  141442. * Enable or disable the render time capture
  141443. */
  141444. set captureRenderTime(value: boolean);
  141445. /**
  141446. * Gets the perf counter used for camera render time capture
  141447. */
  141448. get cameraRenderTimeCounter(): PerfCounter;
  141449. /**
  141450. * Gets the camera render time capture status
  141451. */
  141452. get captureCameraRenderTime(): boolean;
  141453. /**
  141454. * Enable or disable the camera render time capture
  141455. */
  141456. set captureCameraRenderTime(value: boolean);
  141457. /**
  141458. * Gets the perf counter used for draw calls
  141459. */
  141460. get drawCallsCounter(): PerfCounter;
  141461. /**
  141462. * Instantiates a new scene instrumentation.
  141463. * This class can be used to get instrumentation data from a Babylon engine
  141464. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  141465. * @param scene Defines the scene to instrument
  141466. */
  141467. constructor(
  141468. /**
  141469. * Defines the scene to instrument
  141470. */
  141471. scene: Scene);
  141472. /**
  141473. * Dispose and release associated resources.
  141474. */
  141475. dispose(): void;
  141476. }
  141477. }
  141478. declare module BABYLON {
  141479. /** @hidden */
  141480. export var glowMapGenerationPixelShader: {
  141481. name: string;
  141482. shader: string;
  141483. };
  141484. }
  141485. declare module BABYLON {
  141486. /** @hidden */
  141487. export var glowMapGenerationVertexShader: {
  141488. name: string;
  141489. shader: string;
  141490. };
  141491. }
  141492. declare module BABYLON {
  141493. /**
  141494. * Effect layer options. This helps customizing the behaviour
  141495. * of the effect layer.
  141496. */
  141497. export interface IEffectLayerOptions {
  141498. /**
  141499. * Multiplication factor apply to the canvas size to compute the render target size
  141500. * used to generated the objects (the smaller the faster).
  141501. */
  141502. mainTextureRatio: number;
  141503. /**
  141504. * Enforces a fixed size texture to ensure effect stability across devices.
  141505. */
  141506. mainTextureFixedSize?: number;
  141507. /**
  141508. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  141509. */
  141510. alphaBlendingMode: number;
  141511. /**
  141512. * The camera attached to the layer.
  141513. */
  141514. camera: Nullable<Camera>;
  141515. /**
  141516. * The rendering group to draw the layer in.
  141517. */
  141518. renderingGroupId: number;
  141519. }
  141520. /**
  141521. * The effect layer Helps adding post process effect blended with the main pass.
  141522. *
  141523. * This can be for instance use to generate glow or higlight effects on the scene.
  141524. *
  141525. * The effect layer class can not be used directly and is intented to inherited from to be
  141526. * customized per effects.
  141527. */
  141528. export abstract class EffectLayer {
  141529. private _vertexBuffers;
  141530. private _indexBuffer;
  141531. private _cachedDefines;
  141532. private _effectLayerMapGenerationEffect;
  141533. private _effectLayerOptions;
  141534. private _mergeEffect;
  141535. protected _scene: Scene;
  141536. protected _engine: Engine;
  141537. protected _maxSize: number;
  141538. protected _mainTextureDesiredSize: ISize;
  141539. protected _mainTexture: RenderTargetTexture;
  141540. protected _shouldRender: boolean;
  141541. protected _postProcesses: PostProcess[];
  141542. protected _textures: BaseTexture[];
  141543. protected _emissiveTextureAndColor: {
  141544. texture: Nullable<BaseTexture>;
  141545. color: Color4;
  141546. };
  141547. /**
  141548. * The name of the layer
  141549. */
  141550. name: string;
  141551. /**
  141552. * The clear color of the texture used to generate the glow map.
  141553. */
  141554. neutralColor: Color4;
  141555. /**
  141556. * Specifies whether the highlight layer is enabled or not.
  141557. */
  141558. isEnabled: boolean;
  141559. /**
  141560. * Gets the camera attached to the layer.
  141561. */
  141562. get camera(): Nullable<Camera>;
  141563. /**
  141564. * Gets the rendering group id the layer should render in.
  141565. */
  141566. get renderingGroupId(): number;
  141567. set renderingGroupId(renderingGroupId: number);
  141568. /**
  141569. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  141570. */
  141571. disableBoundingBoxesFromEffectLayer: boolean;
  141572. /**
  141573. * An event triggered when the effect layer has been disposed.
  141574. */
  141575. onDisposeObservable: Observable<EffectLayer>;
  141576. /**
  141577. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  141578. */
  141579. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  141580. /**
  141581. * An event triggered when the generated texture is being merged in the scene.
  141582. */
  141583. onBeforeComposeObservable: Observable<EffectLayer>;
  141584. /**
  141585. * An event triggered when the mesh is rendered into the effect render target.
  141586. */
  141587. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  141588. /**
  141589. * An event triggered after the mesh has been rendered into the effect render target.
  141590. */
  141591. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  141592. /**
  141593. * An event triggered when the generated texture has been merged in the scene.
  141594. */
  141595. onAfterComposeObservable: Observable<EffectLayer>;
  141596. /**
  141597. * An event triggered when the efffect layer changes its size.
  141598. */
  141599. onSizeChangedObservable: Observable<EffectLayer>;
  141600. /** @hidden */
  141601. static _SceneComponentInitialization: (scene: Scene) => void;
  141602. /**
  141603. * Instantiates a new effect Layer and references it in the scene.
  141604. * @param name The name of the layer
  141605. * @param scene The scene to use the layer in
  141606. */
  141607. constructor(
  141608. /** The Friendly of the effect in the scene */
  141609. name: string, scene: Scene);
  141610. /**
  141611. * Get the effect name of the layer.
  141612. * @return The effect name
  141613. */
  141614. abstract getEffectName(): string;
  141615. /**
  141616. * Checks for the readiness of the element composing the layer.
  141617. * @param subMesh the mesh to check for
  141618. * @param useInstances specify whether or not to use instances to render the mesh
  141619. * @return true if ready otherwise, false
  141620. */
  141621. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141622. /**
  141623. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141624. * @returns true if the effect requires stencil during the main canvas render pass.
  141625. */
  141626. abstract needStencil(): boolean;
  141627. /**
  141628. * Create the merge effect. This is the shader use to blit the information back
  141629. * to the main canvas at the end of the scene rendering.
  141630. * @returns The effect containing the shader used to merge the effect on the main canvas
  141631. */
  141632. protected abstract _createMergeEffect(): Effect;
  141633. /**
  141634. * Creates the render target textures and post processes used in the effect layer.
  141635. */
  141636. protected abstract _createTextureAndPostProcesses(): void;
  141637. /**
  141638. * Implementation specific of rendering the generating effect on the main canvas.
  141639. * @param effect The effect used to render through
  141640. */
  141641. protected abstract _internalRender(effect: Effect): void;
  141642. /**
  141643. * Sets the required values for both the emissive texture and and the main color.
  141644. */
  141645. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141646. /**
  141647. * Free any resources and references associated to a mesh.
  141648. * Internal use
  141649. * @param mesh The mesh to free.
  141650. */
  141651. abstract _disposeMesh(mesh: Mesh): void;
  141652. /**
  141653. * Serializes this layer (Glow or Highlight for example)
  141654. * @returns a serialized layer object
  141655. */
  141656. abstract serialize?(): any;
  141657. /**
  141658. * Initializes the effect layer with the required options.
  141659. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  141660. */
  141661. protected _init(options: Partial<IEffectLayerOptions>): void;
  141662. /**
  141663. * Generates the index buffer of the full screen quad blending to the main canvas.
  141664. */
  141665. private _generateIndexBuffer;
  141666. /**
  141667. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  141668. */
  141669. private _generateVertexBuffer;
  141670. /**
  141671. * Sets the main texture desired size which is the closest power of two
  141672. * of the engine canvas size.
  141673. */
  141674. private _setMainTextureSize;
  141675. /**
  141676. * Creates the main texture for the effect layer.
  141677. */
  141678. protected _createMainTexture(): void;
  141679. /**
  141680. * Adds specific effects defines.
  141681. * @param defines The defines to add specifics to.
  141682. */
  141683. protected _addCustomEffectDefines(defines: string[]): void;
  141684. /**
  141685. * Checks for the readiness of the element composing the layer.
  141686. * @param subMesh the mesh to check for
  141687. * @param useInstances specify whether or not to use instances to render the mesh
  141688. * @param emissiveTexture the associated emissive texture used to generate the glow
  141689. * @return true if ready otherwise, false
  141690. */
  141691. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  141692. /**
  141693. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  141694. */
  141695. render(): void;
  141696. /**
  141697. * Determine if a given mesh will be used in the current effect.
  141698. * @param mesh mesh to test
  141699. * @returns true if the mesh will be used
  141700. */
  141701. hasMesh(mesh: AbstractMesh): boolean;
  141702. /**
  141703. * Returns true if the layer contains information to display, otherwise false.
  141704. * @returns true if the glow layer should be rendered
  141705. */
  141706. shouldRender(): boolean;
  141707. /**
  141708. * Returns true if the mesh should render, otherwise false.
  141709. * @param mesh The mesh to render
  141710. * @returns true if it should render otherwise false
  141711. */
  141712. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  141713. /**
  141714. * Returns true if the mesh can be rendered, otherwise false.
  141715. * @param mesh The mesh to render
  141716. * @param material The material used on the mesh
  141717. * @returns true if it can be rendered otherwise false
  141718. */
  141719. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141720. /**
  141721. * Returns true if the mesh should render, otherwise false.
  141722. * @param mesh The mesh to render
  141723. * @returns true if it should render otherwise false
  141724. */
  141725. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  141726. /**
  141727. * Renders the submesh passed in parameter to the generation map.
  141728. */
  141729. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  141730. /**
  141731. * Defines whether the current material of the mesh should be use to render the effect.
  141732. * @param mesh defines the current mesh to render
  141733. */
  141734. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141735. /**
  141736. * Rebuild the required buffers.
  141737. * @hidden Internal use only.
  141738. */
  141739. _rebuild(): void;
  141740. /**
  141741. * Dispose only the render target textures and post process.
  141742. */
  141743. private _disposeTextureAndPostProcesses;
  141744. /**
  141745. * Dispose the highlight layer and free resources.
  141746. */
  141747. dispose(): void;
  141748. /**
  141749. * Gets the class name of the effect layer
  141750. * @returns the string with the class name of the effect layer
  141751. */
  141752. getClassName(): string;
  141753. /**
  141754. * Creates an effect layer from parsed effect layer data
  141755. * @param parsedEffectLayer defines effect layer data
  141756. * @param scene defines the current scene
  141757. * @param rootUrl defines the root URL containing the effect layer information
  141758. * @returns a parsed effect Layer
  141759. */
  141760. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  141761. }
  141762. }
  141763. declare module BABYLON {
  141764. interface AbstractScene {
  141765. /**
  141766. * The list of effect layers (highlights/glow) added to the scene
  141767. * @see https://doc.babylonjs.com/how_to/highlight_layer
  141768. * @see https://doc.babylonjs.com/how_to/glow_layer
  141769. */
  141770. effectLayers: Array<EffectLayer>;
  141771. /**
  141772. * Removes the given effect layer from this scene.
  141773. * @param toRemove defines the effect layer to remove
  141774. * @returns the index of the removed effect layer
  141775. */
  141776. removeEffectLayer(toRemove: EffectLayer): number;
  141777. /**
  141778. * Adds the given effect layer to this scene
  141779. * @param newEffectLayer defines the effect layer to add
  141780. */
  141781. addEffectLayer(newEffectLayer: EffectLayer): void;
  141782. }
  141783. /**
  141784. * Defines the layer scene component responsible to manage any effect layers
  141785. * in a given scene.
  141786. */
  141787. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  141788. /**
  141789. * The component name helpfull to identify the component in the list of scene components.
  141790. */
  141791. readonly name: string;
  141792. /**
  141793. * The scene the component belongs to.
  141794. */
  141795. scene: Scene;
  141796. private _engine;
  141797. private _renderEffects;
  141798. private _needStencil;
  141799. private _previousStencilState;
  141800. /**
  141801. * Creates a new instance of the component for the given scene
  141802. * @param scene Defines the scene to register the component in
  141803. */
  141804. constructor(scene: Scene);
  141805. /**
  141806. * Registers the component in a given scene
  141807. */
  141808. register(): void;
  141809. /**
  141810. * Rebuilds the elements related to this component in case of
  141811. * context lost for instance.
  141812. */
  141813. rebuild(): void;
  141814. /**
  141815. * Serializes the component data to the specified json object
  141816. * @param serializationObject The object to serialize to
  141817. */
  141818. serialize(serializationObject: any): void;
  141819. /**
  141820. * Adds all the elements from the container to the scene
  141821. * @param container the container holding the elements
  141822. */
  141823. addFromContainer(container: AbstractScene): void;
  141824. /**
  141825. * Removes all the elements in the container from the scene
  141826. * @param container contains the elements to remove
  141827. * @param dispose if the removed element should be disposed (default: false)
  141828. */
  141829. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141830. /**
  141831. * Disposes the component and the associated ressources.
  141832. */
  141833. dispose(): void;
  141834. private _isReadyForMesh;
  141835. private _renderMainTexture;
  141836. private _setStencil;
  141837. private _setStencilBack;
  141838. private _draw;
  141839. private _drawCamera;
  141840. private _drawRenderingGroup;
  141841. }
  141842. }
  141843. declare module BABYLON {
  141844. /** @hidden */
  141845. export var glowMapMergePixelShader: {
  141846. name: string;
  141847. shader: string;
  141848. };
  141849. }
  141850. declare module BABYLON {
  141851. /** @hidden */
  141852. export var glowMapMergeVertexShader: {
  141853. name: string;
  141854. shader: string;
  141855. };
  141856. }
  141857. declare module BABYLON {
  141858. interface AbstractScene {
  141859. /**
  141860. * Return a the first highlight layer of the scene with a given name.
  141861. * @param name The name of the highlight layer to look for.
  141862. * @return The highlight layer if found otherwise null.
  141863. */
  141864. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  141865. }
  141866. /**
  141867. * Glow layer options. This helps customizing the behaviour
  141868. * of the glow layer.
  141869. */
  141870. export interface IGlowLayerOptions {
  141871. /**
  141872. * Multiplication factor apply to the canvas size to compute the render target size
  141873. * used to generated the glowing objects (the smaller the faster).
  141874. */
  141875. mainTextureRatio: number;
  141876. /**
  141877. * Enforces a fixed size texture to ensure resize independant blur.
  141878. */
  141879. mainTextureFixedSize?: number;
  141880. /**
  141881. * How big is the kernel of the blur texture.
  141882. */
  141883. blurKernelSize: number;
  141884. /**
  141885. * The camera attached to the layer.
  141886. */
  141887. camera: Nullable<Camera>;
  141888. /**
  141889. * Enable MSAA by chosing the number of samples.
  141890. */
  141891. mainTextureSamples?: number;
  141892. /**
  141893. * The rendering group to draw the layer in.
  141894. */
  141895. renderingGroupId: number;
  141896. }
  141897. /**
  141898. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  141899. *
  141900. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  141901. *
  141902. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  141903. */
  141904. export class GlowLayer extends EffectLayer {
  141905. /**
  141906. * Effect Name of the layer.
  141907. */
  141908. static readonly EffectName: string;
  141909. /**
  141910. * The default blur kernel size used for the glow.
  141911. */
  141912. static DefaultBlurKernelSize: number;
  141913. /**
  141914. * The default texture size ratio used for the glow.
  141915. */
  141916. static DefaultTextureRatio: number;
  141917. /**
  141918. * Sets the kernel size of the blur.
  141919. */
  141920. set blurKernelSize(value: number);
  141921. /**
  141922. * Gets the kernel size of the blur.
  141923. */
  141924. get blurKernelSize(): number;
  141925. /**
  141926. * Sets the glow intensity.
  141927. */
  141928. set intensity(value: number);
  141929. /**
  141930. * Gets the glow intensity.
  141931. */
  141932. get intensity(): number;
  141933. private _options;
  141934. private _intensity;
  141935. private _horizontalBlurPostprocess1;
  141936. private _verticalBlurPostprocess1;
  141937. private _horizontalBlurPostprocess2;
  141938. private _verticalBlurPostprocess2;
  141939. private _blurTexture1;
  141940. private _blurTexture2;
  141941. private _postProcesses1;
  141942. private _postProcesses2;
  141943. private _includedOnlyMeshes;
  141944. private _excludedMeshes;
  141945. private _meshesUsingTheirOwnMaterials;
  141946. /**
  141947. * Callback used to let the user override the color selection on a per mesh basis
  141948. */
  141949. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  141950. /**
  141951. * Callback used to let the user override the texture selection on a per mesh basis
  141952. */
  141953. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  141954. /**
  141955. * Instantiates a new glow Layer and references it to the scene.
  141956. * @param name The name of the layer
  141957. * @param scene The scene to use the layer in
  141958. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  141959. */
  141960. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  141961. /**
  141962. * Get the effect name of the layer.
  141963. * @return The effect name
  141964. */
  141965. getEffectName(): string;
  141966. /**
  141967. * Create the merge effect. This is the shader use to blit the information back
  141968. * to the main canvas at the end of the scene rendering.
  141969. */
  141970. protected _createMergeEffect(): Effect;
  141971. /**
  141972. * Creates the render target textures and post processes used in the glow layer.
  141973. */
  141974. protected _createTextureAndPostProcesses(): void;
  141975. /**
  141976. * Checks for the readiness of the element composing the layer.
  141977. * @param subMesh the mesh to check for
  141978. * @param useInstances specify wether or not to use instances to render the mesh
  141979. * @param emissiveTexture the associated emissive texture used to generate the glow
  141980. * @return true if ready otherwise, false
  141981. */
  141982. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141983. /**
  141984. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141985. */
  141986. needStencil(): boolean;
  141987. /**
  141988. * Returns true if the mesh can be rendered, otherwise false.
  141989. * @param mesh The mesh to render
  141990. * @param material The material used on the mesh
  141991. * @returns true if it can be rendered otherwise false
  141992. */
  141993. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141994. /**
  141995. * Implementation specific of rendering the generating effect on the main canvas.
  141996. * @param effect The effect used to render through
  141997. */
  141998. protected _internalRender(effect: Effect): void;
  141999. /**
  142000. * Sets the required values for both the emissive texture and and the main color.
  142001. */
  142002. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  142003. /**
  142004. * Returns true if the mesh should render, otherwise false.
  142005. * @param mesh The mesh to render
  142006. * @returns true if it should render otherwise false
  142007. */
  142008. protected _shouldRenderMesh(mesh: Mesh): boolean;
  142009. /**
  142010. * Adds specific effects defines.
  142011. * @param defines The defines to add specifics to.
  142012. */
  142013. protected _addCustomEffectDefines(defines: string[]): void;
  142014. /**
  142015. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  142016. * @param mesh The mesh to exclude from the glow layer
  142017. */
  142018. addExcludedMesh(mesh: Mesh): void;
  142019. /**
  142020. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  142021. * @param mesh The mesh to remove
  142022. */
  142023. removeExcludedMesh(mesh: Mesh): void;
  142024. /**
  142025. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  142026. * @param mesh The mesh to include in the glow layer
  142027. */
  142028. addIncludedOnlyMesh(mesh: Mesh): void;
  142029. /**
  142030. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  142031. * @param mesh The mesh to remove
  142032. */
  142033. removeIncludedOnlyMesh(mesh: Mesh): void;
  142034. /**
  142035. * Determine if a given mesh will be used in the glow layer
  142036. * @param mesh The mesh to test
  142037. * @returns true if the mesh will be highlighted by the current glow layer
  142038. */
  142039. hasMesh(mesh: AbstractMesh): boolean;
  142040. /**
  142041. * Defines whether the current material of the mesh should be use to render the effect.
  142042. * @param mesh defines the current mesh to render
  142043. */
  142044. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  142045. /**
  142046. * Add a mesh to be rendered through its own material and not with emissive only.
  142047. * @param mesh The mesh for which we need to use its material
  142048. */
  142049. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  142050. /**
  142051. * Remove a mesh from being rendered through its own material and not with emissive only.
  142052. * @param mesh The mesh for which we need to not use its material
  142053. */
  142054. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  142055. /**
  142056. * Free any resources and references associated to a mesh.
  142057. * Internal use
  142058. * @param mesh The mesh to free.
  142059. * @hidden
  142060. */
  142061. _disposeMesh(mesh: Mesh): void;
  142062. /**
  142063. * Gets the class name of the effect layer
  142064. * @returns the string with the class name of the effect layer
  142065. */
  142066. getClassName(): string;
  142067. /**
  142068. * Serializes this glow layer
  142069. * @returns a serialized glow layer object
  142070. */
  142071. serialize(): any;
  142072. /**
  142073. * Creates a Glow Layer from parsed glow layer data
  142074. * @param parsedGlowLayer defines glow layer data
  142075. * @param scene defines the current scene
  142076. * @param rootUrl defines the root URL containing the glow layer information
  142077. * @returns a parsed Glow Layer
  142078. */
  142079. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  142080. }
  142081. }
  142082. declare module BABYLON {
  142083. /** @hidden */
  142084. export var glowBlurPostProcessPixelShader: {
  142085. name: string;
  142086. shader: string;
  142087. };
  142088. }
  142089. declare module BABYLON {
  142090. interface AbstractScene {
  142091. /**
  142092. * Return a the first highlight layer of the scene with a given name.
  142093. * @param name The name of the highlight layer to look for.
  142094. * @return The highlight layer if found otherwise null.
  142095. */
  142096. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  142097. }
  142098. /**
  142099. * Highlight layer options. This helps customizing the behaviour
  142100. * of the highlight layer.
  142101. */
  142102. export interface IHighlightLayerOptions {
  142103. /**
  142104. * Multiplication factor apply to the canvas size to compute the render target size
  142105. * used to generated the glowing objects (the smaller the faster).
  142106. */
  142107. mainTextureRatio: number;
  142108. /**
  142109. * Enforces a fixed size texture to ensure resize independant blur.
  142110. */
  142111. mainTextureFixedSize?: number;
  142112. /**
  142113. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  142114. * of the picture to blur (the smaller the faster).
  142115. */
  142116. blurTextureSizeRatio: number;
  142117. /**
  142118. * How big in texel of the blur texture is the vertical blur.
  142119. */
  142120. blurVerticalSize: number;
  142121. /**
  142122. * How big in texel of the blur texture is the horizontal blur.
  142123. */
  142124. blurHorizontalSize: number;
  142125. /**
  142126. * Alpha blending mode used to apply the blur. Default is combine.
  142127. */
  142128. alphaBlendingMode: number;
  142129. /**
  142130. * The camera attached to the layer.
  142131. */
  142132. camera: Nullable<Camera>;
  142133. /**
  142134. * Should we display highlight as a solid stroke?
  142135. */
  142136. isStroke?: boolean;
  142137. /**
  142138. * The rendering group to draw the layer in.
  142139. */
  142140. renderingGroupId: number;
  142141. }
  142142. /**
  142143. * The highlight layer Helps adding a glow effect around a mesh.
  142144. *
  142145. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  142146. * glowy meshes to your scene.
  142147. *
  142148. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  142149. */
  142150. export class HighlightLayer extends EffectLayer {
  142151. name: string;
  142152. /**
  142153. * Effect Name of the highlight layer.
  142154. */
  142155. static readonly EffectName: string;
  142156. /**
  142157. * The neutral color used during the preparation of the glow effect.
  142158. * This is black by default as the blend operation is a blend operation.
  142159. */
  142160. static NeutralColor: Color4;
  142161. /**
  142162. * Stencil value used for glowing meshes.
  142163. */
  142164. static GlowingMeshStencilReference: number;
  142165. /**
  142166. * Stencil value used for the other meshes in the scene.
  142167. */
  142168. static NormalMeshStencilReference: number;
  142169. /**
  142170. * Specifies whether or not the inner glow is ACTIVE in the layer.
  142171. */
  142172. innerGlow: boolean;
  142173. /**
  142174. * Specifies whether or not the outer glow is ACTIVE in the layer.
  142175. */
  142176. outerGlow: boolean;
  142177. /**
  142178. * Specifies the horizontal size of the blur.
  142179. */
  142180. set blurHorizontalSize(value: number);
  142181. /**
  142182. * Specifies the vertical size of the blur.
  142183. */
  142184. set blurVerticalSize(value: number);
  142185. /**
  142186. * Gets the horizontal size of the blur.
  142187. */
  142188. get blurHorizontalSize(): number;
  142189. /**
  142190. * Gets the vertical size of the blur.
  142191. */
  142192. get blurVerticalSize(): number;
  142193. /**
  142194. * An event triggered when the highlight layer is being blurred.
  142195. */
  142196. onBeforeBlurObservable: Observable<HighlightLayer>;
  142197. /**
  142198. * An event triggered when the highlight layer has been blurred.
  142199. */
  142200. onAfterBlurObservable: Observable<HighlightLayer>;
  142201. private _instanceGlowingMeshStencilReference;
  142202. private _options;
  142203. private _downSamplePostprocess;
  142204. private _horizontalBlurPostprocess;
  142205. private _verticalBlurPostprocess;
  142206. private _blurTexture;
  142207. private _meshes;
  142208. private _excludedMeshes;
  142209. /**
  142210. * Instantiates a new highlight Layer and references it to the scene..
  142211. * @param name The name of the layer
  142212. * @param scene The scene to use the layer in
  142213. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  142214. */
  142215. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  142216. /**
  142217. * Get the effect name of the layer.
  142218. * @return The effect name
  142219. */
  142220. getEffectName(): string;
  142221. /**
  142222. * Create the merge effect. This is the shader use to blit the information back
  142223. * to the main canvas at the end of the scene rendering.
  142224. */
  142225. protected _createMergeEffect(): Effect;
  142226. /**
  142227. * Creates the render target textures and post processes used in the highlight layer.
  142228. */
  142229. protected _createTextureAndPostProcesses(): void;
  142230. /**
  142231. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  142232. */
  142233. needStencil(): boolean;
  142234. /**
  142235. * Checks for the readiness of the element composing the layer.
  142236. * @param subMesh the mesh to check for
  142237. * @param useInstances specify wether or not to use instances to render the mesh
  142238. * @param emissiveTexture the associated emissive texture used to generate the glow
  142239. * @return true if ready otherwise, false
  142240. */
  142241. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142242. /**
  142243. * Implementation specific of rendering the generating effect on the main canvas.
  142244. * @param effect The effect used to render through
  142245. */
  142246. protected _internalRender(effect: Effect): void;
  142247. /**
  142248. * Returns true if the layer contains information to display, otherwise false.
  142249. */
  142250. shouldRender(): boolean;
  142251. /**
  142252. * Returns true if the mesh should render, otherwise false.
  142253. * @param mesh The mesh to render
  142254. * @returns true if it should render otherwise false
  142255. */
  142256. protected _shouldRenderMesh(mesh: Mesh): boolean;
  142257. /**
  142258. * Returns true if the mesh can be rendered, otherwise false.
  142259. * @param mesh The mesh to render
  142260. * @param material The material used on the mesh
  142261. * @returns true if it can be rendered otherwise false
  142262. */
  142263. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  142264. /**
  142265. * Adds specific effects defines.
  142266. * @param defines The defines to add specifics to.
  142267. */
  142268. protected _addCustomEffectDefines(defines: string[]): void;
  142269. /**
  142270. * Sets the required values for both the emissive texture and and the main color.
  142271. */
  142272. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  142273. /**
  142274. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  142275. * @param mesh The mesh to exclude from the highlight layer
  142276. */
  142277. addExcludedMesh(mesh: Mesh): void;
  142278. /**
  142279. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  142280. * @param mesh The mesh to highlight
  142281. */
  142282. removeExcludedMesh(mesh: Mesh): void;
  142283. /**
  142284. * Determine if a given mesh will be highlighted by the current HighlightLayer
  142285. * @param mesh mesh to test
  142286. * @returns true if the mesh will be highlighted by the current HighlightLayer
  142287. */
  142288. hasMesh(mesh: AbstractMesh): boolean;
  142289. /**
  142290. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  142291. * @param mesh The mesh to highlight
  142292. * @param color The color of the highlight
  142293. * @param glowEmissiveOnly Extract the glow from the emissive texture
  142294. */
  142295. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  142296. /**
  142297. * Remove a mesh from the highlight layer in order to make it stop glowing.
  142298. * @param mesh The mesh to highlight
  142299. */
  142300. removeMesh(mesh: Mesh): void;
  142301. /**
  142302. * Remove all the meshes currently referenced in the highlight layer
  142303. */
  142304. removeAllMeshes(): void;
  142305. /**
  142306. * Force the stencil to the normal expected value for none glowing parts
  142307. */
  142308. private _defaultStencilReference;
  142309. /**
  142310. * Free any resources and references associated to a mesh.
  142311. * Internal use
  142312. * @param mesh The mesh to free.
  142313. * @hidden
  142314. */
  142315. _disposeMesh(mesh: Mesh): void;
  142316. /**
  142317. * Dispose the highlight layer and free resources.
  142318. */
  142319. dispose(): void;
  142320. /**
  142321. * Gets the class name of the effect layer
  142322. * @returns the string with the class name of the effect layer
  142323. */
  142324. getClassName(): string;
  142325. /**
  142326. * Serializes this Highlight layer
  142327. * @returns a serialized Highlight layer object
  142328. */
  142329. serialize(): any;
  142330. /**
  142331. * Creates a Highlight layer from parsed Highlight layer data
  142332. * @param parsedHightlightLayer defines the Highlight layer data
  142333. * @param scene defines the current scene
  142334. * @param rootUrl defines the root URL containing the Highlight layer information
  142335. * @returns a parsed Highlight layer
  142336. */
  142337. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  142338. }
  142339. }
  142340. declare module BABYLON {
  142341. interface AbstractScene {
  142342. /**
  142343. * The list of layers (background and foreground) of the scene
  142344. */
  142345. layers: Array<Layer>;
  142346. }
  142347. /**
  142348. * Defines the layer scene component responsible to manage any layers
  142349. * in a given scene.
  142350. */
  142351. export class LayerSceneComponent implements ISceneComponent {
  142352. /**
  142353. * The component name helpfull to identify the component in the list of scene components.
  142354. */
  142355. readonly name: string;
  142356. /**
  142357. * The scene the component belongs to.
  142358. */
  142359. scene: Scene;
  142360. private _engine;
  142361. /**
  142362. * Creates a new instance of the component for the given scene
  142363. * @param scene Defines the scene to register the component in
  142364. */
  142365. constructor(scene: Scene);
  142366. /**
  142367. * Registers the component in a given scene
  142368. */
  142369. register(): void;
  142370. /**
  142371. * Rebuilds the elements related to this component in case of
  142372. * context lost for instance.
  142373. */
  142374. rebuild(): void;
  142375. /**
  142376. * Disposes the component and the associated ressources.
  142377. */
  142378. dispose(): void;
  142379. private _draw;
  142380. private _drawCameraPredicate;
  142381. private _drawCameraBackground;
  142382. private _drawCameraForeground;
  142383. private _drawRenderTargetPredicate;
  142384. private _drawRenderTargetBackground;
  142385. private _drawRenderTargetForeground;
  142386. /**
  142387. * Adds all the elements from the container to the scene
  142388. * @param container the container holding the elements
  142389. */
  142390. addFromContainer(container: AbstractScene): void;
  142391. /**
  142392. * Removes all the elements in the container from the scene
  142393. * @param container contains the elements to remove
  142394. * @param dispose if the removed element should be disposed (default: false)
  142395. */
  142396. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142397. }
  142398. }
  142399. declare module BABYLON {
  142400. /** @hidden */
  142401. export var layerPixelShader: {
  142402. name: string;
  142403. shader: string;
  142404. };
  142405. }
  142406. declare module BABYLON {
  142407. /** @hidden */
  142408. export var layerVertexShader: {
  142409. name: string;
  142410. shader: string;
  142411. };
  142412. }
  142413. declare module BABYLON {
  142414. /**
  142415. * This represents a full screen 2d layer.
  142416. * This can be useful to display a picture in the background of your scene for instance.
  142417. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142418. */
  142419. export class Layer {
  142420. /**
  142421. * Define the name of the layer.
  142422. */
  142423. name: string;
  142424. /**
  142425. * Define the texture the layer should display.
  142426. */
  142427. texture: Nullable<Texture>;
  142428. /**
  142429. * Is the layer in background or foreground.
  142430. */
  142431. isBackground: boolean;
  142432. /**
  142433. * Define the color of the layer (instead of texture).
  142434. */
  142435. color: Color4;
  142436. /**
  142437. * Define the scale of the layer in order to zoom in out of the texture.
  142438. */
  142439. scale: Vector2;
  142440. /**
  142441. * Define an offset for the layer in order to shift the texture.
  142442. */
  142443. offset: Vector2;
  142444. /**
  142445. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  142446. */
  142447. alphaBlendingMode: number;
  142448. /**
  142449. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  142450. * Alpha test will not mix with the background color in case of transparency.
  142451. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  142452. */
  142453. alphaTest: boolean;
  142454. /**
  142455. * Define a mask to restrict the layer to only some of the scene cameras.
  142456. */
  142457. layerMask: number;
  142458. /**
  142459. * Define the list of render target the layer is visible into.
  142460. */
  142461. renderTargetTextures: RenderTargetTexture[];
  142462. /**
  142463. * Define if the layer is only used in renderTarget or if it also
  142464. * renders in the main frame buffer of the canvas.
  142465. */
  142466. renderOnlyInRenderTargetTextures: boolean;
  142467. private _scene;
  142468. private _vertexBuffers;
  142469. private _indexBuffer;
  142470. private _effect;
  142471. private _previousDefines;
  142472. /**
  142473. * An event triggered when the layer is disposed.
  142474. */
  142475. onDisposeObservable: Observable<Layer>;
  142476. private _onDisposeObserver;
  142477. /**
  142478. * Back compatibility with callback before the onDisposeObservable existed.
  142479. * The set callback will be triggered when the layer has been disposed.
  142480. */
  142481. set onDispose(callback: () => void);
  142482. /**
  142483. * An event triggered before rendering the scene
  142484. */
  142485. onBeforeRenderObservable: Observable<Layer>;
  142486. private _onBeforeRenderObserver;
  142487. /**
  142488. * Back compatibility with callback before the onBeforeRenderObservable existed.
  142489. * The set callback will be triggered just before rendering the layer.
  142490. */
  142491. set onBeforeRender(callback: () => void);
  142492. /**
  142493. * An event triggered after rendering the scene
  142494. */
  142495. onAfterRenderObservable: Observable<Layer>;
  142496. private _onAfterRenderObserver;
  142497. /**
  142498. * Back compatibility with callback before the onAfterRenderObservable existed.
  142499. * The set callback will be triggered just after rendering the layer.
  142500. */
  142501. set onAfterRender(callback: () => void);
  142502. /**
  142503. * Instantiates a new layer.
  142504. * This represents a full screen 2d layer.
  142505. * This can be useful to display a picture in the background of your scene for instance.
  142506. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142507. * @param name Define the name of the layer in the scene
  142508. * @param imgUrl Define the url of the texture to display in the layer
  142509. * @param scene Define the scene the layer belongs to
  142510. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  142511. * @param color Defines a color for the layer
  142512. */
  142513. constructor(
  142514. /**
  142515. * Define the name of the layer.
  142516. */
  142517. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  142518. private _createIndexBuffer;
  142519. /** @hidden */
  142520. _rebuild(): void;
  142521. /**
  142522. * Renders the layer in the scene.
  142523. */
  142524. render(): void;
  142525. /**
  142526. * Disposes and releases the associated ressources.
  142527. */
  142528. dispose(): void;
  142529. }
  142530. }
  142531. declare module BABYLON {
  142532. /** @hidden */
  142533. export var lensFlarePixelShader: {
  142534. name: string;
  142535. shader: string;
  142536. };
  142537. }
  142538. declare module BABYLON {
  142539. /** @hidden */
  142540. export var lensFlareVertexShader: {
  142541. name: string;
  142542. shader: string;
  142543. };
  142544. }
  142545. declare module BABYLON {
  142546. /**
  142547. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142548. * It is usually composed of several `lensFlare`.
  142549. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142550. */
  142551. export class LensFlareSystem {
  142552. /**
  142553. * Define the name of the lens flare system
  142554. */
  142555. name: string;
  142556. /**
  142557. * List of lens flares used in this system.
  142558. */
  142559. lensFlares: LensFlare[];
  142560. /**
  142561. * Define a limit from the border the lens flare can be visible.
  142562. */
  142563. borderLimit: number;
  142564. /**
  142565. * Define a viewport border we do not want to see the lens flare in.
  142566. */
  142567. viewportBorder: number;
  142568. /**
  142569. * Define a predicate which could limit the list of meshes able to occlude the effect.
  142570. */
  142571. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  142572. /**
  142573. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  142574. */
  142575. layerMask: number;
  142576. /**
  142577. * Define the id of the lens flare system in the scene.
  142578. * (equal to name by default)
  142579. */
  142580. id: string;
  142581. private _scene;
  142582. private _emitter;
  142583. private _vertexBuffers;
  142584. private _indexBuffer;
  142585. private _effect;
  142586. private _positionX;
  142587. private _positionY;
  142588. private _isEnabled;
  142589. /** @hidden */
  142590. static _SceneComponentInitialization: (scene: Scene) => void;
  142591. /**
  142592. * Instantiates a lens flare system.
  142593. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142594. * It is usually composed of several `lensFlare`.
  142595. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142596. * @param name Define the name of the lens flare system in the scene
  142597. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  142598. * @param scene Define the scene the lens flare system belongs to
  142599. */
  142600. constructor(
  142601. /**
  142602. * Define the name of the lens flare system
  142603. */
  142604. name: string, emitter: any, scene: Scene);
  142605. /**
  142606. * Define if the lens flare system is enabled.
  142607. */
  142608. get isEnabled(): boolean;
  142609. set isEnabled(value: boolean);
  142610. /**
  142611. * Get the scene the effects belongs to.
  142612. * @returns the scene holding the lens flare system
  142613. */
  142614. getScene(): Scene;
  142615. /**
  142616. * Get the emitter of the lens flare system.
  142617. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142618. * @returns the emitter of the lens flare system
  142619. */
  142620. getEmitter(): any;
  142621. /**
  142622. * Set the emitter of the lens flare system.
  142623. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142624. * @param newEmitter Define the new emitter of the system
  142625. */
  142626. setEmitter(newEmitter: any): void;
  142627. /**
  142628. * Get the lens flare system emitter position.
  142629. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  142630. * @returns the position
  142631. */
  142632. getEmitterPosition(): Vector3;
  142633. /**
  142634. * @hidden
  142635. */
  142636. computeEffectivePosition(globalViewport: Viewport): boolean;
  142637. /** @hidden */
  142638. _isVisible(): boolean;
  142639. /**
  142640. * @hidden
  142641. */
  142642. render(): boolean;
  142643. /**
  142644. * Dispose and release the lens flare with its associated resources.
  142645. */
  142646. dispose(): void;
  142647. /**
  142648. * Parse a lens flare system from a JSON repressentation
  142649. * @param parsedLensFlareSystem Define the JSON to parse
  142650. * @param scene Define the scene the parsed system should be instantiated in
  142651. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  142652. * @returns the parsed system
  142653. */
  142654. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  142655. /**
  142656. * Serialize the current Lens Flare System into a JSON representation.
  142657. * @returns the serialized JSON
  142658. */
  142659. serialize(): any;
  142660. }
  142661. }
  142662. declare module BABYLON {
  142663. /**
  142664. * This represents one of the lens effect in a `lensFlareSystem`.
  142665. * It controls one of the indiviual texture used in the effect.
  142666. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142667. */
  142668. export class LensFlare {
  142669. /**
  142670. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142671. */
  142672. size: number;
  142673. /**
  142674. * 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.
  142675. */
  142676. position: number;
  142677. /**
  142678. * Define the lens color.
  142679. */
  142680. color: Color3;
  142681. /**
  142682. * Define the lens texture.
  142683. */
  142684. texture: Nullable<Texture>;
  142685. /**
  142686. * Define the alpha mode to render this particular lens.
  142687. */
  142688. alphaMode: number;
  142689. private _system;
  142690. /**
  142691. * Creates a new Lens Flare.
  142692. * This represents one of the lens effect in a `lensFlareSystem`.
  142693. * It controls one of the indiviual texture used in the effect.
  142694. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142695. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  142696. * @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.
  142697. * @param color Define the lens color
  142698. * @param imgUrl Define the lens texture url
  142699. * @param system Define the `lensFlareSystem` this flare is part of
  142700. * @returns The newly created Lens Flare
  142701. */
  142702. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  142703. /**
  142704. * Instantiates a new Lens Flare.
  142705. * This represents one of the lens effect in a `lensFlareSystem`.
  142706. * It controls one of the indiviual texture used in the effect.
  142707. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142708. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  142709. * @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.
  142710. * @param color Define the lens color
  142711. * @param imgUrl Define the lens texture url
  142712. * @param system Define the `lensFlareSystem` this flare is part of
  142713. */
  142714. constructor(
  142715. /**
  142716. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142717. */
  142718. size: number,
  142719. /**
  142720. * 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.
  142721. */
  142722. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  142723. /**
  142724. * Dispose and release the lens flare with its associated resources.
  142725. */
  142726. dispose(): void;
  142727. }
  142728. }
  142729. declare module BABYLON {
  142730. interface AbstractScene {
  142731. /**
  142732. * The list of lens flare system added to the scene
  142733. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142734. */
  142735. lensFlareSystems: Array<LensFlareSystem>;
  142736. /**
  142737. * Removes the given lens flare system from this scene.
  142738. * @param toRemove The lens flare system to remove
  142739. * @returns The index of the removed lens flare system
  142740. */
  142741. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  142742. /**
  142743. * Adds the given lens flare system to this scene
  142744. * @param newLensFlareSystem The lens flare system to add
  142745. */
  142746. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  142747. /**
  142748. * Gets a lens flare system using its name
  142749. * @param name defines the name to look for
  142750. * @returns the lens flare system or null if not found
  142751. */
  142752. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  142753. /**
  142754. * Gets a lens flare system using its id
  142755. * @param id defines the id to look for
  142756. * @returns the lens flare system or null if not found
  142757. */
  142758. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  142759. }
  142760. /**
  142761. * Defines the lens flare scene component responsible to manage any lens flares
  142762. * in a given scene.
  142763. */
  142764. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  142765. /**
  142766. * The component name helpfull to identify the component in the list of scene components.
  142767. */
  142768. readonly name: string;
  142769. /**
  142770. * The scene the component belongs to.
  142771. */
  142772. scene: Scene;
  142773. /**
  142774. * Creates a new instance of the component for the given scene
  142775. * @param scene Defines the scene to register the component in
  142776. */
  142777. constructor(scene: Scene);
  142778. /**
  142779. * Registers the component in a given scene
  142780. */
  142781. register(): void;
  142782. /**
  142783. * Rebuilds the elements related to this component in case of
  142784. * context lost for instance.
  142785. */
  142786. rebuild(): void;
  142787. /**
  142788. * Adds all the elements from the container to the scene
  142789. * @param container the container holding the elements
  142790. */
  142791. addFromContainer(container: AbstractScene): void;
  142792. /**
  142793. * Removes all the elements in the container from the scene
  142794. * @param container contains the elements to remove
  142795. * @param dispose if the removed element should be disposed (default: false)
  142796. */
  142797. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142798. /**
  142799. * Serializes the component data to the specified json object
  142800. * @param serializationObject The object to serialize to
  142801. */
  142802. serialize(serializationObject: any): void;
  142803. /**
  142804. * Disposes the component and the associated ressources.
  142805. */
  142806. dispose(): void;
  142807. private _draw;
  142808. }
  142809. }
  142810. declare module BABYLON {
  142811. /** @hidden */
  142812. export var depthPixelShader: {
  142813. name: string;
  142814. shader: string;
  142815. };
  142816. }
  142817. declare module BABYLON {
  142818. /** @hidden */
  142819. export var depthVertexShader: {
  142820. name: string;
  142821. shader: string;
  142822. };
  142823. }
  142824. declare module BABYLON {
  142825. /**
  142826. * This represents a depth renderer in Babylon.
  142827. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  142828. */
  142829. export class DepthRenderer {
  142830. private _scene;
  142831. private _depthMap;
  142832. private _effect;
  142833. private readonly _storeNonLinearDepth;
  142834. private readonly _clearColor;
  142835. /** Get if the depth renderer is using packed depth or not */
  142836. readonly isPacked: boolean;
  142837. private _cachedDefines;
  142838. private _camera;
  142839. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  142840. enabled: boolean;
  142841. /**
  142842. * Specifiess that the depth renderer will only be used within
  142843. * the camera it is created for.
  142844. * This can help forcing its rendering during the camera processing.
  142845. */
  142846. useOnlyInActiveCamera: boolean;
  142847. /** @hidden */
  142848. static _SceneComponentInitialization: (scene: Scene) => void;
  142849. /**
  142850. * Instantiates a depth renderer
  142851. * @param scene The scene the renderer belongs to
  142852. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  142853. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  142854. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  142855. */
  142856. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  142857. /**
  142858. * Creates the depth rendering effect and checks if the effect is ready.
  142859. * @param subMesh The submesh to be used to render the depth map of
  142860. * @param useInstances If multiple world instances should be used
  142861. * @returns if the depth renderer is ready to render the depth map
  142862. */
  142863. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142864. /**
  142865. * Gets the texture which the depth map will be written to.
  142866. * @returns The depth map texture
  142867. */
  142868. getDepthMap(): RenderTargetTexture;
  142869. /**
  142870. * Disposes of the depth renderer.
  142871. */
  142872. dispose(): void;
  142873. }
  142874. }
  142875. declare module BABYLON {
  142876. /** @hidden */
  142877. export var minmaxReduxPixelShader: {
  142878. name: string;
  142879. shader: string;
  142880. };
  142881. }
  142882. declare module BABYLON {
  142883. /**
  142884. * This class computes a min/max reduction from a texture: it means it computes the minimum
  142885. * and maximum values from all values of the texture.
  142886. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  142887. * The source values are read from the red channel of the texture.
  142888. */
  142889. export class MinMaxReducer {
  142890. /**
  142891. * Observable triggered when the computation has been performed
  142892. */
  142893. onAfterReductionPerformed: Observable<{
  142894. min: number;
  142895. max: number;
  142896. }>;
  142897. protected _camera: Camera;
  142898. protected _sourceTexture: Nullable<RenderTargetTexture>;
  142899. protected _reductionSteps: Nullable<Array<PostProcess>>;
  142900. protected _postProcessManager: PostProcessManager;
  142901. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  142902. protected _forceFullscreenViewport: boolean;
  142903. /**
  142904. * Creates a min/max reducer
  142905. * @param camera The camera to use for the post processes
  142906. */
  142907. constructor(camera: Camera);
  142908. /**
  142909. * Gets the texture used to read the values from.
  142910. */
  142911. get sourceTexture(): Nullable<RenderTargetTexture>;
  142912. /**
  142913. * Sets the source texture to read the values from.
  142914. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  142915. * because in such textures '1' value must not be taken into account to compute the maximum
  142916. * as this value is used to clear the texture.
  142917. * Note that the computation is not activated by calling this function, you must call activate() for that!
  142918. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  142919. * @param depthRedux Indicates if the texture is a depth texture or not
  142920. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  142921. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142922. */
  142923. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142924. /**
  142925. * Defines the refresh rate of the computation.
  142926. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142927. */
  142928. get refreshRate(): number;
  142929. set refreshRate(value: number);
  142930. protected _activated: boolean;
  142931. /**
  142932. * Gets the activation status of the reducer
  142933. */
  142934. get activated(): boolean;
  142935. /**
  142936. * Activates the reduction computation.
  142937. * When activated, the observers registered in onAfterReductionPerformed are
  142938. * called after the compuation is performed
  142939. */
  142940. activate(): void;
  142941. /**
  142942. * Deactivates the reduction computation.
  142943. */
  142944. deactivate(): void;
  142945. /**
  142946. * Disposes the min/max reducer
  142947. * @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.
  142948. */
  142949. dispose(disposeAll?: boolean): void;
  142950. }
  142951. }
  142952. declare module BABYLON {
  142953. /**
  142954. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  142955. */
  142956. export class DepthReducer extends MinMaxReducer {
  142957. private _depthRenderer;
  142958. private _depthRendererId;
  142959. /**
  142960. * Gets the depth renderer used for the computation.
  142961. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  142962. */
  142963. get depthRenderer(): Nullable<DepthRenderer>;
  142964. /**
  142965. * Creates a depth reducer
  142966. * @param camera The camera used to render the depth texture
  142967. */
  142968. constructor(camera: Camera);
  142969. /**
  142970. * Sets the depth renderer to use to generate the depth map
  142971. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  142972. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  142973. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142974. */
  142975. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  142976. /** @hidden */
  142977. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142978. /**
  142979. * Activates the reduction computation.
  142980. * When activated, the observers registered in onAfterReductionPerformed are
  142981. * called after the compuation is performed
  142982. */
  142983. activate(): void;
  142984. /**
  142985. * Deactivates the reduction computation.
  142986. */
  142987. deactivate(): void;
  142988. /**
  142989. * Disposes the depth reducer
  142990. * @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.
  142991. */
  142992. dispose(disposeAll?: boolean): void;
  142993. }
  142994. }
  142995. declare module BABYLON {
  142996. /**
  142997. * A CSM implementation allowing casting shadows on large scenes.
  142998. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142999. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  143000. */
  143001. export class CascadedShadowGenerator extends ShadowGenerator {
  143002. private static readonly frustumCornersNDCSpace;
  143003. /**
  143004. * Name of the CSM class
  143005. */
  143006. static CLASSNAME: string;
  143007. /**
  143008. * Defines the default number of cascades used by the CSM.
  143009. */
  143010. static readonly DEFAULT_CASCADES_COUNT: number;
  143011. /**
  143012. * Defines the minimum number of cascades used by the CSM.
  143013. */
  143014. static readonly MIN_CASCADES_COUNT: number;
  143015. /**
  143016. * Defines the maximum number of cascades used by the CSM.
  143017. */
  143018. static readonly MAX_CASCADES_COUNT: number;
  143019. protected _validateFilter(filter: number): number;
  143020. /**
  143021. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  143022. */
  143023. penumbraDarkness: number;
  143024. private _numCascades;
  143025. /**
  143026. * Gets or set the number of cascades used by the CSM.
  143027. */
  143028. get numCascades(): number;
  143029. set numCascades(value: number);
  143030. /**
  143031. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  143032. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  143033. */
  143034. stabilizeCascades: boolean;
  143035. private _freezeShadowCastersBoundingInfo;
  143036. private _freezeShadowCastersBoundingInfoObservable;
  143037. /**
  143038. * Enables or disables the shadow casters bounding info computation.
  143039. * If your shadow casters don't move, you can disable this feature.
  143040. * If it is enabled, the bounding box computation is done every frame.
  143041. */
  143042. get freezeShadowCastersBoundingInfo(): boolean;
  143043. set freezeShadowCastersBoundingInfo(freeze: boolean);
  143044. private _scbiMin;
  143045. private _scbiMax;
  143046. protected _computeShadowCastersBoundingInfo(): void;
  143047. protected _shadowCastersBoundingInfo: BoundingInfo;
  143048. /**
  143049. * Gets or sets the shadow casters bounding info.
  143050. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  143051. * so that the system won't overwrite the bounds you provide
  143052. */
  143053. get shadowCastersBoundingInfo(): BoundingInfo;
  143054. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  143055. protected _breaksAreDirty: boolean;
  143056. protected _minDistance: number;
  143057. protected _maxDistance: number;
  143058. /**
  143059. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  143060. *
  143061. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  143062. * If you don't know these values, simply leave them to their defaults and don't call this function.
  143063. * @param min minimal distance for the breaks (default to 0.)
  143064. * @param max maximal distance for the breaks (default to 1.)
  143065. */
  143066. setMinMaxDistance(min: number, max: number): void;
  143067. /** Gets the minimal distance used in the cascade break computation */
  143068. get minDistance(): number;
  143069. /** Gets the maximal distance used in the cascade break computation */
  143070. get maxDistance(): number;
  143071. /**
  143072. * Gets the class name of that object
  143073. * @returns "CascadedShadowGenerator"
  143074. */
  143075. getClassName(): string;
  143076. private _cascadeMinExtents;
  143077. private _cascadeMaxExtents;
  143078. /**
  143079. * Gets a cascade minimum extents
  143080. * @param cascadeIndex index of the cascade
  143081. * @returns the minimum cascade extents
  143082. */
  143083. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  143084. /**
  143085. * Gets a cascade maximum extents
  143086. * @param cascadeIndex index of the cascade
  143087. * @returns the maximum cascade extents
  143088. */
  143089. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  143090. private _cascades;
  143091. private _currentLayer;
  143092. private _viewSpaceFrustumsZ;
  143093. private _viewMatrices;
  143094. private _projectionMatrices;
  143095. private _transformMatrices;
  143096. private _transformMatricesAsArray;
  143097. private _frustumLengths;
  143098. private _lightSizeUVCorrection;
  143099. private _depthCorrection;
  143100. private _frustumCornersWorldSpace;
  143101. private _frustumCenter;
  143102. private _shadowCameraPos;
  143103. private _shadowMaxZ;
  143104. /**
  143105. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  143106. * It defaults to camera.maxZ
  143107. */
  143108. get shadowMaxZ(): number;
  143109. /**
  143110. * Sets the shadow max z distance.
  143111. */
  143112. set shadowMaxZ(value: number);
  143113. protected _debug: boolean;
  143114. /**
  143115. * Gets or sets the debug flag.
  143116. * When enabled, the cascades are materialized by different colors on the screen.
  143117. */
  143118. get debug(): boolean;
  143119. set debug(dbg: boolean);
  143120. private _depthClamp;
  143121. /**
  143122. * Gets or sets the depth clamping value.
  143123. *
  143124. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  143125. * to account for the shadow casters far away.
  143126. *
  143127. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  143128. */
  143129. get depthClamp(): boolean;
  143130. set depthClamp(value: boolean);
  143131. private _cascadeBlendPercentage;
  143132. /**
  143133. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  143134. * It defaults to 0.1 (10% blending).
  143135. */
  143136. get cascadeBlendPercentage(): number;
  143137. set cascadeBlendPercentage(value: number);
  143138. private _lambda;
  143139. /**
  143140. * Gets or set the lambda parameter.
  143141. * This parameter is used to split the camera frustum and create the cascades.
  143142. * 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.
  143143. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  143144. */
  143145. get lambda(): number;
  143146. set lambda(value: number);
  143147. /**
  143148. * Gets the view matrix corresponding to a given cascade
  143149. * @param cascadeNum cascade to retrieve the view matrix from
  143150. * @returns the cascade view matrix
  143151. */
  143152. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  143153. /**
  143154. * Gets the projection matrix corresponding to a given cascade
  143155. * @param cascadeNum cascade to retrieve the projection matrix from
  143156. * @returns the cascade projection matrix
  143157. */
  143158. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  143159. /**
  143160. * Gets the transformation matrix corresponding to a given cascade
  143161. * @param cascadeNum cascade to retrieve the transformation matrix from
  143162. * @returns the cascade transformation matrix
  143163. */
  143164. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  143165. private _depthRenderer;
  143166. /**
  143167. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  143168. *
  143169. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  143170. *
  143171. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  143172. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  143173. * @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
  143174. */
  143175. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  143176. private _depthReducer;
  143177. private _autoCalcDepthBounds;
  143178. /**
  143179. * Gets or sets the autoCalcDepthBounds property.
  143180. *
  143181. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  143182. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  143183. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  143184. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  143185. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  143186. */
  143187. get autoCalcDepthBounds(): boolean;
  143188. set autoCalcDepthBounds(value: boolean);
  143189. /**
  143190. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  143191. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  143192. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  143193. * for setting the refresh rate on the renderer yourself!
  143194. */
  143195. get autoCalcDepthBoundsRefreshRate(): number;
  143196. set autoCalcDepthBoundsRefreshRate(value: number);
  143197. /**
  143198. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  143199. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  143200. * you change the camera near/far planes!
  143201. */
  143202. splitFrustum(): void;
  143203. private _splitFrustum;
  143204. private _computeMatrices;
  143205. private _computeFrustumInWorldSpace;
  143206. private _computeCascadeFrustum;
  143207. /**
  143208. * Support test.
  143209. */
  143210. static get IsSupported(): boolean;
  143211. /** @hidden */
  143212. static _SceneComponentInitialization: (scene: Scene) => void;
  143213. /**
  143214. * Creates a Cascaded Shadow Generator object.
  143215. * A ShadowGenerator is the required tool to use the shadows.
  143216. * Each directional light casting shadows needs to use its own ShadowGenerator.
  143217. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  143218. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  143219. * @param light The directional light object generating the shadows.
  143220. * @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.
  143221. */
  143222. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  143223. protected _initializeGenerator(): void;
  143224. protected _createTargetRenderTexture(): void;
  143225. protected _initializeShadowMap(): void;
  143226. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  143227. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  143228. /**
  143229. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  143230. * @param defines Defines of the material we want to update
  143231. * @param lightIndex Index of the light in the enabled light list of the material
  143232. */
  143233. prepareDefines(defines: any, lightIndex: number): void;
  143234. /**
  143235. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  143236. * defined in the generator but impacting the effect).
  143237. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  143238. * @param effect The effect we are binfing the information for
  143239. */
  143240. bindShadowLight(lightIndex: string, effect: Effect): void;
  143241. /**
  143242. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  143243. * (eq to view projection * shadow projection matrices)
  143244. * @returns The transform matrix used to create the shadow map
  143245. */
  143246. getTransformMatrix(): Matrix;
  143247. /**
  143248. * Disposes the ShadowGenerator.
  143249. * Returns nothing.
  143250. */
  143251. dispose(): void;
  143252. /**
  143253. * Serializes the shadow generator setup to a json object.
  143254. * @returns The serialized JSON object
  143255. */
  143256. serialize(): any;
  143257. /**
  143258. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  143259. * @param parsedShadowGenerator The JSON object to parse
  143260. * @param scene The scene to create the shadow map for
  143261. * @returns The parsed shadow generator
  143262. */
  143263. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  143264. }
  143265. }
  143266. declare module BABYLON {
  143267. /**
  143268. * Defines the shadow generator component responsible to manage any shadow generators
  143269. * in a given scene.
  143270. */
  143271. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  143272. /**
  143273. * The component name helpfull to identify the component in the list of scene components.
  143274. */
  143275. readonly name: string;
  143276. /**
  143277. * The scene the component belongs to.
  143278. */
  143279. scene: Scene;
  143280. /**
  143281. * Creates a new instance of the component for the given scene
  143282. * @param scene Defines the scene to register the component in
  143283. */
  143284. constructor(scene: Scene);
  143285. /**
  143286. * Registers the component in a given scene
  143287. */
  143288. register(): void;
  143289. /**
  143290. * Rebuilds the elements related to this component in case of
  143291. * context lost for instance.
  143292. */
  143293. rebuild(): void;
  143294. /**
  143295. * Serializes the component data to the specified json object
  143296. * @param serializationObject The object to serialize to
  143297. */
  143298. serialize(serializationObject: any): void;
  143299. /**
  143300. * Adds all the elements from the container to the scene
  143301. * @param container the container holding the elements
  143302. */
  143303. addFromContainer(container: AbstractScene): void;
  143304. /**
  143305. * Removes all the elements in the container from the scene
  143306. * @param container contains the elements to remove
  143307. * @param dispose if the removed element should be disposed (default: false)
  143308. */
  143309. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  143310. /**
  143311. * Rebuilds the elements related to this component in case of
  143312. * context lost for instance.
  143313. */
  143314. dispose(): void;
  143315. private _gatherRenderTargets;
  143316. }
  143317. }
  143318. declare module BABYLON {
  143319. /**
  143320. * A point light is a light defined by an unique point in world space.
  143321. * The light is emitted in every direction from this point.
  143322. * A good example of a point light is a standard light bulb.
  143323. * Documentation: https://doc.babylonjs.com/babylon101/lights
  143324. */
  143325. export class PointLight extends ShadowLight {
  143326. private _shadowAngle;
  143327. /**
  143328. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143329. * This specifies what angle the shadow will use to be created.
  143330. *
  143331. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  143332. */
  143333. get shadowAngle(): number;
  143334. /**
  143335. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143336. * This specifies what angle the shadow will use to be created.
  143337. *
  143338. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  143339. */
  143340. set shadowAngle(value: number);
  143341. /**
  143342. * Gets the direction if it has been set.
  143343. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143344. */
  143345. get direction(): Vector3;
  143346. /**
  143347. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143348. */
  143349. set direction(value: Vector3);
  143350. /**
  143351. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  143352. * A PointLight emits the light in every direction.
  143353. * It can cast shadows.
  143354. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  143355. * ```javascript
  143356. * var pointLight = new PointLight("pl", camera.position, scene);
  143357. * ```
  143358. * Documentation : https://doc.babylonjs.com/babylon101/lights
  143359. * @param name The light friendly name
  143360. * @param position The position of the point light in the scene
  143361. * @param scene The scene the lights belongs to
  143362. */
  143363. constructor(name: string, position: Vector3, scene: Scene);
  143364. /**
  143365. * Returns the string "PointLight"
  143366. * @returns the class name
  143367. */
  143368. getClassName(): string;
  143369. /**
  143370. * Returns the integer 0.
  143371. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  143372. */
  143373. getTypeID(): number;
  143374. /**
  143375. * Specifies wether or not the shadowmap should be a cube texture.
  143376. * @returns true if the shadowmap needs to be a cube texture.
  143377. */
  143378. needCube(): boolean;
  143379. /**
  143380. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  143381. * @param faceIndex The index of the face we are computed the direction to generate shadow
  143382. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  143383. */
  143384. getShadowDirection(faceIndex?: number): Vector3;
  143385. /**
  143386. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  143387. * - fov = PI / 2
  143388. * - aspect ratio : 1.0
  143389. * - z-near and far equal to the active camera minZ and maxZ.
  143390. * Returns the PointLight.
  143391. */
  143392. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  143393. protected _buildUniformLayout(): void;
  143394. /**
  143395. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  143396. * @param effect The effect to update
  143397. * @param lightIndex The index of the light in the effect to update
  143398. * @returns The point light
  143399. */
  143400. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  143401. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  143402. /**
  143403. * Prepares the list of defines specific to the light type.
  143404. * @param defines the list of defines
  143405. * @param lightIndex defines the index of the light for the effect
  143406. */
  143407. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  143408. }
  143409. }
  143410. declare module BABYLON {
  143411. /**
  143412. * Header information of HDR texture files.
  143413. */
  143414. export interface HDRInfo {
  143415. /**
  143416. * The height of the texture in pixels.
  143417. */
  143418. height: number;
  143419. /**
  143420. * The width of the texture in pixels.
  143421. */
  143422. width: number;
  143423. /**
  143424. * The index of the beginning of the data in the binary file.
  143425. */
  143426. dataPosition: number;
  143427. }
  143428. /**
  143429. * This groups tools to convert HDR texture to native colors array.
  143430. */
  143431. export class HDRTools {
  143432. private static Ldexp;
  143433. private static Rgbe2float;
  143434. private static readStringLine;
  143435. /**
  143436. * Reads header information from an RGBE texture stored in a native array.
  143437. * More information on this format are available here:
  143438. * https://en.wikipedia.org/wiki/RGBE_image_format
  143439. *
  143440. * @param uint8array The binary file stored in native array.
  143441. * @return The header information.
  143442. */
  143443. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  143444. /**
  143445. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  143446. * This RGBE texture needs to store the information as a panorama.
  143447. *
  143448. * More information on this format are available here:
  143449. * https://en.wikipedia.org/wiki/RGBE_image_format
  143450. *
  143451. * @param buffer The binary file stored in an array buffer.
  143452. * @param size The expected size of the extracted cubemap.
  143453. * @return The Cube Map information.
  143454. */
  143455. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  143456. /**
  143457. * Returns the pixels data extracted from an RGBE texture.
  143458. * This pixels will be stored left to right up to down in the R G B order in one array.
  143459. *
  143460. * More information on this format are available here:
  143461. * https://en.wikipedia.org/wiki/RGBE_image_format
  143462. *
  143463. * @param uint8array The binary file stored in an array buffer.
  143464. * @param hdrInfo The header information of the file.
  143465. * @return The pixels data in RGB right to left up to down order.
  143466. */
  143467. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  143468. private static RGBE_ReadPixels_RLE;
  143469. private static RGBE_ReadPixels_NOT_RLE;
  143470. }
  143471. }
  143472. declare module BABYLON {
  143473. /**
  143474. * Effect Render Options
  143475. */
  143476. export interface IEffectRendererOptions {
  143477. /**
  143478. * Defines the vertices positions.
  143479. */
  143480. positions?: number[];
  143481. /**
  143482. * Defines the indices.
  143483. */
  143484. indices?: number[];
  143485. }
  143486. /**
  143487. * Helper class to render one or more effects.
  143488. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  143489. */
  143490. export class EffectRenderer {
  143491. private engine;
  143492. private static _DefaultOptions;
  143493. private _vertexBuffers;
  143494. private _indexBuffer;
  143495. private _fullscreenViewport;
  143496. /**
  143497. * Creates an effect renderer
  143498. * @param engine the engine to use for rendering
  143499. * @param options defines the options of the effect renderer
  143500. */
  143501. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  143502. /**
  143503. * Sets the current viewport in normalized coordinates 0-1
  143504. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  143505. */
  143506. setViewport(viewport?: Viewport): void;
  143507. /**
  143508. * Binds the embedded attributes buffer to the effect.
  143509. * @param effect Defines the effect to bind the attributes for
  143510. */
  143511. bindBuffers(effect: Effect): void;
  143512. /**
  143513. * Sets the current effect wrapper to use during draw.
  143514. * The effect needs to be ready before calling this api.
  143515. * This also sets the default full screen position attribute.
  143516. * @param effectWrapper Defines the effect to draw with
  143517. */
  143518. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  143519. /**
  143520. * Restores engine states
  143521. */
  143522. restoreStates(): void;
  143523. /**
  143524. * Draws a full screen quad.
  143525. */
  143526. draw(): void;
  143527. private isRenderTargetTexture;
  143528. /**
  143529. * renders one or more effects to a specified texture
  143530. * @param effectWrapper the effect to renderer
  143531. * @param outputTexture texture to draw to, if null it will render to the screen.
  143532. */
  143533. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  143534. /**
  143535. * Disposes of the effect renderer
  143536. */
  143537. dispose(): void;
  143538. }
  143539. /**
  143540. * Options to create an EffectWrapper
  143541. */
  143542. interface EffectWrapperCreationOptions {
  143543. /**
  143544. * Engine to use to create the effect
  143545. */
  143546. engine: ThinEngine;
  143547. /**
  143548. * Fragment shader for the effect
  143549. */
  143550. fragmentShader: string;
  143551. /**
  143552. * Use the shader store instead of direct source code
  143553. */
  143554. useShaderStore?: boolean;
  143555. /**
  143556. * Vertex shader for the effect
  143557. */
  143558. vertexShader?: string;
  143559. /**
  143560. * Attributes to use in the shader
  143561. */
  143562. attributeNames?: Array<string>;
  143563. /**
  143564. * Uniforms to use in the shader
  143565. */
  143566. uniformNames?: Array<string>;
  143567. /**
  143568. * Texture sampler names to use in the shader
  143569. */
  143570. samplerNames?: Array<string>;
  143571. /**
  143572. * Defines to use in the shader
  143573. */
  143574. defines?: Array<string>;
  143575. /**
  143576. * Callback when effect is compiled
  143577. */
  143578. onCompiled?: Nullable<(effect: Effect) => void>;
  143579. /**
  143580. * The friendly name of the effect displayed in Spector.
  143581. */
  143582. name?: string;
  143583. }
  143584. /**
  143585. * Wraps an effect to be used for rendering
  143586. */
  143587. export class EffectWrapper {
  143588. /**
  143589. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  143590. */
  143591. onApplyObservable: Observable<{}>;
  143592. /**
  143593. * The underlying effect
  143594. */
  143595. effect: Effect;
  143596. /**
  143597. * Creates an effect to be renderer
  143598. * @param creationOptions options to create the effect
  143599. */
  143600. constructor(creationOptions: EffectWrapperCreationOptions);
  143601. /**
  143602. * Disposes of the effect wrapper
  143603. */
  143604. dispose(): void;
  143605. }
  143606. }
  143607. declare module BABYLON {
  143608. /** @hidden */
  143609. export var hdrFilteringVertexShader: {
  143610. name: string;
  143611. shader: string;
  143612. };
  143613. }
  143614. declare module BABYLON {
  143615. /** @hidden */
  143616. export var hdrFilteringPixelShader: {
  143617. name: string;
  143618. shader: string;
  143619. };
  143620. }
  143621. declare module BABYLON {
  143622. /**
  143623. * Options for texture filtering
  143624. */
  143625. interface IHDRFilteringOptions {
  143626. /**
  143627. * Scales pixel intensity for the input HDR map.
  143628. */
  143629. hdrScale?: number;
  143630. /**
  143631. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  143632. */
  143633. quality?: number;
  143634. }
  143635. /**
  143636. * Filters HDR maps to get correct renderings of PBR reflections
  143637. */
  143638. export class HDRFiltering {
  143639. private _engine;
  143640. private _effectRenderer;
  143641. private _effectWrapper;
  143642. private _lodGenerationOffset;
  143643. private _lodGenerationScale;
  143644. /**
  143645. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  143646. * you care about baking speed.
  143647. */
  143648. quality: number;
  143649. /**
  143650. * Scales pixel intensity for the input HDR map.
  143651. */
  143652. hdrScale: number;
  143653. /**
  143654. * Instantiates HDR filter for reflection maps
  143655. *
  143656. * @param engine Thin engine
  143657. * @param options Options
  143658. */
  143659. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  143660. private _createRenderTarget;
  143661. private _prefilterInternal;
  143662. private _createEffect;
  143663. /**
  143664. * Get a value indicating if the filter is ready to be used
  143665. * @param texture Texture to filter
  143666. * @returns true if the filter is ready
  143667. */
  143668. isReady(texture: BaseTexture): boolean;
  143669. /**
  143670. * Prefilters a cube texture to have mipmap levels representing roughness values.
  143671. * Prefiltering will be invoked at the end of next rendering pass.
  143672. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  143673. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  143674. * @param texture Texture to filter
  143675. * @param onFinished Callback when filtering is done
  143676. * @return Promise called when prefiltering is done
  143677. */
  143678. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  143679. }
  143680. }
  143681. declare module BABYLON {
  143682. /**
  143683. * This represents a texture coming from an HDR input.
  143684. *
  143685. * The only supported format is currently panorama picture stored in RGBE format.
  143686. * Example of such files can be found on HDRLib: http://hdrlib.com/
  143687. */
  143688. export class HDRCubeTexture extends BaseTexture {
  143689. private static _facesMapping;
  143690. private _generateHarmonics;
  143691. private _noMipmap;
  143692. private _prefilterOnLoad;
  143693. private _textureMatrix;
  143694. private _size;
  143695. private _onLoad;
  143696. private _onError;
  143697. /**
  143698. * The texture URL.
  143699. */
  143700. url: string;
  143701. protected _isBlocking: boolean;
  143702. /**
  143703. * Sets wether or not the texture is blocking during loading.
  143704. */
  143705. set isBlocking(value: boolean);
  143706. /**
  143707. * Gets wether or not the texture is blocking during loading.
  143708. */
  143709. get isBlocking(): boolean;
  143710. protected _rotationY: number;
  143711. /**
  143712. * Sets texture matrix rotation angle around Y axis in radians.
  143713. */
  143714. set rotationY(value: number);
  143715. /**
  143716. * Gets texture matrix rotation angle around Y axis radians.
  143717. */
  143718. get rotationY(): number;
  143719. /**
  143720. * Gets or sets the center of the bounding box associated with the cube texture
  143721. * It must define where the camera used to render the texture was set
  143722. */
  143723. boundingBoxPosition: Vector3;
  143724. private _boundingBoxSize;
  143725. /**
  143726. * Gets or sets the size of the bounding box associated with the cube texture
  143727. * When defined, the cubemap will switch to local mode
  143728. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  143729. * @example https://www.babylonjs-playground.com/#RNASML
  143730. */
  143731. set boundingBoxSize(value: Vector3);
  143732. get boundingBoxSize(): Vector3;
  143733. /**
  143734. * Instantiates an HDRTexture from the following parameters.
  143735. *
  143736. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  143737. * @param sceneOrEngine The scene or engine the texture will be used in
  143738. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143739. * @param noMipmap Forces to not generate the mipmap if true
  143740. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  143741. * @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)
  143742. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  143743. */
  143744. 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>);
  143745. /**
  143746. * Get the current class name of the texture useful for serialization or dynamic coding.
  143747. * @returns "HDRCubeTexture"
  143748. */
  143749. getClassName(): string;
  143750. /**
  143751. * Occurs when the file is raw .hdr file.
  143752. */
  143753. private loadTexture;
  143754. clone(): HDRCubeTexture;
  143755. delayLoad(): void;
  143756. /**
  143757. * Get the texture reflection matrix used to rotate/transform the reflection.
  143758. * @returns the reflection matrix
  143759. */
  143760. getReflectionTextureMatrix(): Matrix;
  143761. /**
  143762. * Set the texture reflection matrix used to rotate/transform the reflection.
  143763. * @param value Define the reflection matrix to set
  143764. */
  143765. setReflectionTextureMatrix(value: Matrix): void;
  143766. /**
  143767. * Parses a JSON representation of an HDR Texture in order to create the texture
  143768. * @param parsedTexture Define the JSON representation
  143769. * @param scene Define the scene the texture should be created in
  143770. * @param rootUrl Define the root url in case we need to load relative dependencies
  143771. * @returns the newly created texture after parsing
  143772. */
  143773. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  143774. serialize(): any;
  143775. }
  143776. }
  143777. declare module BABYLON {
  143778. /**
  143779. * Class used to control physics engine
  143780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143781. */
  143782. export class PhysicsEngine implements IPhysicsEngine {
  143783. private _physicsPlugin;
  143784. /**
  143785. * Global value used to control the smallest number supported by the simulation
  143786. */
  143787. static Epsilon: number;
  143788. private _impostors;
  143789. private _joints;
  143790. private _subTimeStep;
  143791. /**
  143792. * Gets the gravity vector used by the simulation
  143793. */
  143794. gravity: Vector3;
  143795. /**
  143796. * Factory used to create the default physics plugin.
  143797. * @returns The default physics plugin
  143798. */
  143799. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  143800. /**
  143801. * Creates a new Physics Engine
  143802. * @param gravity defines the gravity vector used by the simulation
  143803. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  143804. */
  143805. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  143806. /**
  143807. * Sets the gravity vector used by the simulation
  143808. * @param gravity defines the gravity vector to use
  143809. */
  143810. setGravity(gravity: Vector3): void;
  143811. /**
  143812. * Set the time step of the physics engine.
  143813. * Default is 1/60.
  143814. * To slow it down, enter 1/600 for example.
  143815. * To speed it up, 1/30
  143816. * @param newTimeStep defines the new timestep to apply to this world.
  143817. */
  143818. setTimeStep(newTimeStep?: number): void;
  143819. /**
  143820. * Get the time step of the physics engine.
  143821. * @returns the current time step
  143822. */
  143823. getTimeStep(): number;
  143824. /**
  143825. * Set the sub time step of the physics engine.
  143826. * Default is 0 meaning there is no sub steps
  143827. * To increase physics resolution precision, set a small value (like 1 ms)
  143828. * @param subTimeStep defines the new sub timestep used for physics resolution.
  143829. */
  143830. setSubTimeStep(subTimeStep?: number): void;
  143831. /**
  143832. * Get the sub time step of the physics engine.
  143833. * @returns the current sub time step
  143834. */
  143835. getSubTimeStep(): number;
  143836. /**
  143837. * Release all resources
  143838. */
  143839. dispose(): void;
  143840. /**
  143841. * Gets the name of the current physics plugin
  143842. * @returns the name of the plugin
  143843. */
  143844. getPhysicsPluginName(): string;
  143845. /**
  143846. * Adding a new impostor for the impostor tracking.
  143847. * This will be done by the impostor itself.
  143848. * @param impostor the impostor to add
  143849. */
  143850. addImpostor(impostor: PhysicsImpostor): void;
  143851. /**
  143852. * Remove an impostor from the engine.
  143853. * This impostor and its mesh will not longer be updated by the physics engine.
  143854. * @param impostor the impostor to remove
  143855. */
  143856. removeImpostor(impostor: PhysicsImpostor): void;
  143857. /**
  143858. * Add a joint to the physics engine
  143859. * @param mainImpostor defines the main impostor to which the joint is added.
  143860. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  143861. * @param joint defines the joint that will connect both impostors.
  143862. */
  143863. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143864. /**
  143865. * Removes a joint from the simulation
  143866. * @param mainImpostor defines the impostor used with the joint
  143867. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  143868. * @param joint defines the joint to remove
  143869. */
  143870. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143871. /**
  143872. * Called by the scene. No need to call it.
  143873. * @param delta defines the timespam between frames
  143874. */
  143875. _step(delta: number): void;
  143876. /**
  143877. * Gets the current plugin used to run the simulation
  143878. * @returns current plugin
  143879. */
  143880. getPhysicsPlugin(): IPhysicsEnginePlugin;
  143881. /**
  143882. * Gets the list of physic impostors
  143883. * @returns an array of PhysicsImpostor
  143884. */
  143885. getImpostors(): Array<PhysicsImpostor>;
  143886. /**
  143887. * Gets the impostor for a physics enabled object
  143888. * @param object defines the object impersonated by the impostor
  143889. * @returns the PhysicsImpostor or null if not found
  143890. */
  143891. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  143892. /**
  143893. * Gets the impostor for a physics body object
  143894. * @param body defines physics body used by the impostor
  143895. * @returns the PhysicsImpostor or null if not found
  143896. */
  143897. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  143898. /**
  143899. * Does a raycast in the physics world
  143900. * @param from when should the ray start?
  143901. * @param to when should the ray end?
  143902. * @returns PhysicsRaycastResult
  143903. */
  143904. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143905. }
  143906. }
  143907. declare module BABYLON {
  143908. /** @hidden */
  143909. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  143910. private _useDeltaForWorldStep;
  143911. world: any;
  143912. name: string;
  143913. private _physicsMaterials;
  143914. private _fixedTimeStep;
  143915. private _cannonRaycastResult;
  143916. private _raycastResult;
  143917. private _physicsBodysToRemoveAfterStep;
  143918. private _firstFrame;
  143919. BJSCANNON: any;
  143920. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  143921. setGravity(gravity: Vector3): void;
  143922. setTimeStep(timeStep: number): void;
  143923. getTimeStep(): number;
  143924. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143925. private _removeMarkedPhysicsBodiesFromWorld;
  143926. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143927. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143928. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143929. private _processChildMeshes;
  143930. removePhysicsBody(impostor: PhysicsImpostor): void;
  143931. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143932. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143933. private _addMaterial;
  143934. private _checkWithEpsilon;
  143935. private _createShape;
  143936. private _createHeightmap;
  143937. private _minus90X;
  143938. private _plus90X;
  143939. private _tmpPosition;
  143940. private _tmpDeltaPosition;
  143941. private _tmpUnityRotation;
  143942. private _updatePhysicsBodyTransformation;
  143943. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143944. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143945. isSupported(): boolean;
  143946. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143947. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143948. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143949. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143950. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143951. getBodyMass(impostor: PhysicsImpostor): number;
  143952. getBodyFriction(impostor: PhysicsImpostor): number;
  143953. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143954. getBodyRestitution(impostor: PhysicsImpostor): number;
  143955. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143956. sleepBody(impostor: PhysicsImpostor): void;
  143957. wakeUpBody(impostor: PhysicsImpostor): void;
  143958. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  143959. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143960. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143961. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143962. getRadius(impostor: PhysicsImpostor): number;
  143963. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143964. dispose(): void;
  143965. private _extendNamespace;
  143966. /**
  143967. * Does a raycast in the physics world
  143968. * @param from when should the ray start?
  143969. * @param to when should the ray end?
  143970. * @returns PhysicsRaycastResult
  143971. */
  143972. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143973. }
  143974. }
  143975. declare module BABYLON {
  143976. /** @hidden */
  143977. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  143978. private _useDeltaForWorldStep;
  143979. world: any;
  143980. name: string;
  143981. BJSOIMO: any;
  143982. private _raycastResult;
  143983. private _fixedTimeStep;
  143984. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  143985. setGravity(gravity: Vector3): void;
  143986. setTimeStep(timeStep: number): void;
  143987. getTimeStep(): number;
  143988. private _tmpImpostorsArray;
  143989. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143990. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143991. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143992. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143993. private _tmpPositionVector;
  143994. removePhysicsBody(impostor: PhysicsImpostor): void;
  143995. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143996. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143997. isSupported(): boolean;
  143998. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143999. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  144000. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  144001. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  144002. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  144003. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  144004. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  144005. getBodyMass(impostor: PhysicsImpostor): number;
  144006. getBodyFriction(impostor: PhysicsImpostor): number;
  144007. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  144008. getBodyRestitution(impostor: PhysicsImpostor): number;
  144009. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  144010. sleepBody(impostor: PhysicsImpostor): void;
  144011. wakeUpBody(impostor: PhysicsImpostor): void;
  144012. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  144013. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  144014. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  144015. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  144016. getRadius(impostor: PhysicsImpostor): number;
  144017. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  144018. dispose(): void;
  144019. /**
  144020. * Does a raycast in the physics world
  144021. * @param from when should the ray start?
  144022. * @param to when should the ray end?
  144023. * @returns PhysicsRaycastResult
  144024. */
  144025. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  144026. }
  144027. }
  144028. declare module BABYLON {
  144029. /**
  144030. * AmmoJS Physics plugin
  144031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  144032. * @see https://github.com/kripken/ammo.js/
  144033. */
  144034. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  144035. private _useDeltaForWorldStep;
  144036. /**
  144037. * Reference to the Ammo library
  144038. */
  144039. bjsAMMO: any;
  144040. /**
  144041. * Created ammoJS world which physics bodies are added to
  144042. */
  144043. world: any;
  144044. /**
  144045. * Name of the plugin
  144046. */
  144047. name: string;
  144048. private _timeStep;
  144049. private _fixedTimeStep;
  144050. private _maxSteps;
  144051. private _tmpQuaternion;
  144052. private _tmpAmmoTransform;
  144053. private _tmpAmmoQuaternion;
  144054. private _tmpAmmoConcreteContactResultCallback;
  144055. private _collisionConfiguration;
  144056. private _dispatcher;
  144057. private _overlappingPairCache;
  144058. private _solver;
  144059. private _softBodySolver;
  144060. private _tmpAmmoVectorA;
  144061. private _tmpAmmoVectorB;
  144062. private _tmpAmmoVectorC;
  144063. private _tmpAmmoVectorD;
  144064. private _tmpContactCallbackResult;
  144065. private _tmpAmmoVectorRCA;
  144066. private _tmpAmmoVectorRCB;
  144067. private _raycastResult;
  144068. private _tmpContactPoint;
  144069. private static readonly DISABLE_COLLISION_FLAG;
  144070. private static readonly KINEMATIC_FLAG;
  144071. private static readonly DISABLE_DEACTIVATION_FLAG;
  144072. /**
  144073. * Initializes the ammoJS plugin
  144074. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  144075. * @param ammoInjection can be used to inject your own ammo reference
  144076. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  144077. */
  144078. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  144079. /**
  144080. * Sets the gravity of the physics world (m/(s^2))
  144081. * @param gravity Gravity to set
  144082. */
  144083. setGravity(gravity: Vector3): void;
  144084. /**
  144085. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  144086. * @param timeStep timestep to use in seconds
  144087. */
  144088. setTimeStep(timeStep: number): void;
  144089. /**
  144090. * 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)
  144091. * @param fixedTimeStep fixedTimeStep to use in seconds
  144092. */
  144093. setFixedTimeStep(fixedTimeStep: number): void;
  144094. /**
  144095. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  144096. * @param maxSteps the maximum number of steps by the physics engine per frame
  144097. */
  144098. setMaxSteps(maxSteps: number): void;
  144099. /**
  144100. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  144101. * @returns the current timestep in seconds
  144102. */
  144103. getTimeStep(): number;
  144104. /**
  144105. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  144106. */
  144107. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  144108. private _isImpostorInContact;
  144109. private _isImpostorPairInContact;
  144110. private _stepSimulation;
  144111. /**
  144112. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  144113. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  144114. * After the step the babylon meshes are set to the position of the physics imposters
  144115. * @param delta amount of time to step forward
  144116. * @param impostors array of imposters to update before/after the step
  144117. */
  144118. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  144119. /**
  144120. * Update babylon mesh to match physics world object
  144121. * @param impostor imposter to match
  144122. */
  144123. private _afterSoftStep;
  144124. /**
  144125. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  144126. * @param impostor imposter to match
  144127. */
  144128. private _ropeStep;
  144129. /**
  144130. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  144131. * @param impostor imposter to match
  144132. */
  144133. private _softbodyOrClothStep;
  144134. private _tmpMatrix;
  144135. /**
  144136. * Applies an impulse on the imposter
  144137. * @param impostor imposter to apply impulse to
  144138. * @param force amount of force to be applied to the imposter
  144139. * @param contactPoint the location to apply the impulse on the imposter
  144140. */
  144141. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  144142. /**
  144143. * Applies a force on the imposter
  144144. * @param impostor imposter to apply force
  144145. * @param force amount of force to be applied to the imposter
  144146. * @param contactPoint the location to apply the force on the imposter
  144147. */
  144148. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  144149. /**
  144150. * Creates a physics body using the plugin
  144151. * @param impostor the imposter to create the physics body on
  144152. */
  144153. generatePhysicsBody(impostor: PhysicsImpostor): void;
  144154. /**
  144155. * Removes the physics body from the imposter and disposes of the body's memory
  144156. * @param impostor imposter to remove the physics body from
  144157. */
  144158. removePhysicsBody(impostor: PhysicsImpostor): void;
  144159. /**
  144160. * Generates a joint
  144161. * @param impostorJoint the imposter joint to create the joint with
  144162. */
  144163. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  144164. /**
  144165. * Removes a joint
  144166. * @param impostorJoint the imposter joint to remove the joint from
  144167. */
  144168. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  144169. private _addMeshVerts;
  144170. /**
  144171. * Initialise the soft body vertices to match its object's (mesh) vertices
  144172. * Softbody vertices (nodes) are in world space and to match this
  144173. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  144174. * @param impostor to create the softbody for
  144175. */
  144176. private _softVertexData;
  144177. /**
  144178. * Create an impostor's soft body
  144179. * @param impostor to create the softbody for
  144180. */
  144181. private _createSoftbody;
  144182. /**
  144183. * Create cloth for an impostor
  144184. * @param impostor to create the softbody for
  144185. */
  144186. private _createCloth;
  144187. /**
  144188. * Create rope for an impostor
  144189. * @param impostor to create the softbody for
  144190. */
  144191. private _createRope;
  144192. /**
  144193. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  144194. * @param impostor to create the custom physics shape for
  144195. */
  144196. private _createCustom;
  144197. private _addHullVerts;
  144198. private _createShape;
  144199. /**
  144200. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  144201. * @param impostor imposter containing the physics body and babylon object
  144202. */
  144203. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  144204. /**
  144205. * Sets the babylon object's position/rotation from the physics body's position/rotation
  144206. * @param impostor imposter containing the physics body and babylon object
  144207. * @param newPosition new position
  144208. * @param newRotation new rotation
  144209. */
  144210. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  144211. /**
  144212. * If this plugin is supported
  144213. * @returns true if its supported
  144214. */
  144215. isSupported(): boolean;
  144216. /**
  144217. * Sets the linear velocity of the physics body
  144218. * @param impostor imposter to set the velocity on
  144219. * @param velocity velocity to set
  144220. */
  144221. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  144222. /**
  144223. * Sets the angular velocity of the physics body
  144224. * @param impostor imposter to set the velocity on
  144225. * @param velocity velocity to set
  144226. */
  144227. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  144228. /**
  144229. * gets the linear velocity
  144230. * @param impostor imposter to get linear velocity from
  144231. * @returns linear velocity
  144232. */
  144233. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  144234. /**
  144235. * gets the angular velocity
  144236. * @param impostor imposter to get angular velocity from
  144237. * @returns angular velocity
  144238. */
  144239. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  144240. /**
  144241. * Sets the mass of physics body
  144242. * @param impostor imposter to set the mass on
  144243. * @param mass mass to set
  144244. */
  144245. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  144246. /**
  144247. * Gets the mass of the physics body
  144248. * @param impostor imposter to get the mass from
  144249. * @returns mass
  144250. */
  144251. getBodyMass(impostor: PhysicsImpostor): number;
  144252. /**
  144253. * Gets friction of the impostor
  144254. * @param impostor impostor to get friction from
  144255. * @returns friction value
  144256. */
  144257. getBodyFriction(impostor: PhysicsImpostor): number;
  144258. /**
  144259. * Sets friction of the impostor
  144260. * @param impostor impostor to set friction on
  144261. * @param friction friction value
  144262. */
  144263. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  144264. /**
  144265. * Gets restitution of the impostor
  144266. * @param impostor impostor to get restitution from
  144267. * @returns restitution value
  144268. */
  144269. getBodyRestitution(impostor: PhysicsImpostor): number;
  144270. /**
  144271. * Sets resitution of the impostor
  144272. * @param impostor impostor to set resitution on
  144273. * @param restitution resitution value
  144274. */
  144275. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  144276. /**
  144277. * Gets pressure inside the impostor
  144278. * @param impostor impostor to get pressure from
  144279. * @returns pressure value
  144280. */
  144281. getBodyPressure(impostor: PhysicsImpostor): number;
  144282. /**
  144283. * Sets pressure inside a soft body impostor
  144284. * Cloth and rope must remain 0 pressure
  144285. * @param impostor impostor to set pressure on
  144286. * @param pressure pressure value
  144287. */
  144288. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  144289. /**
  144290. * Gets stiffness of the impostor
  144291. * @param impostor impostor to get stiffness from
  144292. * @returns pressure value
  144293. */
  144294. getBodyStiffness(impostor: PhysicsImpostor): number;
  144295. /**
  144296. * Sets stiffness of the impostor
  144297. * @param impostor impostor to set stiffness on
  144298. * @param stiffness stiffness value from 0 to 1
  144299. */
  144300. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  144301. /**
  144302. * Gets velocityIterations of the impostor
  144303. * @param impostor impostor to get velocity iterations from
  144304. * @returns velocityIterations value
  144305. */
  144306. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  144307. /**
  144308. * Sets velocityIterations of the impostor
  144309. * @param impostor impostor to set velocity iterations on
  144310. * @param velocityIterations velocityIterations value
  144311. */
  144312. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  144313. /**
  144314. * Gets positionIterations of the impostor
  144315. * @param impostor impostor to get position iterations from
  144316. * @returns positionIterations value
  144317. */
  144318. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  144319. /**
  144320. * Sets positionIterations of the impostor
  144321. * @param impostor impostor to set position on
  144322. * @param positionIterations positionIterations value
  144323. */
  144324. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  144325. /**
  144326. * Append an anchor to a cloth object
  144327. * @param impostor is the cloth impostor to add anchor to
  144328. * @param otherImpostor is the rigid impostor to anchor to
  144329. * @param width ratio across width from 0 to 1
  144330. * @param height ratio up height from 0 to 1
  144331. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  144332. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  144333. */
  144334. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  144335. /**
  144336. * Append an hook to a rope object
  144337. * @param impostor is the rope impostor to add hook to
  144338. * @param otherImpostor is the rigid impostor to hook to
  144339. * @param length ratio along the rope from 0 to 1
  144340. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  144341. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  144342. */
  144343. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  144344. /**
  144345. * Sleeps the physics body and stops it from being active
  144346. * @param impostor impostor to sleep
  144347. */
  144348. sleepBody(impostor: PhysicsImpostor): void;
  144349. /**
  144350. * Activates the physics body
  144351. * @param impostor impostor to activate
  144352. */
  144353. wakeUpBody(impostor: PhysicsImpostor): void;
  144354. /**
  144355. * Updates the distance parameters of the joint
  144356. * @param joint joint to update
  144357. * @param maxDistance maximum distance of the joint
  144358. * @param minDistance minimum distance of the joint
  144359. */
  144360. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  144361. /**
  144362. * Sets a motor on the joint
  144363. * @param joint joint to set motor on
  144364. * @param speed speed of the motor
  144365. * @param maxForce maximum force of the motor
  144366. * @param motorIndex index of the motor
  144367. */
  144368. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  144369. /**
  144370. * Sets the motors limit
  144371. * @param joint joint to set limit on
  144372. * @param upperLimit upper limit
  144373. * @param lowerLimit lower limit
  144374. */
  144375. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  144376. /**
  144377. * Syncs the position and rotation of a mesh with the impostor
  144378. * @param mesh mesh to sync
  144379. * @param impostor impostor to update the mesh with
  144380. */
  144381. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  144382. /**
  144383. * Gets the radius of the impostor
  144384. * @param impostor impostor to get radius from
  144385. * @returns the radius
  144386. */
  144387. getRadius(impostor: PhysicsImpostor): number;
  144388. /**
  144389. * Gets the box size of the impostor
  144390. * @param impostor impostor to get box size from
  144391. * @param result the resulting box size
  144392. */
  144393. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  144394. /**
  144395. * Disposes of the impostor
  144396. */
  144397. dispose(): void;
  144398. /**
  144399. * Does a raycast in the physics world
  144400. * @param from when should the ray start?
  144401. * @param to when should the ray end?
  144402. * @returns PhysicsRaycastResult
  144403. */
  144404. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  144405. }
  144406. }
  144407. declare module BABYLON {
  144408. interface AbstractScene {
  144409. /**
  144410. * The list of reflection probes added to the scene
  144411. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144412. */
  144413. reflectionProbes: Array<ReflectionProbe>;
  144414. /**
  144415. * Removes the given reflection probe from this scene.
  144416. * @param toRemove The reflection probe to remove
  144417. * @returns The index of the removed reflection probe
  144418. */
  144419. removeReflectionProbe(toRemove: ReflectionProbe): number;
  144420. /**
  144421. * Adds the given reflection probe to this scene.
  144422. * @param newReflectionProbe The reflection probe to add
  144423. */
  144424. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  144425. }
  144426. /**
  144427. * Class used to generate realtime reflection / refraction cube textures
  144428. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144429. */
  144430. export class ReflectionProbe {
  144431. /** defines the name of the probe */
  144432. name: string;
  144433. private _scene;
  144434. private _renderTargetTexture;
  144435. private _projectionMatrix;
  144436. private _viewMatrix;
  144437. private _target;
  144438. private _add;
  144439. private _attachedMesh;
  144440. private _invertYAxis;
  144441. /** Gets or sets probe position (center of the cube map) */
  144442. position: Vector3;
  144443. /**
  144444. * Creates a new reflection probe
  144445. * @param name defines the name of the probe
  144446. * @param size defines the texture resolution (for each face)
  144447. * @param scene defines the hosting scene
  144448. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  144449. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  144450. */
  144451. constructor(
  144452. /** defines the name of the probe */
  144453. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  144454. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  144455. get samples(): number;
  144456. set samples(value: number);
  144457. /** Gets or sets the refresh rate to use (on every frame by default) */
  144458. get refreshRate(): number;
  144459. set refreshRate(value: number);
  144460. /**
  144461. * Gets the hosting scene
  144462. * @returns a Scene
  144463. */
  144464. getScene(): Scene;
  144465. /** Gets the internal CubeTexture used to render to */
  144466. get cubeTexture(): RenderTargetTexture;
  144467. /** Gets the list of meshes to render */
  144468. get renderList(): Nullable<AbstractMesh[]>;
  144469. /**
  144470. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  144471. * @param mesh defines the mesh to attach to
  144472. */
  144473. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  144474. /**
  144475. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  144476. * @param renderingGroupId The rendering group id corresponding to its index
  144477. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  144478. */
  144479. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  144480. /**
  144481. * Clean all associated resources
  144482. */
  144483. dispose(): void;
  144484. /**
  144485. * Converts the reflection probe information to a readable string for debug purpose.
  144486. * @param fullDetails Supports for multiple levels of logging within scene loading
  144487. * @returns the human readable reflection probe info
  144488. */
  144489. toString(fullDetails?: boolean): string;
  144490. /**
  144491. * Get the class name of the relfection probe.
  144492. * @returns "ReflectionProbe"
  144493. */
  144494. getClassName(): string;
  144495. /**
  144496. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  144497. * @returns The JSON representation of the texture
  144498. */
  144499. serialize(): any;
  144500. /**
  144501. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  144502. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  144503. * @param scene Define the scene the parsed reflection probe should be instantiated in
  144504. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  144505. * @returns The parsed reflection probe if successful
  144506. */
  144507. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  144508. }
  144509. }
  144510. declare module BABYLON {
  144511. /** @hidden */
  144512. export var _BabylonLoaderRegistered: boolean;
  144513. /**
  144514. * Helps setting up some configuration for the babylon file loader.
  144515. */
  144516. export class BabylonFileLoaderConfiguration {
  144517. /**
  144518. * The loader does not allow injecting custom physix engine into the plugins.
  144519. * Unfortunately in ES6, we need to manually inject them into the plugin.
  144520. * So you could set this variable to your engine import to make it work.
  144521. */
  144522. static LoaderInjectedPhysicsEngine: any;
  144523. }
  144524. }
  144525. declare module BABYLON {
  144526. /**
  144527. * A material to use for fast depth-only rendering.
  144528. */
  144529. export class OcclusionMaterial extends ShaderMaterial {
  144530. constructor(name: string, scene: Scene);
  144531. }
  144532. }
  144533. declare module BABYLON {
  144534. /**
  144535. * The Physically based simple base material of BJS.
  144536. *
  144537. * This enables better naming and convention enforcements on top of the pbrMaterial.
  144538. * It is used as the base class for both the specGloss and metalRough conventions.
  144539. */
  144540. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  144541. /**
  144542. * Number of Simultaneous lights allowed on the material.
  144543. */
  144544. maxSimultaneousLights: number;
  144545. /**
  144546. * If sets to true, disables all the lights affecting the material.
  144547. */
  144548. disableLighting: boolean;
  144549. /**
  144550. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  144551. */
  144552. environmentTexture: BaseTexture;
  144553. /**
  144554. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  144555. */
  144556. invertNormalMapX: boolean;
  144557. /**
  144558. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  144559. */
  144560. invertNormalMapY: boolean;
  144561. /**
  144562. * Normal map used in the model.
  144563. */
  144564. normalTexture: BaseTexture;
  144565. /**
  144566. * Emissivie color used to self-illuminate the model.
  144567. */
  144568. emissiveColor: Color3;
  144569. /**
  144570. * Emissivie texture used to self-illuminate the model.
  144571. */
  144572. emissiveTexture: BaseTexture;
  144573. /**
  144574. * Occlusion Channel Strenght.
  144575. */
  144576. occlusionStrength: number;
  144577. /**
  144578. * Occlusion Texture of the material (adding extra occlusion effects).
  144579. */
  144580. occlusionTexture: BaseTexture;
  144581. /**
  144582. * Defines the alpha limits in alpha test mode.
  144583. */
  144584. alphaCutOff: number;
  144585. /**
  144586. * Gets the current double sided mode.
  144587. */
  144588. get doubleSided(): boolean;
  144589. /**
  144590. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  144591. */
  144592. set doubleSided(value: boolean);
  144593. /**
  144594. * Stores the pre-calculated light information of a mesh in a texture.
  144595. */
  144596. lightmapTexture: BaseTexture;
  144597. /**
  144598. * If true, the light map contains occlusion information instead of lighting info.
  144599. */
  144600. useLightmapAsShadowmap: boolean;
  144601. /**
  144602. * Instantiates a new PBRMaterial instance.
  144603. *
  144604. * @param name The material name
  144605. * @param scene The scene the material will be use in.
  144606. */
  144607. constructor(name: string, scene: Scene);
  144608. getClassName(): string;
  144609. }
  144610. }
  144611. declare module BABYLON {
  144612. /**
  144613. * The PBR material of BJS following the metal roughness convention.
  144614. *
  144615. * This fits to the PBR convention in the GLTF definition:
  144616. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  144617. */
  144618. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  144619. /**
  144620. * The base color has two different interpretations depending on the value of metalness.
  144621. * When the material is a metal, the base color is the specific measured reflectance value
  144622. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  144623. * of the material.
  144624. */
  144625. baseColor: Color3;
  144626. /**
  144627. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  144628. * well as opacity information in the alpha channel.
  144629. */
  144630. baseTexture: BaseTexture;
  144631. /**
  144632. * Specifies the metallic scalar value of the material.
  144633. * Can also be used to scale the metalness values of the metallic texture.
  144634. */
  144635. metallic: number;
  144636. /**
  144637. * Specifies the roughness scalar value of the material.
  144638. * Can also be used to scale the roughness values of the metallic texture.
  144639. */
  144640. roughness: number;
  144641. /**
  144642. * Texture containing both the metallic value in the B channel and the
  144643. * roughness value in the G channel to keep better precision.
  144644. */
  144645. metallicRoughnessTexture: BaseTexture;
  144646. /**
  144647. * Instantiates a new PBRMetalRoughnessMaterial instance.
  144648. *
  144649. * @param name The material name
  144650. * @param scene The scene the material will be use in.
  144651. */
  144652. constructor(name: string, scene: Scene);
  144653. /**
  144654. * Return the currrent class name of the material.
  144655. */
  144656. getClassName(): string;
  144657. /**
  144658. * Makes a duplicate of the current material.
  144659. * @param name - name to use for the new material.
  144660. */
  144661. clone(name: string): PBRMetallicRoughnessMaterial;
  144662. /**
  144663. * Serialize the material to a parsable JSON object.
  144664. */
  144665. serialize(): any;
  144666. /**
  144667. * Parses a JSON object correponding to the serialize function.
  144668. */
  144669. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  144670. }
  144671. }
  144672. declare module BABYLON {
  144673. /**
  144674. * The PBR material of BJS following the specular glossiness convention.
  144675. *
  144676. * This fits to the PBR convention in the GLTF definition:
  144677. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  144678. */
  144679. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  144680. /**
  144681. * Specifies the diffuse color of the material.
  144682. */
  144683. diffuseColor: Color3;
  144684. /**
  144685. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  144686. * channel.
  144687. */
  144688. diffuseTexture: BaseTexture;
  144689. /**
  144690. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  144691. */
  144692. specularColor: Color3;
  144693. /**
  144694. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  144695. */
  144696. glossiness: number;
  144697. /**
  144698. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  144699. */
  144700. specularGlossinessTexture: BaseTexture;
  144701. /**
  144702. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  144703. *
  144704. * @param name The material name
  144705. * @param scene The scene the material will be use in.
  144706. */
  144707. constructor(name: string, scene: Scene);
  144708. /**
  144709. * Return the currrent class name of the material.
  144710. */
  144711. getClassName(): string;
  144712. /**
  144713. * Makes a duplicate of the current material.
  144714. * @param name - name to use for the new material.
  144715. */
  144716. clone(name: string): PBRSpecularGlossinessMaterial;
  144717. /**
  144718. * Serialize the material to a parsable JSON object.
  144719. */
  144720. serialize(): any;
  144721. /**
  144722. * Parses a JSON object correponding to the serialize function.
  144723. */
  144724. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  144725. }
  144726. }
  144727. declare module BABYLON {
  144728. /**
  144729. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  144730. * It can help converting any input color in a desired output one. This can then be used to create effects
  144731. * from sepia, black and white to sixties or futuristic rendering...
  144732. *
  144733. * The only supported format is currently 3dl.
  144734. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  144735. */
  144736. export class ColorGradingTexture extends BaseTexture {
  144737. /**
  144738. * The texture URL.
  144739. */
  144740. url: string;
  144741. /**
  144742. * Empty line regex stored for GC.
  144743. */
  144744. private static _noneEmptyLineRegex;
  144745. private _textureMatrix;
  144746. private _onLoad;
  144747. /**
  144748. * Instantiates a ColorGradingTexture from the following parameters.
  144749. *
  144750. * @param url The location of the color gradind data (currently only supporting 3dl)
  144751. * @param sceneOrEngine The scene or engine the texture will be used in
  144752. * @param onLoad defines a callback triggered when the texture has been loaded
  144753. */
  144754. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  144755. /**
  144756. * Fires the onload event from the constructor if requested.
  144757. */
  144758. private _triggerOnLoad;
  144759. /**
  144760. * Returns the texture matrix used in most of the material.
  144761. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  144762. */
  144763. getTextureMatrix(): Matrix;
  144764. /**
  144765. * Occurs when the file being loaded is a .3dl LUT file.
  144766. */
  144767. private load3dlTexture;
  144768. /**
  144769. * Starts the loading process of the texture.
  144770. */
  144771. private loadTexture;
  144772. /**
  144773. * Clones the color gradind texture.
  144774. */
  144775. clone(): ColorGradingTexture;
  144776. /**
  144777. * Called during delayed load for textures.
  144778. */
  144779. delayLoad(): void;
  144780. /**
  144781. * Parses a color grading texture serialized by Babylon.
  144782. * @param parsedTexture The texture information being parsedTexture
  144783. * @param scene The scene to load the texture in
  144784. * @param rootUrl The root url of the data assets to load
  144785. * @return A color gradind texture
  144786. */
  144787. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  144788. /**
  144789. * Serializes the LUT texture to json format.
  144790. */
  144791. serialize(): any;
  144792. }
  144793. }
  144794. declare module BABYLON {
  144795. /**
  144796. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  144797. */
  144798. export class EquiRectangularCubeTexture extends BaseTexture {
  144799. /** The six faces of the cube. */
  144800. private static _FacesMapping;
  144801. private _noMipmap;
  144802. private _onLoad;
  144803. private _onError;
  144804. /** The size of the cubemap. */
  144805. private _size;
  144806. /** The buffer of the image. */
  144807. private _buffer;
  144808. /** The width of the input image. */
  144809. private _width;
  144810. /** The height of the input image. */
  144811. private _height;
  144812. /** The URL to the image. */
  144813. url: string;
  144814. /**
  144815. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  144816. * @param url The location of the image
  144817. * @param scene The scene the texture will be used in
  144818. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  144819. * @param noMipmap Forces to not generate the mipmap if true
  144820. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  144821. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  144822. * @param onLoad — defines a callback called when texture is loaded
  144823. * @param onError — defines a callback called if there is an error
  144824. */
  144825. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  144826. /**
  144827. * Load the image data, by putting the image on a canvas and extracting its buffer.
  144828. */
  144829. private loadImage;
  144830. /**
  144831. * Convert the image buffer into a cubemap and create a CubeTexture.
  144832. */
  144833. private loadTexture;
  144834. /**
  144835. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  144836. * @param buffer The ArrayBuffer that should be converted.
  144837. * @returns The buffer as Float32Array.
  144838. */
  144839. private getFloat32ArrayFromArrayBuffer;
  144840. /**
  144841. * Get the current class name of the texture useful for serialization or dynamic coding.
  144842. * @returns "EquiRectangularCubeTexture"
  144843. */
  144844. getClassName(): string;
  144845. /**
  144846. * Create a clone of the current EquiRectangularCubeTexture and return it.
  144847. * @returns A clone of the current EquiRectangularCubeTexture.
  144848. */
  144849. clone(): EquiRectangularCubeTexture;
  144850. }
  144851. }
  144852. declare module BABYLON {
  144853. /**
  144854. * Defines the options related to the creation of an HtmlElementTexture
  144855. */
  144856. export interface IHtmlElementTextureOptions {
  144857. /**
  144858. * Defines wether mip maps should be created or not.
  144859. */
  144860. generateMipMaps?: boolean;
  144861. /**
  144862. * Defines the sampling mode of the texture.
  144863. */
  144864. samplingMode?: number;
  144865. /**
  144866. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  144867. */
  144868. engine: Nullable<ThinEngine>;
  144869. /**
  144870. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  144871. */
  144872. scene: Nullable<Scene>;
  144873. }
  144874. /**
  144875. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  144876. * To be as efficient as possible depending on your constraints nothing aside the first upload
  144877. * is automatically managed.
  144878. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  144879. * in your application.
  144880. *
  144881. * As the update is not automatic, you need to call them manually.
  144882. */
  144883. export class HtmlElementTexture extends BaseTexture {
  144884. /**
  144885. * The texture URL.
  144886. */
  144887. element: HTMLVideoElement | HTMLCanvasElement;
  144888. private static readonly DefaultOptions;
  144889. private _textureMatrix;
  144890. private _isVideo;
  144891. private _generateMipMaps;
  144892. private _samplingMode;
  144893. /**
  144894. * Instantiates a HtmlElementTexture from the following parameters.
  144895. *
  144896. * @param name Defines the name of the texture
  144897. * @param element Defines the video or canvas the texture is filled with
  144898. * @param options Defines the other none mandatory texture creation options
  144899. */
  144900. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  144901. private _createInternalTexture;
  144902. /**
  144903. * Returns the texture matrix used in most of the material.
  144904. */
  144905. getTextureMatrix(): Matrix;
  144906. /**
  144907. * Updates the content of the texture.
  144908. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  144909. */
  144910. update(invertY?: Nullable<boolean>): void;
  144911. }
  144912. }
  144913. declare module BABYLON {
  144914. /**
  144915. * Based on jsTGALoader - Javascript loader for TGA file
  144916. * By Vincent Thibault
  144917. * @see http://blog.robrowser.com/javascript-tga-loader.html
  144918. */
  144919. export class TGATools {
  144920. private static _TYPE_INDEXED;
  144921. private static _TYPE_RGB;
  144922. private static _TYPE_GREY;
  144923. private static _TYPE_RLE_INDEXED;
  144924. private static _TYPE_RLE_RGB;
  144925. private static _TYPE_RLE_GREY;
  144926. private static _ORIGIN_MASK;
  144927. private static _ORIGIN_SHIFT;
  144928. private static _ORIGIN_BL;
  144929. private static _ORIGIN_BR;
  144930. private static _ORIGIN_UL;
  144931. private static _ORIGIN_UR;
  144932. /**
  144933. * Gets the header of a TGA file
  144934. * @param data defines the TGA data
  144935. * @returns the header
  144936. */
  144937. static GetTGAHeader(data: Uint8Array): any;
  144938. /**
  144939. * Uploads TGA content to a Babylon Texture
  144940. * @hidden
  144941. */
  144942. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  144943. /** @hidden */
  144944. 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;
  144945. /** @hidden */
  144946. 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;
  144947. /** @hidden */
  144948. 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;
  144949. /** @hidden */
  144950. 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;
  144951. /** @hidden */
  144952. 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;
  144953. /** @hidden */
  144954. 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;
  144955. }
  144956. }
  144957. declare module BABYLON {
  144958. /**
  144959. * Implementation of the TGA Texture Loader.
  144960. * @hidden
  144961. */
  144962. export class _TGATextureLoader implements IInternalTextureLoader {
  144963. /**
  144964. * Defines wether the loader supports cascade loading the different faces.
  144965. */
  144966. readonly supportCascades: boolean;
  144967. /**
  144968. * This returns if the loader support the current file information.
  144969. * @param extension defines the file extension of the file being loaded
  144970. * @returns true if the loader can load the specified file
  144971. */
  144972. canLoad(extension: string): boolean;
  144973. /**
  144974. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144975. * @param data contains the texture data
  144976. * @param texture defines the BabylonJS internal texture
  144977. * @param createPolynomials will be true if polynomials have been requested
  144978. * @param onLoad defines the callback to trigger once the texture is ready
  144979. * @param onError defines the callback to trigger in case of error
  144980. */
  144981. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144982. /**
  144983. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144984. * @param data contains the texture data
  144985. * @param texture defines the BabylonJS internal texture
  144986. * @param callback defines the method to call once ready to upload
  144987. */
  144988. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144989. }
  144990. }
  144991. declare module BABYLON {
  144992. /**
  144993. * Info about the .basis files
  144994. */
  144995. class BasisFileInfo {
  144996. /**
  144997. * If the file has alpha
  144998. */
  144999. hasAlpha: boolean;
  145000. /**
  145001. * Info about each image of the basis file
  145002. */
  145003. images: Array<{
  145004. levels: Array<{
  145005. width: number;
  145006. height: number;
  145007. transcodedPixels: ArrayBufferView;
  145008. }>;
  145009. }>;
  145010. }
  145011. /**
  145012. * Result of transcoding a basis file
  145013. */
  145014. class TranscodeResult {
  145015. /**
  145016. * Info about the .basis file
  145017. */
  145018. fileInfo: BasisFileInfo;
  145019. /**
  145020. * Format to use when loading the file
  145021. */
  145022. format: number;
  145023. }
  145024. /**
  145025. * Configuration options for the Basis transcoder
  145026. */
  145027. export class BasisTranscodeConfiguration {
  145028. /**
  145029. * Supported compression formats used to determine the supported output format of the transcoder
  145030. */
  145031. supportedCompressionFormats?: {
  145032. /**
  145033. * etc1 compression format
  145034. */
  145035. etc1?: boolean;
  145036. /**
  145037. * s3tc compression format
  145038. */
  145039. s3tc?: boolean;
  145040. /**
  145041. * pvrtc compression format
  145042. */
  145043. pvrtc?: boolean;
  145044. /**
  145045. * etc2 compression format
  145046. */
  145047. etc2?: boolean;
  145048. };
  145049. /**
  145050. * If mipmap levels should be loaded for transcoded images (Default: true)
  145051. */
  145052. loadMipmapLevels?: boolean;
  145053. /**
  145054. * Index of a single image to load (Default: all images)
  145055. */
  145056. loadSingleImage?: number;
  145057. }
  145058. /**
  145059. * Used to load .Basis files
  145060. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  145061. */
  145062. export class BasisTools {
  145063. private static _IgnoreSupportedFormats;
  145064. /**
  145065. * URL to use when loading the basis transcoder
  145066. */
  145067. static JSModuleURL: string;
  145068. /**
  145069. * URL to use when loading the wasm module for the transcoder
  145070. */
  145071. static WasmModuleURL: string;
  145072. /**
  145073. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  145074. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  145075. * @returns internal format corresponding to the Basis format
  145076. */
  145077. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  145078. private static _WorkerPromise;
  145079. private static _Worker;
  145080. private static _actionId;
  145081. private static _CreateWorkerAsync;
  145082. /**
  145083. * Transcodes a loaded image file to compressed pixel data
  145084. * @param data image data to transcode
  145085. * @param config configuration options for the transcoding
  145086. * @returns a promise resulting in the transcoded image
  145087. */
  145088. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  145089. /**
  145090. * Loads a texture from the transcode result
  145091. * @param texture texture load to
  145092. * @param transcodeResult the result of transcoding the basis file to load from
  145093. */
  145094. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  145095. }
  145096. }
  145097. declare module BABYLON {
  145098. /**
  145099. * Loader for .basis file format
  145100. */
  145101. export class _BasisTextureLoader implements IInternalTextureLoader {
  145102. /**
  145103. * Defines whether the loader supports cascade loading the different faces.
  145104. */
  145105. readonly supportCascades: boolean;
  145106. /**
  145107. * This returns if the loader support the current file information.
  145108. * @param extension defines the file extension of the file being loaded
  145109. * @returns true if the loader can load the specified file
  145110. */
  145111. canLoad(extension: string): boolean;
  145112. /**
  145113. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  145114. * @param data contains the texture data
  145115. * @param texture defines the BabylonJS internal texture
  145116. * @param createPolynomials will be true if polynomials have been requested
  145117. * @param onLoad defines the callback to trigger once the texture is ready
  145118. * @param onError defines the callback to trigger in case of error
  145119. */
  145120. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  145121. /**
  145122. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  145123. * @param data contains the texture data
  145124. * @param texture defines the BabylonJS internal texture
  145125. * @param callback defines the method to call once ready to upload
  145126. */
  145127. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  145128. }
  145129. }
  145130. declare module BABYLON {
  145131. /**
  145132. * Defines the basic options interface of a TexturePacker Frame
  145133. */
  145134. export interface ITexturePackerFrame {
  145135. /**
  145136. * The frame ID
  145137. */
  145138. id: number;
  145139. /**
  145140. * The frames Scale
  145141. */
  145142. scale: Vector2;
  145143. /**
  145144. * The Frames offset
  145145. */
  145146. offset: Vector2;
  145147. }
  145148. /**
  145149. * This is a support class for frame Data on texture packer sets.
  145150. */
  145151. export class TexturePackerFrame implements ITexturePackerFrame {
  145152. /**
  145153. * The frame ID
  145154. */
  145155. id: number;
  145156. /**
  145157. * The frames Scale
  145158. */
  145159. scale: Vector2;
  145160. /**
  145161. * The Frames offset
  145162. */
  145163. offset: Vector2;
  145164. /**
  145165. * Initializes a texture package frame.
  145166. * @param id The numerical frame identifier
  145167. * @param scale Scalar Vector2 for UV frame
  145168. * @param offset Vector2 for the frame position in UV units.
  145169. * @returns TexturePackerFrame
  145170. */
  145171. constructor(id: number, scale: Vector2, offset: Vector2);
  145172. }
  145173. }
  145174. declare module BABYLON {
  145175. /**
  145176. * Defines the basic options interface of a TexturePacker
  145177. */
  145178. export interface ITexturePackerOptions {
  145179. /**
  145180. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  145181. */
  145182. map?: string[];
  145183. /**
  145184. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  145185. */
  145186. uvsIn?: string;
  145187. /**
  145188. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  145189. */
  145190. uvsOut?: string;
  145191. /**
  145192. * number representing the layout style. Defaults to LAYOUT_STRIP
  145193. */
  145194. layout?: number;
  145195. /**
  145196. * number of columns if using custom column count layout(2). This defaults to 4.
  145197. */
  145198. colnum?: number;
  145199. /**
  145200. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  145201. */
  145202. updateInputMeshes?: boolean;
  145203. /**
  145204. * boolean flag to dispose all the source textures. Defaults to true.
  145205. */
  145206. disposeSources?: boolean;
  145207. /**
  145208. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  145209. */
  145210. fillBlanks?: boolean;
  145211. /**
  145212. * string value representing the context fill style color. Defaults to 'black'.
  145213. */
  145214. customFillColor?: string;
  145215. /**
  145216. * Width and Height Value of each Frame in the TexturePacker Sets
  145217. */
  145218. frameSize?: number;
  145219. /**
  145220. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  145221. */
  145222. paddingRatio?: number;
  145223. /**
  145224. * Number that declares the fill method for the padding gutter.
  145225. */
  145226. paddingMode?: number;
  145227. /**
  145228. * If in SUBUV_COLOR padding mode what color to use.
  145229. */
  145230. paddingColor?: Color3 | Color4;
  145231. }
  145232. /**
  145233. * Defines the basic interface of a TexturePacker JSON File
  145234. */
  145235. export interface ITexturePackerJSON {
  145236. /**
  145237. * The frame ID
  145238. */
  145239. name: string;
  145240. /**
  145241. * The base64 channel data
  145242. */
  145243. sets: any;
  145244. /**
  145245. * The options of the Packer
  145246. */
  145247. options: ITexturePackerOptions;
  145248. /**
  145249. * The frame data of the Packer
  145250. */
  145251. frames: Array<number>;
  145252. }
  145253. /**
  145254. * This is a support class that generates a series of packed texture sets.
  145255. * @see https://doc.babylonjs.com/babylon101/materials
  145256. */
  145257. export class TexturePacker {
  145258. /** Packer Layout Constant 0 */
  145259. static readonly LAYOUT_STRIP: number;
  145260. /** Packer Layout Constant 1 */
  145261. static readonly LAYOUT_POWER2: number;
  145262. /** Packer Layout Constant 2 */
  145263. static readonly LAYOUT_COLNUM: number;
  145264. /** Packer Layout Constant 0 */
  145265. static readonly SUBUV_WRAP: number;
  145266. /** Packer Layout Constant 1 */
  145267. static readonly SUBUV_EXTEND: number;
  145268. /** Packer Layout Constant 2 */
  145269. static readonly SUBUV_COLOR: number;
  145270. /** The Name of the Texture Package */
  145271. name: string;
  145272. /** The scene scope of the TexturePacker */
  145273. scene: Scene;
  145274. /** The Meshes to target */
  145275. meshes: AbstractMesh[];
  145276. /** Arguments passed with the Constructor */
  145277. options: ITexturePackerOptions;
  145278. /** The promise that is started upon initialization */
  145279. promise: Nullable<Promise<TexturePacker | string>>;
  145280. /** The Container object for the channel sets that are generated */
  145281. sets: object;
  145282. /** The Container array for the frames that are generated */
  145283. frames: TexturePackerFrame[];
  145284. /** The expected number of textures the system is parsing. */
  145285. private _expecting;
  145286. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  145287. private _paddingValue;
  145288. /**
  145289. * Initializes a texture package series from an array of meshes or a single mesh.
  145290. * @param name The name of the package
  145291. * @param meshes The target meshes to compose the package from
  145292. * @param options The arguments that texture packer should follow while building.
  145293. * @param scene The scene which the textures are scoped to.
  145294. * @returns TexturePacker
  145295. */
  145296. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  145297. /**
  145298. * Starts the package process
  145299. * @param resolve The promises resolution function
  145300. * @returns TexturePacker
  145301. */
  145302. private _createFrames;
  145303. /**
  145304. * Calculates the Size of the Channel Sets
  145305. * @returns Vector2
  145306. */
  145307. private _calculateSize;
  145308. /**
  145309. * Calculates the UV data for the frames.
  145310. * @param baseSize the base frameSize
  145311. * @param padding the base frame padding
  145312. * @param dtSize size of the Dynamic Texture for that channel
  145313. * @param dtUnits is 1/dtSize
  145314. * @param update flag to update the input meshes
  145315. */
  145316. private _calculateMeshUVFrames;
  145317. /**
  145318. * Calculates the frames Offset.
  145319. * @param index of the frame
  145320. * @returns Vector2
  145321. */
  145322. private _getFrameOffset;
  145323. /**
  145324. * Updates a Mesh to the frame data
  145325. * @param mesh that is the target
  145326. * @param frameID or the frame index
  145327. */
  145328. private _updateMeshUV;
  145329. /**
  145330. * Updates a Meshes materials to use the texture packer channels
  145331. * @param m is the mesh to target
  145332. * @param force all channels on the packer to be set.
  145333. */
  145334. private _updateTextureReferences;
  145335. /**
  145336. * Public method to set a Mesh to a frame
  145337. * @param m that is the target
  145338. * @param frameID or the frame index
  145339. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  145340. */
  145341. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  145342. /**
  145343. * Starts the async promise to compile the texture packer.
  145344. * @returns Promise<void>
  145345. */
  145346. processAsync(): Promise<void>;
  145347. /**
  145348. * Disposes all textures associated with this packer
  145349. */
  145350. dispose(): void;
  145351. /**
  145352. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  145353. * @param imageType is the image type to use.
  145354. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  145355. */
  145356. download(imageType?: string, quality?: number): void;
  145357. /**
  145358. * Public method to load a texturePacker JSON file.
  145359. * @param data of the JSON file in string format.
  145360. */
  145361. updateFromJSON(data: string): void;
  145362. }
  145363. }
  145364. declare module BABYLON {
  145365. /**
  145366. * 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.
  145367. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  145368. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  145369. */
  145370. export class CustomProceduralTexture extends ProceduralTexture {
  145371. private _animate;
  145372. private _time;
  145373. private _config;
  145374. private _texturePath;
  145375. /**
  145376. * Instantiates a new Custom Procedural Texture.
  145377. * 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.
  145378. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  145379. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  145380. * @param name Define the name of the texture
  145381. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  145382. * @param size Define the size of the texture to create
  145383. * @param scene Define the scene the texture belongs to
  145384. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  145385. * @param generateMipMaps Define if the texture should creates mip maps or not
  145386. */
  145387. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145388. private _loadJson;
  145389. /**
  145390. * Is the texture ready to be used ? (rendered at least once)
  145391. * @returns true if ready, otherwise, false.
  145392. */
  145393. isReady(): boolean;
  145394. /**
  145395. * Render the texture to its associated render target.
  145396. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  145397. */
  145398. render(useCameraPostProcess?: boolean): void;
  145399. /**
  145400. * Update the list of dependant textures samplers in the shader.
  145401. */
  145402. updateTextures(): void;
  145403. /**
  145404. * Update the uniform values of the procedural texture in the shader.
  145405. */
  145406. updateShaderUniforms(): void;
  145407. /**
  145408. * Define if the texture animates or not.
  145409. */
  145410. get animate(): boolean;
  145411. set animate(value: boolean);
  145412. }
  145413. }
  145414. declare module BABYLON {
  145415. /** @hidden */
  145416. export var noisePixelShader: {
  145417. name: string;
  145418. shader: string;
  145419. };
  145420. }
  145421. declare module BABYLON {
  145422. /**
  145423. * Class used to generate noise procedural textures
  145424. */
  145425. export class NoiseProceduralTexture extends ProceduralTexture {
  145426. /** Gets or sets the start time (default is 0) */
  145427. time: number;
  145428. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  145429. brightness: number;
  145430. /** Defines the number of octaves to process */
  145431. octaves: number;
  145432. /** Defines the level of persistence (0.8 by default) */
  145433. persistence: number;
  145434. /** Gets or sets animation speed factor (default is 1) */
  145435. animationSpeedFactor: number;
  145436. /**
  145437. * Creates a new NoiseProceduralTexture
  145438. * @param name defines the name fo the texture
  145439. * @param size defines the size of the texture (default is 256)
  145440. * @param scene defines the hosting scene
  145441. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  145442. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  145443. */
  145444. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145445. private _updateShaderUniforms;
  145446. protected _getDefines(): string;
  145447. /** Generate the current state of the procedural texture */
  145448. render(useCameraPostProcess?: boolean): void;
  145449. /**
  145450. * Serializes this noise procedural texture
  145451. * @returns a serialized noise procedural texture object
  145452. */
  145453. serialize(): any;
  145454. /**
  145455. * Clone the texture.
  145456. * @returns the cloned texture
  145457. */
  145458. clone(): NoiseProceduralTexture;
  145459. /**
  145460. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  145461. * @param parsedTexture defines parsed texture data
  145462. * @param scene defines the current scene
  145463. * @param rootUrl defines the root URL containing noise procedural texture information
  145464. * @returns a parsed NoiseProceduralTexture
  145465. */
  145466. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  145467. }
  145468. }
  145469. declare module BABYLON {
  145470. /**
  145471. * Raw cube texture where the raw buffers are passed in
  145472. */
  145473. export class RawCubeTexture extends CubeTexture {
  145474. /**
  145475. * Creates a cube texture where the raw buffers are passed in.
  145476. * @param scene defines the scene the texture is attached to
  145477. * @param data defines the array of data to use to create each face
  145478. * @param size defines the size of the textures
  145479. * @param format defines the format of the data
  145480. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  145481. * @param generateMipMaps defines if the engine should generate the mip levels
  145482. * @param invertY defines if data must be stored with Y axis inverted
  145483. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  145484. * @param compression defines the compression used (null by default)
  145485. */
  145486. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  145487. /**
  145488. * Updates the raw cube texture.
  145489. * @param data defines the data to store
  145490. * @param format defines the data format
  145491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  145492. * @param invertY defines if data must be stored with Y axis inverted
  145493. * @param compression defines the compression used (null by default)
  145494. * @param level defines which level of the texture to update
  145495. */
  145496. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  145497. /**
  145498. * Updates a raw cube texture with RGBD encoded data.
  145499. * @param data defines the array of data [mipmap][face] to use to create each face
  145500. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  145501. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  145502. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  145503. * @returns a promsie that resolves when the operation is complete
  145504. */
  145505. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  145506. /**
  145507. * Clones the raw cube texture.
  145508. * @return a new cube texture
  145509. */
  145510. clone(): CubeTexture;
  145511. /** @hidden */
  145512. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  145513. }
  145514. }
  145515. declare module BABYLON {
  145516. /**
  145517. * Class used to store 2D array textures containing user data
  145518. */
  145519. export class RawTexture2DArray extends Texture {
  145520. /** Gets or sets the texture format to use */
  145521. format: number;
  145522. /**
  145523. * Create a new RawTexture2DArray
  145524. * @param data defines the data of the texture
  145525. * @param width defines the width of the texture
  145526. * @param height defines the height of the texture
  145527. * @param depth defines the number of layers of the texture
  145528. * @param format defines the texture format to use
  145529. * @param scene defines the hosting scene
  145530. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145531. * @param invertY defines if texture must be stored with Y axis inverted
  145532. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145533. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145534. */
  145535. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145536. /** Gets or sets the texture format to use */
  145537. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145538. /**
  145539. * Update the texture with new data
  145540. * @param data defines the data to store in the texture
  145541. */
  145542. update(data: ArrayBufferView): void;
  145543. }
  145544. }
  145545. declare module BABYLON {
  145546. /**
  145547. * Class used to store 3D textures containing user data
  145548. */
  145549. export class RawTexture3D extends Texture {
  145550. /** Gets or sets the texture format to use */
  145551. format: number;
  145552. /**
  145553. * Create a new RawTexture3D
  145554. * @param data defines the data of the texture
  145555. * @param width defines the width of the texture
  145556. * @param height defines the height of the texture
  145557. * @param depth defines the depth of the texture
  145558. * @param format defines the texture format to use
  145559. * @param scene defines the hosting scene
  145560. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145561. * @param invertY defines if texture must be stored with Y axis inverted
  145562. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145563. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145564. */
  145565. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145566. /** Gets or sets the texture format to use */
  145567. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145568. /**
  145569. * Update the texture with new data
  145570. * @param data defines the data to store in the texture
  145571. */
  145572. update(data: ArrayBufferView): void;
  145573. }
  145574. }
  145575. declare module BABYLON {
  145576. /**
  145577. * Creates a refraction texture used by refraction channel of the standard material.
  145578. * It is like a mirror but to see through a material.
  145579. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145580. */
  145581. export class RefractionTexture extends RenderTargetTexture {
  145582. /**
  145583. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  145584. * 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.
  145585. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145586. */
  145587. refractionPlane: Plane;
  145588. /**
  145589. * Define how deep under the surface we should see.
  145590. */
  145591. depth: number;
  145592. /**
  145593. * Creates a refraction texture used by refraction channel of the standard material.
  145594. * It is like a mirror but to see through a material.
  145595. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145596. * @param name Define the texture name
  145597. * @param size Define the size of the underlying texture
  145598. * @param scene Define the scene the refraction belongs to
  145599. * @param generateMipMaps Define if we need to generate mips level for the refraction
  145600. */
  145601. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  145602. /**
  145603. * Clone the refraction texture.
  145604. * @returns the cloned texture
  145605. */
  145606. clone(): RefractionTexture;
  145607. /**
  145608. * Serialize the texture to a JSON representation you could use in Parse later on
  145609. * @returns the serialized JSON representation
  145610. */
  145611. serialize(): any;
  145612. }
  145613. }
  145614. declare module BABYLON {
  145615. /**
  145616. * Block used to add support for vertex skinning (bones)
  145617. */
  145618. export class BonesBlock extends NodeMaterialBlock {
  145619. /**
  145620. * Creates a new BonesBlock
  145621. * @param name defines the block name
  145622. */
  145623. constructor(name: string);
  145624. /**
  145625. * Initialize the block and prepare the context for build
  145626. * @param state defines the state that will be used for the build
  145627. */
  145628. initialize(state: NodeMaterialBuildState): void;
  145629. /**
  145630. * Gets the current class name
  145631. * @returns the class name
  145632. */
  145633. getClassName(): string;
  145634. /**
  145635. * Gets the matrix indices input component
  145636. */
  145637. get matricesIndices(): NodeMaterialConnectionPoint;
  145638. /**
  145639. * Gets the matrix weights input component
  145640. */
  145641. get matricesWeights(): NodeMaterialConnectionPoint;
  145642. /**
  145643. * Gets the extra matrix indices input component
  145644. */
  145645. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  145646. /**
  145647. * Gets the extra matrix weights input component
  145648. */
  145649. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  145650. /**
  145651. * Gets the world input component
  145652. */
  145653. get world(): NodeMaterialConnectionPoint;
  145654. /**
  145655. * Gets the output component
  145656. */
  145657. get output(): NodeMaterialConnectionPoint;
  145658. autoConfigure(material: NodeMaterial): void;
  145659. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  145660. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145661. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145662. protected _buildBlock(state: NodeMaterialBuildState): this;
  145663. }
  145664. }
  145665. declare module BABYLON {
  145666. /**
  145667. * Block used to add support for instances
  145668. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  145669. */
  145670. export class InstancesBlock extends NodeMaterialBlock {
  145671. /**
  145672. * Creates a new InstancesBlock
  145673. * @param name defines the block name
  145674. */
  145675. constructor(name: string);
  145676. /**
  145677. * Gets the current class name
  145678. * @returns the class name
  145679. */
  145680. getClassName(): string;
  145681. /**
  145682. * Gets the first world row input component
  145683. */
  145684. get world0(): NodeMaterialConnectionPoint;
  145685. /**
  145686. * Gets the second world row input component
  145687. */
  145688. get world1(): NodeMaterialConnectionPoint;
  145689. /**
  145690. * Gets the third world row input component
  145691. */
  145692. get world2(): NodeMaterialConnectionPoint;
  145693. /**
  145694. * Gets the forth world row input component
  145695. */
  145696. get world3(): NodeMaterialConnectionPoint;
  145697. /**
  145698. * Gets the world input component
  145699. */
  145700. get world(): NodeMaterialConnectionPoint;
  145701. /**
  145702. * Gets the output component
  145703. */
  145704. get output(): NodeMaterialConnectionPoint;
  145705. /**
  145706. * Gets the isntanceID component
  145707. */
  145708. get instanceID(): NodeMaterialConnectionPoint;
  145709. autoConfigure(material: NodeMaterial): void;
  145710. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  145711. protected _buildBlock(state: NodeMaterialBuildState): this;
  145712. }
  145713. }
  145714. declare module BABYLON {
  145715. /**
  145716. * Block used to add morph targets support to vertex shader
  145717. */
  145718. export class MorphTargetsBlock extends NodeMaterialBlock {
  145719. private _repeatableContentAnchor;
  145720. /**
  145721. * Create a new MorphTargetsBlock
  145722. * @param name defines the block name
  145723. */
  145724. constructor(name: string);
  145725. /**
  145726. * Gets the current class name
  145727. * @returns the class name
  145728. */
  145729. getClassName(): string;
  145730. /**
  145731. * Gets the position input component
  145732. */
  145733. get position(): NodeMaterialConnectionPoint;
  145734. /**
  145735. * Gets the normal input component
  145736. */
  145737. get normal(): NodeMaterialConnectionPoint;
  145738. /**
  145739. * Gets the tangent input component
  145740. */
  145741. get tangent(): NodeMaterialConnectionPoint;
  145742. /**
  145743. * Gets the tangent input component
  145744. */
  145745. get uv(): NodeMaterialConnectionPoint;
  145746. /**
  145747. * Gets the position output component
  145748. */
  145749. get positionOutput(): NodeMaterialConnectionPoint;
  145750. /**
  145751. * Gets the normal output component
  145752. */
  145753. get normalOutput(): NodeMaterialConnectionPoint;
  145754. /**
  145755. * Gets the tangent output component
  145756. */
  145757. get tangentOutput(): NodeMaterialConnectionPoint;
  145758. /**
  145759. * Gets the tangent output component
  145760. */
  145761. get uvOutput(): NodeMaterialConnectionPoint;
  145762. initialize(state: NodeMaterialBuildState): void;
  145763. autoConfigure(material: NodeMaterial): void;
  145764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145765. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145766. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  145767. protected _buildBlock(state: NodeMaterialBuildState): this;
  145768. }
  145769. }
  145770. declare module BABYLON {
  145771. /**
  145772. * Block used to get data information from a light
  145773. */
  145774. export class LightInformationBlock extends NodeMaterialBlock {
  145775. private _lightDataUniformName;
  145776. private _lightColorUniformName;
  145777. private _lightTypeDefineName;
  145778. /**
  145779. * Gets or sets the light associated with this block
  145780. */
  145781. light: Nullable<Light>;
  145782. /**
  145783. * Creates a new LightInformationBlock
  145784. * @param name defines the block name
  145785. */
  145786. constructor(name: string);
  145787. /**
  145788. * Gets the current class name
  145789. * @returns the class name
  145790. */
  145791. getClassName(): string;
  145792. /**
  145793. * Gets the world position input component
  145794. */
  145795. get worldPosition(): NodeMaterialConnectionPoint;
  145796. /**
  145797. * Gets the direction output component
  145798. */
  145799. get direction(): NodeMaterialConnectionPoint;
  145800. /**
  145801. * Gets the direction output component
  145802. */
  145803. get color(): NodeMaterialConnectionPoint;
  145804. /**
  145805. * Gets the direction output component
  145806. */
  145807. get intensity(): NodeMaterialConnectionPoint;
  145808. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145809. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145810. protected _buildBlock(state: NodeMaterialBuildState): this;
  145811. serialize(): any;
  145812. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145813. }
  145814. }
  145815. declare module BABYLON {
  145816. /**
  145817. * Block used to add image processing support to fragment shader
  145818. */
  145819. export class ImageProcessingBlock extends NodeMaterialBlock {
  145820. /**
  145821. * Create a new ImageProcessingBlock
  145822. * @param name defines the block name
  145823. */
  145824. constructor(name: string);
  145825. /**
  145826. * Gets the current class name
  145827. * @returns the class name
  145828. */
  145829. getClassName(): string;
  145830. /**
  145831. * Gets the color input component
  145832. */
  145833. get color(): NodeMaterialConnectionPoint;
  145834. /**
  145835. * Gets the output component
  145836. */
  145837. get output(): NodeMaterialConnectionPoint;
  145838. /**
  145839. * Initialize the block and prepare the context for build
  145840. * @param state defines the state that will be used for the build
  145841. */
  145842. initialize(state: NodeMaterialBuildState): void;
  145843. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  145844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145845. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145846. protected _buildBlock(state: NodeMaterialBuildState): this;
  145847. }
  145848. }
  145849. declare module BABYLON {
  145850. /**
  145851. * Block used to pertub normals based on a normal map
  145852. */
  145853. export class PerturbNormalBlock extends NodeMaterialBlock {
  145854. private _tangentSpaceParameterName;
  145855. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145856. invertX: boolean;
  145857. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  145858. invertY: boolean;
  145859. /**
  145860. * Create a new PerturbNormalBlock
  145861. * @param name defines the block name
  145862. */
  145863. constructor(name: string);
  145864. /**
  145865. * Gets the current class name
  145866. * @returns the class name
  145867. */
  145868. getClassName(): string;
  145869. /**
  145870. * Gets the world position input component
  145871. */
  145872. get worldPosition(): NodeMaterialConnectionPoint;
  145873. /**
  145874. * Gets the world normal input component
  145875. */
  145876. get worldNormal(): NodeMaterialConnectionPoint;
  145877. /**
  145878. * Gets the world tangent input component
  145879. */
  145880. get worldTangent(): NodeMaterialConnectionPoint;
  145881. /**
  145882. * Gets the uv input component
  145883. */
  145884. get uv(): NodeMaterialConnectionPoint;
  145885. /**
  145886. * Gets the normal map color input component
  145887. */
  145888. get normalMapColor(): NodeMaterialConnectionPoint;
  145889. /**
  145890. * Gets the strength input component
  145891. */
  145892. get strength(): NodeMaterialConnectionPoint;
  145893. /**
  145894. * Gets the output component
  145895. */
  145896. get output(): NodeMaterialConnectionPoint;
  145897. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145898. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145899. autoConfigure(material: NodeMaterial): void;
  145900. protected _buildBlock(state: NodeMaterialBuildState): this;
  145901. protected _dumpPropertiesCode(): string;
  145902. serialize(): any;
  145903. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145904. }
  145905. }
  145906. declare module BABYLON {
  145907. /**
  145908. * Block used to discard a pixel if a value is smaller than a cutoff
  145909. */
  145910. export class DiscardBlock extends NodeMaterialBlock {
  145911. /**
  145912. * Create a new DiscardBlock
  145913. * @param name defines the block name
  145914. */
  145915. constructor(name: string);
  145916. /**
  145917. * Gets the current class name
  145918. * @returns the class name
  145919. */
  145920. getClassName(): string;
  145921. /**
  145922. * Gets the color input component
  145923. */
  145924. get value(): NodeMaterialConnectionPoint;
  145925. /**
  145926. * Gets the cutoff input component
  145927. */
  145928. get cutoff(): NodeMaterialConnectionPoint;
  145929. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145930. }
  145931. }
  145932. declare module BABYLON {
  145933. /**
  145934. * Block used to test if the fragment shader is front facing
  145935. */
  145936. export class FrontFacingBlock extends NodeMaterialBlock {
  145937. /**
  145938. * Creates a new FrontFacingBlock
  145939. * @param name defines the block name
  145940. */
  145941. constructor(name: string);
  145942. /**
  145943. * Gets the current class name
  145944. * @returns the class name
  145945. */
  145946. getClassName(): string;
  145947. /**
  145948. * Gets the output component
  145949. */
  145950. get output(): NodeMaterialConnectionPoint;
  145951. protected _buildBlock(state: NodeMaterialBuildState): this;
  145952. }
  145953. }
  145954. declare module BABYLON {
  145955. /**
  145956. * Block used to get the derivative value on x and y of a given input
  145957. */
  145958. export class DerivativeBlock extends NodeMaterialBlock {
  145959. /**
  145960. * Create a new DerivativeBlock
  145961. * @param name defines the block name
  145962. */
  145963. constructor(name: string);
  145964. /**
  145965. * Gets the current class name
  145966. * @returns the class name
  145967. */
  145968. getClassName(): string;
  145969. /**
  145970. * Gets the input component
  145971. */
  145972. get input(): NodeMaterialConnectionPoint;
  145973. /**
  145974. * Gets the derivative output on x
  145975. */
  145976. get dx(): NodeMaterialConnectionPoint;
  145977. /**
  145978. * Gets the derivative output on y
  145979. */
  145980. get dy(): NodeMaterialConnectionPoint;
  145981. protected _buildBlock(state: NodeMaterialBuildState): this;
  145982. }
  145983. }
  145984. declare module BABYLON {
  145985. /**
  145986. * Block used to make gl_FragCoord available
  145987. */
  145988. export class FragCoordBlock extends NodeMaterialBlock {
  145989. /**
  145990. * Creates a new FragCoordBlock
  145991. * @param name defines the block name
  145992. */
  145993. constructor(name: string);
  145994. /**
  145995. * Gets the current class name
  145996. * @returns the class name
  145997. */
  145998. getClassName(): string;
  145999. /**
  146000. * Gets the xy component
  146001. */
  146002. get xy(): NodeMaterialConnectionPoint;
  146003. /**
  146004. * Gets the xyz component
  146005. */
  146006. get xyz(): NodeMaterialConnectionPoint;
  146007. /**
  146008. * Gets the xyzw component
  146009. */
  146010. get xyzw(): NodeMaterialConnectionPoint;
  146011. /**
  146012. * Gets the x component
  146013. */
  146014. get x(): NodeMaterialConnectionPoint;
  146015. /**
  146016. * Gets the y component
  146017. */
  146018. get y(): NodeMaterialConnectionPoint;
  146019. /**
  146020. * Gets the z component
  146021. */
  146022. get z(): NodeMaterialConnectionPoint;
  146023. /**
  146024. * Gets the w component
  146025. */
  146026. get output(): NodeMaterialConnectionPoint;
  146027. protected writeOutputs(state: NodeMaterialBuildState): string;
  146028. protected _buildBlock(state: NodeMaterialBuildState): this;
  146029. }
  146030. }
  146031. declare module BABYLON {
  146032. /**
  146033. * Block used to get the screen sizes
  146034. */
  146035. export class ScreenSizeBlock extends NodeMaterialBlock {
  146036. private _varName;
  146037. private _scene;
  146038. /**
  146039. * Creates a new ScreenSizeBlock
  146040. * @param name defines the block name
  146041. */
  146042. constructor(name: string);
  146043. /**
  146044. * Gets the current class name
  146045. * @returns the class name
  146046. */
  146047. getClassName(): string;
  146048. /**
  146049. * Gets the xy component
  146050. */
  146051. get xy(): NodeMaterialConnectionPoint;
  146052. /**
  146053. * Gets the x component
  146054. */
  146055. get x(): NodeMaterialConnectionPoint;
  146056. /**
  146057. * Gets the y component
  146058. */
  146059. get y(): NodeMaterialConnectionPoint;
  146060. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146061. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  146062. protected _buildBlock(state: NodeMaterialBuildState): this;
  146063. }
  146064. }
  146065. declare module BABYLON {
  146066. /**
  146067. * Block used to add support for scene fog
  146068. */
  146069. export class FogBlock extends NodeMaterialBlock {
  146070. private _fogDistanceName;
  146071. private _fogParameters;
  146072. /**
  146073. * Create a new FogBlock
  146074. * @param name defines the block name
  146075. */
  146076. constructor(name: string);
  146077. /**
  146078. * Gets the current class name
  146079. * @returns the class name
  146080. */
  146081. getClassName(): string;
  146082. /**
  146083. * Gets the world position input component
  146084. */
  146085. get worldPosition(): NodeMaterialConnectionPoint;
  146086. /**
  146087. * Gets the view input component
  146088. */
  146089. get view(): NodeMaterialConnectionPoint;
  146090. /**
  146091. * Gets the color input component
  146092. */
  146093. get input(): NodeMaterialConnectionPoint;
  146094. /**
  146095. * Gets the fog color input component
  146096. */
  146097. get fogColor(): NodeMaterialConnectionPoint;
  146098. /**
  146099. * Gets the output component
  146100. */
  146101. get output(): NodeMaterialConnectionPoint;
  146102. autoConfigure(material: NodeMaterial): void;
  146103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146104. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146105. protected _buildBlock(state: NodeMaterialBuildState): this;
  146106. }
  146107. }
  146108. declare module BABYLON {
  146109. /**
  146110. * Block used to add light in the fragment shader
  146111. */
  146112. export class LightBlock extends NodeMaterialBlock {
  146113. private _lightId;
  146114. /**
  146115. * Gets or sets the light associated with this block
  146116. */
  146117. light: Nullable<Light>;
  146118. /**
  146119. * Create a new LightBlock
  146120. * @param name defines the block name
  146121. */
  146122. constructor(name: string);
  146123. /**
  146124. * Gets the current class name
  146125. * @returns the class name
  146126. */
  146127. getClassName(): string;
  146128. /**
  146129. * Gets the world position input component
  146130. */
  146131. get worldPosition(): NodeMaterialConnectionPoint;
  146132. /**
  146133. * Gets the world normal input component
  146134. */
  146135. get worldNormal(): NodeMaterialConnectionPoint;
  146136. /**
  146137. * Gets the camera (or eye) position component
  146138. */
  146139. get cameraPosition(): NodeMaterialConnectionPoint;
  146140. /**
  146141. * Gets the glossiness component
  146142. */
  146143. get glossiness(): NodeMaterialConnectionPoint;
  146144. /**
  146145. * Gets the glossinness power component
  146146. */
  146147. get glossPower(): NodeMaterialConnectionPoint;
  146148. /**
  146149. * Gets the diffuse color component
  146150. */
  146151. get diffuseColor(): NodeMaterialConnectionPoint;
  146152. /**
  146153. * Gets the specular color component
  146154. */
  146155. get specularColor(): NodeMaterialConnectionPoint;
  146156. /**
  146157. * Gets the view matrix component
  146158. */
  146159. get view(): NodeMaterialConnectionPoint;
  146160. /**
  146161. * Gets the diffuse output component
  146162. */
  146163. get diffuseOutput(): NodeMaterialConnectionPoint;
  146164. /**
  146165. * Gets the specular output component
  146166. */
  146167. get specularOutput(): NodeMaterialConnectionPoint;
  146168. /**
  146169. * Gets the shadow output component
  146170. */
  146171. get shadow(): NodeMaterialConnectionPoint;
  146172. autoConfigure(material: NodeMaterial): void;
  146173. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146174. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146176. private _injectVertexCode;
  146177. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146178. serialize(): any;
  146179. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146180. }
  146181. }
  146182. declare module BABYLON {
  146183. /**
  146184. * Block used to read a reflection texture from a sampler
  146185. */
  146186. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  146187. /**
  146188. * Create a new ReflectionTextureBlock
  146189. * @param name defines the block name
  146190. */
  146191. constructor(name: string);
  146192. /**
  146193. * Gets the current class name
  146194. * @returns the class name
  146195. */
  146196. getClassName(): string;
  146197. /**
  146198. * Gets the world position input component
  146199. */
  146200. get position(): NodeMaterialConnectionPoint;
  146201. /**
  146202. * Gets the world position input component
  146203. */
  146204. get worldPosition(): NodeMaterialConnectionPoint;
  146205. /**
  146206. * Gets the world normal input component
  146207. */
  146208. get worldNormal(): NodeMaterialConnectionPoint;
  146209. /**
  146210. * Gets the world input component
  146211. */
  146212. get world(): NodeMaterialConnectionPoint;
  146213. /**
  146214. * Gets the camera (or eye) position component
  146215. */
  146216. get cameraPosition(): NodeMaterialConnectionPoint;
  146217. /**
  146218. * Gets the view input component
  146219. */
  146220. get view(): NodeMaterialConnectionPoint;
  146221. /**
  146222. * Gets the rgb output component
  146223. */
  146224. get rgb(): NodeMaterialConnectionPoint;
  146225. /**
  146226. * Gets the rgba output component
  146227. */
  146228. get rgba(): NodeMaterialConnectionPoint;
  146229. /**
  146230. * Gets the r output component
  146231. */
  146232. get r(): NodeMaterialConnectionPoint;
  146233. /**
  146234. * Gets the g output component
  146235. */
  146236. get g(): NodeMaterialConnectionPoint;
  146237. /**
  146238. * Gets the b output component
  146239. */
  146240. get b(): NodeMaterialConnectionPoint;
  146241. /**
  146242. * Gets the a output component
  146243. */
  146244. get a(): NodeMaterialConnectionPoint;
  146245. autoConfigure(material: NodeMaterial): void;
  146246. protected _buildBlock(state: NodeMaterialBuildState): this;
  146247. }
  146248. }
  146249. declare module BABYLON {
  146250. /**
  146251. * Block used to add 2 vectors
  146252. */
  146253. export class AddBlock extends NodeMaterialBlock {
  146254. /**
  146255. * Creates a new AddBlock
  146256. * @param name defines the block name
  146257. */
  146258. constructor(name: string);
  146259. /**
  146260. * Gets the current class name
  146261. * @returns the class name
  146262. */
  146263. getClassName(): string;
  146264. /**
  146265. * Gets the left operand input component
  146266. */
  146267. get left(): NodeMaterialConnectionPoint;
  146268. /**
  146269. * Gets the right operand input component
  146270. */
  146271. get right(): NodeMaterialConnectionPoint;
  146272. /**
  146273. * Gets the output component
  146274. */
  146275. get output(): NodeMaterialConnectionPoint;
  146276. protected _buildBlock(state: NodeMaterialBuildState): this;
  146277. }
  146278. }
  146279. declare module BABYLON {
  146280. /**
  146281. * Block used to scale a vector by a float
  146282. */
  146283. export class ScaleBlock extends NodeMaterialBlock {
  146284. /**
  146285. * Creates a new ScaleBlock
  146286. * @param name defines the block name
  146287. */
  146288. constructor(name: string);
  146289. /**
  146290. * Gets the current class name
  146291. * @returns the class name
  146292. */
  146293. getClassName(): string;
  146294. /**
  146295. * Gets the input component
  146296. */
  146297. get input(): NodeMaterialConnectionPoint;
  146298. /**
  146299. * Gets the factor input component
  146300. */
  146301. get factor(): NodeMaterialConnectionPoint;
  146302. /**
  146303. * Gets the output component
  146304. */
  146305. get output(): NodeMaterialConnectionPoint;
  146306. protected _buildBlock(state: NodeMaterialBuildState): this;
  146307. }
  146308. }
  146309. declare module BABYLON {
  146310. /**
  146311. * Block used to clamp a float
  146312. */
  146313. export class ClampBlock extends NodeMaterialBlock {
  146314. /** Gets or sets the minimum range */
  146315. minimum: number;
  146316. /** Gets or sets the maximum range */
  146317. maximum: number;
  146318. /**
  146319. * Creates a new ClampBlock
  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 input component
  146330. */
  146331. get value(): NodeMaterialConnectionPoint;
  146332. /**
  146333. * Gets the output component
  146334. */
  146335. get output(): NodeMaterialConnectionPoint;
  146336. protected _buildBlock(state: NodeMaterialBuildState): this;
  146337. protected _dumpPropertiesCode(): string;
  146338. serialize(): any;
  146339. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146340. }
  146341. }
  146342. declare module BABYLON {
  146343. /**
  146344. * Block used to apply a cross product between 2 vectors
  146345. */
  146346. export class CrossBlock extends NodeMaterialBlock {
  146347. /**
  146348. * Creates a new CrossBlock
  146349. * @param name defines the block name
  146350. */
  146351. constructor(name: string);
  146352. /**
  146353. * Gets the current class name
  146354. * @returns the class name
  146355. */
  146356. getClassName(): string;
  146357. /**
  146358. * Gets the left operand input component
  146359. */
  146360. get left(): NodeMaterialConnectionPoint;
  146361. /**
  146362. * Gets the right operand input component
  146363. */
  146364. get right(): NodeMaterialConnectionPoint;
  146365. /**
  146366. * Gets the output component
  146367. */
  146368. get output(): NodeMaterialConnectionPoint;
  146369. protected _buildBlock(state: NodeMaterialBuildState): this;
  146370. }
  146371. }
  146372. declare module BABYLON {
  146373. /**
  146374. * Block used to apply a dot product between 2 vectors
  146375. */
  146376. export class DotBlock extends NodeMaterialBlock {
  146377. /**
  146378. * Creates a new DotBlock
  146379. * @param name defines the block name
  146380. */
  146381. constructor(name: string);
  146382. /**
  146383. * Gets the current class name
  146384. * @returns the class name
  146385. */
  146386. getClassName(): string;
  146387. /**
  146388. * Gets the left operand input component
  146389. */
  146390. get left(): NodeMaterialConnectionPoint;
  146391. /**
  146392. * Gets the right operand input component
  146393. */
  146394. get right(): NodeMaterialConnectionPoint;
  146395. /**
  146396. * Gets the output component
  146397. */
  146398. get output(): NodeMaterialConnectionPoint;
  146399. protected _buildBlock(state: NodeMaterialBuildState): this;
  146400. }
  146401. }
  146402. declare module BABYLON {
  146403. /**
  146404. * Block used to normalize a vector
  146405. */
  146406. export class NormalizeBlock extends NodeMaterialBlock {
  146407. /**
  146408. * Creates a new NormalizeBlock
  146409. * @param name defines the block name
  146410. */
  146411. constructor(name: string);
  146412. /**
  146413. * Gets the current class name
  146414. * @returns the class name
  146415. */
  146416. getClassName(): string;
  146417. /**
  146418. * Gets the input component
  146419. */
  146420. get input(): NodeMaterialConnectionPoint;
  146421. /**
  146422. * Gets the output component
  146423. */
  146424. get output(): NodeMaterialConnectionPoint;
  146425. protected _buildBlock(state: NodeMaterialBuildState): this;
  146426. }
  146427. }
  146428. declare module BABYLON {
  146429. /**
  146430. * Block used to create a Color3/4 out of individual inputs (one for each component)
  146431. */
  146432. export class ColorMergerBlock extends NodeMaterialBlock {
  146433. /**
  146434. * Create a new ColorMergerBlock
  146435. * @param name defines the block name
  146436. */
  146437. constructor(name: string);
  146438. /**
  146439. * Gets the current class name
  146440. * @returns the class name
  146441. */
  146442. getClassName(): string;
  146443. /**
  146444. * Gets the rgb component (input)
  146445. */
  146446. get rgbIn(): NodeMaterialConnectionPoint;
  146447. /**
  146448. * Gets the r component (input)
  146449. */
  146450. get r(): NodeMaterialConnectionPoint;
  146451. /**
  146452. * Gets the g component (input)
  146453. */
  146454. get g(): NodeMaterialConnectionPoint;
  146455. /**
  146456. * Gets the b component (input)
  146457. */
  146458. get b(): NodeMaterialConnectionPoint;
  146459. /**
  146460. * Gets the a component (input)
  146461. */
  146462. get a(): NodeMaterialConnectionPoint;
  146463. /**
  146464. * Gets the rgba component (output)
  146465. */
  146466. get rgba(): NodeMaterialConnectionPoint;
  146467. /**
  146468. * Gets the rgb component (output)
  146469. */
  146470. get rgbOut(): NodeMaterialConnectionPoint;
  146471. /**
  146472. * Gets the rgb component (output)
  146473. * @deprecated Please use rgbOut instead.
  146474. */
  146475. get rgb(): NodeMaterialConnectionPoint;
  146476. protected _buildBlock(state: NodeMaterialBuildState): this;
  146477. }
  146478. }
  146479. declare module BABYLON {
  146480. /**
  146481. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  146482. */
  146483. export class VectorSplitterBlock extends NodeMaterialBlock {
  146484. /**
  146485. * Create a new VectorSplitterBlock
  146486. * @param name defines the block name
  146487. */
  146488. constructor(name: string);
  146489. /**
  146490. * Gets the current class name
  146491. * @returns the class name
  146492. */
  146493. getClassName(): string;
  146494. /**
  146495. * Gets the xyzw component (input)
  146496. */
  146497. get xyzw(): NodeMaterialConnectionPoint;
  146498. /**
  146499. * Gets the xyz component (input)
  146500. */
  146501. get xyzIn(): NodeMaterialConnectionPoint;
  146502. /**
  146503. * Gets the xy component (input)
  146504. */
  146505. get xyIn(): NodeMaterialConnectionPoint;
  146506. /**
  146507. * Gets the xyz component (output)
  146508. */
  146509. get xyzOut(): NodeMaterialConnectionPoint;
  146510. /**
  146511. * Gets the xy component (output)
  146512. */
  146513. get xyOut(): NodeMaterialConnectionPoint;
  146514. /**
  146515. * Gets the x component (output)
  146516. */
  146517. get x(): NodeMaterialConnectionPoint;
  146518. /**
  146519. * Gets the y component (output)
  146520. */
  146521. get y(): NodeMaterialConnectionPoint;
  146522. /**
  146523. * Gets the z component (output)
  146524. */
  146525. get z(): NodeMaterialConnectionPoint;
  146526. /**
  146527. * Gets the w component (output)
  146528. */
  146529. get w(): NodeMaterialConnectionPoint;
  146530. protected _inputRename(name: string): string;
  146531. protected _outputRename(name: string): string;
  146532. protected _buildBlock(state: NodeMaterialBuildState): this;
  146533. }
  146534. }
  146535. declare module BABYLON {
  146536. /**
  146537. * Block used to lerp between 2 values
  146538. */
  146539. export class LerpBlock extends NodeMaterialBlock {
  146540. /**
  146541. * Creates a new LerpBlock
  146542. * @param name defines the block name
  146543. */
  146544. constructor(name: string);
  146545. /**
  146546. * Gets the current class name
  146547. * @returns the class name
  146548. */
  146549. getClassName(): string;
  146550. /**
  146551. * Gets the left operand input component
  146552. */
  146553. get left(): NodeMaterialConnectionPoint;
  146554. /**
  146555. * Gets the right operand input component
  146556. */
  146557. get right(): NodeMaterialConnectionPoint;
  146558. /**
  146559. * Gets the gradient operand input component
  146560. */
  146561. get gradient(): NodeMaterialConnectionPoint;
  146562. /**
  146563. * Gets the output component
  146564. */
  146565. get output(): NodeMaterialConnectionPoint;
  146566. protected _buildBlock(state: NodeMaterialBuildState): this;
  146567. }
  146568. }
  146569. declare module BABYLON {
  146570. /**
  146571. * Block used to divide 2 vectors
  146572. */
  146573. export class DivideBlock extends NodeMaterialBlock {
  146574. /**
  146575. * Creates a new DivideBlock
  146576. * @param name defines the block name
  146577. */
  146578. constructor(name: string);
  146579. /**
  146580. * Gets the current class name
  146581. * @returns the class name
  146582. */
  146583. getClassName(): string;
  146584. /**
  146585. * Gets the left operand input component
  146586. */
  146587. get left(): NodeMaterialConnectionPoint;
  146588. /**
  146589. * Gets the right operand input component
  146590. */
  146591. get right(): NodeMaterialConnectionPoint;
  146592. /**
  146593. * Gets the output component
  146594. */
  146595. get output(): NodeMaterialConnectionPoint;
  146596. protected _buildBlock(state: NodeMaterialBuildState): this;
  146597. }
  146598. }
  146599. declare module BABYLON {
  146600. /**
  146601. * Block used to subtract 2 vectors
  146602. */
  146603. export class SubtractBlock extends NodeMaterialBlock {
  146604. /**
  146605. * Creates a new SubtractBlock
  146606. * @param name defines the block name
  146607. */
  146608. constructor(name: string);
  146609. /**
  146610. * Gets the current class name
  146611. * @returns the class name
  146612. */
  146613. getClassName(): string;
  146614. /**
  146615. * Gets the left operand input component
  146616. */
  146617. get left(): NodeMaterialConnectionPoint;
  146618. /**
  146619. * Gets the right operand input component
  146620. */
  146621. get right(): NodeMaterialConnectionPoint;
  146622. /**
  146623. * Gets the output component
  146624. */
  146625. get output(): NodeMaterialConnectionPoint;
  146626. protected _buildBlock(state: NodeMaterialBuildState): this;
  146627. }
  146628. }
  146629. declare module BABYLON {
  146630. /**
  146631. * Block used to step a value
  146632. */
  146633. export class StepBlock extends NodeMaterialBlock {
  146634. /**
  146635. * Creates a new StepBlock
  146636. * @param name defines the block name
  146637. */
  146638. constructor(name: string);
  146639. /**
  146640. * Gets the current class name
  146641. * @returns the class name
  146642. */
  146643. getClassName(): string;
  146644. /**
  146645. * Gets the value operand input component
  146646. */
  146647. get value(): NodeMaterialConnectionPoint;
  146648. /**
  146649. * Gets the edge operand input component
  146650. */
  146651. get edge(): NodeMaterialConnectionPoint;
  146652. /**
  146653. * Gets the output component
  146654. */
  146655. get output(): NodeMaterialConnectionPoint;
  146656. protected _buildBlock(state: NodeMaterialBuildState): this;
  146657. }
  146658. }
  146659. declare module BABYLON {
  146660. /**
  146661. * Block used to get the opposite (1 - x) of a value
  146662. */
  146663. export class OneMinusBlock extends NodeMaterialBlock {
  146664. /**
  146665. * Creates a new OneMinusBlock
  146666. * @param name defines the block name
  146667. */
  146668. constructor(name: string);
  146669. /**
  146670. * Gets the current class name
  146671. * @returns the class name
  146672. */
  146673. getClassName(): string;
  146674. /**
  146675. * Gets the input component
  146676. */
  146677. get input(): NodeMaterialConnectionPoint;
  146678. /**
  146679. * Gets the output component
  146680. */
  146681. get output(): NodeMaterialConnectionPoint;
  146682. protected _buildBlock(state: NodeMaterialBuildState): this;
  146683. }
  146684. }
  146685. declare module BABYLON {
  146686. /**
  146687. * Block used to get the view direction
  146688. */
  146689. export class ViewDirectionBlock extends NodeMaterialBlock {
  146690. /**
  146691. * Creates a new ViewDirectionBlock
  146692. * @param name defines the block name
  146693. */
  146694. constructor(name: string);
  146695. /**
  146696. * Gets the current class name
  146697. * @returns the class name
  146698. */
  146699. getClassName(): string;
  146700. /**
  146701. * Gets the world position component
  146702. */
  146703. get worldPosition(): NodeMaterialConnectionPoint;
  146704. /**
  146705. * Gets the camera position component
  146706. */
  146707. get cameraPosition(): NodeMaterialConnectionPoint;
  146708. /**
  146709. * Gets the output component
  146710. */
  146711. get output(): NodeMaterialConnectionPoint;
  146712. autoConfigure(material: NodeMaterial): void;
  146713. protected _buildBlock(state: NodeMaterialBuildState): this;
  146714. }
  146715. }
  146716. declare module BABYLON {
  146717. /**
  146718. * Block used to compute fresnel value
  146719. */
  146720. export class FresnelBlock extends NodeMaterialBlock {
  146721. /**
  146722. * Create a new FresnelBlock
  146723. * @param name defines the block name
  146724. */
  146725. constructor(name: string);
  146726. /**
  146727. * Gets the current class name
  146728. * @returns the class name
  146729. */
  146730. getClassName(): string;
  146731. /**
  146732. * Gets the world normal input component
  146733. */
  146734. get worldNormal(): NodeMaterialConnectionPoint;
  146735. /**
  146736. * Gets the view direction input component
  146737. */
  146738. get viewDirection(): NodeMaterialConnectionPoint;
  146739. /**
  146740. * Gets the bias input component
  146741. */
  146742. get bias(): NodeMaterialConnectionPoint;
  146743. /**
  146744. * Gets the camera (or eye) position component
  146745. */
  146746. get power(): NodeMaterialConnectionPoint;
  146747. /**
  146748. * Gets the fresnel output component
  146749. */
  146750. get fresnel(): NodeMaterialConnectionPoint;
  146751. autoConfigure(material: NodeMaterial): void;
  146752. protected _buildBlock(state: NodeMaterialBuildState): this;
  146753. }
  146754. }
  146755. declare module BABYLON {
  146756. /**
  146757. * Block used to get the max of 2 values
  146758. */
  146759. export class MaxBlock extends NodeMaterialBlock {
  146760. /**
  146761. * Creates a new MaxBlock
  146762. * @param name defines the block name
  146763. */
  146764. constructor(name: string);
  146765. /**
  146766. * Gets the current class name
  146767. * @returns the class name
  146768. */
  146769. getClassName(): string;
  146770. /**
  146771. * Gets the left operand input component
  146772. */
  146773. get left(): NodeMaterialConnectionPoint;
  146774. /**
  146775. * Gets the right operand input component
  146776. */
  146777. get right(): NodeMaterialConnectionPoint;
  146778. /**
  146779. * Gets the output component
  146780. */
  146781. get output(): NodeMaterialConnectionPoint;
  146782. protected _buildBlock(state: NodeMaterialBuildState): this;
  146783. }
  146784. }
  146785. declare module BABYLON {
  146786. /**
  146787. * Block used to get the min of 2 values
  146788. */
  146789. export class MinBlock extends NodeMaterialBlock {
  146790. /**
  146791. * Creates a new MinBlock
  146792. * @param name defines the block name
  146793. */
  146794. constructor(name: string);
  146795. /**
  146796. * Gets the current class name
  146797. * @returns the class name
  146798. */
  146799. getClassName(): string;
  146800. /**
  146801. * Gets the left operand input component
  146802. */
  146803. get left(): NodeMaterialConnectionPoint;
  146804. /**
  146805. * Gets the right operand input component
  146806. */
  146807. get right(): NodeMaterialConnectionPoint;
  146808. /**
  146809. * Gets the output component
  146810. */
  146811. get output(): NodeMaterialConnectionPoint;
  146812. protected _buildBlock(state: NodeMaterialBuildState): this;
  146813. }
  146814. }
  146815. declare module BABYLON {
  146816. /**
  146817. * Block used to get the distance between 2 values
  146818. */
  146819. export class DistanceBlock extends NodeMaterialBlock {
  146820. /**
  146821. * Creates a new DistanceBlock
  146822. * @param name defines the block name
  146823. */
  146824. constructor(name: string);
  146825. /**
  146826. * Gets the current class name
  146827. * @returns the class name
  146828. */
  146829. getClassName(): string;
  146830. /**
  146831. * Gets the left operand input component
  146832. */
  146833. get left(): NodeMaterialConnectionPoint;
  146834. /**
  146835. * Gets the right operand input component
  146836. */
  146837. get right(): NodeMaterialConnectionPoint;
  146838. /**
  146839. * Gets the output component
  146840. */
  146841. get output(): NodeMaterialConnectionPoint;
  146842. protected _buildBlock(state: NodeMaterialBuildState): this;
  146843. }
  146844. }
  146845. declare module BABYLON {
  146846. /**
  146847. * Block used to get the length of a vector
  146848. */
  146849. export class LengthBlock extends NodeMaterialBlock {
  146850. /**
  146851. * Creates a new LengthBlock
  146852. * @param name defines the block name
  146853. */
  146854. constructor(name: string);
  146855. /**
  146856. * Gets the current class name
  146857. * @returns the class name
  146858. */
  146859. getClassName(): string;
  146860. /**
  146861. * Gets the value input component
  146862. */
  146863. get value(): NodeMaterialConnectionPoint;
  146864. /**
  146865. * Gets the output component
  146866. */
  146867. get output(): NodeMaterialConnectionPoint;
  146868. protected _buildBlock(state: NodeMaterialBuildState): this;
  146869. }
  146870. }
  146871. declare module BABYLON {
  146872. /**
  146873. * Block used to get negative version of a value (i.e. x * -1)
  146874. */
  146875. export class NegateBlock extends NodeMaterialBlock {
  146876. /**
  146877. * Creates a new NegateBlock
  146878. * @param name defines the block name
  146879. */
  146880. constructor(name: string);
  146881. /**
  146882. * Gets the current class name
  146883. * @returns the class name
  146884. */
  146885. getClassName(): string;
  146886. /**
  146887. * Gets the value input component
  146888. */
  146889. get value(): NodeMaterialConnectionPoint;
  146890. /**
  146891. * Gets the output component
  146892. */
  146893. get output(): NodeMaterialConnectionPoint;
  146894. protected _buildBlock(state: NodeMaterialBuildState): this;
  146895. }
  146896. }
  146897. declare module BABYLON {
  146898. /**
  146899. * Block used to get the value of the first parameter raised to the power of the second
  146900. */
  146901. export class PowBlock extends NodeMaterialBlock {
  146902. /**
  146903. * Creates a new PowBlock
  146904. * @param name defines the block name
  146905. */
  146906. constructor(name: string);
  146907. /**
  146908. * Gets the current class name
  146909. * @returns the class name
  146910. */
  146911. getClassName(): string;
  146912. /**
  146913. * Gets the value operand input component
  146914. */
  146915. get value(): NodeMaterialConnectionPoint;
  146916. /**
  146917. * Gets the power operand input component
  146918. */
  146919. get power(): NodeMaterialConnectionPoint;
  146920. /**
  146921. * Gets the output component
  146922. */
  146923. get output(): NodeMaterialConnectionPoint;
  146924. protected _buildBlock(state: NodeMaterialBuildState): this;
  146925. }
  146926. }
  146927. declare module BABYLON {
  146928. /**
  146929. * Block used to get a random number
  146930. */
  146931. export class RandomNumberBlock extends NodeMaterialBlock {
  146932. /**
  146933. * Creates a new RandomNumberBlock
  146934. * @param name defines the block name
  146935. */
  146936. constructor(name: string);
  146937. /**
  146938. * Gets the current class name
  146939. * @returns the class name
  146940. */
  146941. getClassName(): string;
  146942. /**
  146943. * Gets the seed input component
  146944. */
  146945. get seed(): NodeMaterialConnectionPoint;
  146946. /**
  146947. * Gets the output component
  146948. */
  146949. get output(): NodeMaterialConnectionPoint;
  146950. protected _buildBlock(state: NodeMaterialBuildState): this;
  146951. }
  146952. }
  146953. declare module BABYLON {
  146954. /**
  146955. * Block used to compute arc tangent of 2 values
  146956. */
  146957. export class ArcTan2Block extends NodeMaterialBlock {
  146958. /**
  146959. * Creates a new ArcTan2Block
  146960. * @param name defines the block name
  146961. */
  146962. constructor(name: string);
  146963. /**
  146964. * Gets the current class name
  146965. * @returns the class name
  146966. */
  146967. getClassName(): string;
  146968. /**
  146969. * Gets the x operand input component
  146970. */
  146971. get x(): NodeMaterialConnectionPoint;
  146972. /**
  146973. * Gets the y operand input component
  146974. */
  146975. get y(): NodeMaterialConnectionPoint;
  146976. /**
  146977. * Gets the output component
  146978. */
  146979. get output(): NodeMaterialConnectionPoint;
  146980. protected _buildBlock(state: NodeMaterialBuildState): this;
  146981. }
  146982. }
  146983. declare module BABYLON {
  146984. /**
  146985. * Block used to smooth step a value
  146986. */
  146987. export class SmoothStepBlock extends NodeMaterialBlock {
  146988. /**
  146989. * Creates a new SmoothStepBlock
  146990. * @param name defines the block name
  146991. */
  146992. constructor(name: string);
  146993. /**
  146994. * Gets the current class name
  146995. * @returns the class name
  146996. */
  146997. getClassName(): string;
  146998. /**
  146999. * Gets the value operand input component
  147000. */
  147001. get value(): NodeMaterialConnectionPoint;
  147002. /**
  147003. * Gets the first edge operand input component
  147004. */
  147005. get edge0(): NodeMaterialConnectionPoint;
  147006. /**
  147007. * Gets the second edge operand input component
  147008. */
  147009. get edge1(): NodeMaterialConnectionPoint;
  147010. /**
  147011. * Gets the output component
  147012. */
  147013. get output(): NodeMaterialConnectionPoint;
  147014. protected _buildBlock(state: NodeMaterialBuildState): this;
  147015. }
  147016. }
  147017. declare module BABYLON {
  147018. /**
  147019. * Block used to get the reciprocal (1 / x) of a value
  147020. */
  147021. export class ReciprocalBlock extends NodeMaterialBlock {
  147022. /**
  147023. * Creates a new ReciprocalBlock
  147024. * @param name defines the block name
  147025. */
  147026. constructor(name: string);
  147027. /**
  147028. * Gets the current class name
  147029. * @returns the class name
  147030. */
  147031. getClassName(): string;
  147032. /**
  147033. * Gets the input component
  147034. */
  147035. get input(): NodeMaterialConnectionPoint;
  147036. /**
  147037. * Gets the output component
  147038. */
  147039. get output(): NodeMaterialConnectionPoint;
  147040. protected _buildBlock(state: NodeMaterialBuildState): this;
  147041. }
  147042. }
  147043. declare module BABYLON {
  147044. /**
  147045. * Block used to replace a color by another one
  147046. */
  147047. export class ReplaceColorBlock extends NodeMaterialBlock {
  147048. /**
  147049. * Creates a new ReplaceColorBlock
  147050. * @param name defines the block name
  147051. */
  147052. constructor(name: string);
  147053. /**
  147054. * Gets the current class name
  147055. * @returns the class name
  147056. */
  147057. getClassName(): string;
  147058. /**
  147059. * Gets the value input component
  147060. */
  147061. get value(): NodeMaterialConnectionPoint;
  147062. /**
  147063. * Gets the reference input component
  147064. */
  147065. get reference(): NodeMaterialConnectionPoint;
  147066. /**
  147067. * Gets the distance input component
  147068. */
  147069. get distance(): NodeMaterialConnectionPoint;
  147070. /**
  147071. * Gets the replacement input component
  147072. */
  147073. get replacement(): NodeMaterialConnectionPoint;
  147074. /**
  147075. * Gets the output component
  147076. */
  147077. get output(): NodeMaterialConnectionPoint;
  147078. protected _buildBlock(state: NodeMaterialBuildState): this;
  147079. }
  147080. }
  147081. declare module BABYLON {
  147082. /**
  147083. * Block used to posterize a value
  147084. * @see https://en.wikipedia.org/wiki/Posterization
  147085. */
  147086. export class PosterizeBlock extends NodeMaterialBlock {
  147087. /**
  147088. * Creates a new PosterizeBlock
  147089. * @param name defines the block name
  147090. */
  147091. constructor(name: string);
  147092. /**
  147093. * Gets the current class name
  147094. * @returns the class name
  147095. */
  147096. getClassName(): string;
  147097. /**
  147098. * Gets the value input component
  147099. */
  147100. get value(): NodeMaterialConnectionPoint;
  147101. /**
  147102. * Gets the steps input component
  147103. */
  147104. get steps(): NodeMaterialConnectionPoint;
  147105. /**
  147106. * Gets the output component
  147107. */
  147108. get output(): NodeMaterialConnectionPoint;
  147109. protected _buildBlock(state: NodeMaterialBuildState): this;
  147110. }
  147111. }
  147112. declare module BABYLON {
  147113. /**
  147114. * Operations supported by the Wave block
  147115. */
  147116. export enum WaveBlockKind {
  147117. /** SawTooth */
  147118. SawTooth = 0,
  147119. /** Square */
  147120. Square = 1,
  147121. /** Triangle */
  147122. Triangle = 2
  147123. }
  147124. /**
  147125. * Block used to apply wave operation to floats
  147126. */
  147127. export class WaveBlock extends NodeMaterialBlock {
  147128. /**
  147129. * Gets or sets the kibnd of wave to be applied by the block
  147130. */
  147131. kind: WaveBlockKind;
  147132. /**
  147133. * Creates a new WaveBlock
  147134. * @param name defines the block name
  147135. */
  147136. constructor(name: string);
  147137. /**
  147138. * Gets the current class name
  147139. * @returns the class name
  147140. */
  147141. getClassName(): string;
  147142. /**
  147143. * Gets the input component
  147144. */
  147145. get input(): NodeMaterialConnectionPoint;
  147146. /**
  147147. * Gets the output component
  147148. */
  147149. get output(): NodeMaterialConnectionPoint;
  147150. protected _buildBlock(state: NodeMaterialBuildState): this;
  147151. serialize(): any;
  147152. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147153. }
  147154. }
  147155. declare module BABYLON {
  147156. /**
  147157. * Class used to store a color step for the GradientBlock
  147158. */
  147159. export class GradientBlockColorStep {
  147160. private _step;
  147161. /**
  147162. * Gets value indicating which step this color is associated with (between 0 and 1)
  147163. */
  147164. get step(): number;
  147165. /**
  147166. * Sets a value indicating which step this color is associated with (between 0 and 1)
  147167. */
  147168. set step(val: number);
  147169. private _color;
  147170. /**
  147171. * Gets the color associated with this step
  147172. */
  147173. get color(): Color3;
  147174. /**
  147175. * Sets the color associated with this step
  147176. */
  147177. set color(val: Color3);
  147178. /**
  147179. * Creates a new GradientBlockColorStep
  147180. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  147181. * @param color defines the color associated with this step
  147182. */
  147183. constructor(step: number, color: Color3);
  147184. }
  147185. /**
  147186. * Block used to return a color from a gradient based on an input value between 0 and 1
  147187. */
  147188. export class GradientBlock extends NodeMaterialBlock {
  147189. /**
  147190. * Gets or sets the list of color steps
  147191. */
  147192. colorSteps: GradientBlockColorStep[];
  147193. /** Gets an observable raised when the value is changed */
  147194. onValueChangedObservable: Observable<GradientBlock>;
  147195. /** calls observable when the value is changed*/
  147196. colorStepsUpdated(): void;
  147197. /**
  147198. * Creates a new GradientBlock
  147199. * @param name defines the block name
  147200. */
  147201. constructor(name: string);
  147202. /**
  147203. * Gets the current class name
  147204. * @returns the class name
  147205. */
  147206. getClassName(): string;
  147207. /**
  147208. * Gets the gradient input component
  147209. */
  147210. get gradient(): NodeMaterialConnectionPoint;
  147211. /**
  147212. * Gets the output component
  147213. */
  147214. get output(): NodeMaterialConnectionPoint;
  147215. private _writeColorConstant;
  147216. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147217. serialize(): any;
  147218. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147219. protected _dumpPropertiesCode(): string;
  147220. }
  147221. }
  147222. declare module BABYLON {
  147223. /**
  147224. * Block used to normalize lerp between 2 values
  147225. */
  147226. export class NLerpBlock extends NodeMaterialBlock {
  147227. /**
  147228. * Creates a new NLerpBlock
  147229. * @param name defines the block name
  147230. */
  147231. constructor(name: string);
  147232. /**
  147233. * Gets the current class name
  147234. * @returns the class name
  147235. */
  147236. getClassName(): string;
  147237. /**
  147238. * Gets the left operand input component
  147239. */
  147240. get left(): NodeMaterialConnectionPoint;
  147241. /**
  147242. * Gets the right operand input component
  147243. */
  147244. get right(): NodeMaterialConnectionPoint;
  147245. /**
  147246. * Gets the gradient operand input component
  147247. */
  147248. get gradient(): NodeMaterialConnectionPoint;
  147249. /**
  147250. * Gets the output component
  147251. */
  147252. get output(): NodeMaterialConnectionPoint;
  147253. protected _buildBlock(state: NodeMaterialBuildState): this;
  147254. }
  147255. }
  147256. declare module BABYLON {
  147257. /**
  147258. * block used to Generate a Worley Noise 3D Noise Pattern
  147259. */
  147260. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  147261. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  147262. manhattanDistance: boolean;
  147263. /**
  147264. * Creates a new WorleyNoise3DBlock
  147265. * @param name defines the block name
  147266. */
  147267. constructor(name: string);
  147268. /**
  147269. * Gets the current class name
  147270. * @returns the class name
  147271. */
  147272. getClassName(): string;
  147273. /**
  147274. * Gets the seed input component
  147275. */
  147276. get seed(): NodeMaterialConnectionPoint;
  147277. /**
  147278. * Gets the jitter input component
  147279. */
  147280. get jitter(): NodeMaterialConnectionPoint;
  147281. /**
  147282. * Gets the output component
  147283. */
  147284. get output(): NodeMaterialConnectionPoint;
  147285. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147286. /**
  147287. * Exposes the properties to the UI?
  147288. */
  147289. protected _dumpPropertiesCode(): string;
  147290. /**
  147291. * Exposes the properties to the Seralize?
  147292. */
  147293. serialize(): any;
  147294. /**
  147295. * Exposes the properties to the deseralize?
  147296. */
  147297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147298. }
  147299. }
  147300. declare module BABYLON {
  147301. /**
  147302. * block used to Generate a Simplex Perlin 3d Noise Pattern
  147303. */
  147304. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  147305. /**
  147306. * Creates a new SimplexPerlin3DBlock
  147307. * @param name defines the block name
  147308. */
  147309. constructor(name: string);
  147310. /**
  147311. * Gets the current class name
  147312. * @returns the class name
  147313. */
  147314. getClassName(): string;
  147315. /**
  147316. * Gets the seed operand input component
  147317. */
  147318. get seed(): NodeMaterialConnectionPoint;
  147319. /**
  147320. * Gets the output component
  147321. */
  147322. get output(): NodeMaterialConnectionPoint;
  147323. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147324. }
  147325. }
  147326. declare module BABYLON {
  147327. /**
  147328. * Block used to blend normals
  147329. */
  147330. export class NormalBlendBlock extends NodeMaterialBlock {
  147331. /**
  147332. * Creates a new NormalBlendBlock
  147333. * @param name defines the block name
  147334. */
  147335. constructor(name: string);
  147336. /**
  147337. * Gets the current class name
  147338. * @returns the class name
  147339. */
  147340. getClassName(): string;
  147341. /**
  147342. * Gets the first input component
  147343. */
  147344. get normalMap0(): NodeMaterialConnectionPoint;
  147345. /**
  147346. * Gets the second input component
  147347. */
  147348. get normalMap1(): NodeMaterialConnectionPoint;
  147349. /**
  147350. * Gets the output component
  147351. */
  147352. get output(): NodeMaterialConnectionPoint;
  147353. protected _buildBlock(state: NodeMaterialBuildState): this;
  147354. }
  147355. }
  147356. declare module BABYLON {
  147357. /**
  147358. * Block used to rotate a 2d vector by a given angle
  147359. */
  147360. export class Rotate2dBlock extends NodeMaterialBlock {
  147361. /**
  147362. * Creates a new Rotate2dBlock
  147363. * @param name defines the block name
  147364. */
  147365. constructor(name: string);
  147366. /**
  147367. * Gets the current class name
  147368. * @returns the class name
  147369. */
  147370. getClassName(): string;
  147371. /**
  147372. * Gets the input vector
  147373. */
  147374. get input(): NodeMaterialConnectionPoint;
  147375. /**
  147376. * Gets the input angle
  147377. */
  147378. get angle(): NodeMaterialConnectionPoint;
  147379. /**
  147380. * Gets the output component
  147381. */
  147382. get output(): NodeMaterialConnectionPoint;
  147383. autoConfigure(material: NodeMaterial): void;
  147384. protected _buildBlock(state: NodeMaterialBuildState): this;
  147385. }
  147386. }
  147387. declare module BABYLON {
  147388. /**
  147389. * Block used to get the reflected vector from a direction and a normal
  147390. */
  147391. export class ReflectBlock extends NodeMaterialBlock {
  147392. /**
  147393. * Creates a new ReflectBlock
  147394. * @param name defines the block name
  147395. */
  147396. constructor(name: string);
  147397. /**
  147398. * Gets the current class name
  147399. * @returns the class name
  147400. */
  147401. getClassName(): string;
  147402. /**
  147403. * Gets the incident component
  147404. */
  147405. get incident(): NodeMaterialConnectionPoint;
  147406. /**
  147407. * Gets the normal component
  147408. */
  147409. get normal(): NodeMaterialConnectionPoint;
  147410. /**
  147411. * Gets the output component
  147412. */
  147413. get output(): NodeMaterialConnectionPoint;
  147414. protected _buildBlock(state: NodeMaterialBuildState): this;
  147415. }
  147416. }
  147417. declare module BABYLON {
  147418. /**
  147419. * Block used to get the refracted vector from a direction and a normal
  147420. */
  147421. export class RefractBlock extends NodeMaterialBlock {
  147422. /**
  147423. * Creates a new RefractBlock
  147424. * @param name defines the block name
  147425. */
  147426. constructor(name: string);
  147427. /**
  147428. * Gets the current class name
  147429. * @returns the class name
  147430. */
  147431. getClassName(): string;
  147432. /**
  147433. * Gets the incident component
  147434. */
  147435. get incident(): NodeMaterialConnectionPoint;
  147436. /**
  147437. * Gets the normal component
  147438. */
  147439. get normal(): NodeMaterialConnectionPoint;
  147440. /**
  147441. * Gets the index of refraction component
  147442. */
  147443. get ior(): NodeMaterialConnectionPoint;
  147444. /**
  147445. * Gets the output component
  147446. */
  147447. get output(): NodeMaterialConnectionPoint;
  147448. protected _buildBlock(state: NodeMaterialBuildState): this;
  147449. }
  147450. }
  147451. declare module BABYLON {
  147452. /**
  147453. * Block used to desaturate a color
  147454. */
  147455. export class DesaturateBlock extends NodeMaterialBlock {
  147456. /**
  147457. * Creates a new DesaturateBlock
  147458. * @param name defines the block name
  147459. */
  147460. constructor(name: string);
  147461. /**
  147462. * Gets the current class name
  147463. * @returns the class name
  147464. */
  147465. getClassName(): string;
  147466. /**
  147467. * Gets the color operand input component
  147468. */
  147469. get color(): NodeMaterialConnectionPoint;
  147470. /**
  147471. * Gets the level operand input component
  147472. */
  147473. get level(): NodeMaterialConnectionPoint;
  147474. /**
  147475. * Gets the output component
  147476. */
  147477. get output(): NodeMaterialConnectionPoint;
  147478. protected _buildBlock(state: NodeMaterialBuildState): this;
  147479. }
  147480. }
  147481. declare module BABYLON {
  147482. /**
  147483. * Block used to implement the reflection module of the PBR material
  147484. */
  147485. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  147486. /** @hidden */
  147487. _defineLODReflectionAlpha: string;
  147488. /** @hidden */
  147489. _defineLinearSpecularReflection: string;
  147490. private _vEnvironmentIrradianceName;
  147491. /** @hidden */
  147492. _vReflectionMicrosurfaceInfosName: string;
  147493. /** @hidden */
  147494. _vReflectionInfosName: string;
  147495. /** @hidden */
  147496. _vReflectionFilteringInfoName: string;
  147497. private _scene;
  147498. /**
  147499. * The properties below are set by the main PBR block prior to calling methods of this class.
  147500. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147501. * It's less burden on the user side in the editor part.
  147502. */
  147503. /** @hidden */
  147504. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147505. /** @hidden */
  147506. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147507. /** @hidden */
  147508. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  147509. /** @hidden */
  147510. viewConnectionPoint: NodeMaterialConnectionPoint;
  147511. /**
  147512. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  147513. * diffuse part of the IBL.
  147514. */
  147515. useSphericalHarmonics: boolean;
  147516. /**
  147517. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  147518. */
  147519. forceIrradianceInFragment: boolean;
  147520. /**
  147521. * Create a new ReflectionBlock
  147522. * @param name defines the block name
  147523. */
  147524. constructor(name: string);
  147525. /**
  147526. * Gets the current class name
  147527. * @returns the class name
  147528. */
  147529. getClassName(): string;
  147530. /**
  147531. * Gets the position input component
  147532. */
  147533. get position(): NodeMaterialConnectionPoint;
  147534. /**
  147535. * Gets the world position input component
  147536. */
  147537. get worldPosition(): NodeMaterialConnectionPoint;
  147538. /**
  147539. * Gets the world normal input component
  147540. */
  147541. get worldNormal(): NodeMaterialConnectionPoint;
  147542. /**
  147543. * Gets the world input component
  147544. */
  147545. get world(): NodeMaterialConnectionPoint;
  147546. /**
  147547. * Gets the camera (or eye) position component
  147548. */
  147549. get cameraPosition(): NodeMaterialConnectionPoint;
  147550. /**
  147551. * Gets the view input component
  147552. */
  147553. get view(): NodeMaterialConnectionPoint;
  147554. /**
  147555. * Gets the color input component
  147556. */
  147557. get color(): NodeMaterialConnectionPoint;
  147558. /**
  147559. * Gets the reflection object output component
  147560. */
  147561. get reflection(): NodeMaterialConnectionPoint;
  147562. /**
  147563. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  147564. */
  147565. get hasTexture(): boolean;
  147566. /**
  147567. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  147568. */
  147569. get reflectionColor(): string;
  147570. protected _getTexture(): Nullable<BaseTexture>;
  147571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147573. /**
  147574. * Gets the code to inject in the vertex shader
  147575. * @param state current state of the node material building
  147576. * @returns the shader code
  147577. */
  147578. handleVertexSide(state: NodeMaterialBuildState): string;
  147579. /**
  147580. * Gets the main code of the block (fragment side)
  147581. * @param state current state of the node material building
  147582. * @param normalVarName name of the existing variable corresponding to the normal
  147583. * @returns the shader code
  147584. */
  147585. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  147586. protected _buildBlock(state: NodeMaterialBuildState): this;
  147587. protected _dumpPropertiesCode(): string;
  147588. serialize(): any;
  147589. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147590. }
  147591. }
  147592. declare module BABYLON {
  147593. /**
  147594. * Block used to implement the sheen module of the PBR material
  147595. */
  147596. export class SheenBlock extends NodeMaterialBlock {
  147597. /**
  147598. * Create a new SheenBlock
  147599. * @param name defines the block name
  147600. */
  147601. constructor(name: string);
  147602. /**
  147603. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  147604. * It allows the strength of the sheen effect to not depend on the base color of the material,
  147605. * making it easier to setup and tweak the effect
  147606. */
  147607. albedoScaling: boolean;
  147608. /**
  147609. * Defines if the sheen is linked to the sheen color.
  147610. */
  147611. linkSheenWithAlbedo: boolean;
  147612. /**
  147613. * Initialize the block and prepare the context for build
  147614. * @param state defines the state that will be used for the build
  147615. */
  147616. initialize(state: NodeMaterialBuildState): void;
  147617. /**
  147618. * Gets the current class name
  147619. * @returns the class name
  147620. */
  147621. getClassName(): string;
  147622. /**
  147623. * Gets the intensity input component
  147624. */
  147625. get intensity(): NodeMaterialConnectionPoint;
  147626. /**
  147627. * Gets the color input component
  147628. */
  147629. get color(): NodeMaterialConnectionPoint;
  147630. /**
  147631. * Gets the roughness input component
  147632. */
  147633. get roughness(): NodeMaterialConnectionPoint;
  147634. /**
  147635. * Gets the sheen object output component
  147636. */
  147637. get sheen(): NodeMaterialConnectionPoint;
  147638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147639. /**
  147640. * Gets the main code of the block (fragment side)
  147641. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147642. * @returns the shader code
  147643. */
  147644. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  147645. protected _buildBlock(state: NodeMaterialBuildState): this;
  147646. protected _dumpPropertiesCode(): string;
  147647. serialize(): any;
  147648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147649. }
  147650. }
  147651. declare module BABYLON {
  147652. /**
  147653. * Block used to implement the anisotropy module of the PBR material
  147654. */
  147655. export class AnisotropyBlock extends NodeMaterialBlock {
  147656. /**
  147657. * The two properties below are set by the main PBR block prior to calling methods of this class.
  147658. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147659. * It's less burden on the user side in the editor part.
  147660. */
  147661. /** @hidden */
  147662. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147663. /** @hidden */
  147664. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147665. /**
  147666. * Create a new AnisotropyBlock
  147667. * @param name defines the block name
  147668. */
  147669. constructor(name: string);
  147670. /**
  147671. * Initialize the block and prepare the context for build
  147672. * @param state defines the state that will be used for the build
  147673. */
  147674. initialize(state: NodeMaterialBuildState): void;
  147675. /**
  147676. * Gets the current class name
  147677. * @returns the class name
  147678. */
  147679. getClassName(): string;
  147680. /**
  147681. * Gets the intensity input component
  147682. */
  147683. get intensity(): NodeMaterialConnectionPoint;
  147684. /**
  147685. * Gets the direction input component
  147686. */
  147687. get direction(): NodeMaterialConnectionPoint;
  147688. /**
  147689. * Gets the uv input component
  147690. */
  147691. get uv(): NodeMaterialConnectionPoint;
  147692. /**
  147693. * Gets the worldTangent input component
  147694. */
  147695. get worldTangent(): NodeMaterialConnectionPoint;
  147696. /**
  147697. * Gets the anisotropy object output component
  147698. */
  147699. get anisotropy(): NodeMaterialConnectionPoint;
  147700. private _generateTBNSpace;
  147701. /**
  147702. * Gets the main code of the block (fragment side)
  147703. * @param state current state of the node material building
  147704. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147705. * @returns the shader code
  147706. */
  147707. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  147708. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147709. protected _buildBlock(state: NodeMaterialBuildState): this;
  147710. }
  147711. }
  147712. declare module BABYLON {
  147713. /**
  147714. * Block used to implement the clear coat module of the PBR material
  147715. */
  147716. export class ClearCoatBlock extends NodeMaterialBlock {
  147717. private _scene;
  147718. /**
  147719. * Create a new ClearCoatBlock
  147720. * @param name defines the block name
  147721. */
  147722. constructor(name: string);
  147723. /**
  147724. * Defines if the F0 value should be remapped to account for the interface change in the material.
  147725. */
  147726. remapF0OnInterfaceChange: boolean;
  147727. /**
  147728. * Initialize the block and prepare the context for build
  147729. * @param state defines the state that will be used for the build
  147730. */
  147731. initialize(state: NodeMaterialBuildState): void;
  147732. /**
  147733. * Gets the current class name
  147734. * @returns the class name
  147735. */
  147736. getClassName(): string;
  147737. /**
  147738. * Gets the intensity input component
  147739. */
  147740. get intensity(): NodeMaterialConnectionPoint;
  147741. /**
  147742. * Gets the roughness input component
  147743. */
  147744. get roughness(): NodeMaterialConnectionPoint;
  147745. /**
  147746. * Gets the ior input component
  147747. */
  147748. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147749. /**
  147750. * Gets the bump texture input component
  147751. */
  147752. get normalMapColor(): NodeMaterialConnectionPoint;
  147753. /**
  147754. * Gets the uv input component
  147755. */
  147756. get uv(): NodeMaterialConnectionPoint;
  147757. /**
  147758. * Gets the tint color input component
  147759. */
  147760. get tintColor(): NodeMaterialConnectionPoint;
  147761. /**
  147762. * Gets the tint "at distance" input component
  147763. */
  147764. get tintAtDistance(): NodeMaterialConnectionPoint;
  147765. /**
  147766. * Gets the tint thickness input component
  147767. */
  147768. get tintThickness(): NodeMaterialConnectionPoint;
  147769. /**
  147770. * Gets the world tangent input component
  147771. */
  147772. get worldTangent(): NodeMaterialConnectionPoint;
  147773. /**
  147774. * Gets the clear coat object output component
  147775. */
  147776. get clearcoat(): NodeMaterialConnectionPoint;
  147777. autoConfigure(material: NodeMaterial): void;
  147778. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147779. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147780. private _generateTBNSpace;
  147781. /**
  147782. * Gets the main code of the block (fragment side)
  147783. * @param state current state of the node material building
  147784. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  147785. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147786. * @param worldPosVarName name of the variable holding the world position
  147787. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147788. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  147789. * @param worldNormalVarName name of the variable holding the world normal
  147790. * @returns the shader code
  147791. */
  147792. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  147793. protected _buildBlock(state: NodeMaterialBuildState): this;
  147794. protected _dumpPropertiesCode(): string;
  147795. serialize(): any;
  147796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147797. }
  147798. }
  147799. declare module BABYLON {
  147800. /**
  147801. * Block used to implement the sub surface module of the PBR material
  147802. */
  147803. export class SubSurfaceBlock extends NodeMaterialBlock {
  147804. /**
  147805. * Create a new SubSurfaceBlock
  147806. * @param name defines the block name
  147807. */
  147808. constructor(name: string);
  147809. /**
  147810. * Initialize the block and prepare the context for build
  147811. * @param state defines the state that will be used for the build
  147812. */
  147813. initialize(state: NodeMaterialBuildState): void;
  147814. /**
  147815. * Gets the current class name
  147816. * @returns the class name
  147817. */
  147818. getClassName(): string;
  147819. /**
  147820. * Gets the thickness component
  147821. */
  147822. get thickness(): NodeMaterialConnectionPoint;
  147823. /**
  147824. * Gets the tint color input component
  147825. */
  147826. get tintColor(): NodeMaterialConnectionPoint;
  147827. /**
  147828. * Gets the translucency intensity input component
  147829. */
  147830. get translucencyIntensity(): NodeMaterialConnectionPoint;
  147831. /**
  147832. * Gets the translucency diffusion distance input component
  147833. */
  147834. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  147835. /**
  147836. * Gets the refraction object parameters
  147837. */
  147838. get refraction(): NodeMaterialConnectionPoint;
  147839. /**
  147840. * Gets the sub surface object output component
  147841. */
  147842. get subsurface(): NodeMaterialConnectionPoint;
  147843. autoConfigure(material: NodeMaterial): void;
  147844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147845. /**
  147846. * Gets the main code of the block (fragment side)
  147847. * @param state current state of the node material building
  147848. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  147849. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147850. * @param worldPosVarName name of the variable holding the world position
  147851. * @returns the shader code
  147852. */
  147853. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  147854. protected _buildBlock(state: NodeMaterialBuildState): this;
  147855. }
  147856. }
  147857. declare module BABYLON {
  147858. /**
  147859. * Block used to implement the PBR metallic/roughness model
  147860. */
  147861. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  147862. /**
  147863. * Gets or sets the light associated with this block
  147864. */
  147865. light: Nullable<Light>;
  147866. private _lightId;
  147867. private _scene;
  147868. private _environmentBRDFTexture;
  147869. private _environmentBrdfSamplerName;
  147870. private _vNormalWName;
  147871. private _invertNormalName;
  147872. private _metallicReflectanceColor;
  147873. private _metallicF0Factor;
  147874. private _vMetallicReflectanceFactorsName;
  147875. /**
  147876. * Create a new ReflectionBlock
  147877. * @param name defines the block name
  147878. */
  147879. constructor(name: string);
  147880. /**
  147881. * Intensity of the direct lights e.g. the four lights available in your scene.
  147882. * This impacts both the direct diffuse and specular highlights.
  147883. */
  147884. directIntensity: number;
  147885. /**
  147886. * Intensity of the environment e.g. how much the environment will light the object
  147887. * either through harmonics for rough material or through the refelction for shiny ones.
  147888. */
  147889. environmentIntensity: number;
  147890. /**
  147891. * This is a special control allowing the reduction of the specular highlights coming from the
  147892. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  147893. */
  147894. specularIntensity: number;
  147895. /**
  147896. * Defines the falloff type used in this material.
  147897. * It by default is Physical.
  147898. */
  147899. lightFalloff: number;
  147900. /**
  147901. * Specifies that alpha test should be used
  147902. */
  147903. useAlphaTest: boolean;
  147904. /**
  147905. * Defines the alpha limits in alpha test mode.
  147906. */
  147907. alphaTestCutoff: number;
  147908. /**
  147909. * Specifies that alpha blending should be used
  147910. */
  147911. useAlphaBlending: boolean;
  147912. /**
  147913. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  147914. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  147915. */
  147916. useRadianceOverAlpha: boolean;
  147917. /**
  147918. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  147919. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  147920. */
  147921. useSpecularOverAlpha: boolean;
  147922. /**
  147923. * Enables specular anti aliasing in the PBR shader.
  147924. * It will both interacts on the Geometry for analytical and IBL lighting.
  147925. * It also prefilter the roughness map based on the bump values.
  147926. */
  147927. enableSpecularAntiAliasing: boolean;
  147928. /**
  147929. * Enables realtime filtering on the texture.
  147930. */
  147931. realTimeFiltering: boolean;
  147932. /**
  147933. * Quality switch for realtime filtering
  147934. */
  147935. realTimeFilteringQuality: number;
  147936. /**
  147937. * Defines if the material uses energy conservation.
  147938. */
  147939. useEnergyConservation: boolean;
  147940. /**
  147941. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  147942. * too much the area relying on ambient texture to define their ambient occlusion.
  147943. */
  147944. useRadianceOcclusion: boolean;
  147945. /**
  147946. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  147947. * makes the reflect vector face the model (under horizon).
  147948. */
  147949. useHorizonOcclusion: boolean;
  147950. /**
  147951. * If set to true, no lighting calculations will be applied.
  147952. */
  147953. unlit: boolean;
  147954. /**
  147955. * Force normal to face away from face.
  147956. */
  147957. forceNormalForward: boolean;
  147958. /**
  147959. * Defines the material debug mode.
  147960. * It helps seeing only some components of the material while troubleshooting.
  147961. */
  147962. debugMode: number;
  147963. /**
  147964. * Specify from where on screen the debug mode should start.
  147965. * The value goes from -1 (full screen) to 1 (not visible)
  147966. * It helps with side by side comparison against the final render
  147967. * This defaults to 0
  147968. */
  147969. debugLimit: number;
  147970. /**
  147971. * As the default viewing range might not be enough (if the ambient is really small for instance)
  147972. * You can use the factor to better multiply the final value.
  147973. */
  147974. debugFactor: number;
  147975. /**
  147976. * Initialize the block and prepare the context for build
  147977. * @param state defines the state that will be used for the build
  147978. */
  147979. initialize(state: NodeMaterialBuildState): void;
  147980. /**
  147981. * Gets the current class name
  147982. * @returns the class name
  147983. */
  147984. getClassName(): string;
  147985. /**
  147986. * Gets the world position input component
  147987. */
  147988. get worldPosition(): NodeMaterialConnectionPoint;
  147989. /**
  147990. * Gets the world normal input component
  147991. */
  147992. get worldNormal(): NodeMaterialConnectionPoint;
  147993. /**
  147994. * Gets the view matrix parameter
  147995. */
  147996. get view(): NodeMaterialConnectionPoint;
  147997. /**
  147998. * Gets the camera position input component
  147999. */
  148000. get cameraPosition(): NodeMaterialConnectionPoint;
  148001. /**
  148002. * Gets the perturbed normal input component
  148003. */
  148004. get perturbedNormal(): NodeMaterialConnectionPoint;
  148005. /**
  148006. * Gets the base color input component
  148007. */
  148008. get baseColor(): NodeMaterialConnectionPoint;
  148009. /**
  148010. * Gets the metallic input component
  148011. */
  148012. get metallic(): NodeMaterialConnectionPoint;
  148013. /**
  148014. * Gets the roughness input component
  148015. */
  148016. get roughness(): NodeMaterialConnectionPoint;
  148017. /**
  148018. * Gets the ambient occlusion input component
  148019. */
  148020. get ambientOcc(): NodeMaterialConnectionPoint;
  148021. /**
  148022. * Gets the opacity input component
  148023. */
  148024. get opacity(): NodeMaterialConnectionPoint;
  148025. /**
  148026. * Gets the index of refraction input component
  148027. */
  148028. get indexOfRefraction(): NodeMaterialConnectionPoint;
  148029. /**
  148030. * Gets the ambient color input component
  148031. */
  148032. get ambientColor(): NodeMaterialConnectionPoint;
  148033. /**
  148034. * Gets the reflection object parameters
  148035. */
  148036. get reflection(): NodeMaterialConnectionPoint;
  148037. /**
  148038. * Gets the clear coat object parameters
  148039. */
  148040. get clearcoat(): NodeMaterialConnectionPoint;
  148041. /**
  148042. * Gets the sheen object parameters
  148043. */
  148044. get sheen(): NodeMaterialConnectionPoint;
  148045. /**
  148046. * Gets the sub surface object parameters
  148047. */
  148048. get subsurface(): NodeMaterialConnectionPoint;
  148049. /**
  148050. * Gets the anisotropy object parameters
  148051. */
  148052. get anisotropy(): NodeMaterialConnectionPoint;
  148053. /**
  148054. * Gets the ambient output component
  148055. */
  148056. get ambientClr(): NodeMaterialConnectionPoint;
  148057. /**
  148058. * Gets the diffuse output component
  148059. */
  148060. get diffuseDir(): NodeMaterialConnectionPoint;
  148061. /**
  148062. * Gets the specular output component
  148063. */
  148064. get specularDir(): NodeMaterialConnectionPoint;
  148065. /**
  148066. * Gets the clear coat output component
  148067. */
  148068. get clearcoatDir(): NodeMaterialConnectionPoint;
  148069. /**
  148070. * Gets the sheen output component
  148071. */
  148072. get sheenDir(): NodeMaterialConnectionPoint;
  148073. /**
  148074. * Gets the indirect diffuse output component
  148075. */
  148076. get diffuseIndirect(): NodeMaterialConnectionPoint;
  148077. /**
  148078. * Gets the indirect specular output component
  148079. */
  148080. get specularIndirect(): NodeMaterialConnectionPoint;
  148081. /**
  148082. * Gets the indirect clear coat output component
  148083. */
  148084. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  148085. /**
  148086. * Gets the indirect sheen output component
  148087. */
  148088. get sheenIndirect(): NodeMaterialConnectionPoint;
  148089. /**
  148090. * Gets the refraction output component
  148091. */
  148092. get refraction(): NodeMaterialConnectionPoint;
  148093. /**
  148094. * Gets the global lighting output component
  148095. */
  148096. get lighting(): NodeMaterialConnectionPoint;
  148097. /**
  148098. * Gets the shadow output component
  148099. */
  148100. get shadow(): NodeMaterialConnectionPoint;
  148101. /**
  148102. * Gets the alpha output component
  148103. */
  148104. get alpha(): NodeMaterialConnectionPoint;
  148105. autoConfigure(material: NodeMaterial): void;
  148106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  148107. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  148108. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  148109. private _injectVertexCode;
  148110. private _getAlbedoOpacityCode;
  148111. private _getAmbientOcclusionCode;
  148112. private _getReflectivityCode;
  148113. protected _buildBlock(state: NodeMaterialBuildState): this;
  148114. protected _dumpPropertiesCode(): string;
  148115. serialize(): any;
  148116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  148117. }
  148118. }
  148119. declare module BABYLON {
  148120. /**
  148121. * Block used to compute value of one parameter modulo another
  148122. */
  148123. export class ModBlock extends NodeMaterialBlock {
  148124. /**
  148125. * Creates a new ModBlock
  148126. * @param name defines the block name
  148127. */
  148128. constructor(name: string);
  148129. /**
  148130. * Gets the current class name
  148131. * @returns the class name
  148132. */
  148133. getClassName(): string;
  148134. /**
  148135. * Gets the left operand input component
  148136. */
  148137. get left(): NodeMaterialConnectionPoint;
  148138. /**
  148139. * Gets the right operand input component
  148140. */
  148141. get right(): NodeMaterialConnectionPoint;
  148142. /**
  148143. * Gets the output component
  148144. */
  148145. get output(): NodeMaterialConnectionPoint;
  148146. protected _buildBlock(state: NodeMaterialBuildState): this;
  148147. }
  148148. }
  148149. declare module BABYLON {
  148150. /**
  148151. * Configuration for Draco compression
  148152. */
  148153. export interface IDracoCompressionConfiguration {
  148154. /**
  148155. * Configuration for the decoder.
  148156. */
  148157. decoder: {
  148158. /**
  148159. * The url to the WebAssembly module.
  148160. */
  148161. wasmUrl?: string;
  148162. /**
  148163. * The url to the WebAssembly binary.
  148164. */
  148165. wasmBinaryUrl?: string;
  148166. /**
  148167. * The url to the fallback JavaScript module.
  148168. */
  148169. fallbackUrl?: string;
  148170. };
  148171. }
  148172. /**
  148173. * Draco compression (https://google.github.io/draco/)
  148174. *
  148175. * This class wraps the Draco module.
  148176. *
  148177. * **Encoder**
  148178. *
  148179. * The encoder is not currently implemented.
  148180. *
  148181. * **Decoder**
  148182. *
  148183. * 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.
  148184. *
  148185. * To update the configuration, use the following code:
  148186. * ```javascript
  148187. * DracoCompression.Configuration = {
  148188. * decoder: {
  148189. * wasmUrl: "<url to the WebAssembly library>",
  148190. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  148191. * fallbackUrl: "<url to the fallback JavaScript library>",
  148192. * }
  148193. * };
  148194. * ```
  148195. *
  148196. * 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.
  148197. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  148198. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  148199. *
  148200. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  148201. * ```javascript
  148202. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  148203. * ```
  148204. *
  148205. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  148206. */
  148207. export class DracoCompression implements IDisposable {
  148208. private _workerPoolPromise?;
  148209. private _decoderModulePromise?;
  148210. /**
  148211. * The configuration. Defaults to the following urls:
  148212. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  148213. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  148214. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  148215. */
  148216. static Configuration: IDracoCompressionConfiguration;
  148217. /**
  148218. * Returns true if the decoder configuration is available.
  148219. */
  148220. static get DecoderAvailable(): boolean;
  148221. /**
  148222. * Default number of workers to create when creating the draco compression object.
  148223. */
  148224. static DefaultNumWorkers: number;
  148225. private static GetDefaultNumWorkers;
  148226. private static _Default;
  148227. /**
  148228. * Default instance for the draco compression object.
  148229. */
  148230. static get Default(): DracoCompression;
  148231. /**
  148232. * Constructor
  148233. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  148234. */
  148235. constructor(numWorkers?: number);
  148236. /**
  148237. * Stop all async operations and release resources.
  148238. */
  148239. dispose(): void;
  148240. /**
  148241. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  148242. * @returns a promise that resolves when ready
  148243. */
  148244. whenReadyAsync(): Promise<void>;
  148245. /**
  148246. * Decode Draco compressed mesh data to vertex data.
  148247. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  148248. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  148249. * @returns A promise that resolves with the decoded vertex data
  148250. */
  148251. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  148252. [kind: string]: number;
  148253. }): Promise<VertexData>;
  148254. }
  148255. }
  148256. declare module BABYLON {
  148257. /**
  148258. * Class for building Constructive Solid Geometry
  148259. */
  148260. export class CSG {
  148261. private polygons;
  148262. /**
  148263. * The world matrix
  148264. */
  148265. matrix: Matrix;
  148266. /**
  148267. * Stores the position
  148268. */
  148269. position: Vector3;
  148270. /**
  148271. * Stores the rotation
  148272. */
  148273. rotation: Vector3;
  148274. /**
  148275. * Stores the rotation quaternion
  148276. */
  148277. rotationQuaternion: Nullable<Quaternion>;
  148278. /**
  148279. * Stores the scaling vector
  148280. */
  148281. scaling: Vector3;
  148282. /**
  148283. * Convert the Mesh to CSG
  148284. * @param mesh The Mesh to convert to CSG
  148285. * @returns A new CSG from the Mesh
  148286. */
  148287. static FromMesh(mesh: Mesh): CSG;
  148288. /**
  148289. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  148290. * @param polygons Polygons used to construct a CSG solid
  148291. */
  148292. private static FromPolygons;
  148293. /**
  148294. * Clones, or makes a deep copy, of the CSG
  148295. * @returns A new CSG
  148296. */
  148297. clone(): CSG;
  148298. /**
  148299. * Unions this CSG with another CSG
  148300. * @param csg The CSG to union against this CSG
  148301. * @returns The unioned CSG
  148302. */
  148303. union(csg: CSG): CSG;
  148304. /**
  148305. * Unions this CSG with another CSG in place
  148306. * @param csg The CSG to union against this CSG
  148307. */
  148308. unionInPlace(csg: CSG): void;
  148309. /**
  148310. * Subtracts this CSG with another CSG
  148311. * @param csg The CSG to subtract against this CSG
  148312. * @returns A new CSG
  148313. */
  148314. subtract(csg: CSG): CSG;
  148315. /**
  148316. * Subtracts this CSG with another CSG in place
  148317. * @param csg The CSG to subtact against this CSG
  148318. */
  148319. subtractInPlace(csg: CSG): void;
  148320. /**
  148321. * Intersect this CSG with another CSG
  148322. * @param csg The CSG to intersect against this CSG
  148323. * @returns A new CSG
  148324. */
  148325. intersect(csg: CSG): CSG;
  148326. /**
  148327. * Intersects this CSG with another CSG in place
  148328. * @param csg The CSG to intersect against this CSG
  148329. */
  148330. intersectInPlace(csg: CSG): void;
  148331. /**
  148332. * Return a new CSG solid with solid and empty space switched. This solid is
  148333. * not modified.
  148334. * @returns A new CSG solid with solid and empty space switched
  148335. */
  148336. inverse(): CSG;
  148337. /**
  148338. * Inverses the CSG in place
  148339. */
  148340. inverseInPlace(): void;
  148341. /**
  148342. * This is used to keep meshes transformations so they can be restored
  148343. * when we build back a Babylon Mesh
  148344. * NB : All CSG operations are performed in world coordinates
  148345. * @param csg The CSG to copy the transform attributes from
  148346. * @returns This CSG
  148347. */
  148348. copyTransformAttributes(csg: CSG): CSG;
  148349. /**
  148350. * Build Raw mesh from CSG
  148351. * Coordinates here are in world space
  148352. * @param name The name of the mesh geometry
  148353. * @param scene The Scene
  148354. * @param keepSubMeshes Specifies if the submeshes should be kept
  148355. * @returns A new Mesh
  148356. */
  148357. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  148358. /**
  148359. * Build Mesh from CSG taking material and transforms into account
  148360. * @param name The name of the Mesh
  148361. * @param material The material of the Mesh
  148362. * @param scene The Scene
  148363. * @param keepSubMeshes Specifies if submeshes should be kept
  148364. * @returns The new Mesh
  148365. */
  148366. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  148367. }
  148368. }
  148369. declare module BABYLON {
  148370. /**
  148371. * Class used to create a trail following a mesh
  148372. */
  148373. export class TrailMesh extends Mesh {
  148374. private _generator;
  148375. private _autoStart;
  148376. private _running;
  148377. private _diameter;
  148378. private _length;
  148379. private _sectionPolygonPointsCount;
  148380. private _sectionVectors;
  148381. private _sectionNormalVectors;
  148382. private _beforeRenderObserver;
  148383. /**
  148384. * @constructor
  148385. * @param name The value used by scene.getMeshByName() to do a lookup.
  148386. * @param generator The mesh or transform node to generate a trail.
  148387. * @param scene The scene to add this mesh to.
  148388. * @param diameter Diameter of trailing mesh. Default is 1.
  148389. * @param length Length of trailing mesh. Default is 60.
  148390. * @param autoStart Automatically start trailing mesh. Default true.
  148391. */
  148392. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  148393. /**
  148394. * "TrailMesh"
  148395. * @returns "TrailMesh"
  148396. */
  148397. getClassName(): string;
  148398. private _createMesh;
  148399. /**
  148400. * Start trailing mesh.
  148401. */
  148402. start(): void;
  148403. /**
  148404. * Stop trailing mesh.
  148405. */
  148406. stop(): void;
  148407. /**
  148408. * Update trailing mesh geometry.
  148409. */
  148410. update(): void;
  148411. /**
  148412. * Returns a new TrailMesh object.
  148413. * @param name is a string, the name given to the new mesh
  148414. * @param newGenerator use new generator object for cloned trail mesh
  148415. * @returns a new mesh
  148416. */
  148417. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  148418. /**
  148419. * Serializes this trail mesh
  148420. * @param serializationObject object to write serialization to
  148421. */
  148422. serialize(serializationObject: any): void;
  148423. /**
  148424. * Parses a serialized trail mesh
  148425. * @param parsedMesh the serialized mesh
  148426. * @param scene the scene to create the trail mesh in
  148427. * @returns the created trail mesh
  148428. */
  148429. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  148430. }
  148431. }
  148432. declare module BABYLON {
  148433. /**
  148434. * Class containing static functions to help procedurally build meshes
  148435. */
  148436. export class TiledBoxBuilder {
  148437. /**
  148438. * Creates a box mesh
  148439. * 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)
  148440. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148444. * @param name defines the name of the mesh
  148445. * @param options defines the options used to create the mesh
  148446. * @param scene defines the hosting scene
  148447. * @returns the box mesh
  148448. */
  148449. static CreateTiledBox(name: string, options: {
  148450. pattern?: number;
  148451. width?: number;
  148452. height?: number;
  148453. depth?: number;
  148454. tileSize?: number;
  148455. tileWidth?: number;
  148456. tileHeight?: number;
  148457. alignHorizontal?: number;
  148458. alignVertical?: number;
  148459. faceUV?: Vector4[];
  148460. faceColors?: Color4[];
  148461. sideOrientation?: number;
  148462. updatable?: boolean;
  148463. }, scene?: Nullable<Scene>): Mesh;
  148464. }
  148465. }
  148466. declare module BABYLON {
  148467. /**
  148468. * Class containing static functions to help procedurally build meshes
  148469. */
  148470. export class TorusKnotBuilder {
  148471. /**
  148472. * Creates a torus knot mesh
  148473. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148474. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148475. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148476. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148480. * @param name defines the name of the mesh
  148481. * @param options defines the options used to create the mesh
  148482. * @param scene defines the hosting scene
  148483. * @returns the torus knot mesh
  148484. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148485. */
  148486. static CreateTorusKnot(name: string, options: {
  148487. radius?: number;
  148488. tube?: number;
  148489. radialSegments?: number;
  148490. tubularSegments?: number;
  148491. p?: number;
  148492. q?: number;
  148493. updatable?: boolean;
  148494. sideOrientation?: number;
  148495. frontUVs?: Vector4;
  148496. backUVs?: Vector4;
  148497. }, scene: any): Mesh;
  148498. }
  148499. }
  148500. declare module BABYLON {
  148501. /**
  148502. * Polygon
  148503. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  148504. */
  148505. export class Polygon {
  148506. /**
  148507. * Creates a rectangle
  148508. * @param xmin bottom X coord
  148509. * @param ymin bottom Y coord
  148510. * @param xmax top X coord
  148511. * @param ymax top Y coord
  148512. * @returns points that make the resulting rectation
  148513. */
  148514. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  148515. /**
  148516. * Creates a circle
  148517. * @param radius radius of circle
  148518. * @param cx scale in x
  148519. * @param cy scale in y
  148520. * @param numberOfSides number of sides that make up the circle
  148521. * @returns points that make the resulting circle
  148522. */
  148523. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  148524. /**
  148525. * Creates a polygon from input string
  148526. * @param input Input polygon data
  148527. * @returns the parsed points
  148528. */
  148529. static Parse(input: string): Vector2[];
  148530. /**
  148531. * Starts building a polygon from x and y coordinates
  148532. * @param x x coordinate
  148533. * @param y y coordinate
  148534. * @returns the started path2
  148535. */
  148536. static StartingAt(x: number, y: number): Path2;
  148537. }
  148538. /**
  148539. * Builds a polygon
  148540. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  148541. */
  148542. export class PolygonMeshBuilder {
  148543. private _points;
  148544. private _outlinepoints;
  148545. private _holes;
  148546. private _name;
  148547. private _scene;
  148548. private _epoints;
  148549. private _eholes;
  148550. private _addToepoint;
  148551. /**
  148552. * Babylon reference to the earcut plugin.
  148553. */
  148554. bjsEarcut: any;
  148555. /**
  148556. * Creates a PolygonMeshBuilder
  148557. * @param name name of the builder
  148558. * @param contours Path of the polygon
  148559. * @param scene scene to add to when creating the mesh
  148560. * @param earcutInjection can be used to inject your own earcut reference
  148561. */
  148562. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  148563. /**
  148564. * Adds a whole within the polygon
  148565. * @param hole Array of points defining the hole
  148566. * @returns this
  148567. */
  148568. addHole(hole: Vector2[]): PolygonMeshBuilder;
  148569. /**
  148570. * Creates the polygon
  148571. * @param updatable If the mesh should be updatable
  148572. * @param depth The depth of the mesh created
  148573. * @returns the created mesh
  148574. */
  148575. build(updatable?: boolean, depth?: number): Mesh;
  148576. /**
  148577. * Creates the polygon
  148578. * @param depth The depth of the mesh created
  148579. * @returns the created VertexData
  148580. */
  148581. buildVertexData(depth?: number): VertexData;
  148582. /**
  148583. * Adds a side to the polygon
  148584. * @param positions points that make the polygon
  148585. * @param normals normals of the polygon
  148586. * @param uvs uvs of the polygon
  148587. * @param indices indices of the polygon
  148588. * @param bounds bounds of the polygon
  148589. * @param points points of the polygon
  148590. * @param depth depth of the polygon
  148591. * @param flip flip of the polygon
  148592. */
  148593. private addSide;
  148594. }
  148595. }
  148596. declare module BABYLON {
  148597. /**
  148598. * Class containing static functions to help procedurally build meshes
  148599. */
  148600. export class PolygonBuilder {
  148601. /**
  148602. * Creates a polygon mesh
  148603. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  148604. * * 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
  148605. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  148608. * * Remember you can only change the shape positions, not their number when updating a polygon
  148609. * @param name defines the name of the mesh
  148610. * @param options defines the options used to create the mesh
  148611. * @param scene defines the hosting scene
  148612. * @param earcutInjection can be used to inject your own earcut reference
  148613. * @returns the polygon mesh
  148614. */
  148615. static CreatePolygon(name: string, options: {
  148616. shape: Vector3[];
  148617. holes?: Vector3[][];
  148618. depth?: number;
  148619. faceUV?: Vector4[];
  148620. faceColors?: Color4[];
  148621. updatable?: boolean;
  148622. sideOrientation?: number;
  148623. frontUVs?: Vector4;
  148624. backUVs?: Vector4;
  148625. wrap?: boolean;
  148626. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148627. /**
  148628. * Creates an extruded polygon mesh, with depth in the Y direction.
  148629. * * 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)
  148630. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148631. * @param name defines the name of the mesh
  148632. * @param options defines the options used to create the mesh
  148633. * @param scene defines the hosting scene
  148634. * @param earcutInjection can be used to inject your own earcut reference
  148635. * @returns the polygon mesh
  148636. */
  148637. static ExtrudePolygon(name: string, options: {
  148638. shape: Vector3[];
  148639. holes?: Vector3[][];
  148640. depth?: number;
  148641. faceUV?: Vector4[];
  148642. faceColors?: Color4[];
  148643. updatable?: boolean;
  148644. sideOrientation?: number;
  148645. frontUVs?: Vector4;
  148646. backUVs?: Vector4;
  148647. wrap?: boolean;
  148648. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148649. }
  148650. }
  148651. declare module BABYLON {
  148652. /**
  148653. * Class containing static functions to help procedurally build meshes
  148654. */
  148655. export class LatheBuilder {
  148656. /**
  148657. * Creates lathe mesh.
  148658. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148659. * * 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
  148660. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148661. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148662. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148663. * * 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
  148664. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148665. * * 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
  148666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148668. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148670. * @param name defines the name of the mesh
  148671. * @param options defines the options used to create the mesh
  148672. * @param scene defines the hosting scene
  148673. * @returns the lathe mesh
  148674. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148675. */
  148676. static CreateLathe(name: string, options: {
  148677. shape: Vector3[];
  148678. radius?: number;
  148679. tessellation?: number;
  148680. clip?: number;
  148681. arc?: number;
  148682. closed?: boolean;
  148683. updatable?: boolean;
  148684. sideOrientation?: number;
  148685. frontUVs?: Vector4;
  148686. backUVs?: Vector4;
  148687. cap?: number;
  148688. invertUV?: boolean;
  148689. }, scene?: Nullable<Scene>): Mesh;
  148690. }
  148691. }
  148692. declare module BABYLON {
  148693. /**
  148694. * Class containing static functions to help procedurally build meshes
  148695. */
  148696. export class TiledPlaneBuilder {
  148697. /**
  148698. * Creates a tiled plane mesh
  148699. * * The parameter `pattern` will, depending on value, do nothing or
  148700. * * * flip (reflect about central vertical) alternate tiles across and up
  148701. * * * flip every tile on alternate rows
  148702. * * * rotate (180 degs) alternate tiles across and up
  148703. * * * rotate every tile on alternate rows
  148704. * * * flip and rotate alternate tiles across and up
  148705. * * * flip and rotate every tile on alternate rows
  148706. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  148707. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  148708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148709. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148710. * * 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)
  148711. * * 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)
  148712. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148713. * @param name defines the name of the mesh
  148714. * @param options defines the options used to create the mesh
  148715. * @param scene defines the hosting scene
  148716. * @returns the box mesh
  148717. */
  148718. static CreateTiledPlane(name: string, options: {
  148719. pattern?: number;
  148720. tileSize?: number;
  148721. tileWidth?: number;
  148722. tileHeight?: number;
  148723. size?: number;
  148724. width?: number;
  148725. height?: number;
  148726. alignHorizontal?: number;
  148727. alignVertical?: number;
  148728. sideOrientation?: number;
  148729. frontUVs?: Vector4;
  148730. backUVs?: Vector4;
  148731. updatable?: boolean;
  148732. }, scene?: Nullable<Scene>): Mesh;
  148733. }
  148734. }
  148735. declare module BABYLON {
  148736. /**
  148737. * Class containing static functions to help procedurally build meshes
  148738. */
  148739. export class TubeBuilder {
  148740. /**
  148741. * Creates a tube mesh.
  148742. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148743. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  148744. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  148745. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  148746. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  148747. * * 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)
  148748. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  148749. * * 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
  148750. * * 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
  148751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148753. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 tube mesh
  148759. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148760. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148761. */
  148762. static CreateTube(name: string, options: {
  148763. path: Vector3[];
  148764. radius?: number;
  148765. tessellation?: number;
  148766. radiusFunction?: {
  148767. (i: number, distance: number): number;
  148768. };
  148769. cap?: number;
  148770. arc?: number;
  148771. updatable?: boolean;
  148772. sideOrientation?: number;
  148773. frontUVs?: Vector4;
  148774. backUVs?: Vector4;
  148775. instance?: Mesh;
  148776. invertUV?: boolean;
  148777. }, scene?: Nullable<Scene>): Mesh;
  148778. }
  148779. }
  148780. declare module BABYLON {
  148781. /**
  148782. * Class containing static functions to help procedurally build meshes
  148783. */
  148784. export class IcoSphereBuilder {
  148785. /**
  148786. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148787. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148788. * * 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`)
  148789. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148790. * * 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
  148791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148794. * @param name defines the name of the mesh
  148795. * @param options defines the options used to create the mesh
  148796. * @param scene defines the hosting scene
  148797. * @returns the icosahedron mesh
  148798. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148799. */
  148800. static CreateIcoSphere(name: string, options: {
  148801. radius?: number;
  148802. radiusX?: number;
  148803. radiusY?: number;
  148804. radiusZ?: number;
  148805. flat?: boolean;
  148806. subdivisions?: number;
  148807. sideOrientation?: number;
  148808. frontUVs?: Vector4;
  148809. backUVs?: Vector4;
  148810. updatable?: boolean;
  148811. }, scene?: Nullable<Scene>): Mesh;
  148812. }
  148813. }
  148814. declare module BABYLON {
  148815. /**
  148816. * Class containing static functions to help procedurally build meshes
  148817. */
  148818. export class DecalBuilder {
  148819. /**
  148820. * Creates a decal mesh.
  148821. * 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
  148822. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148823. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148824. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148825. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148826. * @param name defines the name of the mesh
  148827. * @param sourceMesh defines the mesh where the decal must be applied
  148828. * @param options defines the options used to create the mesh
  148829. * @param scene defines the hosting scene
  148830. * @returns the decal mesh
  148831. * @see https://doc.babylonjs.com/how_to/decals
  148832. */
  148833. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148834. position?: Vector3;
  148835. normal?: Vector3;
  148836. size?: Vector3;
  148837. angle?: number;
  148838. }): Mesh;
  148839. }
  148840. }
  148841. declare module BABYLON {
  148842. /**
  148843. * Class containing static functions to help procedurally build meshes
  148844. */
  148845. export class MeshBuilder {
  148846. /**
  148847. * Creates a box mesh
  148848. * * The parameter `size` sets the size (float) of each box side (default 1)
  148849. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  148850. * * 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)
  148851. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148856. * @param name defines the name of the mesh
  148857. * @param options defines the options used to create the mesh
  148858. * @param scene defines the hosting scene
  148859. * @returns the box mesh
  148860. */
  148861. static CreateBox(name: string, options: {
  148862. size?: number;
  148863. width?: number;
  148864. height?: number;
  148865. depth?: number;
  148866. faceUV?: Vector4[];
  148867. faceColors?: Color4[];
  148868. sideOrientation?: number;
  148869. frontUVs?: Vector4;
  148870. backUVs?: Vector4;
  148871. wrap?: boolean;
  148872. topBaseAt?: number;
  148873. bottomBaseAt?: number;
  148874. updatable?: boolean;
  148875. }, scene?: Nullable<Scene>): Mesh;
  148876. /**
  148877. * Creates a tiled box mesh
  148878. * * faceTiles sets the pattern, tile size and number of tiles for a face
  148879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148880. * @param name defines the name of the mesh
  148881. * @param options defines the options used to create the mesh
  148882. * @param scene defines the hosting scene
  148883. * @returns the tiled box mesh
  148884. */
  148885. static CreateTiledBox(name: string, options: {
  148886. pattern?: number;
  148887. size?: number;
  148888. width?: number;
  148889. height?: number;
  148890. depth: number;
  148891. tileSize?: number;
  148892. tileWidth?: number;
  148893. tileHeight?: number;
  148894. faceUV?: Vector4[];
  148895. faceColors?: Color4[];
  148896. alignHorizontal?: number;
  148897. alignVertical?: number;
  148898. sideOrientation?: number;
  148899. updatable?: boolean;
  148900. }, scene?: Nullable<Scene>): Mesh;
  148901. /**
  148902. * Creates a sphere mesh
  148903. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  148904. * * 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`)
  148905. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  148906. * * 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
  148907. * * 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)
  148908. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148909. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148911. * @param name defines the name of the mesh
  148912. * @param options defines the options used to create the mesh
  148913. * @param scene defines the hosting scene
  148914. * @returns the sphere mesh
  148915. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  148916. */
  148917. static CreateSphere(name: string, options: {
  148918. segments?: number;
  148919. diameter?: number;
  148920. diameterX?: number;
  148921. diameterY?: number;
  148922. diameterZ?: number;
  148923. arc?: number;
  148924. slice?: number;
  148925. sideOrientation?: number;
  148926. frontUVs?: Vector4;
  148927. backUVs?: Vector4;
  148928. updatable?: boolean;
  148929. }, scene?: Nullable<Scene>): Mesh;
  148930. /**
  148931. * Creates a plane polygonal mesh. By default, this is a disc
  148932. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  148933. * * 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
  148934. * * 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
  148935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148938. * @param name defines the name of the mesh
  148939. * @param options defines the options used to create the mesh
  148940. * @param scene defines the hosting scene
  148941. * @returns the plane polygonal mesh
  148942. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  148943. */
  148944. static CreateDisc(name: string, options: {
  148945. radius?: number;
  148946. tessellation?: number;
  148947. arc?: number;
  148948. updatable?: boolean;
  148949. sideOrientation?: number;
  148950. frontUVs?: Vector4;
  148951. backUVs?: Vector4;
  148952. }, scene?: Nullable<Scene>): Mesh;
  148953. /**
  148954. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148955. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148956. * * 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`)
  148957. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148958. * * 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
  148959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148962. * @param name defines the name of the mesh
  148963. * @param options defines the options used to create the mesh
  148964. * @param scene defines the hosting scene
  148965. * @returns the icosahedron mesh
  148966. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148967. */
  148968. static CreateIcoSphere(name: string, options: {
  148969. radius?: number;
  148970. radiusX?: number;
  148971. radiusY?: number;
  148972. radiusZ?: number;
  148973. flat?: boolean;
  148974. subdivisions?: number;
  148975. sideOrientation?: number;
  148976. frontUVs?: Vector4;
  148977. backUVs?: Vector4;
  148978. updatable?: boolean;
  148979. }, scene?: Nullable<Scene>): Mesh;
  148980. /**
  148981. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148982. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  148983. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  148984. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  148985. * * 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
  148986. * * 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
  148987. * * 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
  148988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148991. * * 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
  148992. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  148993. * * 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
  148994. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  148995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148996. * @param name defines the name of the mesh
  148997. * @param options defines the options used to create the mesh
  148998. * @param scene defines the hosting scene
  148999. * @returns the ribbon mesh
  149000. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  149001. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149002. */
  149003. static CreateRibbon(name: string, options: {
  149004. pathArray: Vector3[][];
  149005. closeArray?: boolean;
  149006. closePath?: boolean;
  149007. offset?: number;
  149008. updatable?: boolean;
  149009. sideOrientation?: number;
  149010. frontUVs?: Vector4;
  149011. backUVs?: Vector4;
  149012. instance?: Mesh;
  149013. invertUV?: boolean;
  149014. uvs?: Vector2[];
  149015. colors?: Color4[];
  149016. }, scene?: Nullable<Scene>): Mesh;
  149017. /**
  149018. * Creates a cylinder or a cone mesh
  149019. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  149020. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  149021. * * 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.
  149022. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  149023. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  149024. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  149025. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  149026. * * 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).
  149027. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  149028. * * 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).
  149029. * * 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
  149030. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  149031. * * 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
  149032. * * 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.
  149033. * * If `enclose` is false, a ring surface is one element.
  149034. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  149035. * * 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
  149036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149039. * @param name defines the name of the mesh
  149040. * @param options defines the options used to create the mesh
  149041. * @param scene defines the hosting scene
  149042. * @returns the cylinder mesh
  149043. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  149044. */
  149045. static CreateCylinder(name: string, options: {
  149046. height?: number;
  149047. diameterTop?: number;
  149048. diameterBottom?: number;
  149049. diameter?: number;
  149050. tessellation?: number;
  149051. subdivisions?: number;
  149052. arc?: number;
  149053. faceColors?: Color4[];
  149054. faceUV?: Vector4[];
  149055. updatable?: boolean;
  149056. hasRings?: boolean;
  149057. enclose?: boolean;
  149058. cap?: number;
  149059. sideOrientation?: number;
  149060. frontUVs?: Vector4;
  149061. backUVs?: Vector4;
  149062. }, scene?: Nullable<Scene>): Mesh;
  149063. /**
  149064. * Creates a torus mesh
  149065. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  149066. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  149067. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  149068. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149069. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149071. * @param name defines the name of the mesh
  149072. * @param options defines the options used to create the mesh
  149073. * @param scene defines the hosting scene
  149074. * @returns the torus mesh
  149075. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  149076. */
  149077. static CreateTorus(name: string, options: {
  149078. diameter?: number;
  149079. thickness?: number;
  149080. tessellation?: number;
  149081. updatable?: boolean;
  149082. sideOrientation?: number;
  149083. frontUVs?: Vector4;
  149084. backUVs?: Vector4;
  149085. }, scene?: Nullable<Scene>): Mesh;
  149086. /**
  149087. * Creates a torus knot mesh
  149088. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  149089. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  149090. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  149091. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  149092. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149093. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149095. * @param name defines the name of the mesh
  149096. * @param options defines the options used to create the mesh
  149097. * @param scene defines the hosting scene
  149098. * @returns the torus knot mesh
  149099. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  149100. */
  149101. static CreateTorusKnot(name: string, options: {
  149102. radius?: number;
  149103. tube?: number;
  149104. radialSegments?: number;
  149105. tubularSegments?: number;
  149106. p?: number;
  149107. q?: number;
  149108. updatable?: boolean;
  149109. sideOrientation?: number;
  149110. frontUVs?: Vector4;
  149111. backUVs?: Vector4;
  149112. }, scene?: Nullable<Scene>): Mesh;
  149113. /**
  149114. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  149115. * * 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
  149116. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  149117. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  149118. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  149119. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  149120. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  149121. * * 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
  149122. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  149123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  149125. * @param name defines the name of the new line system
  149126. * @param options defines the options used to create the line system
  149127. * @param scene defines the hosting scene
  149128. * @returns a new line system mesh
  149129. */
  149130. static CreateLineSystem(name: string, options: {
  149131. lines: Vector3[][];
  149132. updatable?: boolean;
  149133. instance?: Nullable<LinesMesh>;
  149134. colors?: Nullable<Color4[][]>;
  149135. useVertexAlpha?: boolean;
  149136. }, scene: Nullable<Scene>): LinesMesh;
  149137. /**
  149138. * Creates a line mesh
  149139. * 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
  149140. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  149141. * * The parameter `points` is an array successive Vector3
  149142. * * 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
  149143. * * The optional parameter `colors` is an array of successive Color4, one per line point
  149144. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  149145. * * When updating an instance, remember that only point positions can change, not the number of points
  149146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  149148. * @param name defines the name of the new line system
  149149. * @param options defines the options used to create the line system
  149150. * @param scene defines the hosting scene
  149151. * @returns a new line mesh
  149152. */
  149153. static CreateLines(name: string, options: {
  149154. points: Vector3[];
  149155. updatable?: boolean;
  149156. instance?: Nullable<LinesMesh>;
  149157. colors?: Color4[];
  149158. useVertexAlpha?: boolean;
  149159. }, scene?: Nullable<Scene>): LinesMesh;
  149160. /**
  149161. * Creates a dashed line mesh
  149162. * * 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
  149163. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  149164. * * The parameter `points` is an array successive Vector3
  149165. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  149166. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  149167. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  149168. * * 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
  149169. * * When updating an instance, remember that only point positions can change, not the number of points
  149170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149171. * @param name defines the name of the mesh
  149172. * @param options defines the options used to create the mesh
  149173. * @param scene defines the hosting scene
  149174. * @returns the dashed line mesh
  149175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  149176. */
  149177. static CreateDashedLines(name: string, options: {
  149178. points: Vector3[];
  149179. dashSize?: number;
  149180. gapSize?: number;
  149181. dashNb?: number;
  149182. updatable?: boolean;
  149183. instance?: LinesMesh;
  149184. }, scene?: Nullable<Scene>): LinesMesh;
  149185. /**
  149186. * 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.
  149187. * * 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.
  149188. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  149189. * * 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.
  149190. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  149191. * * 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
  149192. * * 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
  149193. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  149194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149196. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  149197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149198. * @param name defines the name of the mesh
  149199. * @param options defines the options used to create the mesh
  149200. * @param scene defines the hosting scene
  149201. * @returns the extruded shape mesh
  149202. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  149204. */
  149205. static ExtrudeShape(name: string, options: {
  149206. shape: Vector3[];
  149207. path: Vector3[];
  149208. scale?: number;
  149209. rotation?: number;
  149210. cap?: number;
  149211. updatable?: boolean;
  149212. sideOrientation?: number;
  149213. frontUVs?: Vector4;
  149214. backUVs?: Vector4;
  149215. instance?: Mesh;
  149216. invertUV?: boolean;
  149217. }, scene?: Nullable<Scene>): Mesh;
  149218. /**
  149219. * Creates an custom extruded shape mesh.
  149220. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  149221. * * 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.
  149222. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  149223. * * 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
  149224. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  149225. * * 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
  149226. * * It must returns a float value that will be the scale value applied to the shape on each path point
  149227. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  149228. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  149229. * * 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
  149230. * * 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
  149231. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  149232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149234. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149235. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149236. * @param name defines the name of the mesh
  149237. * @param options defines the options used to create the mesh
  149238. * @param scene defines the hosting scene
  149239. * @returns the custom extruded shape mesh
  149240. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  149241. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149242. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  149243. */
  149244. static ExtrudeShapeCustom(name: string, options: {
  149245. shape: Vector3[];
  149246. path: Vector3[];
  149247. scaleFunction?: any;
  149248. rotationFunction?: any;
  149249. ribbonCloseArray?: boolean;
  149250. ribbonClosePath?: boolean;
  149251. cap?: number;
  149252. updatable?: boolean;
  149253. sideOrientation?: number;
  149254. frontUVs?: Vector4;
  149255. backUVs?: Vector4;
  149256. instance?: Mesh;
  149257. invertUV?: boolean;
  149258. }, scene?: Nullable<Scene>): Mesh;
  149259. /**
  149260. * Creates lathe mesh.
  149261. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  149262. * * 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
  149263. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  149264. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  149265. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  149266. * * 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
  149267. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  149268. * * 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
  149269. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149270. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149271. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149273. * @param name defines the name of the mesh
  149274. * @param options defines the options used to create the mesh
  149275. * @param scene defines the hosting scene
  149276. * @returns the lathe mesh
  149277. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  149278. */
  149279. static CreateLathe(name: string, options: {
  149280. shape: Vector3[];
  149281. radius?: number;
  149282. tessellation?: number;
  149283. clip?: number;
  149284. arc?: number;
  149285. closed?: boolean;
  149286. updatable?: boolean;
  149287. sideOrientation?: number;
  149288. frontUVs?: Vector4;
  149289. backUVs?: Vector4;
  149290. cap?: number;
  149291. invertUV?: boolean;
  149292. }, scene?: Nullable<Scene>): Mesh;
  149293. /**
  149294. * Creates a tiled plane mesh
  149295. * * You can set a limited pattern arrangement with the tiles
  149296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149299. * @param name defines the name of the mesh
  149300. * @param options defines the options used to create the mesh
  149301. * @param scene defines the hosting scene
  149302. * @returns the plane mesh
  149303. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  149304. */
  149305. static CreateTiledPlane(name: string, options: {
  149306. pattern?: number;
  149307. tileSize?: number;
  149308. tileWidth?: number;
  149309. tileHeight?: number;
  149310. size?: number;
  149311. width?: number;
  149312. height?: number;
  149313. alignHorizontal?: number;
  149314. alignVertical?: number;
  149315. sideOrientation?: number;
  149316. frontUVs?: Vector4;
  149317. backUVs?: Vector4;
  149318. updatable?: boolean;
  149319. }, scene?: Nullable<Scene>): Mesh;
  149320. /**
  149321. * Creates a plane mesh
  149322. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  149323. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  149324. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  149325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149326. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149328. * @param name defines the name of the mesh
  149329. * @param options defines the options used to create the mesh
  149330. * @param scene defines the hosting scene
  149331. * @returns the plane mesh
  149332. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  149333. */
  149334. static CreatePlane(name: string, options: {
  149335. size?: number;
  149336. width?: number;
  149337. height?: number;
  149338. sideOrientation?: number;
  149339. frontUVs?: Vector4;
  149340. backUVs?: Vector4;
  149341. updatable?: boolean;
  149342. sourcePlane?: Plane;
  149343. }, scene?: Nullable<Scene>): Mesh;
  149344. /**
  149345. * Creates a ground mesh
  149346. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  149347. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  149348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149349. * @param name defines the name of the mesh
  149350. * @param options defines the options used to create the mesh
  149351. * @param scene defines the hosting scene
  149352. * @returns the ground mesh
  149353. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  149354. */
  149355. static CreateGround(name: string, options: {
  149356. width?: number;
  149357. height?: number;
  149358. subdivisions?: number;
  149359. subdivisionsX?: number;
  149360. subdivisionsY?: number;
  149361. updatable?: boolean;
  149362. }, scene?: Nullable<Scene>): Mesh;
  149363. /**
  149364. * Creates a tiled ground mesh
  149365. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  149366. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  149367. * * 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
  149368. * * 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
  149369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149370. * @param name defines the name of the mesh
  149371. * @param options defines the options used to create the mesh
  149372. * @param scene defines the hosting scene
  149373. * @returns the tiled ground mesh
  149374. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  149375. */
  149376. static CreateTiledGround(name: string, options: {
  149377. xmin: number;
  149378. zmin: number;
  149379. xmax: number;
  149380. zmax: number;
  149381. subdivisions?: {
  149382. w: number;
  149383. h: number;
  149384. };
  149385. precision?: {
  149386. w: number;
  149387. h: number;
  149388. };
  149389. updatable?: boolean;
  149390. }, scene?: Nullable<Scene>): Mesh;
  149391. /**
  149392. * Creates a ground mesh from a height map
  149393. * * The parameter `url` sets the URL of the height map image resource.
  149394. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  149395. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  149396. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  149397. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  149398. * * 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.
  149399. * * 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).
  149400. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  149401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149402. * @param name defines the name of the mesh
  149403. * @param url defines the url to the height map
  149404. * @param options defines the options used to create the mesh
  149405. * @param scene defines the hosting scene
  149406. * @returns the ground mesh
  149407. * @see https://doc.babylonjs.com/babylon101/height_map
  149408. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  149409. */
  149410. static CreateGroundFromHeightMap(name: string, url: string, options: {
  149411. width?: number;
  149412. height?: number;
  149413. subdivisions?: number;
  149414. minHeight?: number;
  149415. maxHeight?: number;
  149416. colorFilter?: Color3;
  149417. alphaFilter?: number;
  149418. updatable?: boolean;
  149419. onReady?: (mesh: GroundMesh) => void;
  149420. }, scene?: Nullable<Scene>): GroundMesh;
  149421. /**
  149422. * Creates a polygon mesh
  149423. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  149424. * * 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
  149425. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  149426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  149428. * * Remember you can only change the shape positions, not their number when updating a polygon
  149429. * @param name defines the name of the mesh
  149430. * @param options defines the options used to create the mesh
  149431. * @param scene defines the hosting scene
  149432. * @param earcutInjection can be used to inject your own earcut reference
  149433. * @returns the polygon mesh
  149434. */
  149435. static CreatePolygon(name: string, options: {
  149436. shape: Vector3[];
  149437. holes?: Vector3[][];
  149438. depth?: number;
  149439. faceUV?: Vector4[];
  149440. faceColors?: Color4[];
  149441. updatable?: boolean;
  149442. sideOrientation?: number;
  149443. frontUVs?: Vector4;
  149444. backUVs?: Vector4;
  149445. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149446. /**
  149447. * Creates an extruded polygon mesh, with depth in the Y direction.
  149448. * * 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)
  149449. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  149450. * @param name defines the name of the mesh
  149451. * @param options defines the options used to create the mesh
  149452. * @param scene defines the hosting scene
  149453. * @param earcutInjection can be used to inject your own earcut reference
  149454. * @returns the polygon mesh
  149455. */
  149456. static ExtrudePolygon(name: string, options: {
  149457. shape: Vector3[];
  149458. holes?: Vector3[][];
  149459. depth?: number;
  149460. faceUV?: Vector4[];
  149461. faceColors?: Color4[];
  149462. updatable?: boolean;
  149463. sideOrientation?: number;
  149464. frontUVs?: Vector4;
  149465. backUVs?: Vector4;
  149466. wrap?: boolean;
  149467. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149468. /**
  149469. * Creates a tube mesh.
  149470. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  149471. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  149472. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  149473. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  149474. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  149475. * * 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)
  149476. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  149477. * * 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
  149478. * * 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
  149479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149483. * @param name defines the name of the mesh
  149484. * @param options defines the options used to create the mesh
  149485. * @param scene defines the hosting scene
  149486. * @returns the tube mesh
  149487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149488. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  149489. */
  149490. static CreateTube(name: string, options: {
  149491. path: Vector3[];
  149492. radius?: number;
  149493. tessellation?: number;
  149494. radiusFunction?: {
  149495. (i: number, distance: number): number;
  149496. };
  149497. cap?: number;
  149498. arc?: number;
  149499. updatable?: boolean;
  149500. sideOrientation?: number;
  149501. frontUVs?: Vector4;
  149502. backUVs?: Vector4;
  149503. instance?: Mesh;
  149504. invertUV?: boolean;
  149505. }, scene?: Nullable<Scene>): Mesh;
  149506. /**
  149507. * Creates a polyhedron mesh
  149508. * * 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
  149509. * * The parameter `size` (positive float, default 1) sets the polygon size
  149510. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  149511. * * 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`
  149512. * * 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
  149513. * * 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)`)
  149514. * * 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
  149515. * * 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
  149516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149519. * @param name defines the name of the mesh
  149520. * @param options defines the options used to create the mesh
  149521. * @param scene defines the hosting scene
  149522. * @returns the polyhedron mesh
  149523. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  149524. */
  149525. static CreatePolyhedron(name: string, options: {
  149526. type?: number;
  149527. size?: number;
  149528. sizeX?: number;
  149529. sizeY?: number;
  149530. sizeZ?: number;
  149531. custom?: any;
  149532. faceUV?: Vector4[];
  149533. faceColors?: Color4[];
  149534. flat?: boolean;
  149535. updatable?: boolean;
  149536. sideOrientation?: number;
  149537. frontUVs?: Vector4;
  149538. backUVs?: Vector4;
  149539. }, scene?: Nullable<Scene>): Mesh;
  149540. /**
  149541. * Creates a decal mesh.
  149542. * 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
  149543. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  149544. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  149545. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  149546. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  149547. * @param name defines the name of the mesh
  149548. * @param sourceMesh defines the mesh where the decal must be applied
  149549. * @param options defines the options used to create the mesh
  149550. * @param scene defines the hosting scene
  149551. * @returns the decal mesh
  149552. * @see https://doc.babylonjs.com/how_to/decals
  149553. */
  149554. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  149555. position?: Vector3;
  149556. normal?: Vector3;
  149557. size?: Vector3;
  149558. angle?: number;
  149559. }): Mesh;
  149560. /**
  149561. * Creates a Capsule Mesh
  149562. * @param name defines the name of the mesh.
  149563. * @param options the constructors options used to shape the mesh.
  149564. * @param scene defines the scene the mesh is scoped to.
  149565. * @returns the capsule mesh
  149566. * @see https://doc.babylonjs.com/how_to/capsule_shape
  149567. */
  149568. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  149569. }
  149570. }
  149571. declare module BABYLON {
  149572. /**
  149573. * A simplifier interface for future simplification implementations
  149574. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149575. */
  149576. export interface ISimplifier {
  149577. /**
  149578. * Simplification of a given mesh according to the given settings.
  149579. * Since this requires computation, it is assumed that the function runs async.
  149580. * @param settings The settings of the simplification, including quality and distance
  149581. * @param successCallback A callback that will be called after the mesh was simplified.
  149582. * @param errorCallback in case of an error, this callback will be called. optional.
  149583. */
  149584. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  149585. }
  149586. /**
  149587. * Expected simplification settings.
  149588. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  149589. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149590. */
  149591. export interface ISimplificationSettings {
  149592. /**
  149593. * Gets or sets the expected quality
  149594. */
  149595. quality: number;
  149596. /**
  149597. * Gets or sets the distance when this optimized version should be used
  149598. */
  149599. distance: number;
  149600. /**
  149601. * Gets an already optimized mesh
  149602. */
  149603. optimizeMesh?: boolean;
  149604. }
  149605. /**
  149606. * Class used to specify simplification options
  149607. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149608. */
  149609. export class SimplificationSettings implements ISimplificationSettings {
  149610. /** expected quality */
  149611. quality: number;
  149612. /** distance when this optimized version should be used */
  149613. distance: number;
  149614. /** already optimized mesh */
  149615. optimizeMesh?: boolean | undefined;
  149616. /**
  149617. * Creates a SimplificationSettings
  149618. * @param quality expected quality
  149619. * @param distance distance when this optimized version should be used
  149620. * @param optimizeMesh already optimized mesh
  149621. */
  149622. constructor(
  149623. /** expected quality */
  149624. quality: number,
  149625. /** distance when this optimized version should be used */
  149626. distance: number,
  149627. /** already optimized mesh */
  149628. optimizeMesh?: boolean | undefined);
  149629. }
  149630. /**
  149631. * Interface used to define a simplification task
  149632. */
  149633. export interface ISimplificationTask {
  149634. /**
  149635. * Array of settings
  149636. */
  149637. settings: Array<ISimplificationSettings>;
  149638. /**
  149639. * Simplification type
  149640. */
  149641. simplificationType: SimplificationType;
  149642. /**
  149643. * Mesh to simplify
  149644. */
  149645. mesh: Mesh;
  149646. /**
  149647. * Callback called on success
  149648. */
  149649. successCallback?: () => void;
  149650. /**
  149651. * Defines if parallel processing can be used
  149652. */
  149653. parallelProcessing: boolean;
  149654. }
  149655. /**
  149656. * Queue used to order the simplification tasks
  149657. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149658. */
  149659. export class SimplificationQueue {
  149660. private _simplificationArray;
  149661. /**
  149662. * Gets a boolean indicating that the process is still running
  149663. */
  149664. running: boolean;
  149665. /**
  149666. * Creates a new queue
  149667. */
  149668. constructor();
  149669. /**
  149670. * Adds a new simplification task
  149671. * @param task defines a task to add
  149672. */
  149673. addTask(task: ISimplificationTask): void;
  149674. /**
  149675. * Execute next task
  149676. */
  149677. executeNext(): void;
  149678. /**
  149679. * Execute a simplification task
  149680. * @param task defines the task to run
  149681. */
  149682. runSimplification(task: ISimplificationTask): void;
  149683. private getSimplifier;
  149684. }
  149685. /**
  149686. * The implemented types of simplification
  149687. * At the moment only Quadratic Error Decimation is implemented
  149688. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149689. */
  149690. export enum SimplificationType {
  149691. /** Quadratic error decimation */
  149692. QUADRATIC = 0
  149693. }
  149694. /**
  149695. * An implementation of the Quadratic Error simplification algorithm.
  149696. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  149697. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  149698. * @author RaananW
  149699. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149700. */
  149701. export class QuadraticErrorSimplification implements ISimplifier {
  149702. private _mesh;
  149703. private triangles;
  149704. private vertices;
  149705. private references;
  149706. private _reconstructedMesh;
  149707. /** Gets or sets the number pf sync interations */
  149708. syncIterations: number;
  149709. /** Gets or sets the aggressiveness of the simplifier */
  149710. aggressiveness: number;
  149711. /** Gets or sets the number of allowed iterations for decimation */
  149712. decimationIterations: number;
  149713. /** Gets or sets the espilon to use for bounding box computation */
  149714. boundingBoxEpsilon: number;
  149715. /**
  149716. * Creates a new QuadraticErrorSimplification
  149717. * @param _mesh defines the target mesh
  149718. */
  149719. constructor(_mesh: Mesh);
  149720. /**
  149721. * Simplification of a given mesh according to the given settings.
  149722. * Since this requires computation, it is assumed that the function runs async.
  149723. * @param settings The settings of the simplification, including quality and distance
  149724. * @param successCallback A callback that will be called after the mesh was simplified.
  149725. */
  149726. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  149727. private runDecimation;
  149728. private initWithMesh;
  149729. private init;
  149730. private reconstructMesh;
  149731. private initDecimatedMesh;
  149732. private isFlipped;
  149733. private updateTriangles;
  149734. private identifyBorder;
  149735. private updateMesh;
  149736. private vertexError;
  149737. private calculateError;
  149738. }
  149739. }
  149740. declare module BABYLON {
  149741. interface Scene {
  149742. /** @hidden (Backing field) */
  149743. _simplificationQueue: SimplificationQueue;
  149744. /**
  149745. * Gets or sets the simplification queue attached to the scene
  149746. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149747. */
  149748. simplificationQueue: SimplificationQueue;
  149749. }
  149750. interface Mesh {
  149751. /**
  149752. * Simplify the mesh according to the given array of settings.
  149753. * Function will return immediately and will simplify async
  149754. * @param settings a collection of simplification settings
  149755. * @param parallelProcessing should all levels calculate parallel or one after the other
  149756. * @param simplificationType the type of simplification to run
  149757. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  149758. * @returns the current mesh
  149759. */
  149760. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  149761. }
  149762. /**
  149763. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  149764. * created in a scene
  149765. */
  149766. export class SimplicationQueueSceneComponent implements ISceneComponent {
  149767. /**
  149768. * The component name helpfull to identify the component in the list of scene components.
  149769. */
  149770. readonly name: string;
  149771. /**
  149772. * The scene the component belongs to.
  149773. */
  149774. scene: Scene;
  149775. /**
  149776. * Creates a new instance of the component for the given scene
  149777. * @param scene Defines the scene to register the component in
  149778. */
  149779. constructor(scene: Scene);
  149780. /**
  149781. * Registers the component in a given scene
  149782. */
  149783. register(): void;
  149784. /**
  149785. * Rebuilds the elements related to this component in case of
  149786. * context lost for instance.
  149787. */
  149788. rebuild(): void;
  149789. /**
  149790. * Disposes the component and the associated ressources
  149791. */
  149792. dispose(): void;
  149793. private _beforeCameraUpdate;
  149794. }
  149795. }
  149796. declare module BABYLON {
  149797. interface Mesh {
  149798. /**
  149799. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  149800. */
  149801. thinInstanceEnablePicking: boolean;
  149802. /**
  149803. * Creates a new thin instance
  149804. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  149805. * @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
  149806. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  149807. */
  149808. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  149809. /**
  149810. * Adds the transformation (matrix) of the current mesh as a thin instance
  149811. * @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
  149812. * @returns the thin instance index number
  149813. */
  149814. thinInstanceAddSelf(refresh: boolean): number;
  149815. /**
  149816. * Registers a custom attribute to be used with thin instances
  149817. * @param kind name of the attribute
  149818. * @param stride size in floats of the attribute
  149819. */
  149820. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  149821. /**
  149822. * Sets the matrix of a thin instance
  149823. * @param index index of the thin instance
  149824. * @param matrix matrix to set
  149825. * @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
  149826. */
  149827. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  149828. /**
  149829. * Sets the value of a custom attribute for a thin instance
  149830. * @param kind name of the attribute
  149831. * @param index index of the thin instance
  149832. * @param value value to set
  149833. * @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
  149834. */
  149835. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  149836. /**
  149837. * 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.
  149838. */
  149839. thinInstanceCount: number;
  149840. /**
  149841. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  149842. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  149843. * @param buffer buffer to set
  149844. * @param stride size in floats of each value of the buffer
  149845. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  149846. */
  149847. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  149848. /**
  149849. * Gets the list of world matrices
  149850. * @return an array containing all the world matrices from the thin instances
  149851. */
  149852. thinInstanceGetWorldMatrices(): Matrix[];
  149853. /**
  149854. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  149855. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149856. */
  149857. thinInstanceBufferUpdated(kind: string): void;
  149858. /**
  149859. * Applies a partial update to a buffer directly on the GPU
  149860. * 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
  149861. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149862. * @param data the data to set in the GPU buffer
  149863. * @param offset the offset in the GPU buffer where to update the data
  149864. */
  149865. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  149866. /**
  149867. * Refreshes the bounding info, taking into account all the thin instances defined
  149868. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  149869. */
  149870. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  149871. /** @hidden */
  149872. _thinInstanceInitializeUserStorage(): void;
  149873. /** @hidden */
  149874. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  149875. /** @hidden */
  149876. _userThinInstanceBuffersStorage: {
  149877. data: {
  149878. [key: string]: Float32Array;
  149879. };
  149880. sizes: {
  149881. [key: string]: number;
  149882. };
  149883. vertexBuffers: {
  149884. [key: string]: Nullable<VertexBuffer>;
  149885. };
  149886. strides: {
  149887. [key: string]: number;
  149888. };
  149889. };
  149890. }
  149891. }
  149892. declare module BABYLON {
  149893. /**
  149894. * Navigation plugin interface to add navigation constrained by a navigation mesh
  149895. */
  149896. export interface INavigationEnginePlugin {
  149897. /**
  149898. * plugin name
  149899. */
  149900. name: string;
  149901. /**
  149902. * Creates a navigation mesh
  149903. * @param meshes array of all the geometry used to compute the navigatio mesh
  149904. * @param parameters bunch of parameters used to filter geometry
  149905. */
  149906. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149907. /**
  149908. * Create a navigation mesh debug mesh
  149909. * @param scene is where the mesh will be added
  149910. * @returns debug display mesh
  149911. */
  149912. createDebugNavMesh(scene: Scene): Mesh;
  149913. /**
  149914. * Get a navigation mesh constrained position, closest to the parameter position
  149915. * @param position world position
  149916. * @returns the closest point to position constrained by the navigation mesh
  149917. */
  149918. getClosestPoint(position: Vector3): Vector3;
  149919. /**
  149920. * Get a navigation mesh constrained position, closest to the parameter position
  149921. * @param position world position
  149922. * @param result output the closest point to position constrained by the navigation mesh
  149923. */
  149924. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149925. /**
  149926. * Get a navigation mesh constrained position, within a particular radius
  149927. * @param position world position
  149928. * @param maxRadius the maximum distance to the constrained world position
  149929. * @returns the closest point to position constrained by the navigation mesh
  149930. */
  149931. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149932. /**
  149933. * Get a navigation mesh constrained position, within a particular radius
  149934. * @param position world position
  149935. * @param maxRadius the maximum distance to the constrained world position
  149936. * @param result output the closest point to position constrained by the navigation mesh
  149937. */
  149938. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149939. /**
  149940. * Compute the final position from a segment made of destination-position
  149941. * @param position world position
  149942. * @param destination world position
  149943. * @returns the resulting point along the navmesh
  149944. */
  149945. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149946. /**
  149947. * Compute the final position from a segment made of destination-position
  149948. * @param position world position
  149949. * @param destination world position
  149950. * @param result output the resulting point along the navmesh
  149951. */
  149952. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149953. /**
  149954. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149955. * @param start world position
  149956. * @param end world position
  149957. * @returns array containing world position composing the path
  149958. */
  149959. computePath(start: Vector3, end: Vector3): Vector3[];
  149960. /**
  149961. * If this plugin is supported
  149962. * @returns true if plugin is supported
  149963. */
  149964. isSupported(): boolean;
  149965. /**
  149966. * Create a new Crowd so you can add agents
  149967. * @param maxAgents the maximum agent count in the crowd
  149968. * @param maxAgentRadius the maximum radius an agent can have
  149969. * @param scene to attach the crowd to
  149970. * @returns the crowd you can add agents to
  149971. */
  149972. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149973. /**
  149974. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149975. * The queries will try to find a solution within those bounds
  149976. * default is (1,1,1)
  149977. * @param extent x,y,z value that define the extent around the queries point of reference
  149978. */
  149979. setDefaultQueryExtent(extent: Vector3): void;
  149980. /**
  149981. * Get the Bounding box extent specified by setDefaultQueryExtent
  149982. * @returns the box extent values
  149983. */
  149984. getDefaultQueryExtent(): Vector3;
  149985. /**
  149986. * build the navmesh from a previously saved state using getNavmeshData
  149987. * @param data the Uint8Array returned by getNavmeshData
  149988. */
  149989. buildFromNavmeshData(data: Uint8Array): void;
  149990. /**
  149991. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149992. * @returns data the Uint8Array that can be saved and reused
  149993. */
  149994. getNavmeshData(): Uint8Array;
  149995. /**
  149996. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149997. * @param result output the box extent values
  149998. */
  149999. getDefaultQueryExtentToRef(result: Vector3): void;
  150000. /**
  150001. * Set the time step of the navigation tick update.
  150002. * Default is 1/60.
  150003. * A value of 0 will disable fixed time update
  150004. * @param newTimeStep the new timestep to apply to this world.
  150005. */
  150006. setTimeStep(newTimeStep: number): void;
  150007. /**
  150008. * Get the time step of the navigation tick update.
  150009. * @returns the current time step
  150010. */
  150011. getTimeStep(): number;
  150012. /**
  150013. * If delta time in navigation tick update is greater than the time step
  150014. * a number of sub iterations are done. If more iterations are need to reach deltatime
  150015. * they will be discarded.
  150016. * A value of 0 will set to no maximum and update will use as many substeps as needed
  150017. * @param newStepCount the maximum number of iterations
  150018. */
  150019. setMaximumSubStepCount(newStepCount: number): void;
  150020. /**
  150021. * Get the maximum number of iterations per navigation tick update
  150022. * @returns the maximum number of iterations
  150023. */
  150024. getMaximumSubStepCount(): number;
  150025. /**
  150026. * Release all resources
  150027. */
  150028. dispose(): void;
  150029. }
  150030. /**
  150031. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  150032. */
  150033. export interface ICrowd {
  150034. /**
  150035. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  150036. * You can attach anything to that node. The node position is updated in the scene update tick.
  150037. * @param pos world position that will be constrained by the navigation mesh
  150038. * @param parameters agent parameters
  150039. * @param transform hooked to the agent that will be update by the scene
  150040. * @returns agent index
  150041. */
  150042. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  150043. /**
  150044. * Returns the agent position in world space
  150045. * @param index agent index returned by addAgent
  150046. * @returns world space position
  150047. */
  150048. getAgentPosition(index: number): Vector3;
  150049. /**
  150050. * Gets the agent position result in world space
  150051. * @param index agent index returned by addAgent
  150052. * @param result output world space position
  150053. */
  150054. getAgentPositionToRef(index: number, result: Vector3): void;
  150055. /**
  150056. * Gets the agent velocity in world space
  150057. * @param index agent index returned by addAgent
  150058. * @returns world space velocity
  150059. */
  150060. getAgentVelocity(index: number): Vector3;
  150061. /**
  150062. * Gets the agent velocity result in world space
  150063. * @param index agent index returned by addAgent
  150064. * @param result output world space velocity
  150065. */
  150066. getAgentVelocityToRef(index: number, result: Vector3): void;
  150067. /**
  150068. * Gets the agent next target point on the path
  150069. * @param index agent index returned by addAgent
  150070. * @returns world space position
  150071. */
  150072. getAgentNextTargetPath(index: number): Vector3;
  150073. /**
  150074. * Gets the agent state
  150075. * @param index agent index returned by addAgent
  150076. * @returns agent state
  150077. */
  150078. getAgentState(index: number): number;
  150079. /**
  150080. * returns true if the agent in over an off mesh link connection
  150081. * @param index agent index returned by addAgent
  150082. * @returns true if over an off mesh link connection
  150083. */
  150084. overOffmeshConnection(index: number): boolean;
  150085. /**
  150086. * Gets the agent next target point on the path
  150087. * @param index agent index returned by addAgent
  150088. * @param result output world space position
  150089. */
  150090. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  150091. /**
  150092. * remove a particular agent previously created
  150093. * @param index agent index returned by addAgent
  150094. */
  150095. removeAgent(index: number): void;
  150096. /**
  150097. * get the list of all agents attached to this crowd
  150098. * @returns list of agent indices
  150099. */
  150100. getAgents(): number[];
  150101. /**
  150102. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  150103. * @param deltaTime in seconds
  150104. */
  150105. update(deltaTime: number): void;
  150106. /**
  150107. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  150108. * @param index agent index returned by addAgent
  150109. * @param destination targeted world position
  150110. */
  150111. agentGoto(index: number, destination: Vector3): void;
  150112. /**
  150113. * Teleport the agent to a new position
  150114. * @param index agent index returned by addAgent
  150115. * @param destination targeted world position
  150116. */
  150117. agentTeleport(index: number, destination: Vector3): void;
  150118. /**
  150119. * Update agent parameters
  150120. * @param index agent index returned by addAgent
  150121. * @param parameters agent parameters
  150122. */
  150123. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  150124. /**
  150125. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150126. * The queries will try to find a solution within those bounds
  150127. * default is (1,1,1)
  150128. * @param extent x,y,z value that define the extent around the queries point of reference
  150129. */
  150130. setDefaultQueryExtent(extent: Vector3): void;
  150131. /**
  150132. * Get the Bounding box extent specified by setDefaultQueryExtent
  150133. * @returns the box extent values
  150134. */
  150135. getDefaultQueryExtent(): Vector3;
  150136. /**
  150137. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150138. * @param result output the box extent values
  150139. */
  150140. getDefaultQueryExtentToRef(result: Vector3): void;
  150141. /**
  150142. * Release all resources
  150143. */
  150144. dispose(): void;
  150145. }
  150146. /**
  150147. * Configures an agent
  150148. */
  150149. export interface IAgentParameters {
  150150. /**
  150151. * Agent radius. [Limit: >= 0]
  150152. */
  150153. radius: number;
  150154. /**
  150155. * Agent height. [Limit: > 0]
  150156. */
  150157. height: number;
  150158. /**
  150159. * Maximum allowed acceleration. [Limit: >= 0]
  150160. */
  150161. maxAcceleration: number;
  150162. /**
  150163. * Maximum allowed speed. [Limit: >= 0]
  150164. */
  150165. maxSpeed: number;
  150166. /**
  150167. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  150168. */
  150169. collisionQueryRange: number;
  150170. /**
  150171. * The path visibility optimization range. [Limit: > 0]
  150172. */
  150173. pathOptimizationRange: number;
  150174. /**
  150175. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  150176. */
  150177. separationWeight: number;
  150178. }
  150179. /**
  150180. * Configures the navigation mesh creation
  150181. */
  150182. export interface INavMeshParameters {
  150183. /**
  150184. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  150185. */
  150186. cs: number;
  150187. /**
  150188. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  150189. */
  150190. ch: number;
  150191. /**
  150192. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  150193. */
  150194. walkableSlopeAngle: number;
  150195. /**
  150196. * Minimum floor to 'ceiling' height that will still allow the floor area to
  150197. * be considered walkable. [Limit: >= 3] [Units: vx]
  150198. */
  150199. walkableHeight: number;
  150200. /**
  150201. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  150202. */
  150203. walkableClimb: number;
  150204. /**
  150205. * The distance to erode/shrink the walkable area of the heightfield away from
  150206. * obstructions. [Limit: >=0] [Units: vx]
  150207. */
  150208. walkableRadius: number;
  150209. /**
  150210. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  150211. */
  150212. maxEdgeLen: number;
  150213. /**
  150214. * The maximum distance a simplfied contour's border edges should deviate
  150215. * the original raw contour. [Limit: >=0] [Units: vx]
  150216. */
  150217. maxSimplificationError: number;
  150218. /**
  150219. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  150220. */
  150221. minRegionArea: number;
  150222. /**
  150223. * Any regions with a span count smaller than this value will, if possible,
  150224. * be merged with larger regions. [Limit: >=0] [Units: vx]
  150225. */
  150226. mergeRegionArea: number;
  150227. /**
  150228. * The maximum number of vertices allowed for polygons generated during the
  150229. * contour to polygon conversion process. [Limit: >= 3]
  150230. */
  150231. maxVertsPerPoly: number;
  150232. /**
  150233. * Sets the sampling distance to use when generating the detail mesh.
  150234. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  150235. */
  150236. detailSampleDist: number;
  150237. /**
  150238. * The maximum distance the detail mesh surface should deviate from heightfield
  150239. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  150240. */
  150241. detailSampleMaxError: number;
  150242. }
  150243. }
  150244. declare module BABYLON {
  150245. /**
  150246. * RecastJS navigation plugin
  150247. */
  150248. export class RecastJSPlugin implements INavigationEnginePlugin {
  150249. /**
  150250. * Reference to the Recast library
  150251. */
  150252. bjsRECAST: any;
  150253. /**
  150254. * plugin name
  150255. */
  150256. name: string;
  150257. /**
  150258. * the first navmesh created. We might extend this to support multiple navmeshes
  150259. */
  150260. navMesh: any;
  150261. private _maximumSubStepCount;
  150262. private _timeStep;
  150263. /**
  150264. * Initializes the recastJS plugin
  150265. * @param recastInjection can be used to inject your own recast reference
  150266. */
  150267. constructor(recastInjection?: any);
  150268. /**
  150269. * Set the time step of the navigation tick update.
  150270. * Default is 1/60.
  150271. * A value of 0 will disable fixed time update
  150272. * @param newTimeStep the new timestep to apply to this world.
  150273. */
  150274. setTimeStep(newTimeStep?: number): void;
  150275. /**
  150276. * Get the time step of the navigation tick update.
  150277. * @returns the current time step
  150278. */
  150279. getTimeStep(): number;
  150280. /**
  150281. * If delta time in navigation tick update is greater than the time step
  150282. * a number of sub iterations are done. If more iterations are need to reach deltatime
  150283. * they will be discarded.
  150284. * A value of 0 will set to no maximum and update will use as many substeps as needed
  150285. * @param newStepCount the maximum number of iterations
  150286. */
  150287. setMaximumSubStepCount(newStepCount?: number): void;
  150288. /**
  150289. * Get the maximum number of iterations per navigation tick update
  150290. * @returns the maximum number of iterations
  150291. */
  150292. getMaximumSubStepCount(): number;
  150293. /**
  150294. * Creates a navigation mesh
  150295. * @param meshes array of all the geometry used to compute the navigatio mesh
  150296. * @param parameters bunch of parameters used to filter geometry
  150297. */
  150298. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  150299. /**
  150300. * Create a navigation mesh debug mesh
  150301. * @param scene is where the mesh will be added
  150302. * @returns debug display mesh
  150303. */
  150304. createDebugNavMesh(scene: Scene): Mesh;
  150305. /**
  150306. * Get a navigation mesh constrained position, closest to the parameter position
  150307. * @param position world position
  150308. * @returns the closest point to position constrained by the navigation mesh
  150309. */
  150310. getClosestPoint(position: Vector3): Vector3;
  150311. /**
  150312. * Get a navigation mesh constrained position, closest to the parameter position
  150313. * @param position world position
  150314. * @param result output the closest point to position constrained by the navigation mesh
  150315. */
  150316. getClosestPointToRef(position: Vector3, result: Vector3): void;
  150317. /**
  150318. * Get a navigation mesh constrained position, within a particular radius
  150319. * @param position world position
  150320. * @param maxRadius the maximum distance to the constrained world position
  150321. * @returns the closest point to position constrained by the navigation mesh
  150322. */
  150323. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  150324. /**
  150325. * Get a navigation mesh constrained position, within a particular radius
  150326. * @param position world position
  150327. * @param maxRadius the maximum distance to the constrained world position
  150328. * @param result output the closest point to position constrained by the navigation mesh
  150329. */
  150330. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  150331. /**
  150332. * Compute the final position from a segment made of destination-position
  150333. * @param position world position
  150334. * @param destination world position
  150335. * @returns the resulting point along the navmesh
  150336. */
  150337. moveAlong(position: Vector3, destination: Vector3): Vector3;
  150338. /**
  150339. * Compute the final position from a segment made of destination-position
  150340. * @param position world position
  150341. * @param destination world position
  150342. * @param result output the resulting point along the navmesh
  150343. */
  150344. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  150345. /**
  150346. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  150347. * @param start world position
  150348. * @param end world position
  150349. * @returns array containing world position composing the path
  150350. */
  150351. computePath(start: Vector3, end: Vector3): Vector3[];
  150352. /**
  150353. * Create a new Crowd so you can add agents
  150354. * @param maxAgents the maximum agent count in the crowd
  150355. * @param maxAgentRadius the maximum radius an agent can have
  150356. * @param scene to attach the crowd to
  150357. * @returns the crowd you can add agents to
  150358. */
  150359. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  150360. /**
  150361. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150362. * The queries will try to find a solution within those bounds
  150363. * default is (1,1,1)
  150364. * @param extent x,y,z value that define the extent around the queries point of reference
  150365. */
  150366. setDefaultQueryExtent(extent: Vector3): void;
  150367. /**
  150368. * Get the Bounding box extent specified by setDefaultQueryExtent
  150369. * @returns the box extent values
  150370. */
  150371. getDefaultQueryExtent(): Vector3;
  150372. /**
  150373. * build the navmesh from a previously saved state using getNavmeshData
  150374. * @param data the Uint8Array returned by getNavmeshData
  150375. */
  150376. buildFromNavmeshData(data: Uint8Array): void;
  150377. /**
  150378. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  150379. * @returns data the Uint8Array that can be saved and reused
  150380. */
  150381. getNavmeshData(): Uint8Array;
  150382. /**
  150383. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150384. * @param result output the box extent values
  150385. */
  150386. getDefaultQueryExtentToRef(result: Vector3): void;
  150387. /**
  150388. * Disposes
  150389. */
  150390. dispose(): void;
  150391. /**
  150392. * If this plugin is supported
  150393. * @returns true if plugin is supported
  150394. */
  150395. isSupported(): boolean;
  150396. }
  150397. /**
  150398. * Recast detour crowd implementation
  150399. */
  150400. export class RecastJSCrowd implements ICrowd {
  150401. /**
  150402. * Recast/detour plugin
  150403. */
  150404. bjsRECASTPlugin: RecastJSPlugin;
  150405. /**
  150406. * Link to the detour crowd
  150407. */
  150408. recastCrowd: any;
  150409. /**
  150410. * One transform per agent
  150411. */
  150412. transforms: TransformNode[];
  150413. /**
  150414. * All agents created
  150415. */
  150416. agents: number[];
  150417. /**
  150418. * Link to the scene is kept to unregister the crowd from the scene
  150419. */
  150420. private _scene;
  150421. /**
  150422. * Observer for crowd updates
  150423. */
  150424. private _onBeforeAnimationsObserver;
  150425. /**
  150426. * Constructor
  150427. * @param plugin recastJS plugin
  150428. * @param maxAgents the maximum agent count in the crowd
  150429. * @param maxAgentRadius the maximum radius an agent can have
  150430. * @param scene to attach the crowd to
  150431. * @returns the crowd you can add agents to
  150432. */
  150433. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  150434. /**
  150435. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  150436. * You can attach anything to that node. The node position is updated in the scene update tick.
  150437. * @param pos world position that will be constrained by the navigation mesh
  150438. * @param parameters agent parameters
  150439. * @param transform hooked to the agent that will be update by the scene
  150440. * @returns agent index
  150441. */
  150442. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  150443. /**
  150444. * Returns the agent position in world space
  150445. * @param index agent index returned by addAgent
  150446. * @returns world space position
  150447. */
  150448. getAgentPosition(index: number): Vector3;
  150449. /**
  150450. * Returns the agent position result in world space
  150451. * @param index agent index returned by addAgent
  150452. * @param result output world space position
  150453. */
  150454. getAgentPositionToRef(index: number, result: Vector3): void;
  150455. /**
  150456. * Returns the agent velocity in world space
  150457. * @param index agent index returned by addAgent
  150458. * @returns world space velocity
  150459. */
  150460. getAgentVelocity(index: number): Vector3;
  150461. /**
  150462. * Returns the agent velocity result in world space
  150463. * @param index agent index returned by addAgent
  150464. * @param result output world space velocity
  150465. */
  150466. getAgentVelocityToRef(index: number, result: Vector3): void;
  150467. /**
  150468. * Returns the agent next target point on the path
  150469. * @param index agent index returned by addAgent
  150470. * @returns world space position
  150471. */
  150472. getAgentNextTargetPath(index: number): Vector3;
  150473. /**
  150474. * Returns the agent next target point on the path
  150475. * @param index agent index returned by addAgent
  150476. * @param result output world space position
  150477. */
  150478. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  150479. /**
  150480. * Gets the agent state
  150481. * @param index agent index returned by addAgent
  150482. * @returns agent state
  150483. */
  150484. getAgentState(index: number): number;
  150485. /**
  150486. * returns true if the agent in over an off mesh link connection
  150487. * @param index agent index returned by addAgent
  150488. * @returns true if over an off mesh link connection
  150489. */
  150490. overOffmeshConnection(index: number): boolean;
  150491. /**
  150492. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  150493. * @param index agent index returned by addAgent
  150494. * @param destination targeted world position
  150495. */
  150496. agentGoto(index: number, destination: Vector3): void;
  150497. /**
  150498. * Teleport the agent to a new position
  150499. * @param index agent index returned by addAgent
  150500. * @param destination targeted world position
  150501. */
  150502. agentTeleport(index: number, destination: Vector3): void;
  150503. /**
  150504. * Update agent parameters
  150505. * @param index agent index returned by addAgent
  150506. * @param parameters agent parameters
  150507. */
  150508. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  150509. /**
  150510. * remove a particular agent previously created
  150511. * @param index agent index returned by addAgent
  150512. */
  150513. removeAgent(index: number): void;
  150514. /**
  150515. * get the list of all agents attached to this crowd
  150516. * @returns list of agent indices
  150517. */
  150518. getAgents(): number[];
  150519. /**
  150520. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  150521. * @param deltaTime in seconds
  150522. */
  150523. update(deltaTime: number): void;
  150524. /**
  150525. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150526. * The queries will try to find a solution within those bounds
  150527. * default is (1,1,1)
  150528. * @param extent x,y,z value that define the extent around the queries point of reference
  150529. */
  150530. setDefaultQueryExtent(extent: Vector3): void;
  150531. /**
  150532. * Get the Bounding box extent specified by setDefaultQueryExtent
  150533. * @returns the box extent values
  150534. */
  150535. getDefaultQueryExtent(): Vector3;
  150536. /**
  150537. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150538. * @param result output the box extent values
  150539. */
  150540. getDefaultQueryExtentToRef(result: Vector3): void;
  150541. /**
  150542. * Release all resources
  150543. */
  150544. dispose(): void;
  150545. }
  150546. }
  150547. declare module BABYLON {
  150548. /**
  150549. * Class used to enable access to IndexedDB
  150550. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  150551. */
  150552. export class Database implements IOfflineProvider {
  150553. private _callbackManifestChecked;
  150554. private _currentSceneUrl;
  150555. private _db;
  150556. private _enableSceneOffline;
  150557. private _enableTexturesOffline;
  150558. private _manifestVersionFound;
  150559. private _mustUpdateRessources;
  150560. private _hasReachedQuota;
  150561. private _isSupported;
  150562. private _idbFactory;
  150563. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  150564. private static IsUASupportingBlobStorage;
  150565. /**
  150566. * Gets a boolean indicating if Database storate is enabled (off by default)
  150567. */
  150568. static IDBStorageEnabled: boolean;
  150569. /**
  150570. * Gets a boolean indicating if scene must be saved in the database
  150571. */
  150572. get enableSceneOffline(): boolean;
  150573. /**
  150574. * Gets a boolean indicating if textures must be saved in the database
  150575. */
  150576. get enableTexturesOffline(): boolean;
  150577. /**
  150578. * Creates a new Database
  150579. * @param urlToScene defines the url to load the scene
  150580. * @param callbackManifestChecked defines the callback to use when manifest is checked
  150581. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  150582. */
  150583. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  150584. private static _ParseURL;
  150585. private static _ReturnFullUrlLocation;
  150586. private _checkManifestFile;
  150587. /**
  150588. * Open the database and make it available
  150589. * @param successCallback defines the callback to call on success
  150590. * @param errorCallback defines the callback to call on error
  150591. */
  150592. open(successCallback: () => void, errorCallback: () => void): void;
  150593. /**
  150594. * Loads an image from the database
  150595. * @param url defines the url to load from
  150596. * @param image defines the target DOM image
  150597. */
  150598. loadImage(url: string, image: HTMLImageElement): void;
  150599. private _loadImageFromDBAsync;
  150600. private _saveImageIntoDBAsync;
  150601. private _checkVersionFromDB;
  150602. private _loadVersionFromDBAsync;
  150603. private _saveVersionIntoDBAsync;
  150604. /**
  150605. * Loads a file from database
  150606. * @param url defines the URL to load from
  150607. * @param sceneLoaded defines a callback to call on success
  150608. * @param progressCallBack defines a callback to call when progress changed
  150609. * @param errorCallback defines a callback to call on error
  150610. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  150611. */
  150612. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  150613. private _loadFileAsync;
  150614. private _saveFileAsync;
  150615. /**
  150616. * Validates if xhr data is correct
  150617. * @param xhr defines the request to validate
  150618. * @param dataType defines the expected data type
  150619. * @returns true if data is correct
  150620. */
  150621. private static _ValidateXHRData;
  150622. }
  150623. }
  150624. declare module BABYLON {
  150625. /** @hidden */
  150626. export var gpuUpdateParticlesPixelShader: {
  150627. name: string;
  150628. shader: string;
  150629. };
  150630. }
  150631. declare module BABYLON {
  150632. /** @hidden */
  150633. export var gpuUpdateParticlesVertexShader: {
  150634. name: string;
  150635. shader: string;
  150636. };
  150637. }
  150638. declare module BABYLON {
  150639. /** @hidden */
  150640. export var clipPlaneFragmentDeclaration2: {
  150641. name: string;
  150642. shader: string;
  150643. };
  150644. }
  150645. declare module BABYLON {
  150646. /** @hidden */
  150647. export var gpuRenderParticlesPixelShader: {
  150648. name: string;
  150649. shader: string;
  150650. };
  150651. }
  150652. declare module BABYLON {
  150653. /** @hidden */
  150654. export var clipPlaneVertexDeclaration2: {
  150655. name: string;
  150656. shader: string;
  150657. };
  150658. }
  150659. declare module BABYLON {
  150660. /** @hidden */
  150661. export var gpuRenderParticlesVertexShader: {
  150662. name: string;
  150663. shader: string;
  150664. };
  150665. }
  150666. declare module BABYLON {
  150667. /**
  150668. * This represents a GPU particle system in Babylon
  150669. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  150670. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  150671. */
  150672. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  150673. /**
  150674. * The layer mask we are rendering the particles through.
  150675. */
  150676. layerMask: number;
  150677. private _capacity;
  150678. private _activeCount;
  150679. private _currentActiveCount;
  150680. private _accumulatedCount;
  150681. private _renderEffect;
  150682. private _updateEffect;
  150683. private _buffer0;
  150684. private _buffer1;
  150685. private _spriteBuffer;
  150686. private _updateVAO;
  150687. private _renderVAO;
  150688. private _targetIndex;
  150689. private _sourceBuffer;
  150690. private _targetBuffer;
  150691. private _currentRenderId;
  150692. private _started;
  150693. private _stopped;
  150694. private _timeDelta;
  150695. private _randomTexture;
  150696. private _randomTexture2;
  150697. private _attributesStrideSize;
  150698. private _updateEffectOptions;
  150699. private _randomTextureSize;
  150700. private _actualFrame;
  150701. private _customEffect;
  150702. private readonly _rawTextureWidth;
  150703. /**
  150704. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  150705. */
  150706. static get IsSupported(): boolean;
  150707. /**
  150708. * An event triggered when the system is disposed.
  150709. */
  150710. onDisposeObservable: Observable<IParticleSystem>;
  150711. /**
  150712. * An event triggered when the system is stopped
  150713. */
  150714. onStoppedObservable: Observable<IParticleSystem>;
  150715. /**
  150716. * Gets the maximum number of particles active at the same time.
  150717. * @returns The max number of active particles.
  150718. */
  150719. getCapacity(): number;
  150720. /**
  150721. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  150722. * to override the particles.
  150723. */
  150724. forceDepthWrite: boolean;
  150725. /**
  150726. * Gets or set the number of active particles
  150727. */
  150728. get activeParticleCount(): number;
  150729. set activeParticleCount(value: number);
  150730. private _preWarmDone;
  150731. /**
  150732. * Specifies if the particles are updated in emitter local space or world space.
  150733. */
  150734. isLocal: boolean;
  150735. /** Gets or sets a matrix to use to compute projection */
  150736. defaultProjectionMatrix: Matrix;
  150737. /**
  150738. * Is this system ready to be used/rendered
  150739. * @return true if the system is ready
  150740. */
  150741. isReady(): boolean;
  150742. /**
  150743. * Gets if the system has been started. (Note: this will still be true after stop is called)
  150744. * @returns True if it has been started, otherwise false.
  150745. */
  150746. isStarted(): boolean;
  150747. /**
  150748. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  150749. * @returns True if it has been stopped, otherwise false.
  150750. */
  150751. isStopped(): boolean;
  150752. /**
  150753. * Gets a boolean indicating that the system is stopping
  150754. * @returns true if the system is currently stopping
  150755. */
  150756. isStopping(): boolean;
  150757. /**
  150758. * Gets the number of particles active at the same time.
  150759. * @returns The number of active particles.
  150760. */
  150761. getActiveCount(): number;
  150762. /**
  150763. * Starts the particle system and begins to emit
  150764. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  150765. */
  150766. start(delay?: number): void;
  150767. /**
  150768. * Stops the particle system.
  150769. */
  150770. stop(): void;
  150771. /**
  150772. * Remove all active particles
  150773. */
  150774. reset(): void;
  150775. /**
  150776. * Returns the string "GPUParticleSystem"
  150777. * @returns a string containing the class name
  150778. */
  150779. getClassName(): string;
  150780. /**
  150781. * Gets the custom effect used to render the particles
  150782. * @param blendMode Blend mode for which the effect should be retrieved
  150783. * @returns The effect
  150784. */
  150785. getCustomEffect(blendMode?: number): Nullable<Effect>;
  150786. /**
  150787. * Sets the custom effect used to render the particles
  150788. * @param effect The effect to set
  150789. * @param blendMode Blend mode for which the effect should be set
  150790. */
  150791. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  150792. /** @hidden */
  150793. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  150794. /**
  150795. * Observable that will be called just before the particles are drawn
  150796. */
  150797. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  150798. /**
  150799. * Gets the name of the particle vertex shader
  150800. */
  150801. get vertexShaderName(): string;
  150802. private _colorGradientsTexture;
  150803. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  150804. /**
  150805. * Adds a new color gradient
  150806. * @param gradient defines the gradient to use (between 0 and 1)
  150807. * @param color1 defines the color to affect to the specified gradient
  150808. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  150809. * @returns the current particle system
  150810. */
  150811. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  150812. private _refreshColorGradient;
  150813. /** Force the system to rebuild all gradients that need to be resync */
  150814. forceRefreshGradients(): void;
  150815. /**
  150816. * Remove a specific color gradient
  150817. * @param gradient defines the gradient to remove
  150818. * @returns the current particle system
  150819. */
  150820. removeColorGradient(gradient: number): GPUParticleSystem;
  150821. private _angularSpeedGradientsTexture;
  150822. private _sizeGradientsTexture;
  150823. private _velocityGradientsTexture;
  150824. private _limitVelocityGradientsTexture;
  150825. private _dragGradientsTexture;
  150826. private _addFactorGradient;
  150827. /**
  150828. * Adds a new size gradient
  150829. * @param gradient defines the gradient to use (between 0 and 1)
  150830. * @param factor defines the size factor to affect to the specified gradient
  150831. * @returns the current particle system
  150832. */
  150833. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  150834. /**
  150835. * Remove a specific size gradient
  150836. * @param gradient defines the gradient to remove
  150837. * @returns the current particle system
  150838. */
  150839. removeSizeGradient(gradient: number): GPUParticleSystem;
  150840. private _refreshFactorGradient;
  150841. /**
  150842. * Adds a new angular speed gradient
  150843. * @param gradient defines the gradient to use (between 0 and 1)
  150844. * @param factor defines the angular speed to affect to the specified gradient
  150845. * @returns the current particle system
  150846. */
  150847. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  150848. /**
  150849. * Remove a specific angular speed gradient
  150850. * @param gradient defines the gradient to remove
  150851. * @returns the current particle system
  150852. */
  150853. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  150854. /**
  150855. * Adds a new velocity gradient
  150856. * @param gradient defines the gradient to use (between 0 and 1)
  150857. * @param factor defines the velocity to affect to the specified gradient
  150858. * @returns the current particle system
  150859. */
  150860. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150861. /**
  150862. * Remove a specific velocity gradient
  150863. * @param gradient defines the gradient to remove
  150864. * @returns the current particle system
  150865. */
  150866. removeVelocityGradient(gradient: number): GPUParticleSystem;
  150867. /**
  150868. * Adds a new limit velocity gradient
  150869. * @param gradient defines the gradient to use (between 0 and 1)
  150870. * @param factor defines the limit velocity value to affect to the specified gradient
  150871. * @returns the current particle system
  150872. */
  150873. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150874. /**
  150875. * Remove a specific limit velocity gradient
  150876. * @param gradient defines the gradient to remove
  150877. * @returns the current particle system
  150878. */
  150879. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  150880. /**
  150881. * Adds a new drag gradient
  150882. * @param gradient defines the gradient to use (between 0 and 1)
  150883. * @param factor defines the drag value to affect to the specified gradient
  150884. * @returns the current particle system
  150885. */
  150886. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  150887. /**
  150888. * Remove a specific drag gradient
  150889. * @param gradient defines the gradient to remove
  150890. * @returns the current particle system
  150891. */
  150892. removeDragGradient(gradient: number): GPUParticleSystem;
  150893. /**
  150894. * Not supported by GPUParticleSystem
  150895. * @param gradient defines the gradient to use (between 0 and 1)
  150896. * @param factor defines the emit rate value to affect to the specified gradient
  150897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150898. * @returns the current particle system
  150899. */
  150900. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150901. /**
  150902. * Not supported by GPUParticleSystem
  150903. * @param gradient defines the gradient to remove
  150904. * @returns the current particle system
  150905. */
  150906. removeEmitRateGradient(gradient: number): IParticleSystem;
  150907. /**
  150908. * Not supported by GPUParticleSystem
  150909. * @param gradient defines the gradient to use (between 0 and 1)
  150910. * @param factor defines the start size value to affect to the specified gradient
  150911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150912. * @returns the current particle system
  150913. */
  150914. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150915. /**
  150916. * Not supported by GPUParticleSystem
  150917. * @param gradient defines the gradient to remove
  150918. * @returns the current particle system
  150919. */
  150920. removeStartSizeGradient(gradient: number): IParticleSystem;
  150921. /**
  150922. * Not supported by GPUParticleSystem
  150923. * @param gradient defines the gradient to use (between 0 and 1)
  150924. * @param min defines the color remap minimal range
  150925. * @param max defines the color remap maximal range
  150926. * @returns the current particle system
  150927. */
  150928. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150929. /**
  150930. * Not supported by GPUParticleSystem
  150931. * @param gradient defines the gradient to remove
  150932. * @returns the current particle system
  150933. */
  150934. removeColorRemapGradient(): IParticleSystem;
  150935. /**
  150936. * Not supported by GPUParticleSystem
  150937. * @param gradient defines the gradient to use (between 0 and 1)
  150938. * @param min defines the alpha remap minimal range
  150939. * @param max defines the alpha remap maximal range
  150940. * @returns the current particle system
  150941. */
  150942. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150943. /**
  150944. * Not supported by GPUParticleSystem
  150945. * @param gradient defines the gradient to remove
  150946. * @returns the current particle system
  150947. */
  150948. removeAlphaRemapGradient(): IParticleSystem;
  150949. /**
  150950. * Not supported by GPUParticleSystem
  150951. * @param gradient defines the gradient to use (between 0 and 1)
  150952. * @param color defines the color to affect to the specified gradient
  150953. * @returns the current particle system
  150954. */
  150955. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  150956. /**
  150957. * Not supported by GPUParticleSystem
  150958. * @param gradient defines the gradient to remove
  150959. * @returns the current particle system
  150960. */
  150961. removeRampGradient(): IParticleSystem;
  150962. /**
  150963. * Not supported by GPUParticleSystem
  150964. * @returns the list of ramp gradients
  150965. */
  150966. getRampGradients(): Nullable<Array<Color3Gradient>>;
  150967. /**
  150968. * Not supported by GPUParticleSystem
  150969. * Gets or sets a boolean indicating that ramp gradients must be used
  150970. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  150971. */
  150972. get useRampGradients(): boolean;
  150973. set useRampGradients(value: boolean);
  150974. /**
  150975. * Not supported by GPUParticleSystem
  150976. * @param gradient defines the gradient to use (between 0 and 1)
  150977. * @param factor defines the life time factor to affect to the specified gradient
  150978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150979. * @returns the current particle system
  150980. */
  150981. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150982. /**
  150983. * Not supported by GPUParticleSystem
  150984. * @param gradient defines the gradient to remove
  150985. * @returns the current particle system
  150986. */
  150987. removeLifeTimeGradient(gradient: number): IParticleSystem;
  150988. /**
  150989. * Instantiates a GPU particle system.
  150990. * 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.
  150991. * @param name The name of the particle system
  150992. * @param options The options used to create the system
  150993. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  150994. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  150995. * @param customEffect a custom effect used to change the way particles are rendered by default
  150996. */
  150997. constructor(name: string, options: Partial<{
  150998. capacity: number;
  150999. randomTextureSize: number;
  151000. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  151001. protected _reset(): void;
  151002. private _createUpdateVAO;
  151003. private _createRenderVAO;
  151004. private _initialize;
  151005. /** @hidden */
  151006. _recreateUpdateEffect(): void;
  151007. private _getEffect;
  151008. /**
  151009. * Fill the defines array according to the current settings of the particle system
  151010. * @param defines Array to be updated
  151011. * @param blendMode blend mode to take into account when updating the array
  151012. */
  151013. fillDefines(defines: Array<string>, blendMode?: number): void;
  151014. /**
  151015. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  151016. * @param uniforms Uniforms array to fill
  151017. * @param attributes Attributes array to fill
  151018. * @param samplers Samplers array to fill
  151019. */
  151020. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  151021. /** @hidden */
  151022. _recreateRenderEffect(): Effect;
  151023. /**
  151024. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  151025. * @param preWarm defines if we are in the pre-warmimg phase
  151026. */
  151027. animate(preWarm?: boolean): void;
  151028. private _createFactorGradientTexture;
  151029. private _createSizeGradientTexture;
  151030. private _createAngularSpeedGradientTexture;
  151031. private _createVelocityGradientTexture;
  151032. private _createLimitVelocityGradientTexture;
  151033. private _createDragGradientTexture;
  151034. private _createColorGradientTexture;
  151035. /**
  151036. * Renders the particle system in its current state
  151037. * @param preWarm defines if the system should only update the particles but not render them
  151038. * @returns the current number of particles
  151039. */
  151040. render(preWarm?: boolean): number;
  151041. /**
  151042. * Rebuilds the particle system
  151043. */
  151044. rebuild(): void;
  151045. private _releaseBuffers;
  151046. private _releaseVAOs;
  151047. /**
  151048. * Disposes the particle system and free the associated resources
  151049. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  151050. */
  151051. dispose(disposeTexture?: boolean): void;
  151052. /**
  151053. * Clones the particle system.
  151054. * @param name The name of the cloned object
  151055. * @param newEmitter The new emitter to use
  151056. * @returns the cloned particle system
  151057. */
  151058. clone(name: string, newEmitter: any): GPUParticleSystem;
  151059. /**
  151060. * Serializes the particle system to a JSON object
  151061. * @param serializeTexture defines if the texture must be serialized as well
  151062. * @returns the JSON object
  151063. */
  151064. serialize(serializeTexture?: boolean): any;
  151065. /**
  151066. * Parses a JSON object to create a GPU particle system.
  151067. * @param parsedParticleSystem The JSON object to parse
  151068. * @param sceneOrEngine The scene or the engine to create the particle system in
  151069. * @param rootUrl The root url to use to load external dependencies like texture
  151070. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  151071. * @returns the parsed GPU particle system
  151072. */
  151073. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  151074. }
  151075. }
  151076. declare module BABYLON {
  151077. /**
  151078. * Represents a set of particle systems working together to create a specific effect
  151079. */
  151080. export class ParticleSystemSet implements IDisposable {
  151081. /**
  151082. * Gets or sets base Assets URL
  151083. */
  151084. static BaseAssetsUrl: string;
  151085. private _emitterCreationOptions;
  151086. private _emitterNode;
  151087. /**
  151088. * Gets the particle system list
  151089. */
  151090. systems: IParticleSystem[];
  151091. /**
  151092. * Gets the emitter node used with this set
  151093. */
  151094. get emitterNode(): Nullable<TransformNode>;
  151095. /**
  151096. * Creates a new emitter mesh as a sphere
  151097. * @param options defines the options used to create the sphere
  151098. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  151099. * @param scene defines the hosting scene
  151100. */
  151101. setEmitterAsSphere(options: {
  151102. diameter: number;
  151103. segments: number;
  151104. color: Color3;
  151105. }, renderingGroupId: number, scene: Scene): void;
  151106. /**
  151107. * Starts all particle systems of the set
  151108. * @param emitter defines an optional mesh to use as emitter for the particle systems
  151109. */
  151110. start(emitter?: AbstractMesh): void;
  151111. /**
  151112. * Release all associated resources
  151113. */
  151114. dispose(): void;
  151115. /**
  151116. * Serialize the set into a JSON compatible object
  151117. * @param serializeTexture defines if the texture must be serialized as well
  151118. * @returns a JSON compatible representation of the set
  151119. */
  151120. serialize(serializeTexture?: boolean): any;
  151121. /**
  151122. * Parse a new ParticleSystemSet from a serialized source
  151123. * @param data defines a JSON compatible representation of the set
  151124. * @param scene defines the hosting scene
  151125. * @param gpu defines if we want GPU particles or CPU particles
  151126. * @returns a new ParticleSystemSet
  151127. */
  151128. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  151129. }
  151130. }
  151131. declare module BABYLON {
  151132. /**
  151133. * This class is made for on one-liner static method to help creating particle system set.
  151134. */
  151135. export class ParticleHelper {
  151136. /**
  151137. * Gets or sets base Assets URL
  151138. */
  151139. static BaseAssetsUrl: string;
  151140. /** Define the Url to load snippets */
  151141. static SnippetUrl: string;
  151142. /**
  151143. * Create a default particle system that you can tweak
  151144. * @param emitter defines the emitter to use
  151145. * @param capacity defines the system capacity (default is 500 particles)
  151146. * @param scene defines the hosting scene
  151147. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  151148. * @returns the new Particle system
  151149. */
  151150. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  151151. /**
  151152. * This is the main static method (one-liner) of this helper to create different particle systems
  151153. * @param type This string represents the type to the particle system to create
  151154. * @param scene The scene where the particle system should live
  151155. * @param gpu If the system will use gpu
  151156. * @returns the ParticleSystemSet created
  151157. */
  151158. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  151159. /**
  151160. * Static function used to export a particle system to a ParticleSystemSet variable.
  151161. * Please note that the emitter shape is not exported
  151162. * @param systems defines the particle systems to export
  151163. * @returns the created particle system set
  151164. */
  151165. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  151166. /**
  151167. * Creates a particle system from a snippet saved in a remote file
  151168. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  151169. * @param url defines the url to load from
  151170. * @param scene defines the hosting scene
  151171. * @param gpu If the system will use gpu
  151172. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  151173. * @returns a promise that will resolve to the new particle system
  151174. */
  151175. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  151176. /**
  151177. * Creates a particle system from a snippet saved by the particle system editor
  151178. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  151179. * @param scene defines the hosting scene
  151180. * @param gpu If the system will use gpu
  151181. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  151182. * @returns a promise that will resolve to the new particle system
  151183. */
  151184. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  151185. }
  151186. }
  151187. declare module BABYLON {
  151188. interface Engine {
  151189. /**
  151190. * Create an effect to use with particle systems.
  151191. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  151192. * the particle system for which you want to create a custom effect in the last parameter
  151193. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  151194. * @param uniformsNames defines a list of attribute names
  151195. * @param samplers defines an array of string used to represent textures
  151196. * @param defines defines the string containing the defines to use to compile the shaders
  151197. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  151198. * @param onCompiled defines a function to call when the effect creation is successful
  151199. * @param onError defines a function to call when the effect creation has failed
  151200. * @param particleSystem the particle system you want to create the effect for
  151201. * @returns the new Effect
  151202. */
  151203. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  151204. }
  151205. interface Mesh {
  151206. /**
  151207. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  151208. * @returns an array of IParticleSystem
  151209. */
  151210. getEmittedParticleSystems(): IParticleSystem[];
  151211. /**
  151212. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  151213. * @returns an array of IParticleSystem
  151214. */
  151215. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  151216. }
  151217. }
  151218. declare module BABYLON {
  151219. /** Defines the 4 color options */
  151220. export enum PointColor {
  151221. /** color value */
  151222. Color = 2,
  151223. /** uv value */
  151224. UV = 1,
  151225. /** random value */
  151226. Random = 0,
  151227. /** stated value */
  151228. Stated = 3
  151229. }
  151230. /**
  151231. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  151232. * 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.
  151233. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  151234. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  151235. *
  151236. * Full documentation here : TO BE ENTERED
  151237. */
  151238. export class PointsCloudSystem implements IDisposable {
  151239. /**
  151240. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  151241. * Example : var p = SPS.particles[i];
  151242. */
  151243. particles: CloudPoint[];
  151244. /**
  151245. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  151246. */
  151247. nbParticles: number;
  151248. /**
  151249. * This a counter for your own usage. It's not set by any SPS functions.
  151250. */
  151251. counter: number;
  151252. /**
  151253. * The PCS name. This name is also given to the underlying mesh.
  151254. */
  151255. name: string;
  151256. /**
  151257. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  151258. */
  151259. mesh: Mesh;
  151260. /**
  151261. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  151262. * Please read :
  151263. */
  151264. vars: any;
  151265. /**
  151266. * @hidden
  151267. */
  151268. _size: number;
  151269. private _scene;
  151270. private _promises;
  151271. private _positions;
  151272. private _indices;
  151273. private _normals;
  151274. private _colors;
  151275. private _uvs;
  151276. private _indices32;
  151277. private _positions32;
  151278. private _colors32;
  151279. private _uvs32;
  151280. private _updatable;
  151281. private _isVisibilityBoxLocked;
  151282. private _alwaysVisible;
  151283. private _groups;
  151284. private _groupCounter;
  151285. private _computeParticleColor;
  151286. private _computeParticleTexture;
  151287. private _computeParticleRotation;
  151288. private _computeBoundingBox;
  151289. private _isReady;
  151290. /**
  151291. * Creates a PCS (Points Cloud System) object
  151292. * @param name (String) is the PCS name, this will be the underlying mesh name
  151293. * @param pointSize (number) is the size for each point
  151294. * @param scene (Scene) is the scene in which the PCS is added
  151295. * @param options defines the options of the PCS e.g.
  151296. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  151297. */
  151298. constructor(name: string, pointSize: number, scene: Scene, options?: {
  151299. updatable?: boolean;
  151300. });
  151301. /**
  151302. * Builds the PCS underlying mesh. Returns a standard Mesh.
  151303. * If no points were added to the PCS, the returned mesh is just a single point.
  151304. * @returns a promise for the created mesh
  151305. */
  151306. buildMeshAsync(): Promise<Mesh>;
  151307. /**
  151308. * @hidden
  151309. */
  151310. private _buildMesh;
  151311. private _addParticle;
  151312. private _randomUnitVector;
  151313. private _getColorIndicesForCoord;
  151314. private _setPointsColorOrUV;
  151315. private _colorFromTexture;
  151316. private _calculateDensity;
  151317. /**
  151318. * Adds points to the PCS in random positions within a unit sphere
  151319. * @param nb (positive integer) the number of particles to be created from this model
  151320. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  151321. * @returns the number of groups in the system
  151322. */
  151323. addPoints(nb: number, pointFunction?: any): number;
  151324. /**
  151325. * Adds points to the PCS from the surface of the model shape
  151326. * @param mesh is any Mesh object that will be used as a surface model for the points
  151327. * @param nb (positive integer) the number of particles to be created from this model
  151328. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  151329. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  151330. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  151331. * @returns the number of groups in the system
  151332. */
  151333. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  151334. /**
  151335. * Adds points to the PCS inside the model shape
  151336. * @param mesh is any Mesh object that will be used as a surface model for the points
  151337. * @param nb (positive integer) the number of particles to be created from this model
  151338. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  151339. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  151340. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  151341. * @returns the number of groups in the system
  151342. */
  151343. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  151344. /**
  151345. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  151346. * This method calls `updateParticle()` for each particle of the SPS.
  151347. * For an animated SPS, it is usually called within the render loop.
  151348. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  151349. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  151350. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  151351. * @returns the PCS.
  151352. */
  151353. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  151354. /**
  151355. * Disposes the PCS.
  151356. */
  151357. dispose(): void;
  151358. /**
  151359. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  151360. * doc :
  151361. * @returns the PCS.
  151362. */
  151363. refreshVisibleSize(): PointsCloudSystem;
  151364. /**
  151365. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  151366. * @param size the size (float) of the visibility box
  151367. * note : this doesn't lock the PCS mesh bounding box.
  151368. * doc :
  151369. */
  151370. setVisibilityBox(size: number): void;
  151371. /**
  151372. * Gets whether the PCS is always visible or not
  151373. * doc :
  151374. */
  151375. get isAlwaysVisible(): boolean;
  151376. /**
  151377. * Sets the PCS as always visible or not
  151378. * doc :
  151379. */
  151380. set isAlwaysVisible(val: boolean);
  151381. /**
  151382. * Tells to `setParticles()` to compute the particle rotations or not
  151383. * Default value : false. The PCS is faster when it's set to false
  151384. * Note : particle rotations are only applied to parent particles
  151385. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  151386. */
  151387. set computeParticleRotation(val: boolean);
  151388. /**
  151389. * Tells to `setParticles()` to compute the particle colors or not.
  151390. * Default value : true. The PCS is faster when it's set to false.
  151391. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  151392. */
  151393. set computeParticleColor(val: boolean);
  151394. set computeParticleTexture(val: boolean);
  151395. /**
  151396. * Gets if `setParticles()` computes the particle colors or not.
  151397. * Default value : false. The PCS is faster when it's set to false.
  151398. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  151399. */
  151400. get computeParticleColor(): boolean;
  151401. /**
  151402. * Gets if `setParticles()` computes the particle textures or not.
  151403. * Default value : false. The PCS is faster when it's set to false.
  151404. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  151405. */
  151406. get computeParticleTexture(): boolean;
  151407. /**
  151408. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  151409. */
  151410. set computeBoundingBox(val: boolean);
  151411. /**
  151412. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  151413. */
  151414. get computeBoundingBox(): boolean;
  151415. /**
  151416. * This function does nothing. It may be overwritten to set all the particle first values.
  151417. * The PCS doesn't call this function, you may have to call it by your own.
  151418. * doc :
  151419. */
  151420. initParticles(): void;
  151421. /**
  151422. * This function does nothing. It may be overwritten to recycle a particle
  151423. * The PCS doesn't call this function, you can to call it
  151424. * doc :
  151425. * @param particle The particle to recycle
  151426. * @returns the recycled particle
  151427. */
  151428. recycleParticle(particle: CloudPoint): CloudPoint;
  151429. /**
  151430. * Updates a particle : this function should be overwritten by the user.
  151431. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  151432. * doc :
  151433. * @example : just set a particle position or velocity and recycle conditions
  151434. * @param particle The particle to update
  151435. * @returns the updated particle
  151436. */
  151437. updateParticle(particle: CloudPoint): CloudPoint;
  151438. /**
  151439. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  151440. * This does nothing and may be overwritten by the user.
  151441. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  151442. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  151443. * @param update the boolean update value actually passed to setParticles()
  151444. */
  151445. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  151446. /**
  151447. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  151448. * This will be passed three parameters.
  151449. * This does nothing and may be overwritten by the user.
  151450. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  151451. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  151452. * @param update the boolean update value actually passed to setParticles()
  151453. */
  151454. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  151455. }
  151456. }
  151457. declare module BABYLON {
  151458. /**
  151459. * Represents one particle of a points cloud system.
  151460. */
  151461. export class CloudPoint {
  151462. /**
  151463. * particle global index
  151464. */
  151465. idx: number;
  151466. /**
  151467. * The color of the particle
  151468. */
  151469. color: Nullable<Color4>;
  151470. /**
  151471. * The world space position of the particle.
  151472. */
  151473. position: Vector3;
  151474. /**
  151475. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  151476. */
  151477. rotation: Vector3;
  151478. /**
  151479. * The world space rotation quaternion of the particle.
  151480. */
  151481. rotationQuaternion: Nullable<Quaternion>;
  151482. /**
  151483. * The uv of the particle.
  151484. */
  151485. uv: Nullable<Vector2>;
  151486. /**
  151487. * The current speed of the particle.
  151488. */
  151489. velocity: Vector3;
  151490. /**
  151491. * The pivot point in the particle local space.
  151492. */
  151493. pivot: Vector3;
  151494. /**
  151495. * Must the particle be translated from its pivot point in its local space ?
  151496. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  151497. * Default : false
  151498. */
  151499. translateFromPivot: boolean;
  151500. /**
  151501. * Index of this particle in the global "positions" array (Internal use)
  151502. * @hidden
  151503. */
  151504. _pos: number;
  151505. /**
  151506. * @hidden Index of this particle in the global "indices" array (Internal use)
  151507. */
  151508. _ind: number;
  151509. /**
  151510. * Group this particle belongs to
  151511. */
  151512. _group: PointsGroup;
  151513. /**
  151514. * Group id of this particle
  151515. */
  151516. groupId: number;
  151517. /**
  151518. * Index of the particle in its group id (Internal use)
  151519. */
  151520. idxInGroup: number;
  151521. /**
  151522. * @hidden Particle BoundingInfo object (Internal use)
  151523. */
  151524. _boundingInfo: BoundingInfo;
  151525. /**
  151526. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  151527. */
  151528. _pcs: PointsCloudSystem;
  151529. /**
  151530. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  151531. */
  151532. _stillInvisible: boolean;
  151533. /**
  151534. * @hidden Last computed particle rotation matrix
  151535. */
  151536. _rotationMatrix: number[];
  151537. /**
  151538. * Parent particle Id, if any.
  151539. * Default null.
  151540. */
  151541. parentId: Nullable<number>;
  151542. /**
  151543. * @hidden Internal global position in the PCS.
  151544. */
  151545. _globalPosition: Vector3;
  151546. /**
  151547. * Creates a Point Cloud object.
  151548. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  151549. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  151550. * @param group (PointsGroup) is the group the particle belongs to
  151551. * @param groupId (integer) is the group identifier in the PCS.
  151552. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  151553. * @param pcs defines the PCS it is associated to
  151554. */
  151555. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  151556. /**
  151557. * get point size
  151558. */
  151559. get size(): Vector3;
  151560. /**
  151561. * Set point size
  151562. */
  151563. set size(scale: Vector3);
  151564. /**
  151565. * Legacy support, changed quaternion to rotationQuaternion
  151566. */
  151567. get quaternion(): Nullable<Quaternion>;
  151568. /**
  151569. * Legacy support, changed quaternion to rotationQuaternion
  151570. */
  151571. set quaternion(q: Nullable<Quaternion>);
  151572. /**
  151573. * Returns a boolean. True if the particle intersects a mesh, else false
  151574. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  151575. * @param target is the object (point or mesh) what the intersection is computed against
  151576. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  151577. * @returns true if it intersects
  151578. */
  151579. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  151580. /**
  151581. * get the rotation matrix of the particle
  151582. * @hidden
  151583. */
  151584. getRotationMatrix(m: Matrix): void;
  151585. }
  151586. /**
  151587. * Represents a group of points in a points cloud system
  151588. * * PCS internal tool, don't use it manually.
  151589. */
  151590. export class PointsGroup {
  151591. /**
  151592. * The group id
  151593. * @hidden
  151594. */
  151595. groupID: number;
  151596. /**
  151597. * image data for group (internal use)
  151598. * @hidden
  151599. */
  151600. _groupImageData: Nullable<ArrayBufferView>;
  151601. /**
  151602. * Image Width (internal use)
  151603. * @hidden
  151604. */
  151605. _groupImgWidth: number;
  151606. /**
  151607. * Image Height (internal use)
  151608. * @hidden
  151609. */
  151610. _groupImgHeight: number;
  151611. /**
  151612. * Custom position function (internal use)
  151613. * @hidden
  151614. */
  151615. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  151616. /**
  151617. * density per facet for surface points
  151618. * @hidden
  151619. */
  151620. _groupDensity: number[];
  151621. /**
  151622. * Only when points are colored by texture carries pointer to texture list array
  151623. * @hidden
  151624. */
  151625. _textureNb: number;
  151626. /**
  151627. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  151628. * PCS internal tool, don't use it manually.
  151629. * @hidden
  151630. */
  151631. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  151632. }
  151633. }
  151634. declare module BABYLON {
  151635. interface Scene {
  151636. /** @hidden (Backing field) */
  151637. _physicsEngine: Nullable<IPhysicsEngine>;
  151638. /** @hidden */
  151639. _physicsTimeAccumulator: number;
  151640. /**
  151641. * Gets the current physics engine
  151642. * @returns a IPhysicsEngine or null if none attached
  151643. */
  151644. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  151645. /**
  151646. * Enables physics to the current scene
  151647. * @param gravity defines the scene's gravity for the physics engine
  151648. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  151649. * @return a boolean indicating if the physics engine was initialized
  151650. */
  151651. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  151652. /**
  151653. * Disables and disposes the physics engine associated with the scene
  151654. */
  151655. disablePhysicsEngine(): void;
  151656. /**
  151657. * Gets a boolean indicating if there is an active physics engine
  151658. * @returns a boolean indicating if there is an active physics engine
  151659. */
  151660. isPhysicsEnabled(): boolean;
  151661. /**
  151662. * Deletes a physics compound impostor
  151663. * @param compound defines the compound to delete
  151664. */
  151665. deleteCompoundImpostor(compound: any): void;
  151666. /**
  151667. * An event triggered when physic simulation is about to be run
  151668. */
  151669. onBeforePhysicsObservable: Observable<Scene>;
  151670. /**
  151671. * An event triggered when physic simulation has been done
  151672. */
  151673. onAfterPhysicsObservable: Observable<Scene>;
  151674. }
  151675. interface AbstractMesh {
  151676. /** @hidden */
  151677. _physicsImpostor: Nullable<PhysicsImpostor>;
  151678. /**
  151679. * Gets or sets impostor used for physic simulation
  151680. * @see https://doc.babylonjs.com/features/physics_engine
  151681. */
  151682. physicsImpostor: Nullable<PhysicsImpostor>;
  151683. /**
  151684. * Gets the current physics impostor
  151685. * @see https://doc.babylonjs.com/features/physics_engine
  151686. * @returns a physics impostor or null
  151687. */
  151688. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  151689. /** Apply a physic impulse to the mesh
  151690. * @param force defines the force to apply
  151691. * @param contactPoint defines where to apply the force
  151692. * @returns the current mesh
  151693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  151694. */
  151695. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  151696. /**
  151697. * Creates a physic joint between two meshes
  151698. * @param otherMesh defines the other mesh to use
  151699. * @param pivot1 defines the pivot to use on this mesh
  151700. * @param pivot2 defines the pivot to use on the other mesh
  151701. * @param options defines additional options (can be plugin dependent)
  151702. * @returns the current mesh
  151703. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  151704. */
  151705. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  151706. /** @hidden */
  151707. _disposePhysicsObserver: Nullable<Observer<Node>>;
  151708. }
  151709. /**
  151710. * Defines the physics engine scene component responsible to manage a physics engine
  151711. */
  151712. export class PhysicsEngineSceneComponent implements ISceneComponent {
  151713. /**
  151714. * The component name helpful to identify the component in the list of scene components.
  151715. */
  151716. readonly name: string;
  151717. /**
  151718. * The scene the component belongs to.
  151719. */
  151720. scene: Scene;
  151721. /**
  151722. * Creates a new instance of the component for the given scene
  151723. * @param scene Defines the scene to register the component in
  151724. */
  151725. constructor(scene: Scene);
  151726. /**
  151727. * Registers the component in a given scene
  151728. */
  151729. register(): void;
  151730. /**
  151731. * Rebuilds the elements related to this component in case of
  151732. * context lost for instance.
  151733. */
  151734. rebuild(): void;
  151735. /**
  151736. * Disposes the component and the associated ressources
  151737. */
  151738. dispose(): void;
  151739. }
  151740. }
  151741. declare module BABYLON {
  151742. /**
  151743. * A helper for physics simulations
  151744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151745. */
  151746. export class PhysicsHelper {
  151747. private _scene;
  151748. private _physicsEngine;
  151749. /**
  151750. * Initializes the Physics helper
  151751. * @param scene Babylon.js scene
  151752. */
  151753. constructor(scene: Scene);
  151754. /**
  151755. * Applies a radial explosion impulse
  151756. * @param origin the origin of the explosion
  151757. * @param radiusOrEventOptions the radius or the options of radial explosion
  151758. * @param strength the explosion strength
  151759. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151760. * @returns A physics radial explosion event, or null
  151761. */
  151762. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151763. /**
  151764. * Applies a radial explosion force
  151765. * @param origin the origin of the explosion
  151766. * @param radiusOrEventOptions the radius or the options of radial explosion
  151767. * @param strength the explosion strength
  151768. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151769. * @returns A physics radial explosion event, or null
  151770. */
  151771. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151772. /**
  151773. * Creates a gravitational field
  151774. * @param origin the origin of the explosion
  151775. * @param radiusOrEventOptions the radius or the options of radial explosion
  151776. * @param strength the explosion strength
  151777. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151778. * @returns A physics gravitational field event, or null
  151779. */
  151780. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  151781. /**
  151782. * Creates a physics updraft event
  151783. * @param origin the origin of the updraft
  151784. * @param radiusOrEventOptions the radius or the options of the updraft
  151785. * @param strength the strength of the updraft
  151786. * @param height the height of the updraft
  151787. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  151788. * @returns A physics updraft event, or null
  151789. */
  151790. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  151791. /**
  151792. * Creates a physics vortex event
  151793. * @param origin the of the vortex
  151794. * @param radiusOrEventOptions the radius or the options of the vortex
  151795. * @param strength the strength of the vortex
  151796. * @param height the height of the vortex
  151797. * @returns a Physics vortex event, or null
  151798. * A physics vortex event or null
  151799. */
  151800. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  151801. }
  151802. /**
  151803. * Represents a physics radial explosion event
  151804. */
  151805. class PhysicsRadialExplosionEvent {
  151806. private _scene;
  151807. private _options;
  151808. private _sphere;
  151809. private _dataFetched;
  151810. /**
  151811. * Initializes a radial explosioin event
  151812. * @param _scene BabylonJS scene
  151813. * @param _options The options for the vortex event
  151814. */
  151815. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  151816. /**
  151817. * Returns the data related to the radial explosion event (sphere).
  151818. * @returns The radial explosion event data
  151819. */
  151820. getData(): PhysicsRadialExplosionEventData;
  151821. /**
  151822. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  151823. * @param impostor A physics imposter
  151824. * @param origin the origin of the explosion
  151825. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  151826. */
  151827. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  151828. /**
  151829. * Triggers affecterd impostors callbacks
  151830. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  151831. */
  151832. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  151833. /**
  151834. * Disposes the sphere.
  151835. * @param force Specifies if the sphere should be disposed by force
  151836. */
  151837. dispose(force?: boolean): void;
  151838. /*** Helpers ***/
  151839. private _prepareSphere;
  151840. private _intersectsWithSphere;
  151841. }
  151842. /**
  151843. * Represents a gravitational field event
  151844. */
  151845. class PhysicsGravitationalFieldEvent {
  151846. private _physicsHelper;
  151847. private _scene;
  151848. private _origin;
  151849. private _options;
  151850. private _tickCallback;
  151851. private _sphere;
  151852. private _dataFetched;
  151853. /**
  151854. * Initializes the physics gravitational field event
  151855. * @param _physicsHelper A physics helper
  151856. * @param _scene BabylonJS scene
  151857. * @param _origin The origin position of the gravitational field event
  151858. * @param _options The options for the vortex event
  151859. */
  151860. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  151861. /**
  151862. * Returns the data related to the gravitational field event (sphere).
  151863. * @returns A gravitational field event
  151864. */
  151865. getData(): PhysicsGravitationalFieldEventData;
  151866. /**
  151867. * Enables the gravitational field.
  151868. */
  151869. enable(): void;
  151870. /**
  151871. * Disables the gravitational field.
  151872. */
  151873. disable(): void;
  151874. /**
  151875. * Disposes the sphere.
  151876. * @param force The force to dispose from the gravitational field event
  151877. */
  151878. dispose(force?: boolean): void;
  151879. private _tick;
  151880. }
  151881. /**
  151882. * Represents a physics updraft event
  151883. */
  151884. class PhysicsUpdraftEvent {
  151885. private _scene;
  151886. private _origin;
  151887. private _options;
  151888. private _physicsEngine;
  151889. private _originTop;
  151890. private _originDirection;
  151891. private _tickCallback;
  151892. private _cylinder;
  151893. private _cylinderPosition;
  151894. private _dataFetched;
  151895. /**
  151896. * Initializes the physics updraft event
  151897. * @param _scene BabylonJS scene
  151898. * @param _origin The origin position of the updraft
  151899. * @param _options The options for the updraft event
  151900. */
  151901. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  151902. /**
  151903. * Returns the data related to the updraft event (cylinder).
  151904. * @returns A physics updraft event
  151905. */
  151906. getData(): PhysicsUpdraftEventData;
  151907. /**
  151908. * Enables the updraft.
  151909. */
  151910. enable(): void;
  151911. /**
  151912. * Disables the updraft.
  151913. */
  151914. disable(): void;
  151915. /**
  151916. * Disposes the cylinder.
  151917. * @param force Specifies if the updraft should be disposed by force
  151918. */
  151919. dispose(force?: boolean): void;
  151920. private getImpostorHitData;
  151921. private _tick;
  151922. /*** Helpers ***/
  151923. private _prepareCylinder;
  151924. private _intersectsWithCylinder;
  151925. }
  151926. /**
  151927. * Represents a physics vortex event
  151928. */
  151929. class PhysicsVortexEvent {
  151930. private _scene;
  151931. private _origin;
  151932. private _options;
  151933. private _physicsEngine;
  151934. private _originTop;
  151935. private _tickCallback;
  151936. private _cylinder;
  151937. private _cylinderPosition;
  151938. private _dataFetched;
  151939. /**
  151940. * Initializes the physics vortex event
  151941. * @param _scene The BabylonJS scene
  151942. * @param _origin The origin position of the vortex
  151943. * @param _options The options for the vortex event
  151944. */
  151945. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  151946. /**
  151947. * Returns the data related to the vortex event (cylinder).
  151948. * @returns The physics vortex event data
  151949. */
  151950. getData(): PhysicsVortexEventData;
  151951. /**
  151952. * Enables the vortex.
  151953. */
  151954. enable(): void;
  151955. /**
  151956. * Disables the cortex.
  151957. */
  151958. disable(): void;
  151959. /**
  151960. * Disposes the sphere.
  151961. * @param force
  151962. */
  151963. dispose(force?: boolean): void;
  151964. private getImpostorHitData;
  151965. private _tick;
  151966. /*** Helpers ***/
  151967. private _prepareCylinder;
  151968. private _intersectsWithCylinder;
  151969. }
  151970. /**
  151971. * Options fot the radial explosion event
  151972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151973. */
  151974. export class PhysicsRadialExplosionEventOptions {
  151975. /**
  151976. * The radius of the sphere for the radial explosion.
  151977. */
  151978. radius: number;
  151979. /**
  151980. * The strenth of the explosion.
  151981. */
  151982. strength: number;
  151983. /**
  151984. * The strenght of the force in correspondence to the distance of the affected object
  151985. */
  151986. falloff: PhysicsRadialImpulseFalloff;
  151987. /**
  151988. * Sphere options for the radial explosion.
  151989. */
  151990. sphere: {
  151991. segments: number;
  151992. diameter: number;
  151993. };
  151994. /**
  151995. * Sphere options for the radial explosion.
  151996. */
  151997. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  151998. }
  151999. /**
  152000. * Options fot the updraft event
  152001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152002. */
  152003. export class PhysicsUpdraftEventOptions {
  152004. /**
  152005. * The radius of the cylinder for the vortex
  152006. */
  152007. radius: number;
  152008. /**
  152009. * The strenth of the updraft.
  152010. */
  152011. strength: number;
  152012. /**
  152013. * The height of the cylinder for the updraft.
  152014. */
  152015. height: number;
  152016. /**
  152017. * The mode for the the updraft.
  152018. */
  152019. updraftMode: PhysicsUpdraftMode;
  152020. }
  152021. /**
  152022. * Options fot the vortex event
  152023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152024. */
  152025. export class PhysicsVortexEventOptions {
  152026. /**
  152027. * The radius of the cylinder for the vortex
  152028. */
  152029. radius: number;
  152030. /**
  152031. * The strenth of the vortex.
  152032. */
  152033. strength: number;
  152034. /**
  152035. * The height of the cylinder for the vortex.
  152036. */
  152037. height: number;
  152038. /**
  152039. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  152040. */
  152041. centripetalForceThreshold: number;
  152042. /**
  152043. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  152044. */
  152045. centripetalForceMultiplier: number;
  152046. /**
  152047. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  152048. */
  152049. centrifugalForceMultiplier: number;
  152050. /**
  152051. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  152052. */
  152053. updraftForceMultiplier: number;
  152054. }
  152055. /**
  152056. * The strenght of the force in correspondence to the distance of the affected object
  152057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152058. */
  152059. export enum PhysicsRadialImpulseFalloff {
  152060. /** Defines that impulse is constant in strength across it's whole radius */
  152061. Constant = 0,
  152062. /** Defines that impulse gets weaker if it's further from the origin */
  152063. Linear = 1
  152064. }
  152065. /**
  152066. * The strength of the force in correspondence to the distance of the affected object
  152067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152068. */
  152069. export enum PhysicsUpdraftMode {
  152070. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  152071. Center = 0,
  152072. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  152073. Perpendicular = 1
  152074. }
  152075. /**
  152076. * Interface for a physics hit data
  152077. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152078. */
  152079. export interface PhysicsHitData {
  152080. /**
  152081. * The force applied at the contact point
  152082. */
  152083. force: Vector3;
  152084. /**
  152085. * The contact point
  152086. */
  152087. contactPoint: Vector3;
  152088. /**
  152089. * The distance from the origin to the contact point
  152090. */
  152091. distanceFromOrigin: number;
  152092. }
  152093. /**
  152094. * Interface for radial explosion event data
  152095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152096. */
  152097. export interface PhysicsRadialExplosionEventData {
  152098. /**
  152099. * A sphere used for the radial explosion event
  152100. */
  152101. sphere: Mesh;
  152102. }
  152103. /**
  152104. * Interface for gravitational field event data
  152105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152106. */
  152107. export interface PhysicsGravitationalFieldEventData {
  152108. /**
  152109. * A sphere mesh used for the gravitational field event
  152110. */
  152111. sphere: Mesh;
  152112. }
  152113. /**
  152114. * Interface for updraft event data
  152115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152116. */
  152117. export interface PhysicsUpdraftEventData {
  152118. /**
  152119. * A cylinder used for the updraft event
  152120. */
  152121. cylinder: Mesh;
  152122. }
  152123. /**
  152124. * Interface for vortex event data
  152125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152126. */
  152127. export interface PhysicsVortexEventData {
  152128. /**
  152129. * A cylinder used for the vortex event
  152130. */
  152131. cylinder: Mesh;
  152132. }
  152133. /**
  152134. * Interface for an affected physics impostor
  152135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152136. */
  152137. export interface PhysicsAffectedImpostorWithData {
  152138. /**
  152139. * The impostor affected by the effect
  152140. */
  152141. impostor: PhysicsImpostor;
  152142. /**
  152143. * The data about the hit/horce from the explosion
  152144. */
  152145. hitData: PhysicsHitData;
  152146. }
  152147. }
  152148. declare module BABYLON {
  152149. /** @hidden */
  152150. export var blackAndWhitePixelShader: {
  152151. name: string;
  152152. shader: string;
  152153. };
  152154. }
  152155. declare module BABYLON {
  152156. /**
  152157. * Post process used to render in black and white
  152158. */
  152159. export class BlackAndWhitePostProcess extends PostProcess {
  152160. /**
  152161. * Linear about to convert he result to black and white (default: 1)
  152162. */
  152163. degree: number;
  152164. /**
  152165. * Gets a string identifying the name of the class
  152166. * @returns "BlackAndWhitePostProcess" string
  152167. */
  152168. getClassName(): string;
  152169. /**
  152170. * Creates a black and white post process
  152171. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  152172. * @param name The name of the effect.
  152173. * @param options The required width/height ratio to downsize to before computing the render pass.
  152174. * @param camera The camera to apply the render pass to.
  152175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152176. * @param engine The engine which the post process will be applied. (default: current engine)
  152177. * @param reusable If the post process can be reused on the same frame. (default: false)
  152178. */
  152179. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152180. /** @hidden */
  152181. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  152182. }
  152183. }
  152184. declare module BABYLON {
  152185. /**
  152186. * This represents a set of one or more post processes in Babylon.
  152187. * A post process can be used to apply a shader to a texture after it is rendered.
  152188. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152189. */
  152190. export class PostProcessRenderEffect {
  152191. private _postProcesses;
  152192. private _getPostProcesses;
  152193. private _singleInstance;
  152194. private _cameras;
  152195. private _indicesForCamera;
  152196. /**
  152197. * Name of the effect
  152198. * @hidden
  152199. */
  152200. _name: string;
  152201. /**
  152202. * Instantiates a post process render effect.
  152203. * A post process can be used to apply a shader to a texture after it is rendered.
  152204. * @param engine The engine the effect is tied to
  152205. * @param name The name of the effect
  152206. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  152207. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  152208. */
  152209. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  152210. /**
  152211. * Checks if all the post processes in the effect are supported.
  152212. */
  152213. get isSupported(): boolean;
  152214. /**
  152215. * Updates the current state of the effect
  152216. * @hidden
  152217. */
  152218. _update(): void;
  152219. /**
  152220. * Attaches the effect on cameras
  152221. * @param cameras The camera to attach to.
  152222. * @hidden
  152223. */
  152224. _attachCameras(cameras: Camera): void;
  152225. /**
  152226. * Attaches the effect on cameras
  152227. * @param cameras The camera to attach to.
  152228. * @hidden
  152229. */
  152230. _attachCameras(cameras: Camera[]): void;
  152231. /**
  152232. * Detaches the effect on cameras
  152233. * @param cameras The camera to detatch from.
  152234. * @hidden
  152235. */
  152236. _detachCameras(cameras: Camera): void;
  152237. /**
  152238. * Detatches the effect on cameras
  152239. * @param cameras The camera to detatch from.
  152240. * @hidden
  152241. */
  152242. _detachCameras(cameras: Camera[]): void;
  152243. /**
  152244. * Enables the effect on given cameras
  152245. * @param cameras The camera to enable.
  152246. * @hidden
  152247. */
  152248. _enable(cameras: Camera): void;
  152249. /**
  152250. * Enables the effect on given cameras
  152251. * @param cameras The camera to enable.
  152252. * @hidden
  152253. */
  152254. _enable(cameras: Nullable<Camera[]>): void;
  152255. /**
  152256. * Disables the effect on the given cameras
  152257. * @param cameras The camera to disable.
  152258. * @hidden
  152259. */
  152260. _disable(cameras: Camera): void;
  152261. /**
  152262. * Disables the effect on the given cameras
  152263. * @param cameras The camera to disable.
  152264. * @hidden
  152265. */
  152266. _disable(cameras: Nullable<Camera[]>): void;
  152267. /**
  152268. * Gets a list of the post processes contained in the effect.
  152269. * @param camera The camera to get the post processes on.
  152270. * @returns The list of the post processes in the effect.
  152271. */
  152272. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  152273. }
  152274. }
  152275. declare module BABYLON {
  152276. /** @hidden */
  152277. export var extractHighlightsPixelShader: {
  152278. name: string;
  152279. shader: string;
  152280. };
  152281. }
  152282. declare module BABYLON {
  152283. /**
  152284. * 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.
  152285. */
  152286. export class ExtractHighlightsPostProcess extends PostProcess {
  152287. /**
  152288. * The luminance threshold, pixels below this value will be set to black.
  152289. */
  152290. threshold: number;
  152291. /** @hidden */
  152292. _exposure: number;
  152293. /**
  152294. * Post process which has the input texture to be used when performing highlight extraction
  152295. * @hidden
  152296. */
  152297. _inputPostProcess: Nullable<PostProcess>;
  152298. /**
  152299. * Gets a string identifying the name of the class
  152300. * @returns "ExtractHighlightsPostProcess" string
  152301. */
  152302. getClassName(): string;
  152303. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152304. }
  152305. }
  152306. declare module BABYLON {
  152307. /** @hidden */
  152308. export var bloomMergePixelShader: {
  152309. name: string;
  152310. shader: string;
  152311. };
  152312. }
  152313. declare module BABYLON {
  152314. /**
  152315. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  152316. */
  152317. export class BloomMergePostProcess extends PostProcess {
  152318. /** Weight of the bloom to be added to the original input. */
  152319. weight: number;
  152320. /**
  152321. * Gets a string identifying the name of the class
  152322. * @returns "BloomMergePostProcess" string
  152323. */
  152324. getClassName(): string;
  152325. /**
  152326. * Creates a new instance of @see BloomMergePostProcess
  152327. * @param name The name of the effect.
  152328. * @param originalFromInput Post process which's input will be used for the merge.
  152329. * @param blurred Blurred highlights post process which's output will be used.
  152330. * @param weight Weight of the bloom to be added to the original input.
  152331. * @param options The required width/height ratio to downsize to before computing the render pass.
  152332. * @param camera The camera to apply the render pass to.
  152333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152334. * @param engine The engine which the post process will be applied. (default: current engine)
  152335. * @param reusable If the post process can be reused on the same frame. (default: false)
  152336. * @param textureType Type of textures used when performing the post process. (default: 0)
  152337. * @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)
  152338. */
  152339. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  152340. /** Weight of the bloom to be added to the original input. */
  152341. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152342. }
  152343. }
  152344. declare module BABYLON {
  152345. /**
  152346. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  152347. */
  152348. export class BloomEffect extends PostProcessRenderEffect {
  152349. private bloomScale;
  152350. /**
  152351. * @hidden Internal
  152352. */
  152353. _effects: Array<PostProcess>;
  152354. /**
  152355. * @hidden Internal
  152356. */
  152357. _downscale: ExtractHighlightsPostProcess;
  152358. private _blurX;
  152359. private _blurY;
  152360. private _merge;
  152361. /**
  152362. * The luminance threshold to find bright areas of the image to bloom.
  152363. */
  152364. get threshold(): number;
  152365. set threshold(value: number);
  152366. /**
  152367. * The strength of the bloom.
  152368. */
  152369. get weight(): number;
  152370. set weight(value: number);
  152371. /**
  152372. * Specifies the size of the bloom blur kernel, relative to the final output size
  152373. */
  152374. get kernel(): number;
  152375. set kernel(value: number);
  152376. /**
  152377. * Creates a new instance of @see BloomEffect
  152378. * @param scene The scene the effect belongs to.
  152379. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  152380. * @param bloomKernel The size of the kernel to be used when applying the blur.
  152381. * @param bloomWeight The the strength of bloom.
  152382. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152383. * @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)
  152384. */
  152385. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  152386. /**
  152387. * Disposes each of the internal effects for a given camera.
  152388. * @param camera The camera to dispose the effect on.
  152389. */
  152390. disposeEffects(camera: Camera): void;
  152391. /**
  152392. * @hidden Internal
  152393. */
  152394. _updateEffects(): void;
  152395. /**
  152396. * Internal
  152397. * @returns if all the contained post processes are ready.
  152398. * @hidden
  152399. */
  152400. _isReady(): boolean;
  152401. }
  152402. }
  152403. declare module BABYLON {
  152404. /** @hidden */
  152405. export var chromaticAberrationPixelShader: {
  152406. name: string;
  152407. shader: string;
  152408. };
  152409. }
  152410. declare module BABYLON {
  152411. /**
  152412. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  152413. */
  152414. export class ChromaticAberrationPostProcess extends PostProcess {
  152415. /**
  152416. * The amount of seperation of rgb channels (default: 30)
  152417. */
  152418. aberrationAmount: number;
  152419. /**
  152420. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  152421. */
  152422. radialIntensity: number;
  152423. /**
  152424. * 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))
  152425. */
  152426. direction: Vector2;
  152427. /**
  152428. * 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))
  152429. */
  152430. centerPosition: Vector2;
  152431. /** The width of the screen to apply the effect on */
  152432. screenWidth: number;
  152433. /** The height of the screen to apply the effect on */
  152434. screenHeight: number;
  152435. /**
  152436. * Gets a string identifying the name of the class
  152437. * @returns "ChromaticAberrationPostProcess" string
  152438. */
  152439. getClassName(): string;
  152440. /**
  152441. * Creates a new instance ChromaticAberrationPostProcess
  152442. * @param name The name of the effect.
  152443. * @param screenWidth The width of the screen to apply the effect on.
  152444. * @param screenHeight The height of the screen to apply the effect on.
  152445. * @param options The required width/height ratio to downsize to before computing the render pass.
  152446. * @param camera The camera to apply the render pass to.
  152447. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152448. * @param engine The engine which the post process will be applied. (default: current engine)
  152449. * @param reusable If the post process can be reused on the same frame. (default: false)
  152450. * @param textureType Type of textures used when performing the post process. (default: 0)
  152451. * @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)
  152452. */
  152453. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152454. /** @hidden */
  152455. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  152456. }
  152457. }
  152458. declare module BABYLON {
  152459. /** @hidden */
  152460. export var circleOfConfusionPixelShader: {
  152461. name: string;
  152462. shader: string;
  152463. };
  152464. }
  152465. declare module BABYLON {
  152466. /**
  152467. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  152468. */
  152469. export class CircleOfConfusionPostProcess extends PostProcess {
  152470. /**
  152471. * 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.
  152472. */
  152473. lensSize: number;
  152474. /**
  152475. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152476. */
  152477. fStop: number;
  152478. /**
  152479. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152480. */
  152481. focusDistance: number;
  152482. /**
  152483. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  152484. */
  152485. focalLength: number;
  152486. /**
  152487. * Gets a string identifying the name of the class
  152488. * @returns "CircleOfConfusionPostProcess" string
  152489. */
  152490. getClassName(): string;
  152491. private _depthTexture;
  152492. /**
  152493. * Creates a new instance CircleOfConfusionPostProcess
  152494. * @param name The name of the effect.
  152495. * @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.
  152496. * @param options The required width/height ratio to downsize to before computing the render pass.
  152497. * @param camera The camera to apply the render pass to.
  152498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152499. * @param engine The engine which the post process will be applied. (default: current engine)
  152500. * @param reusable If the post process can be reused on the same frame. (default: false)
  152501. * @param textureType Type of textures used when performing the post process. (default: 0)
  152502. * @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)
  152503. */
  152504. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152505. /**
  152506. * 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.
  152507. */
  152508. set depthTexture(value: RenderTargetTexture);
  152509. }
  152510. }
  152511. declare module BABYLON {
  152512. /** @hidden */
  152513. export var colorCorrectionPixelShader: {
  152514. name: string;
  152515. shader: string;
  152516. };
  152517. }
  152518. declare module BABYLON {
  152519. /**
  152520. *
  152521. * This post-process allows the modification of rendered colors by using
  152522. * a 'look-up table' (LUT). This effect is also called Color Grading.
  152523. *
  152524. * The object needs to be provided an url to a texture containing the color
  152525. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  152526. * Use an image editing software to tweak the LUT to match your needs.
  152527. *
  152528. * For an example of a color LUT, see here:
  152529. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  152530. * For explanations on color grading, see here:
  152531. * @see http://udn.epicgames.com/Three/ColorGrading.html
  152532. *
  152533. */
  152534. export class ColorCorrectionPostProcess extends PostProcess {
  152535. private _colorTableTexture;
  152536. /**
  152537. * Gets the color table url used to create the LUT texture
  152538. */
  152539. colorTableUrl: string;
  152540. /**
  152541. * Gets a string identifying the name of the class
  152542. * @returns "ColorCorrectionPostProcess" string
  152543. */
  152544. getClassName(): string;
  152545. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152546. /** @hidden */
  152547. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  152548. }
  152549. }
  152550. declare module BABYLON {
  152551. /** @hidden */
  152552. export var convolutionPixelShader: {
  152553. name: string;
  152554. shader: string;
  152555. };
  152556. }
  152557. declare module BABYLON {
  152558. /**
  152559. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  152560. * input texture to perform effects such as edge detection or sharpening
  152561. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152562. */
  152563. export class ConvolutionPostProcess extends PostProcess {
  152564. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  152565. kernel: number[];
  152566. /**
  152567. * Gets a string identifying the name of the class
  152568. * @returns "ConvolutionPostProcess" string
  152569. */
  152570. getClassName(): string;
  152571. /**
  152572. * Creates a new instance ConvolutionPostProcess
  152573. * @param name The name of the effect.
  152574. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  152575. * @param options The required width/height ratio to downsize to before computing the render pass.
  152576. * @param camera The camera to apply the render pass to.
  152577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152578. * @param engine The engine which the post process will be applied. (default: current engine)
  152579. * @param reusable If the post process can be reused on the same frame. (default: false)
  152580. * @param textureType Type of textures used when performing the post process. (default: 0)
  152581. */
  152582. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152583. /** @hidden */
  152584. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  152585. /**
  152586. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152587. */
  152588. static EdgeDetect0Kernel: number[];
  152589. /**
  152590. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152591. */
  152592. static EdgeDetect1Kernel: number[];
  152593. /**
  152594. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152595. */
  152596. static EdgeDetect2Kernel: number[];
  152597. /**
  152598. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152599. */
  152600. static SharpenKernel: number[];
  152601. /**
  152602. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152603. */
  152604. static EmbossKernel: number[];
  152605. /**
  152606. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152607. */
  152608. static GaussianKernel: number[];
  152609. }
  152610. }
  152611. declare module BABYLON {
  152612. /**
  152613. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  152614. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  152615. * based on samples that have a large difference in distance than the center pixel.
  152616. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  152617. */
  152618. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  152619. /**
  152620. * The direction the blur should be applied
  152621. */
  152622. direction: Vector2;
  152623. /**
  152624. * Gets a string identifying the name of the class
  152625. * @returns "DepthOfFieldBlurPostProcess" string
  152626. */
  152627. getClassName(): string;
  152628. /**
  152629. * Creates a new instance CircleOfConfusionPostProcess
  152630. * @param name The name of the effect.
  152631. * @param scene The scene the effect belongs to.
  152632. * @param direction The direction the blur should be applied.
  152633. * @param kernel The size of the kernel used to blur.
  152634. * @param options The required width/height ratio to downsize to before computing the render pass.
  152635. * @param camera The camera to apply the render pass to.
  152636. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  152637. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  152638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152639. * @param engine The engine which the post process will be applied. (default: current engine)
  152640. * @param reusable If the post process can be reused on the same frame. (default: false)
  152641. * @param textureType Type of textures used when performing the post process. (default: 0)
  152642. * @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)
  152643. */
  152644. 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);
  152645. }
  152646. }
  152647. declare module BABYLON {
  152648. /** @hidden */
  152649. export var depthOfFieldMergePixelShader: {
  152650. name: string;
  152651. shader: string;
  152652. };
  152653. }
  152654. declare module BABYLON {
  152655. /**
  152656. * Options to be set when merging outputs from the default pipeline.
  152657. */
  152658. export class DepthOfFieldMergePostProcessOptions {
  152659. /**
  152660. * The original image to merge on top of
  152661. */
  152662. originalFromInput: PostProcess;
  152663. /**
  152664. * Parameters to perform the merge of the depth of field effect
  152665. */
  152666. depthOfField?: {
  152667. circleOfConfusion: PostProcess;
  152668. blurSteps: Array<PostProcess>;
  152669. };
  152670. /**
  152671. * Parameters to perform the merge of bloom effect
  152672. */
  152673. bloom?: {
  152674. blurred: PostProcess;
  152675. weight: number;
  152676. };
  152677. }
  152678. /**
  152679. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  152680. */
  152681. export class DepthOfFieldMergePostProcess extends PostProcess {
  152682. private blurSteps;
  152683. /**
  152684. * Gets a string identifying the name of the class
  152685. * @returns "DepthOfFieldMergePostProcess" string
  152686. */
  152687. getClassName(): string;
  152688. /**
  152689. * Creates a new instance of DepthOfFieldMergePostProcess
  152690. * @param name The name of the effect.
  152691. * @param originalFromInput Post process which's input will be used for the merge.
  152692. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  152693. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  152694. * @param options The required width/height ratio to downsize to before computing the render pass.
  152695. * @param camera The camera to apply the render pass to.
  152696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152697. * @param engine The engine which the post process will be applied. (default: current engine)
  152698. * @param reusable If the post process can be reused on the same frame. (default: false)
  152699. * @param textureType Type of textures used when performing the post process. (default: 0)
  152700. * @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)
  152701. */
  152702. 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);
  152703. /**
  152704. * Updates the effect with the current post process compile time values and recompiles the shader.
  152705. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  152706. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  152707. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  152708. * @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
  152709. * @param onCompiled Called when the shader has been compiled.
  152710. * @param onError Called if there is an error when compiling a shader.
  152711. */
  152712. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  152713. }
  152714. }
  152715. declare module BABYLON {
  152716. /**
  152717. * Specifies the level of max blur that should be applied when using the depth of field effect
  152718. */
  152719. export enum DepthOfFieldEffectBlurLevel {
  152720. /**
  152721. * Subtle blur
  152722. */
  152723. Low = 0,
  152724. /**
  152725. * Medium blur
  152726. */
  152727. Medium = 1,
  152728. /**
  152729. * Large blur
  152730. */
  152731. High = 2
  152732. }
  152733. /**
  152734. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  152735. */
  152736. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  152737. private _circleOfConfusion;
  152738. /**
  152739. * @hidden Internal, blurs from high to low
  152740. */
  152741. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  152742. private _depthOfFieldBlurY;
  152743. private _dofMerge;
  152744. /**
  152745. * @hidden Internal post processes in depth of field effect
  152746. */
  152747. _effects: Array<PostProcess>;
  152748. /**
  152749. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  152750. */
  152751. set focalLength(value: number);
  152752. get focalLength(): number;
  152753. /**
  152754. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152755. */
  152756. set fStop(value: number);
  152757. get fStop(): number;
  152758. /**
  152759. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152760. */
  152761. set focusDistance(value: number);
  152762. get focusDistance(): number;
  152763. /**
  152764. * 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.
  152765. */
  152766. set lensSize(value: number);
  152767. get lensSize(): number;
  152768. /**
  152769. * Creates a new instance DepthOfFieldEffect
  152770. * @param scene The scene the effect belongs to.
  152771. * @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.
  152772. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152773. * @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)
  152774. */
  152775. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  152776. /**
  152777. * Get the current class name of the current effet
  152778. * @returns "DepthOfFieldEffect"
  152779. */
  152780. getClassName(): string;
  152781. /**
  152782. * 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.
  152783. */
  152784. set depthTexture(value: RenderTargetTexture);
  152785. /**
  152786. * Disposes each of the internal effects for a given camera.
  152787. * @param camera The camera to dispose the effect on.
  152788. */
  152789. disposeEffects(camera: Camera): void;
  152790. /**
  152791. * @hidden Internal
  152792. */
  152793. _updateEffects(): void;
  152794. /**
  152795. * Internal
  152796. * @returns if all the contained post processes are ready.
  152797. * @hidden
  152798. */
  152799. _isReady(): boolean;
  152800. }
  152801. }
  152802. declare module BABYLON {
  152803. /** @hidden */
  152804. export var displayPassPixelShader: {
  152805. name: string;
  152806. shader: string;
  152807. };
  152808. }
  152809. declare module BABYLON {
  152810. /**
  152811. * DisplayPassPostProcess which produces an output the same as it's input
  152812. */
  152813. export class DisplayPassPostProcess extends PostProcess {
  152814. /**
  152815. * Gets a string identifying the name of the class
  152816. * @returns "DisplayPassPostProcess" string
  152817. */
  152818. getClassName(): string;
  152819. /**
  152820. * Creates the DisplayPassPostProcess
  152821. * @param name The name of the effect.
  152822. * @param options The required width/height ratio to downsize to before computing the render pass.
  152823. * @param camera The camera to apply the render pass to.
  152824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152825. * @param engine The engine which the post process will be applied. (default: current engine)
  152826. * @param reusable If the post process can be reused on the same frame. (default: false)
  152827. */
  152828. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152829. /** @hidden */
  152830. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  152831. }
  152832. }
  152833. declare module BABYLON {
  152834. /** @hidden */
  152835. export var filterPixelShader: {
  152836. name: string;
  152837. shader: string;
  152838. };
  152839. }
  152840. declare module BABYLON {
  152841. /**
  152842. * Applies a kernel filter to the image
  152843. */
  152844. export class FilterPostProcess extends PostProcess {
  152845. /** The matrix to be applied to the image */
  152846. kernelMatrix: Matrix;
  152847. /**
  152848. * Gets a string identifying the name of the class
  152849. * @returns "FilterPostProcess" string
  152850. */
  152851. getClassName(): string;
  152852. /**
  152853. *
  152854. * @param name The name of the effect.
  152855. * @param kernelMatrix The matrix to be applied to the image
  152856. * @param options The required width/height ratio to downsize to before computing the render pass.
  152857. * @param camera The camera to apply the render pass to.
  152858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152859. * @param engine The engine which the post process will be applied. (default: current engine)
  152860. * @param reusable If the post process can be reused on the same frame. (default: false)
  152861. */
  152862. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152863. /** @hidden */
  152864. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  152865. }
  152866. }
  152867. declare module BABYLON {
  152868. /** @hidden */
  152869. export var fxaaPixelShader: {
  152870. name: string;
  152871. shader: string;
  152872. };
  152873. }
  152874. declare module BABYLON {
  152875. /** @hidden */
  152876. export var fxaaVertexShader: {
  152877. name: string;
  152878. shader: string;
  152879. };
  152880. }
  152881. declare module BABYLON {
  152882. /**
  152883. * Fxaa post process
  152884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  152885. */
  152886. export class FxaaPostProcess extends PostProcess {
  152887. /**
  152888. * Gets a string identifying the name of the class
  152889. * @returns "FxaaPostProcess" string
  152890. */
  152891. getClassName(): string;
  152892. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152893. private _getDefines;
  152894. /** @hidden */
  152895. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  152896. }
  152897. }
  152898. declare module BABYLON {
  152899. /** @hidden */
  152900. export var grainPixelShader: {
  152901. name: string;
  152902. shader: string;
  152903. };
  152904. }
  152905. declare module BABYLON {
  152906. /**
  152907. * The GrainPostProcess adds noise to the image at mid luminance levels
  152908. */
  152909. export class GrainPostProcess extends PostProcess {
  152910. /**
  152911. * The intensity of the grain added (default: 30)
  152912. */
  152913. intensity: number;
  152914. /**
  152915. * If the grain should be randomized on every frame
  152916. */
  152917. animated: boolean;
  152918. /**
  152919. * Gets a string identifying the name of the class
  152920. * @returns "GrainPostProcess" string
  152921. */
  152922. getClassName(): string;
  152923. /**
  152924. * Creates a new instance of @see GrainPostProcess
  152925. * @param name The name of the effect.
  152926. * @param options The required width/height ratio to downsize to before computing the render pass.
  152927. * @param camera The camera to apply the render pass to.
  152928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152929. * @param engine The engine which the post process will be applied. (default: current engine)
  152930. * @param reusable If the post process can be reused on the same frame. (default: false)
  152931. * @param textureType Type of textures used when performing the post process. (default: 0)
  152932. * @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)
  152933. */
  152934. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152935. /** @hidden */
  152936. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  152937. }
  152938. }
  152939. declare module BABYLON {
  152940. /** @hidden */
  152941. export var highlightsPixelShader: {
  152942. name: string;
  152943. shader: string;
  152944. };
  152945. }
  152946. declare module BABYLON {
  152947. /**
  152948. * Extracts highlights from the image
  152949. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152950. */
  152951. export class HighlightsPostProcess extends PostProcess {
  152952. /**
  152953. * Gets a string identifying the name of the class
  152954. * @returns "HighlightsPostProcess" string
  152955. */
  152956. getClassName(): string;
  152957. /**
  152958. * Extracts highlights from the image
  152959. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152960. * @param name The name of the effect.
  152961. * @param options The required width/height ratio to downsize to before computing the render pass.
  152962. * @param camera The camera to apply the render pass to.
  152963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152964. * @param engine The engine which the post process will be applied. (default: current engine)
  152965. * @param reusable If the post process can be reused on the same frame. (default: false)
  152966. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  152967. */
  152968. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152969. }
  152970. }
  152971. declare module BABYLON {
  152972. /**
  152973. * Contains all parameters needed for the prepass to perform
  152974. * motion blur
  152975. */
  152976. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  152977. /**
  152978. * Is motion blur enabled
  152979. */
  152980. enabled: boolean;
  152981. /**
  152982. * Name of the configuration
  152983. */
  152984. name: string;
  152985. /**
  152986. * Textures that should be present in the MRT for this effect to work
  152987. */
  152988. readonly texturesRequired: number[];
  152989. }
  152990. }
  152991. declare module BABYLON {
  152992. interface Scene {
  152993. /** @hidden (Backing field) */
  152994. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152995. /**
  152996. * Gets or Sets the current geometry buffer associated to the scene.
  152997. */
  152998. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152999. /**
  153000. * Enables a GeometryBufferRender and associates it with the scene
  153001. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  153002. * @returns the GeometryBufferRenderer
  153003. */
  153004. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  153005. /**
  153006. * Disables the GeometryBufferRender associated with the scene
  153007. */
  153008. disableGeometryBufferRenderer(): void;
  153009. }
  153010. /**
  153011. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153012. * in several rendering techniques.
  153013. */
  153014. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  153015. /**
  153016. * The component name helpful to identify the component in the list of scene components.
  153017. */
  153018. readonly name: string;
  153019. /**
  153020. * The scene the component belongs to.
  153021. */
  153022. scene: Scene;
  153023. /**
  153024. * Creates a new instance of the component for the given scene
  153025. * @param scene Defines the scene to register the component in
  153026. */
  153027. constructor(scene: Scene);
  153028. /**
  153029. * Registers the component in a given scene
  153030. */
  153031. register(): void;
  153032. /**
  153033. * Rebuilds the elements related to this component in case of
  153034. * context lost for instance.
  153035. */
  153036. rebuild(): void;
  153037. /**
  153038. * Disposes the component and the associated ressources
  153039. */
  153040. dispose(): void;
  153041. private _gatherRenderTargets;
  153042. }
  153043. }
  153044. declare module BABYLON {
  153045. /** @hidden */
  153046. export var motionBlurPixelShader: {
  153047. name: string;
  153048. shader: string;
  153049. };
  153050. }
  153051. declare module BABYLON {
  153052. /**
  153053. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  153054. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  153055. * As an example, all you have to do is to create the post-process:
  153056. * var mb = new BABYLON.MotionBlurPostProcess(
  153057. * 'mb', // The name of the effect.
  153058. * scene, // The scene containing the objects to blur according to their velocity.
  153059. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  153060. * camera // The camera to apply the render pass to.
  153061. * );
  153062. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  153063. */
  153064. export class MotionBlurPostProcess extends PostProcess {
  153065. /**
  153066. * Defines how much the image is blurred by the movement. Default value is equal to 1
  153067. */
  153068. motionStrength: number;
  153069. /**
  153070. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  153071. */
  153072. get motionBlurSamples(): number;
  153073. /**
  153074. * Sets the number of iterations to be used for motion blur quality
  153075. */
  153076. set motionBlurSamples(samples: number);
  153077. private _motionBlurSamples;
  153078. /**
  153079. * Gets wether or not the motion blur post-process is in object based mode.
  153080. */
  153081. get isObjectBased(): boolean;
  153082. /**
  153083. * Sets wether or not the motion blur post-process is in object based mode.
  153084. */
  153085. set isObjectBased(value: boolean);
  153086. private _isObjectBased;
  153087. private _forceGeometryBuffer;
  153088. private _geometryBufferRenderer;
  153089. private _prePassRenderer;
  153090. private _invViewProjection;
  153091. private _previousViewProjection;
  153092. /**
  153093. * Gets a string identifying the name of the class
  153094. * @returns "MotionBlurPostProcess" string
  153095. */
  153096. getClassName(): string;
  153097. /**
  153098. * Creates a new instance MotionBlurPostProcess
  153099. * @param name The name of the effect.
  153100. * @param scene The scene containing the objects to blur according to their velocity.
  153101. * @param options The required width/height ratio to downsize to before computing the render pass.
  153102. * @param camera The camera to apply the render pass to.
  153103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153104. * @param engine The engine which the post process will be applied. (default: current engine)
  153105. * @param reusable If the post process can be reused on the same frame. (default: false)
  153106. * @param textureType Type of textures used when performing the post process. (default: 0)
  153107. * @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: true)
  153108. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  153109. */
  153110. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  153111. /**
  153112. * Excludes the given skinned mesh from computing bones velocities.
  153113. * 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.
  153114. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  153115. */
  153116. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  153117. /**
  153118. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  153119. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  153120. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  153121. */
  153122. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  153123. /**
  153124. * Disposes the post process.
  153125. * @param camera The camera to dispose the post process on.
  153126. */
  153127. dispose(camera?: Camera): void;
  153128. /**
  153129. * Called on the mode changed (object based or screen based).
  153130. */
  153131. private _applyMode;
  153132. /**
  153133. * Called on the effect is applied when the motion blur post-process is in object based mode.
  153134. */
  153135. private _onApplyObjectBased;
  153136. /**
  153137. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  153138. */
  153139. private _onApplyScreenBased;
  153140. /**
  153141. * Called on the effect must be updated (changed mode, samples count, etc.).
  153142. */
  153143. private _updateEffect;
  153144. /** @hidden */
  153145. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  153146. }
  153147. }
  153148. declare module BABYLON {
  153149. /** @hidden */
  153150. export var refractionPixelShader: {
  153151. name: string;
  153152. shader: string;
  153153. };
  153154. }
  153155. declare module BABYLON {
  153156. /**
  153157. * Post process which applies a refractin texture
  153158. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  153159. */
  153160. export class RefractionPostProcess extends PostProcess {
  153161. private _refTexture;
  153162. private _ownRefractionTexture;
  153163. /** the base color of the refraction (used to taint the rendering) */
  153164. color: Color3;
  153165. /** simulated refraction depth */
  153166. depth: number;
  153167. /** the coefficient of the base color (0 to remove base color tainting) */
  153168. colorLevel: number;
  153169. /** Gets the url used to load the refraction texture */
  153170. refractionTextureUrl: string;
  153171. /**
  153172. * Gets or sets the refraction texture
  153173. * Please note that you are responsible for disposing the texture if you set it manually
  153174. */
  153175. get refractionTexture(): Texture;
  153176. set refractionTexture(value: Texture);
  153177. /**
  153178. * Gets a string identifying the name of the class
  153179. * @returns "RefractionPostProcess" string
  153180. */
  153181. getClassName(): string;
  153182. /**
  153183. * Initializes the RefractionPostProcess
  153184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  153185. * @param name The name of the effect.
  153186. * @param refractionTextureUrl Url of the refraction texture to use
  153187. * @param color the base color of the refraction (used to taint the rendering)
  153188. * @param depth simulated refraction depth
  153189. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  153190. * @param camera The camera to apply the render pass to.
  153191. * @param options The required width/height ratio to downsize to before computing the render pass.
  153192. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153193. * @param engine The engine which the post process will be applied. (default: current engine)
  153194. * @param reusable If the post process can be reused on the same frame. (default: false)
  153195. */
  153196. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153197. /**
  153198. * Disposes of the post process
  153199. * @param camera Camera to dispose post process on
  153200. */
  153201. dispose(camera: Camera): void;
  153202. /** @hidden */
  153203. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  153204. }
  153205. }
  153206. declare module BABYLON {
  153207. /** @hidden */
  153208. export var sharpenPixelShader: {
  153209. name: string;
  153210. shader: string;
  153211. };
  153212. }
  153213. declare module BABYLON {
  153214. /**
  153215. * The SharpenPostProcess applies a sharpen kernel to every pixel
  153216. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  153217. */
  153218. export class SharpenPostProcess extends PostProcess {
  153219. /**
  153220. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  153221. */
  153222. colorAmount: number;
  153223. /**
  153224. * How much sharpness should be applied (default: 0.3)
  153225. */
  153226. edgeAmount: number;
  153227. /**
  153228. * Gets a string identifying the name of the class
  153229. * @returns "SharpenPostProcess" string
  153230. */
  153231. getClassName(): string;
  153232. /**
  153233. * Creates a new instance ConvolutionPostProcess
  153234. * @param name The name of the effect.
  153235. * @param options The required width/height ratio to downsize to before computing the render pass.
  153236. * @param camera The camera to apply the render pass to.
  153237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153238. * @param engine The engine which the post process will be applied. (default: current engine)
  153239. * @param reusable If the post process can be reused on the same frame. (default: false)
  153240. * @param textureType Type of textures used when performing the post process. (default: 0)
  153241. * @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)
  153242. */
  153243. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153244. /** @hidden */
  153245. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  153246. }
  153247. }
  153248. declare module BABYLON {
  153249. /**
  153250. * PostProcessRenderPipeline
  153251. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153252. */
  153253. export class PostProcessRenderPipeline {
  153254. private engine;
  153255. private _renderEffects;
  153256. private _renderEffectsForIsolatedPass;
  153257. /**
  153258. * List of inspectable custom properties (used by the Inspector)
  153259. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  153260. */
  153261. inspectableCustomProperties: IInspectable[];
  153262. /**
  153263. * @hidden
  153264. */
  153265. protected _cameras: Camera[];
  153266. /** @hidden */
  153267. _name: string;
  153268. /**
  153269. * Gets pipeline name
  153270. */
  153271. get name(): string;
  153272. /** Gets the list of attached cameras */
  153273. get cameras(): Camera[];
  153274. /**
  153275. * Initializes a PostProcessRenderPipeline
  153276. * @param engine engine to add the pipeline to
  153277. * @param name name of the pipeline
  153278. */
  153279. constructor(engine: Engine, name: string);
  153280. /**
  153281. * Gets the class name
  153282. * @returns "PostProcessRenderPipeline"
  153283. */
  153284. getClassName(): string;
  153285. /**
  153286. * If all the render effects in the pipeline are supported
  153287. */
  153288. get isSupported(): boolean;
  153289. /**
  153290. * Adds an effect to the pipeline
  153291. * @param renderEffect the effect to add
  153292. */
  153293. addEffect(renderEffect: PostProcessRenderEffect): void;
  153294. /** @hidden */
  153295. _rebuild(): void;
  153296. /** @hidden */
  153297. _enableEffect(renderEffectName: string, cameras: Camera): void;
  153298. /** @hidden */
  153299. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  153300. /** @hidden */
  153301. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  153302. /** @hidden */
  153303. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  153304. /** @hidden */
  153305. _attachCameras(cameras: Camera, unique: boolean): void;
  153306. /** @hidden */
  153307. _attachCameras(cameras: Camera[], unique: boolean): void;
  153308. /** @hidden */
  153309. _detachCameras(cameras: Camera): void;
  153310. /** @hidden */
  153311. _detachCameras(cameras: Nullable<Camera[]>): void;
  153312. /** @hidden */
  153313. _update(): void;
  153314. /** @hidden */
  153315. _reset(): void;
  153316. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  153317. /**
  153318. * Sets the required values to the prepass renderer.
  153319. * @param prePassRenderer defines the prepass renderer to setup.
  153320. * @returns true if the pre pass is needed.
  153321. */
  153322. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  153323. /**
  153324. * Disposes of the pipeline
  153325. */
  153326. dispose(): void;
  153327. }
  153328. }
  153329. declare module BABYLON {
  153330. /**
  153331. * PostProcessRenderPipelineManager class
  153332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153333. */
  153334. export class PostProcessRenderPipelineManager {
  153335. private _renderPipelines;
  153336. /**
  153337. * Initializes a PostProcessRenderPipelineManager
  153338. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153339. */
  153340. constructor();
  153341. /**
  153342. * Gets the list of supported render pipelines
  153343. */
  153344. get supportedPipelines(): PostProcessRenderPipeline[];
  153345. /**
  153346. * Adds a pipeline to the manager
  153347. * @param renderPipeline The pipeline to add
  153348. */
  153349. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  153350. /**
  153351. * Attaches a camera to the pipeline
  153352. * @param renderPipelineName The name of the pipeline to attach to
  153353. * @param cameras the camera to attach
  153354. * @param unique if the camera can be attached multiple times to the pipeline
  153355. */
  153356. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  153357. /**
  153358. * Detaches a camera from the pipeline
  153359. * @param renderPipelineName The name of the pipeline to detach from
  153360. * @param cameras the camera to detach
  153361. */
  153362. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  153363. /**
  153364. * Enables an effect by name on a pipeline
  153365. * @param renderPipelineName the name of the pipeline to enable the effect in
  153366. * @param renderEffectName the name of the effect to enable
  153367. * @param cameras the cameras that the effect should be enabled on
  153368. */
  153369. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  153370. /**
  153371. * Disables an effect by name on a pipeline
  153372. * @param renderPipelineName the name of the pipeline to disable the effect in
  153373. * @param renderEffectName the name of the effect to disable
  153374. * @param cameras the cameras that the effect should be disabled on
  153375. */
  153376. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  153377. /**
  153378. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  153379. */
  153380. update(): void;
  153381. /** @hidden */
  153382. _rebuild(): void;
  153383. /**
  153384. * Disposes of the manager and pipelines
  153385. */
  153386. dispose(): void;
  153387. }
  153388. }
  153389. declare module BABYLON {
  153390. interface Scene {
  153391. /** @hidden (Backing field) */
  153392. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  153393. /**
  153394. * Gets the postprocess render pipeline manager
  153395. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153396. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  153397. */
  153398. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  153399. }
  153400. /**
  153401. * Defines the Render Pipeline scene component responsible to rendering pipelines
  153402. */
  153403. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  153404. /**
  153405. * The component name helpfull to identify the component in the list of scene components.
  153406. */
  153407. readonly name: string;
  153408. /**
  153409. * The scene the component belongs to.
  153410. */
  153411. scene: Scene;
  153412. /**
  153413. * Creates a new instance of the component for the given scene
  153414. * @param scene Defines the scene to register the component in
  153415. */
  153416. constructor(scene: Scene);
  153417. /**
  153418. * Registers the component in a given scene
  153419. */
  153420. register(): void;
  153421. /**
  153422. * Rebuilds the elements related to this component in case of
  153423. * context lost for instance.
  153424. */
  153425. rebuild(): void;
  153426. /**
  153427. * Disposes the component and the associated ressources
  153428. */
  153429. dispose(): void;
  153430. private _gatherRenderTargets;
  153431. }
  153432. }
  153433. declare module BABYLON {
  153434. /**
  153435. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  153436. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  153437. */
  153438. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153439. private _scene;
  153440. private _camerasToBeAttached;
  153441. /**
  153442. * ID of the sharpen post process,
  153443. */
  153444. private readonly SharpenPostProcessId;
  153445. /**
  153446. * @ignore
  153447. * ID of the image processing post process;
  153448. */
  153449. readonly ImageProcessingPostProcessId: string;
  153450. /**
  153451. * @ignore
  153452. * ID of the Fast Approximate Anti-Aliasing post process;
  153453. */
  153454. readonly FxaaPostProcessId: string;
  153455. /**
  153456. * ID of the chromatic aberration post process,
  153457. */
  153458. private readonly ChromaticAberrationPostProcessId;
  153459. /**
  153460. * ID of the grain post process
  153461. */
  153462. private readonly GrainPostProcessId;
  153463. /**
  153464. * Sharpen post process which will apply a sharpen convolution to enhance edges
  153465. */
  153466. sharpen: SharpenPostProcess;
  153467. private _sharpenEffect;
  153468. private bloom;
  153469. /**
  153470. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  153471. */
  153472. depthOfField: DepthOfFieldEffect;
  153473. /**
  153474. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  153475. */
  153476. fxaa: FxaaPostProcess;
  153477. /**
  153478. * Image post processing pass used to perform operations such as tone mapping or color grading.
  153479. */
  153480. imageProcessing: ImageProcessingPostProcess;
  153481. /**
  153482. * Chromatic aberration post process which will shift rgb colors in the image
  153483. */
  153484. chromaticAberration: ChromaticAberrationPostProcess;
  153485. private _chromaticAberrationEffect;
  153486. /**
  153487. * Grain post process which add noise to the image
  153488. */
  153489. grain: GrainPostProcess;
  153490. private _grainEffect;
  153491. /**
  153492. * Glow post process which adds a glow to emissive areas of the image
  153493. */
  153494. private _glowLayer;
  153495. /**
  153496. * Animations which can be used to tweak settings over a period of time
  153497. */
  153498. animations: Animation[];
  153499. private _imageProcessingConfigurationObserver;
  153500. private _sharpenEnabled;
  153501. private _bloomEnabled;
  153502. private _depthOfFieldEnabled;
  153503. private _depthOfFieldBlurLevel;
  153504. private _fxaaEnabled;
  153505. private _imageProcessingEnabled;
  153506. private _defaultPipelineTextureType;
  153507. private _bloomScale;
  153508. private _chromaticAberrationEnabled;
  153509. private _grainEnabled;
  153510. private _buildAllowed;
  153511. /**
  153512. * This is triggered each time the pipeline has been built.
  153513. */
  153514. onBuildObservable: Observable<DefaultRenderingPipeline>;
  153515. /**
  153516. * Gets active scene
  153517. */
  153518. get scene(): Scene;
  153519. /**
  153520. * Enable or disable the sharpen process from the pipeline
  153521. */
  153522. set sharpenEnabled(enabled: boolean);
  153523. get sharpenEnabled(): boolean;
  153524. private _resizeObserver;
  153525. private _hardwareScaleLevel;
  153526. private _bloomKernel;
  153527. /**
  153528. * Specifies the size of the bloom blur kernel, relative to the final output size
  153529. */
  153530. get bloomKernel(): number;
  153531. set bloomKernel(value: number);
  153532. /**
  153533. * Specifies the weight of the bloom in the final rendering
  153534. */
  153535. private _bloomWeight;
  153536. /**
  153537. * Specifies the luma threshold for the area that will be blurred by the bloom
  153538. */
  153539. private _bloomThreshold;
  153540. private _hdr;
  153541. /**
  153542. * The strength of the bloom.
  153543. */
  153544. set bloomWeight(value: number);
  153545. get bloomWeight(): number;
  153546. /**
  153547. * The strength of the bloom.
  153548. */
  153549. set bloomThreshold(value: number);
  153550. get bloomThreshold(): number;
  153551. /**
  153552. * The scale of the bloom, lower value will provide better performance.
  153553. */
  153554. set bloomScale(value: number);
  153555. get bloomScale(): number;
  153556. /**
  153557. * Enable or disable the bloom from the pipeline
  153558. */
  153559. set bloomEnabled(enabled: boolean);
  153560. get bloomEnabled(): boolean;
  153561. private _rebuildBloom;
  153562. /**
  153563. * If the depth of field is enabled.
  153564. */
  153565. get depthOfFieldEnabled(): boolean;
  153566. set depthOfFieldEnabled(enabled: boolean);
  153567. /**
  153568. * Blur level of the depth of field effect. (Higher blur will effect performance)
  153569. */
  153570. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  153571. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  153572. /**
  153573. * If the anti aliasing is enabled.
  153574. */
  153575. set fxaaEnabled(enabled: boolean);
  153576. get fxaaEnabled(): boolean;
  153577. private _samples;
  153578. /**
  153579. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  153580. */
  153581. set samples(sampleCount: number);
  153582. get samples(): number;
  153583. /**
  153584. * If image processing is enabled.
  153585. */
  153586. set imageProcessingEnabled(enabled: boolean);
  153587. get imageProcessingEnabled(): boolean;
  153588. /**
  153589. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  153590. */
  153591. set glowLayerEnabled(enabled: boolean);
  153592. get glowLayerEnabled(): boolean;
  153593. /**
  153594. * Gets the glow layer (or null if not defined)
  153595. */
  153596. get glowLayer(): Nullable<GlowLayer>;
  153597. /**
  153598. * Enable or disable the chromaticAberration process from the pipeline
  153599. */
  153600. set chromaticAberrationEnabled(enabled: boolean);
  153601. get chromaticAberrationEnabled(): boolean;
  153602. /**
  153603. * Enable or disable the grain process from the pipeline
  153604. */
  153605. set grainEnabled(enabled: boolean);
  153606. get grainEnabled(): boolean;
  153607. /**
  153608. * @constructor
  153609. * @param name - The rendering pipeline name (default: "")
  153610. * @param hdr - If high dynamic range textures should be used (default: true)
  153611. * @param scene - The scene linked to this pipeline (default: the last created scene)
  153612. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  153613. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  153614. */
  153615. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  153616. /**
  153617. * Get the class name
  153618. * @returns "DefaultRenderingPipeline"
  153619. */
  153620. getClassName(): string;
  153621. /**
  153622. * Force the compilation of the entire pipeline.
  153623. */
  153624. prepare(): void;
  153625. private _hasCleared;
  153626. private _prevPostProcess;
  153627. private _prevPrevPostProcess;
  153628. private _setAutoClearAndTextureSharing;
  153629. private _depthOfFieldSceneObserver;
  153630. private _buildPipeline;
  153631. private _disposePostProcesses;
  153632. /**
  153633. * Adds a camera to the pipeline
  153634. * @param camera the camera to be added
  153635. */
  153636. addCamera(camera: Camera): void;
  153637. /**
  153638. * Removes a camera from the pipeline
  153639. * @param camera the camera to remove
  153640. */
  153641. removeCamera(camera: Camera): void;
  153642. /**
  153643. * Dispose of the pipeline and stop all post processes
  153644. */
  153645. dispose(): void;
  153646. /**
  153647. * Serialize the rendering pipeline (Used when exporting)
  153648. * @returns the serialized object
  153649. */
  153650. serialize(): any;
  153651. /**
  153652. * Parse the serialized pipeline
  153653. * @param source Source pipeline.
  153654. * @param scene The scene to load the pipeline to.
  153655. * @param rootUrl The URL of the serialized pipeline.
  153656. * @returns An instantiated pipeline from the serialized object.
  153657. */
  153658. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  153659. }
  153660. }
  153661. declare module BABYLON {
  153662. /** @hidden */
  153663. export var lensHighlightsPixelShader: {
  153664. name: string;
  153665. shader: string;
  153666. };
  153667. }
  153668. declare module BABYLON {
  153669. /** @hidden */
  153670. export var depthOfFieldPixelShader: {
  153671. name: string;
  153672. shader: string;
  153673. };
  153674. }
  153675. declare module BABYLON {
  153676. /**
  153677. * BABYLON.JS Chromatic Aberration GLSL Shader
  153678. * Author: Olivier Guyot
  153679. * Separates very slightly R, G and B colors on the edges of the screen
  153680. * Inspired by Francois Tarlier & Martins Upitis
  153681. */
  153682. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  153683. /**
  153684. * @ignore
  153685. * The chromatic aberration PostProcess id in the pipeline
  153686. */
  153687. LensChromaticAberrationEffect: string;
  153688. /**
  153689. * @ignore
  153690. * The highlights enhancing PostProcess id in the pipeline
  153691. */
  153692. HighlightsEnhancingEffect: string;
  153693. /**
  153694. * @ignore
  153695. * The depth-of-field PostProcess id in the pipeline
  153696. */
  153697. LensDepthOfFieldEffect: string;
  153698. private _scene;
  153699. private _depthTexture;
  153700. private _grainTexture;
  153701. private _chromaticAberrationPostProcess;
  153702. private _highlightsPostProcess;
  153703. private _depthOfFieldPostProcess;
  153704. private _edgeBlur;
  153705. private _grainAmount;
  153706. private _chromaticAberration;
  153707. private _distortion;
  153708. private _highlightsGain;
  153709. private _highlightsThreshold;
  153710. private _dofDistance;
  153711. private _dofAperture;
  153712. private _dofDarken;
  153713. private _dofPentagon;
  153714. private _blurNoise;
  153715. /**
  153716. * @constructor
  153717. *
  153718. * Effect parameters are as follow:
  153719. * {
  153720. * chromatic_aberration: number; // from 0 to x (1 for realism)
  153721. * edge_blur: number; // from 0 to x (1 for realism)
  153722. * distortion: number; // from 0 to x (1 for realism)
  153723. * grain_amount: number; // from 0 to 1
  153724. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  153725. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  153726. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  153727. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  153728. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  153729. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  153730. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  153731. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  153732. * }
  153733. * Note: if an effect parameter is unset, effect is disabled
  153734. *
  153735. * @param name The rendering pipeline name
  153736. * @param parameters - An object containing all parameters (see above)
  153737. * @param scene The scene linked to this pipeline
  153738. * @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)
  153739. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153740. */
  153741. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  153742. /**
  153743. * Get the class name
  153744. * @returns "LensRenderingPipeline"
  153745. */
  153746. getClassName(): string;
  153747. /**
  153748. * Gets associated scene
  153749. */
  153750. get scene(): Scene;
  153751. /**
  153752. * Gets or sets the edge blur
  153753. */
  153754. get edgeBlur(): number;
  153755. set edgeBlur(value: number);
  153756. /**
  153757. * Gets or sets the grain amount
  153758. */
  153759. get grainAmount(): number;
  153760. set grainAmount(value: number);
  153761. /**
  153762. * Gets or sets the chromatic aberration amount
  153763. */
  153764. get chromaticAberration(): number;
  153765. set chromaticAberration(value: number);
  153766. /**
  153767. * Gets or sets the depth of field aperture
  153768. */
  153769. get dofAperture(): number;
  153770. set dofAperture(value: number);
  153771. /**
  153772. * Gets or sets the edge distortion
  153773. */
  153774. get edgeDistortion(): number;
  153775. set edgeDistortion(value: number);
  153776. /**
  153777. * Gets or sets the depth of field distortion
  153778. */
  153779. get dofDistortion(): number;
  153780. set dofDistortion(value: number);
  153781. /**
  153782. * Gets or sets the darken out of focus amount
  153783. */
  153784. get darkenOutOfFocus(): number;
  153785. set darkenOutOfFocus(value: number);
  153786. /**
  153787. * Gets or sets a boolean indicating if blur noise is enabled
  153788. */
  153789. get blurNoise(): boolean;
  153790. set blurNoise(value: boolean);
  153791. /**
  153792. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  153793. */
  153794. get pentagonBokeh(): boolean;
  153795. set pentagonBokeh(value: boolean);
  153796. /**
  153797. * Gets or sets the highlight grain amount
  153798. */
  153799. get highlightsGain(): number;
  153800. set highlightsGain(value: number);
  153801. /**
  153802. * Gets or sets the highlight threshold
  153803. */
  153804. get highlightsThreshold(): number;
  153805. set highlightsThreshold(value: number);
  153806. /**
  153807. * Sets the amount of blur at the edges
  153808. * @param amount blur amount
  153809. */
  153810. setEdgeBlur(amount: number): void;
  153811. /**
  153812. * Sets edge blur to 0
  153813. */
  153814. disableEdgeBlur(): void;
  153815. /**
  153816. * Sets the amout of grain
  153817. * @param amount Amount of grain
  153818. */
  153819. setGrainAmount(amount: number): void;
  153820. /**
  153821. * Set grain amount to 0
  153822. */
  153823. disableGrain(): void;
  153824. /**
  153825. * Sets the chromatic aberration amount
  153826. * @param amount amount of chromatic aberration
  153827. */
  153828. setChromaticAberration(amount: number): void;
  153829. /**
  153830. * Sets chromatic aberration amount to 0
  153831. */
  153832. disableChromaticAberration(): void;
  153833. /**
  153834. * Sets the EdgeDistortion amount
  153835. * @param amount amount of EdgeDistortion
  153836. */
  153837. setEdgeDistortion(amount: number): void;
  153838. /**
  153839. * Sets edge distortion to 0
  153840. */
  153841. disableEdgeDistortion(): void;
  153842. /**
  153843. * Sets the FocusDistance amount
  153844. * @param amount amount of FocusDistance
  153845. */
  153846. setFocusDistance(amount: number): void;
  153847. /**
  153848. * Disables depth of field
  153849. */
  153850. disableDepthOfField(): void;
  153851. /**
  153852. * Sets the Aperture amount
  153853. * @param amount amount of Aperture
  153854. */
  153855. setAperture(amount: number): void;
  153856. /**
  153857. * Sets the DarkenOutOfFocus amount
  153858. * @param amount amount of DarkenOutOfFocus
  153859. */
  153860. setDarkenOutOfFocus(amount: number): void;
  153861. private _pentagonBokehIsEnabled;
  153862. /**
  153863. * Creates a pentagon bokeh effect
  153864. */
  153865. enablePentagonBokeh(): void;
  153866. /**
  153867. * Disables the pentagon bokeh effect
  153868. */
  153869. disablePentagonBokeh(): void;
  153870. /**
  153871. * Enables noise blur
  153872. */
  153873. enableNoiseBlur(): void;
  153874. /**
  153875. * Disables noise blur
  153876. */
  153877. disableNoiseBlur(): void;
  153878. /**
  153879. * Sets the HighlightsGain amount
  153880. * @param amount amount of HighlightsGain
  153881. */
  153882. setHighlightsGain(amount: number): void;
  153883. /**
  153884. * Sets the HighlightsThreshold amount
  153885. * @param amount amount of HighlightsThreshold
  153886. */
  153887. setHighlightsThreshold(amount: number): void;
  153888. /**
  153889. * Disables highlights
  153890. */
  153891. disableHighlights(): void;
  153892. /**
  153893. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  153894. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  153895. */
  153896. dispose(disableDepthRender?: boolean): void;
  153897. private _createChromaticAberrationPostProcess;
  153898. private _createHighlightsPostProcess;
  153899. private _createDepthOfFieldPostProcess;
  153900. private _createGrainTexture;
  153901. }
  153902. }
  153903. declare module BABYLON {
  153904. /**
  153905. * Contains all parameters needed for the prepass to perform
  153906. * screen space subsurface scattering
  153907. */
  153908. export class SSAO2Configuration implements PrePassEffectConfiguration {
  153909. /**
  153910. * Is subsurface enabled
  153911. */
  153912. enabled: boolean;
  153913. /**
  153914. * Name of the configuration
  153915. */
  153916. name: string;
  153917. /**
  153918. * Textures that should be present in the MRT for this effect to work
  153919. */
  153920. readonly texturesRequired: number[];
  153921. }
  153922. }
  153923. declare module BABYLON {
  153924. /** @hidden */
  153925. export var ssao2PixelShader: {
  153926. name: string;
  153927. shader: string;
  153928. };
  153929. }
  153930. declare module BABYLON {
  153931. /** @hidden */
  153932. export var ssaoCombinePixelShader: {
  153933. name: string;
  153934. shader: string;
  153935. };
  153936. }
  153937. declare module BABYLON {
  153938. /**
  153939. * Render pipeline to produce ssao effect
  153940. */
  153941. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  153942. /**
  153943. * @ignore
  153944. * The PassPostProcess id in the pipeline that contains the original scene color
  153945. */
  153946. SSAOOriginalSceneColorEffect: string;
  153947. /**
  153948. * @ignore
  153949. * The SSAO PostProcess id in the pipeline
  153950. */
  153951. SSAORenderEffect: string;
  153952. /**
  153953. * @ignore
  153954. * The horizontal blur PostProcess id in the pipeline
  153955. */
  153956. SSAOBlurHRenderEffect: string;
  153957. /**
  153958. * @ignore
  153959. * The vertical blur PostProcess id in the pipeline
  153960. */
  153961. SSAOBlurVRenderEffect: string;
  153962. /**
  153963. * @ignore
  153964. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153965. */
  153966. SSAOCombineRenderEffect: string;
  153967. /**
  153968. * The output strength of the SSAO post-process. Default value is 1.0.
  153969. */
  153970. totalStrength: number;
  153971. /**
  153972. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  153973. */
  153974. maxZ: number;
  153975. /**
  153976. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  153977. */
  153978. minZAspect: number;
  153979. private _samples;
  153980. /**
  153981. * Number of samples used for the SSAO calculations. Default value is 8
  153982. */
  153983. set samples(n: number);
  153984. get samples(): number;
  153985. private _textureSamples;
  153986. /**
  153987. * Number of samples to use for antialiasing
  153988. */
  153989. set textureSamples(n: number);
  153990. get textureSamples(): number;
  153991. /**
  153992. * Force rendering the geometry through geometry buffer
  153993. */
  153994. private _forceGeometryBuffer;
  153995. /**
  153996. * Ratio object used for SSAO ratio and blur ratio
  153997. */
  153998. private _ratio;
  153999. /**
  154000. * Dynamically generated sphere sampler.
  154001. */
  154002. private _sampleSphere;
  154003. /**
  154004. * Blur filter offsets
  154005. */
  154006. private _samplerOffsets;
  154007. private _expensiveBlur;
  154008. /**
  154009. * If bilateral blur should be used
  154010. */
  154011. set expensiveBlur(b: boolean);
  154012. get expensiveBlur(): boolean;
  154013. /**
  154014. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  154015. */
  154016. radius: number;
  154017. /**
  154018. * The base color of the SSAO post-process
  154019. * The final result is "base + ssao" between [0, 1]
  154020. */
  154021. base: number;
  154022. /**
  154023. * Support test.
  154024. */
  154025. static get IsSupported(): boolean;
  154026. private _scene;
  154027. private _randomTexture;
  154028. private _originalColorPostProcess;
  154029. private _ssaoPostProcess;
  154030. private _blurHPostProcess;
  154031. private _blurVPostProcess;
  154032. private _ssaoCombinePostProcess;
  154033. private _prePassRenderer;
  154034. /**
  154035. * Gets active scene
  154036. */
  154037. get scene(): Scene;
  154038. /**
  154039. * @constructor
  154040. * @param name The rendering pipeline name
  154041. * @param scene The scene linked to this pipeline
  154042. * @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 }
  154043. * @param cameras The array of cameras that the rendering pipeline will be attached to
  154044. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  154045. */
  154046. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  154047. /**
  154048. * Get the class name
  154049. * @returns "SSAO2RenderingPipeline"
  154050. */
  154051. getClassName(): string;
  154052. /**
  154053. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  154054. */
  154055. dispose(disableGeometryBufferRenderer?: boolean): void;
  154056. private _createBlurPostProcess;
  154057. /** @hidden */
  154058. _rebuild(): void;
  154059. private _bits;
  154060. private _radicalInverse_VdC;
  154061. private _hammersley;
  154062. private _hemisphereSample_uniform;
  154063. private _generateHemisphere;
  154064. private _getDefinesForSSAO;
  154065. private _createSSAOPostProcess;
  154066. private _createSSAOCombinePostProcess;
  154067. private _createRandomTexture;
  154068. /**
  154069. * Serialize the rendering pipeline (Used when exporting)
  154070. * @returns the serialized object
  154071. */
  154072. serialize(): any;
  154073. /**
  154074. * Parse the serialized pipeline
  154075. * @param source Source pipeline.
  154076. * @param scene The scene to load the pipeline to.
  154077. * @param rootUrl The URL of the serialized pipeline.
  154078. * @returns An instantiated pipeline from the serialized object.
  154079. */
  154080. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  154081. }
  154082. }
  154083. declare module BABYLON {
  154084. /** @hidden */
  154085. export var ssaoPixelShader: {
  154086. name: string;
  154087. shader: string;
  154088. };
  154089. }
  154090. declare module BABYLON {
  154091. /**
  154092. * Render pipeline to produce ssao effect
  154093. */
  154094. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  154095. /**
  154096. * @ignore
  154097. * The PassPostProcess id in the pipeline that contains the original scene color
  154098. */
  154099. SSAOOriginalSceneColorEffect: string;
  154100. /**
  154101. * @ignore
  154102. * The SSAO PostProcess id in the pipeline
  154103. */
  154104. SSAORenderEffect: string;
  154105. /**
  154106. * @ignore
  154107. * The horizontal blur PostProcess id in the pipeline
  154108. */
  154109. SSAOBlurHRenderEffect: string;
  154110. /**
  154111. * @ignore
  154112. * The vertical blur PostProcess id in the pipeline
  154113. */
  154114. SSAOBlurVRenderEffect: string;
  154115. /**
  154116. * @ignore
  154117. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  154118. */
  154119. SSAOCombineRenderEffect: string;
  154120. /**
  154121. * The output strength of the SSAO post-process. Default value is 1.0.
  154122. */
  154123. totalStrength: number;
  154124. /**
  154125. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  154126. */
  154127. radius: number;
  154128. /**
  154129. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  154130. * Must not be equal to fallOff and superior to fallOff.
  154131. * Default value is 0.0075
  154132. */
  154133. area: number;
  154134. /**
  154135. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  154136. * Must not be equal to area and inferior to area.
  154137. * Default value is 0.000001
  154138. */
  154139. fallOff: number;
  154140. /**
  154141. * The base color of the SSAO post-process
  154142. * The final result is "base + ssao" between [0, 1]
  154143. */
  154144. base: number;
  154145. private _scene;
  154146. private _depthTexture;
  154147. private _randomTexture;
  154148. private _originalColorPostProcess;
  154149. private _ssaoPostProcess;
  154150. private _blurHPostProcess;
  154151. private _blurVPostProcess;
  154152. private _ssaoCombinePostProcess;
  154153. private _firstUpdate;
  154154. /**
  154155. * Gets active scene
  154156. */
  154157. get scene(): Scene;
  154158. /**
  154159. * @constructor
  154160. * @param name - The rendering pipeline name
  154161. * @param scene - The scene linked to this pipeline
  154162. * @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 }
  154163. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  154164. */
  154165. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  154166. /**
  154167. * Get the class name
  154168. * @returns "SSAORenderingPipeline"
  154169. */
  154170. getClassName(): string;
  154171. /**
  154172. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  154173. */
  154174. dispose(disableDepthRender?: boolean): void;
  154175. private _createBlurPostProcess;
  154176. /** @hidden */
  154177. _rebuild(): void;
  154178. private _createSSAOPostProcess;
  154179. private _createSSAOCombinePostProcess;
  154180. private _createRandomTexture;
  154181. }
  154182. }
  154183. declare module BABYLON {
  154184. /**
  154185. * Contains all parameters needed for the prepass to perform
  154186. * screen space reflections
  154187. */
  154188. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  154189. /**
  154190. * Is ssr enabled
  154191. */
  154192. enabled: boolean;
  154193. /**
  154194. * Name of the configuration
  154195. */
  154196. name: string;
  154197. /**
  154198. * Textures that should be present in the MRT for this effect to work
  154199. */
  154200. readonly texturesRequired: number[];
  154201. }
  154202. }
  154203. declare module BABYLON {
  154204. /** @hidden */
  154205. export var screenSpaceReflectionPixelShader: {
  154206. name: string;
  154207. shader: string;
  154208. };
  154209. }
  154210. declare module BABYLON {
  154211. /**
  154212. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  154213. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  154214. */
  154215. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  154216. /**
  154217. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  154218. */
  154219. threshold: number;
  154220. /**
  154221. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  154222. */
  154223. strength: number;
  154224. /**
  154225. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  154226. */
  154227. reflectionSpecularFalloffExponent: number;
  154228. /**
  154229. * 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]
  154230. */
  154231. step: number;
  154232. /**
  154233. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  154234. */
  154235. roughnessFactor: number;
  154236. private _forceGeometryBuffer;
  154237. private _geometryBufferRenderer;
  154238. private _prePassRenderer;
  154239. private _enableSmoothReflections;
  154240. private _reflectionSamples;
  154241. private _smoothSteps;
  154242. /**
  154243. * Gets a string identifying the name of the class
  154244. * @returns "ScreenSpaceReflectionPostProcess" string
  154245. */
  154246. getClassName(): string;
  154247. /**
  154248. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  154249. * @param name The name of the effect.
  154250. * @param scene The scene containing the objects to calculate reflections.
  154251. * @param options The required width/height ratio to downsize to before computing the render pass.
  154252. * @param camera The camera to apply the render pass to.
  154253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154254. * @param engine The engine which the post process will be applied. (default: current engine)
  154255. * @param reusable If the post process can be reused on the same frame. (default: false)
  154256. * @param textureType Type of textures used when performing the post process. (default: 0)
  154257. * @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: true)
  154258. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  154259. */
  154260. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  154261. /**
  154262. * Gets wether or not smoothing reflections is enabled.
  154263. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  154264. */
  154265. get enableSmoothReflections(): boolean;
  154266. /**
  154267. * Sets wether or not smoothing reflections is enabled.
  154268. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  154269. */
  154270. set enableSmoothReflections(enabled: boolean);
  154271. /**
  154272. * Gets the number of samples taken while computing reflections. More samples count is high,
  154273. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  154274. */
  154275. get reflectionSamples(): number;
  154276. /**
  154277. * Sets the number of samples taken while computing reflections. More samples count is high,
  154278. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  154279. */
  154280. set reflectionSamples(samples: number);
  154281. /**
  154282. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  154283. * more the post-process will require GPU power and can generate a drop in FPS.
  154284. * Default value (5.0) work pretty well in all cases but can be adjusted.
  154285. */
  154286. get smoothSteps(): number;
  154287. set smoothSteps(steps: number);
  154288. private _updateEffectDefines;
  154289. /** @hidden */
  154290. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  154291. }
  154292. }
  154293. declare module BABYLON {
  154294. /** @hidden */
  154295. export var standardPixelShader: {
  154296. name: string;
  154297. shader: string;
  154298. };
  154299. }
  154300. declare module BABYLON {
  154301. /**
  154302. * Standard rendering pipeline
  154303. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  154304. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  154305. */
  154306. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  154307. /**
  154308. * Public members
  154309. */
  154310. /**
  154311. * Post-process which contains the original scene color before the pipeline applies all the effects
  154312. */
  154313. originalPostProcess: Nullable<PostProcess>;
  154314. /**
  154315. * Post-process used to down scale an image x4
  154316. */
  154317. downSampleX4PostProcess: Nullable<PostProcess>;
  154318. /**
  154319. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  154320. */
  154321. brightPassPostProcess: Nullable<PostProcess>;
  154322. /**
  154323. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  154324. */
  154325. blurHPostProcesses: PostProcess[];
  154326. /**
  154327. * Post-process array storing all the vertical blur post-processes used by the pipeline
  154328. */
  154329. blurVPostProcesses: PostProcess[];
  154330. /**
  154331. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  154332. */
  154333. textureAdderPostProcess: Nullable<PostProcess>;
  154334. /**
  154335. * Post-process used to create volumetric lighting effect
  154336. */
  154337. volumetricLightPostProcess: Nullable<PostProcess>;
  154338. /**
  154339. * Post-process used to smooth the previous volumetric light post-process on the X axis
  154340. */
  154341. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  154342. /**
  154343. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  154344. */
  154345. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  154346. /**
  154347. * Post-process used to merge the volumetric light effect and the real scene color
  154348. */
  154349. volumetricLightMergePostProces: Nullable<PostProcess>;
  154350. /**
  154351. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  154352. */
  154353. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  154354. /**
  154355. * Base post-process used to calculate the average luminance of the final image for HDR
  154356. */
  154357. luminancePostProcess: Nullable<PostProcess>;
  154358. /**
  154359. * Post-processes used to create down sample post-processes in order to get
  154360. * the average luminance of the final image for HDR
  154361. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  154362. */
  154363. luminanceDownSamplePostProcesses: PostProcess[];
  154364. /**
  154365. * Post-process used to create a HDR effect (light adaptation)
  154366. */
  154367. hdrPostProcess: Nullable<PostProcess>;
  154368. /**
  154369. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  154370. */
  154371. textureAdderFinalPostProcess: Nullable<PostProcess>;
  154372. /**
  154373. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  154374. */
  154375. lensFlareFinalPostProcess: Nullable<PostProcess>;
  154376. /**
  154377. * Post-process used to merge the final HDR post-process and the real scene color
  154378. */
  154379. hdrFinalPostProcess: Nullable<PostProcess>;
  154380. /**
  154381. * Post-process used to create a lens flare effect
  154382. */
  154383. lensFlarePostProcess: Nullable<PostProcess>;
  154384. /**
  154385. * Post-process that merges the result of the lens flare post-process and the real scene color
  154386. */
  154387. lensFlareComposePostProcess: Nullable<PostProcess>;
  154388. /**
  154389. * Post-process used to create a motion blur effect
  154390. */
  154391. motionBlurPostProcess: Nullable<PostProcess>;
  154392. /**
  154393. * Post-process used to create a depth of field effect
  154394. */
  154395. depthOfFieldPostProcess: Nullable<PostProcess>;
  154396. /**
  154397. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  154398. */
  154399. fxaaPostProcess: Nullable<FxaaPostProcess>;
  154400. /**
  154401. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  154402. */
  154403. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  154404. /**
  154405. * Represents the brightness threshold in order to configure the illuminated surfaces
  154406. */
  154407. brightThreshold: number;
  154408. /**
  154409. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  154410. */
  154411. blurWidth: number;
  154412. /**
  154413. * Sets if the blur for highlighted surfaces must be only horizontal
  154414. */
  154415. horizontalBlur: boolean;
  154416. /**
  154417. * Gets the overall exposure used by the pipeline
  154418. */
  154419. get exposure(): number;
  154420. /**
  154421. * Sets the overall exposure used by the pipeline
  154422. */
  154423. set exposure(value: number);
  154424. /**
  154425. * Texture used typically to simulate "dirty" on camera lens
  154426. */
  154427. lensTexture: Nullable<Texture>;
  154428. /**
  154429. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  154430. */
  154431. volumetricLightCoefficient: number;
  154432. /**
  154433. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  154434. */
  154435. volumetricLightPower: number;
  154436. /**
  154437. * Used the set the blur intensity to smooth the volumetric lights
  154438. */
  154439. volumetricLightBlurScale: number;
  154440. /**
  154441. * Light (spot or directional) used to generate the volumetric lights rays
  154442. * The source light must have a shadow generate so the pipeline can get its
  154443. * depth map
  154444. */
  154445. sourceLight: Nullable<SpotLight | DirectionalLight>;
  154446. /**
  154447. * For eye adaptation, represents the minimum luminance the eye can see
  154448. */
  154449. hdrMinimumLuminance: number;
  154450. /**
  154451. * For eye adaptation, represents the decrease luminance speed
  154452. */
  154453. hdrDecreaseRate: number;
  154454. /**
  154455. * For eye adaptation, represents the increase luminance speed
  154456. */
  154457. hdrIncreaseRate: number;
  154458. /**
  154459. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  154460. */
  154461. get hdrAutoExposure(): boolean;
  154462. /**
  154463. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  154464. */
  154465. set hdrAutoExposure(value: boolean);
  154466. /**
  154467. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  154468. */
  154469. lensColorTexture: Nullable<Texture>;
  154470. /**
  154471. * The overall strengh for the lens flare effect
  154472. */
  154473. lensFlareStrength: number;
  154474. /**
  154475. * Dispersion coefficient for lens flare ghosts
  154476. */
  154477. lensFlareGhostDispersal: number;
  154478. /**
  154479. * Main lens flare halo width
  154480. */
  154481. lensFlareHaloWidth: number;
  154482. /**
  154483. * Based on the lens distortion effect, defines how much the lens flare result
  154484. * is distorted
  154485. */
  154486. lensFlareDistortionStrength: number;
  154487. /**
  154488. * Configures the blur intensity used for for lens flare (halo)
  154489. */
  154490. lensFlareBlurWidth: number;
  154491. /**
  154492. * Lens star texture must be used to simulate rays on the flares and is available
  154493. * in the documentation
  154494. */
  154495. lensStarTexture: Nullable<Texture>;
  154496. /**
  154497. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  154498. * flare effect by taking account of the dirt texture
  154499. */
  154500. lensFlareDirtTexture: Nullable<Texture>;
  154501. /**
  154502. * Represents the focal length for the depth of field effect
  154503. */
  154504. depthOfFieldDistance: number;
  154505. /**
  154506. * Represents the blur intensity for the blurred part of the depth of field effect
  154507. */
  154508. depthOfFieldBlurWidth: number;
  154509. /**
  154510. * Gets how much the image is blurred by the movement while using the motion blur post-process
  154511. */
  154512. get motionStrength(): number;
  154513. /**
  154514. * Sets how much the image is blurred by the movement while using the motion blur post-process
  154515. */
  154516. set motionStrength(strength: number);
  154517. /**
  154518. * Gets wether or not the motion blur post-process is object based or screen based.
  154519. */
  154520. get objectBasedMotionBlur(): boolean;
  154521. /**
  154522. * Sets wether or not the motion blur post-process should be object based or screen based
  154523. */
  154524. set objectBasedMotionBlur(value: boolean);
  154525. /**
  154526. * List of animations for the pipeline (IAnimatable implementation)
  154527. */
  154528. animations: Animation[];
  154529. /**
  154530. * Private members
  154531. */
  154532. private _scene;
  154533. private _currentDepthOfFieldSource;
  154534. private _basePostProcess;
  154535. private _fixedExposure;
  154536. private _currentExposure;
  154537. private _hdrAutoExposure;
  154538. private _hdrCurrentLuminance;
  154539. private _motionStrength;
  154540. private _isObjectBasedMotionBlur;
  154541. private _floatTextureType;
  154542. private _camerasToBeAttached;
  154543. private _ratio;
  154544. private _bloomEnabled;
  154545. private _depthOfFieldEnabled;
  154546. private _vlsEnabled;
  154547. private _lensFlareEnabled;
  154548. private _hdrEnabled;
  154549. private _motionBlurEnabled;
  154550. private _fxaaEnabled;
  154551. private _screenSpaceReflectionsEnabled;
  154552. private _motionBlurSamples;
  154553. private _volumetricLightStepsCount;
  154554. private _samples;
  154555. /**
  154556. * @ignore
  154557. * Specifies if the bloom pipeline is enabled
  154558. */
  154559. get BloomEnabled(): boolean;
  154560. set BloomEnabled(enabled: boolean);
  154561. /**
  154562. * @ignore
  154563. * Specifies if the depth of field pipeline is enabed
  154564. */
  154565. get DepthOfFieldEnabled(): boolean;
  154566. set DepthOfFieldEnabled(enabled: boolean);
  154567. /**
  154568. * @ignore
  154569. * Specifies if the lens flare pipeline is enabed
  154570. */
  154571. get LensFlareEnabled(): boolean;
  154572. set LensFlareEnabled(enabled: boolean);
  154573. /**
  154574. * @ignore
  154575. * Specifies if the HDR pipeline is enabled
  154576. */
  154577. get HDREnabled(): boolean;
  154578. set HDREnabled(enabled: boolean);
  154579. /**
  154580. * @ignore
  154581. * Specifies if the volumetric lights scattering effect is enabled
  154582. */
  154583. get VLSEnabled(): boolean;
  154584. set VLSEnabled(enabled: boolean);
  154585. /**
  154586. * @ignore
  154587. * Specifies if the motion blur effect is enabled
  154588. */
  154589. get MotionBlurEnabled(): boolean;
  154590. set MotionBlurEnabled(enabled: boolean);
  154591. /**
  154592. * Specifies if anti-aliasing is enabled
  154593. */
  154594. get fxaaEnabled(): boolean;
  154595. set fxaaEnabled(enabled: boolean);
  154596. /**
  154597. * Specifies if screen space reflections are enabled.
  154598. */
  154599. get screenSpaceReflectionsEnabled(): boolean;
  154600. set screenSpaceReflectionsEnabled(enabled: boolean);
  154601. /**
  154602. * Specifies the number of steps used to calculate the volumetric lights
  154603. * Typically in interval [50, 200]
  154604. */
  154605. get volumetricLightStepsCount(): number;
  154606. set volumetricLightStepsCount(count: number);
  154607. /**
  154608. * Specifies the number of samples used for the motion blur effect
  154609. * Typically in interval [16, 64]
  154610. */
  154611. get motionBlurSamples(): number;
  154612. set motionBlurSamples(samples: number);
  154613. /**
  154614. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  154615. */
  154616. get samples(): number;
  154617. set samples(sampleCount: number);
  154618. /**
  154619. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  154620. * @constructor
  154621. * @param name The rendering pipeline name
  154622. * @param scene The scene linked to this pipeline
  154623. * @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)
  154624. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  154625. * @param cameras The array of cameras that the rendering pipeline will be attached to
  154626. */
  154627. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  154628. private _buildPipeline;
  154629. private _createDownSampleX4PostProcess;
  154630. private _createBrightPassPostProcess;
  154631. private _createBlurPostProcesses;
  154632. private _createTextureAdderPostProcess;
  154633. private _createVolumetricLightPostProcess;
  154634. private _createLuminancePostProcesses;
  154635. private _createHdrPostProcess;
  154636. private _createLensFlarePostProcess;
  154637. private _createDepthOfFieldPostProcess;
  154638. private _createMotionBlurPostProcess;
  154639. private _getDepthTexture;
  154640. private _disposePostProcesses;
  154641. /**
  154642. * Dispose of the pipeline and stop all post processes
  154643. */
  154644. dispose(): void;
  154645. /**
  154646. * Serialize the rendering pipeline (Used when exporting)
  154647. * @returns the serialized object
  154648. */
  154649. serialize(): any;
  154650. /**
  154651. * Parse the serialized pipeline
  154652. * @param source Source pipeline.
  154653. * @param scene The scene to load the pipeline to.
  154654. * @param rootUrl The URL of the serialized pipeline.
  154655. * @returns An instantiated pipeline from the serialized object.
  154656. */
  154657. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  154658. /**
  154659. * Luminance steps
  154660. */
  154661. static LuminanceSteps: number;
  154662. }
  154663. }
  154664. declare module BABYLON {
  154665. /** @hidden */
  154666. export var stereoscopicInterlacePixelShader: {
  154667. name: string;
  154668. shader: string;
  154669. };
  154670. }
  154671. declare module BABYLON {
  154672. /**
  154673. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  154674. */
  154675. export class StereoscopicInterlacePostProcessI extends PostProcess {
  154676. private _stepSize;
  154677. private _passedProcess;
  154678. /**
  154679. * Gets a string identifying the name of the class
  154680. * @returns "StereoscopicInterlacePostProcessI" string
  154681. */
  154682. getClassName(): string;
  154683. /**
  154684. * Initializes a StereoscopicInterlacePostProcessI
  154685. * @param name The name of the effect.
  154686. * @param rigCameras The rig cameras to be appled to the post process
  154687. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  154688. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  154689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154690. * @param engine The engine which the post process will be applied. (default: current engine)
  154691. * @param reusable If the post process can be reused on the same frame. (default: false)
  154692. */
  154693. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154694. }
  154695. /**
  154696. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  154697. */
  154698. export class StereoscopicInterlacePostProcess extends PostProcess {
  154699. private _stepSize;
  154700. private _passedProcess;
  154701. /**
  154702. * Gets a string identifying the name of the class
  154703. * @returns "StereoscopicInterlacePostProcess" string
  154704. */
  154705. getClassName(): string;
  154706. /**
  154707. * Initializes a StereoscopicInterlacePostProcess
  154708. * @param name The name of the effect.
  154709. * @param rigCameras The rig cameras to be appled to the post process
  154710. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  154711. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154712. * @param engine The engine which the post process will be applied. (default: current engine)
  154713. * @param reusable If the post process can be reused on the same frame. (default: false)
  154714. */
  154715. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154716. }
  154717. }
  154718. declare module BABYLON {
  154719. /** @hidden */
  154720. export var tonemapPixelShader: {
  154721. name: string;
  154722. shader: string;
  154723. };
  154724. }
  154725. declare module BABYLON {
  154726. /** Defines operator used for tonemapping */
  154727. export enum TonemappingOperator {
  154728. /** Hable */
  154729. Hable = 0,
  154730. /** Reinhard */
  154731. Reinhard = 1,
  154732. /** HejiDawson */
  154733. HejiDawson = 2,
  154734. /** Photographic */
  154735. Photographic = 3
  154736. }
  154737. /**
  154738. * Defines a post process to apply tone mapping
  154739. */
  154740. export class TonemapPostProcess extends PostProcess {
  154741. private _operator;
  154742. /** Defines the required exposure adjustement */
  154743. exposureAdjustment: number;
  154744. /**
  154745. * Gets a string identifying the name of the class
  154746. * @returns "TonemapPostProcess" string
  154747. */
  154748. getClassName(): string;
  154749. /**
  154750. * Creates a new TonemapPostProcess
  154751. * @param name defines the name of the postprocess
  154752. * @param _operator defines the operator to use
  154753. * @param exposureAdjustment defines the required exposure adjustement
  154754. * @param camera defines the camera to use (can be null)
  154755. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  154756. * @param engine defines the hosting engine (can be ignore if camera is set)
  154757. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  154758. */
  154759. constructor(name: string, _operator: TonemappingOperator,
  154760. /** Defines the required exposure adjustement */
  154761. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  154762. }
  154763. }
  154764. declare module BABYLON {
  154765. /** @hidden */
  154766. export var volumetricLightScatteringPixelShader: {
  154767. name: string;
  154768. shader: string;
  154769. };
  154770. }
  154771. declare module BABYLON {
  154772. /** @hidden */
  154773. export var volumetricLightScatteringPassVertexShader: {
  154774. name: string;
  154775. shader: string;
  154776. };
  154777. }
  154778. declare module BABYLON {
  154779. /** @hidden */
  154780. export var volumetricLightScatteringPassPixelShader: {
  154781. name: string;
  154782. shader: string;
  154783. };
  154784. }
  154785. declare module BABYLON {
  154786. /**
  154787. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  154788. */
  154789. export class VolumetricLightScatteringPostProcess extends PostProcess {
  154790. private _volumetricLightScatteringPass;
  154791. private _volumetricLightScatteringRTT;
  154792. private _viewPort;
  154793. private _screenCoordinates;
  154794. private _cachedDefines;
  154795. /**
  154796. * If not undefined, the mesh position is computed from the attached node position
  154797. */
  154798. attachedNode: {
  154799. position: Vector3;
  154800. };
  154801. /**
  154802. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  154803. */
  154804. customMeshPosition: Vector3;
  154805. /**
  154806. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  154807. */
  154808. useCustomMeshPosition: boolean;
  154809. /**
  154810. * If the post-process should inverse the light scattering direction
  154811. */
  154812. invert: boolean;
  154813. /**
  154814. * The internal mesh used by the post-process
  154815. */
  154816. mesh: Mesh;
  154817. /**
  154818. * @hidden
  154819. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  154820. */
  154821. get useDiffuseColor(): boolean;
  154822. set useDiffuseColor(useDiffuseColor: boolean);
  154823. /**
  154824. * Array containing the excluded meshes not rendered in the internal pass
  154825. */
  154826. excludedMeshes: AbstractMesh[];
  154827. /**
  154828. * Controls the overall intensity of the post-process
  154829. */
  154830. exposure: number;
  154831. /**
  154832. * Dissipates each sample's contribution in range [0, 1]
  154833. */
  154834. decay: number;
  154835. /**
  154836. * Controls the overall intensity of each sample
  154837. */
  154838. weight: number;
  154839. /**
  154840. * Controls the density of each sample
  154841. */
  154842. density: number;
  154843. /**
  154844. * @constructor
  154845. * @param name The post-process name
  154846. * @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)
  154847. * @param camera The camera that the post-process will be attached to
  154848. * @param mesh The mesh used to create the light scattering
  154849. * @param samples The post-process quality, default 100
  154850. * @param samplingModeThe post-process filtering mode
  154851. * @param engine The babylon engine
  154852. * @param reusable If the post-process is reusable
  154853. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  154854. */
  154855. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  154856. /**
  154857. * Returns the string "VolumetricLightScatteringPostProcess"
  154858. * @returns "VolumetricLightScatteringPostProcess"
  154859. */
  154860. getClassName(): string;
  154861. private _isReady;
  154862. /**
  154863. * Sets the new light position for light scattering effect
  154864. * @param position The new custom light position
  154865. */
  154866. setCustomMeshPosition(position: Vector3): void;
  154867. /**
  154868. * Returns the light position for light scattering effect
  154869. * @return Vector3 The custom light position
  154870. */
  154871. getCustomMeshPosition(): Vector3;
  154872. /**
  154873. * Disposes the internal assets and detaches the post-process from the camera
  154874. */
  154875. dispose(camera: Camera): void;
  154876. /**
  154877. * Returns the render target texture used by the post-process
  154878. * @return the render target texture used by the post-process
  154879. */
  154880. getPass(): RenderTargetTexture;
  154881. private _meshExcluded;
  154882. private _createPass;
  154883. private _updateMeshScreenCoordinates;
  154884. /**
  154885. * Creates a default mesh for the Volumeric Light Scattering post-process
  154886. * @param name The mesh name
  154887. * @param scene The scene where to create the mesh
  154888. * @return the default mesh
  154889. */
  154890. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  154891. }
  154892. }
  154893. declare module BABYLON {
  154894. /** @hidden */
  154895. export var screenSpaceCurvaturePixelShader: {
  154896. name: string;
  154897. shader: string;
  154898. };
  154899. }
  154900. declare module BABYLON {
  154901. /**
  154902. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  154903. */
  154904. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  154905. /**
  154906. * Defines how much ridge the curvature effect displays.
  154907. */
  154908. ridge: number;
  154909. /**
  154910. * Defines how much valley the curvature effect displays.
  154911. */
  154912. valley: number;
  154913. private _geometryBufferRenderer;
  154914. /**
  154915. * Gets a string identifying the name of the class
  154916. * @returns "ScreenSpaceCurvaturePostProcess" string
  154917. */
  154918. getClassName(): string;
  154919. /**
  154920. * Creates a new instance ScreenSpaceCurvaturePostProcess
  154921. * @param name The name of the effect.
  154922. * @param scene The scene containing the objects to blur according to their velocity.
  154923. * @param options The required width/height ratio to downsize to before computing the render pass.
  154924. * @param camera The camera to apply the render pass to.
  154925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154926. * @param engine The engine which the post process will be applied. (default: current engine)
  154927. * @param reusable If the post process can be reused on the same frame. (default: false)
  154928. * @param textureType Type of textures used when performing the post process. (default: 0)
  154929. * @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)
  154930. */
  154931. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  154932. /**
  154933. * Support test.
  154934. */
  154935. static get IsSupported(): boolean;
  154936. /** @hidden */
  154937. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  154938. }
  154939. }
  154940. declare module BABYLON {
  154941. interface Scene {
  154942. /** @hidden (Backing field) */
  154943. _boundingBoxRenderer: BoundingBoxRenderer;
  154944. /** @hidden (Backing field) */
  154945. _forceShowBoundingBoxes: boolean;
  154946. /**
  154947. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  154948. */
  154949. forceShowBoundingBoxes: boolean;
  154950. /**
  154951. * Gets the bounding box renderer associated with the scene
  154952. * @returns a BoundingBoxRenderer
  154953. */
  154954. getBoundingBoxRenderer(): BoundingBoxRenderer;
  154955. }
  154956. interface AbstractMesh {
  154957. /** @hidden (Backing field) */
  154958. _showBoundingBox: boolean;
  154959. /**
  154960. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  154961. */
  154962. showBoundingBox: boolean;
  154963. }
  154964. /**
  154965. * Component responsible of rendering the bounding box of the meshes in a scene.
  154966. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  154967. */
  154968. export class BoundingBoxRenderer implements ISceneComponent {
  154969. /**
  154970. * The component name helpfull to identify the component in the list of scene components.
  154971. */
  154972. readonly name: string;
  154973. /**
  154974. * The scene the component belongs to.
  154975. */
  154976. scene: Scene;
  154977. /**
  154978. * Color of the bounding box lines placed in front of an object
  154979. */
  154980. frontColor: Color3;
  154981. /**
  154982. * Color of the bounding box lines placed behind an object
  154983. */
  154984. backColor: Color3;
  154985. /**
  154986. * Defines if the renderer should show the back lines or not
  154987. */
  154988. showBackLines: boolean;
  154989. /**
  154990. * Observable raised before rendering a bounding box
  154991. */
  154992. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  154993. /**
  154994. * Observable raised after rendering a bounding box
  154995. */
  154996. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  154997. /**
  154998. * Observable raised after resources are created
  154999. */
  155000. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  155001. /**
  155002. * When false, no bounding boxes will be rendered
  155003. */
  155004. enabled: boolean;
  155005. /**
  155006. * @hidden
  155007. */
  155008. renderList: SmartArray<BoundingBox>;
  155009. private _colorShader;
  155010. private _vertexBuffers;
  155011. private _indexBuffer;
  155012. private _fillIndexBuffer;
  155013. private _fillIndexData;
  155014. /**
  155015. * Instantiates a new bounding box renderer in a scene.
  155016. * @param scene the scene the renderer renders in
  155017. */
  155018. constructor(scene: Scene);
  155019. /**
  155020. * Registers the component in a given scene
  155021. */
  155022. register(): void;
  155023. private _evaluateSubMesh;
  155024. private _preActiveMesh;
  155025. private _prepareResources;
  155026. private _createIndexBuffer;
  155027. /**
  155028. * Rebuilds the elements related to this component in case of
  155029. * context lost for instance.
  155030. */
  155031. rebuild(): void;
  155032. /**
  155033. * @hidden
  155034. */
  155035. reset(): void;
  155036. /**
  155037. * Render the bounding boxes of a specific rendering group
  155038. * @param renderingGroupId defines the rendering group to render
  155039. */
  155040. render(renderingGroupId: number): void;
  155041. /**
  155042. * In case of occlusion queries, we can render the occlusion bounding box through this method
  155043. * @param mesh Define the mesh to render the occlusion bounding box for
  155044. */
  155045. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  155046. /**
  155047. * Dispose and release the resources attached to this renderer.
  155048. */
  155049. dispose(): void;
  155050. }
  155051. }
  155052. declare module BABYLON {
  155053. interface Scene {
  155054. /** @hidden (Backing field) */
  155055. _depthRenderer: {
  155056. [id: string]: DepthRenderer;
  155057. };
  155058. /**
  155059. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  155060. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  155061. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  155062. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  155063. * @returns the created depth renderer
  155064. */
  155065. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  155066. /**
  155067. * Disables a depth renderer for a given camera
  155068. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  155069. */
  155070. disableDepthRenderer(camera?: Nullable<Camera>): void;
  155071. }
  155072. /**
  155073. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  155074. * in several rendering techniques.
  155075. */
  155076. export class DepthRendererSceneComponent implements ISceneComponent {
  155077. /**
  155078. * The component name helpfull to identify the component in the list of scene components.
  155079. */
  155080. readonly name: string;
  155081. /**
  155082. * The scene the component belongs to.
  155083. */
  155084. scene: Scene;
  155085. /**
  155086. * Creates a new instance of the component for the given scene
  155087. * @param scene Defines the scene to register the component in
  155088. */
  155089. constructor(scene: Scene);
  155090. /**
  155091. * Registers the component in a given scene
  155092. */
  155093. register(): void;
  155094. /**
  155095. * Rebuilds the elements related to this component in case of
  155096. * context lost for instance.
  155097. */
  155098. rebuild(): void;
  155099. /**
  155100. * Disposes the component and the associated ressources
  155101. */
  155102. dispose(): void;
  155103. private _gatherRenderTargets;
  155104. private _gatherActiveCameraRenderTargets;
  155105. }
  155106. }
  155107. declare module BABYLON {
  155108. interface AbstractScene {
  155109. /** @hidden (Backing field) */
  155110. _prePassRenderer: Nullable<PrePassRenderer>;
  155111. /**
  155112. * Gets or Sets the current prepass renderer associated to the scene.
  155113. */
  155114. prePassRenderer: Nullable<PrePassRenderer>;
  155115. /**
  155116. * Enables the prepass and associates it with the scene
  155117. * @returns the PrePassRenderer
  155118. */
  155119. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  155120. /**
  155121. * Disables the prepass associated with the scene
  155122. */
  155123. disablePrePassRenderer(): void;
  155124. }
  155125. /**
  155126. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  155127. * in several rendering techniques.
  155128. */
  155129. export class PrePassRendererSceneComponent implements ISceneComponent {
  155130. /**
  155131. * The component name helpful to identify the component in the list of scene components.
  155132. */
  155133. readonly name: string;
  155134. /**
  155135. * The scene the component belongs to.
  155136. */
  155137. scene: Scene;
  155138. /**
  155139. * Creates a new instance of the component for the given scene
  155140. * @param scene Defines the scene to register the component in
  155141. */
  155142. constructor(scene: Scene);
  155143. /**
  155144. * Registers the component in a given scene
  155145. */
  155146. register(): void;
  155147. private _beforeCameraDraw;
  155148. private _afterCameraDraw;
  155149. private _beforeClearStage;
  155150. private _beforeRenderingMeshStage;
  155151. private _afterRenderingMeshStage;
  155152. /**
  155153. * Rebuilds the elements related to this component in case of
  155154. * context lost for instance.
  155155. */
  155156. rebuild(): void;
  155157. /**
  155158. * Disposes the component and the associated ressources
  155159. */
  155160. dispose(): void;
  155161. }
  155162. }
  155163. declare module BABYLON {
  155164. /** @hidden */
  155165. export var fibonacci: {
  155166. name: string;
  155167. shader: string;
  155168. };
  155169. }
  155170. declare module BABYLON {
  155171. /** @hidden */
  155172. export var diffusionProfile: {
  155173. name: string;
  155174. shader: string;
  155175. };
  155176. }
  155177. declare module BABYLON {
  155178. /** @hidden */
  155179. export var subSurfaceScatteringPixelShader: {
  155180. name: string;
  155181. shader: string;
  155182. };
  155183. }
  155184. declare module BABYLON {
  155185. /**
  155186. * Sub surface scattering post process
  155187. */
  155188. export class SubSurfaceScatteringPostProcess extends PostProcess {
  155189. /**
  155190. * Gets a string identifying the name of the class
  155191. * @returns "SubSurfaceScatteringPostProcess" string
  155192. */
  155193. getClassName(): string;
  155194. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  155195. }
  155196. }
  155197. declare module BABYLON {
  155198. /**
  155199. * Contains all parameters needed for the prepass to perform
  155200. * screen space subsurface scattering
  155201. */
  155202. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  155203. /** @hidden */
  155204. static _SceneComponentInitialization: (scene: Scene) => void;
  155205. private _ssDiffusionS;
  155206. private _ssFilterRadii;
  155207. private _ssDiffusionD;
  155208. /**
  155209. * Post process to attach for screen space subsurface scattering
  155210. */
  155211. postProcess: SubSurfaceScatteringPostProcess;
  155212. /**
  155213. * Diffusion profile color for subsurface scattering
  155214. */
  155215. get ssDiffusionS(): number[];
  155216. /**
  155217. * Diffusion profile max color channel value for subsurface scattering
  155218. */
  155219. get ssDiffusionD(): number[];
  155220. /**
  155221. * Diffusion profile filter radius for subsurface scattering
  155222. */
  155223. get ssFilterRadii(): number[];
  155224. /**
  155225. * Is subsurface enabled
  155226. */
  155227. enabled: boolean;
  155228. /**
  155229. * Name of the configuration
  155230. */
  155231. name: string;
  155232. /**
  155233. * Diffusion profile colors for subsurface scattering
  155234. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  155235. * See ...
  155236. * Note that you can only store up to 5 of them
  155237. */
  155238. ssDiffusionProfileColors: Color3[];
  155239. /**
  155240. * Defines the ratio real world => scene units.
  155241. * Used for subsurface scattering
  155242. */
  155243. metersPerUnit: number;
  155244. /**
  155245. * Textures that should be present in the MRT for this effect to work
  155246. */
  155247. readonly texturesRequired: number[];
  155248. private _scene;
  155249. /**
  155250. * Builds a subsurface configuration object
  155251. * @param scene The scene
  155252. */
  155253. constructor(scene: Scene);
  155254. /**
  155255. * Adds a new diffusion profile.
  155256. * Useful for more realistic subsurface scattering on diverse materials.
  155257. * @param color The color of the diffusion profile. Should be the average color of the material.
  155258. * @return The index of the diffusion profile for the material subsurface configuration
  155259. */
  155260. addDiffusionProfile(color: Color3): number;
  155261. /**
  155262. * Creates the sss post process
  155263. * @return The created post process
  155264. */
  155265. createPostProcess(): SubSurfaceScatteringPostProcess;
  155266. /**
  155267. * Deletes all diffusion profiles.
  155268. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  155269. */
  155270. clearAllDiffusionProfiles(): void;
  155271. /**
  155272. * Disposes this object
  155273. */
  155274. dispose(): void;
  155275. /**
  155276. * @hidden
  155277. * https://zero-radiance.github.io/post/sampling-diffusion/
  155278. *
  155279. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  155280. * ------------------------------------------------------------------------------------
  155281. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  155282. * PDF[r, phi, s] = r * R[r, phi, s]
  155283. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  155284. * ------------------------------------------------------------------------------------
  155285. * We importance sample the color channel with the widest scattering distance.
  155286. */
  155287. getDiffusionProfileParameters(color: Color3): number;
  155288. /**
  155289. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  155290. * 'u' is the random number (the value of the CDF): [0, 1).
  155291. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  155292. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  155293. */
  155294. private _sampleBurleyDiffusionProfile;
  155295. }
  155296. }
  155297. declare module BABYLON {
  155298. interface AbstractScene {
  155299. /** @hidden (Backing field) */
  155300. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  155301. /**
  155302. * Gets or Sets the current prepass renderer associated to the scene.
  155303. */
  155304. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  155305. /**
  155306. * Enables the subsurface effect for prepass
  155307. * @returns the SubSurfaceConfiguration
  155308. */
  155309. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  155310. /**
  155311. * Disables the subsurface effect for prepass
  155312. */
  155313. disableSubSurfaceForPrePass(): void;
  155314. }
  155315. /**
  155316. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  155317. * in several rendering techniques.
  155318. */
  155319. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  155320. /**
  155321. * The component name helpful to identify the component in the list of scene components.
  155322. */
  155323. readonly name: string;
  155324. /**
  155325. * The scene the component belongs to.
  155326. */
  155327. scene: Scene;
  155328. /**
  155329. * Creates a new instance of the component for the given scene
  155330. * @param scene Defines the scene to register the component in
  155331. */
  155332. constructor(scene: Scene);
  155333. /**
  155334. * Registers the component in a given scene
  155335. */
  155336. register(): void;
  155337. /**
  155338. * Serializes the component data to the specified json object
  155339. * @param serializationObject The object to serialize to
  155340. */
  155341. serialize(serializationObject: any): void;
  155342. /**
  155343. * Adds all the elements from the container to the scene
  155344. * @param container the container holding the elements
  155345. */
  155346. addFromContainer(container: AbstractScene): void;
  155347. /**
  155348. * Removes all the elements in the container from the scene
  155349. * @param container contains the elements to remove
  155350. * @param dispose if the removed element should be disposed (default: false)
  155351. */
  155352. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  155353. /**
  155354. * Rebuilds the elements related to this component in case of
  155355. * context lost for instance.
  155356. */
  155357. rebuild(): void;
  155358. /**
  155359. * Disposes the component and the associated ressources
  155360. */
  155361. dispose(): void;
  155362. }
  155363. }
  155364. declare module BABYLON {
  155365. /** @hidden */
  155366. export var outlinePixelShader: {
  155367. name: string;
  155368. shader: string;
  155369. };
  155370. }
  155371. declare module BABYLON {
  155372. /** @hidden */
  155373. export var outlineVertexShader: {
  155374. name: string;
  155375. shader: string;
  155376. };
  155377. }
  155378. declare module BABYLON {
  155379. interface Scene {
  155380. /** @hidden */
  155381. _outlineRenderer: OutlineRenderer;
  155382. /**
  155383. * Gets the outline renderer associated with the scene
  155384. * @returns a OutlineRenderer
  155385. */
  155386. getOutlineRenderer(): OutlineRenderer;
  155387. }
  155388. interface AbstractMesh {
  155389. /** @hidden (Backing field) */
  155390. _renderOutline: boolean;
  155391. /**
  155392. * Gets or sets a boolean indicating if the outline must be rendered as well
  155393. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  155394. */
  155395. renderOutline: boolean;
  155396. /** @hidden (Backing field) */
  155397. _renderOverlay: boolean;
  155398. /**
  155399. * Gets or sets a boolean indicating if the overlay must be rendered as well
  155400. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  155401. */
  155402. renderOverlay: boolean;
  155403. }
  155404. /**
  155405. * This class is responsible to draw bothe outline/overlay of meshes.
  155406. * It should not be used directly but through the available method on mesh.
  155407. */
  155408. export class OutlineRenderer implements ISceneComponent {
  155409. /**
  155410. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  155411. */
  155412. private static _StencilReference;
  155413. /**
  155414. * The name of the component. Each component must have a unique name.
  155415. */
  155416. name: string;
  155417. /**
  155418. * The scene the component belongs to.
  155419. */
  155420. scene: Scene;
  155421. /**
  155422. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  155423. */
  155424. zOffset: number;
  155425. private _engine;
  155426. private _effect;
  155427. private _cachedDefines;
  155428. private _savedDepthWrite;
  155429. /**
  155430. * Instantiates a new outline renderer. (There could be only one per scene).
  155431. * @param scene Defines the scene it belongs to
  155432. */
  155433. constructor(scene: Scene);
  155434. /**
  155435. * Register the component to one instance of a scene.
  155436. */
  155437. register(): void;
  155438. /**
  155439. * Rebuilds the elements related to this component in case of
  155440. * context lost for instance.
  155441. */
  155442. rebuild(): void;
  155443. /**
  155444. * Disposes the component and the associated ressources.
  155445. */
  155446. dispose(): void;
  155447. /**
  155448. * Renders the outline in the canvas.
  155449. * @param subMesh Defines the sumesh to render
  155450. * @param batch Defines the batch of meshes in case of instances
  155451. * @param useOverlay Defines if the rendering is for the overlay or the outline
  155452. */
  155453. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  155454. /**
  155455. * Returns whether or not the outline renderer is ready for a given submesh.
  155456. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  155457. * @param subMesh Defines the submesh to check readyness for
  155458. * @param useInstances Defines wheter wee are trying to render instances or not
  155459. * @returns true if ready otherwise false
  155460. */
  155461. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  155462. private _beforeRenderingMesh;
  155463. private _afterRenderingMesh;
  155464. }
  155465. }
  155466. declare module BABYLON {
  155467. /**
  155468. * Defines the basic options interface of a Sprite Frame Source Size.
  155469. */
  155470. export interface ISpriteJSONSpriteSourceSize {
  155471. /**
  155472. * number of the original width of the Frame
  155473. */
  155474. w: number;
  155475. /**
  155476. * number of the original height of the Frame
  155477. */
  155478. h: number;
  155479. }
  155480. /**
  155481. * Defines the basic options interface of a Sprite Frame Data.
  155482. */
  155483. export interface ISpriteJSONSpriteFrameData {
  155484. /**
  155485. * number of the x offset of the Frame
  155486. */
  155487. x: number;
  155488. /**
  155489. * number of the y offset of the Frame
  155490. */
  155491. y: number;
  155492. /**
  155493. * number of the width of the Frame
  155494. */
  155495. w: number;
  155496. /**
  155497. * number of the height of the Frame
  155498. */
  155499. h: number;
  155500. }
  155501. /**
  155502. * Defines the basic options interface of a JSON Sprite.
  155503. */
  155504. export interface ISpriteJSONSprite {
  155505. /**
  155506. * string name of the Frame
  155507. */
  155508. filename: string;
  155509. /**
  155510. * ISpriteJSONSpriteFrame basic object of the frame data
  155511. */
  155512. frame: ISpriteJSONSpriteFrameData;
  155513. /**
  155514. * boolean to flag is the frame was rotated.
  155515. */
  155516. rotated: boolean;
  155517. /**
  155518. * boolean to flag is the frame was trimmed.
  155519. */
  155520. trimmed: boolean;
  155521. /**
  155522. * ISpriteJSONSpriteFrame basic object of the source data
  155523. */
  155524. spriteSourceSize: ISpriteJSONSpriteFrameData;
  155525. /**
  155526. * ISpriteJSONSpriteFrame basic object of the source data
  155527. */
  155528. sourceSize: ISpriteJSONSpriteSourceSize;
  155529. }
  155530. /**
  155531. * Defines the basic options interface of a JSON atlas.
  155532. */
  155533. export interface ISpriteJSONAtlas {
  155534. /**
  155535. * Array of objects that contain the frame data.
  155536. */
  155537. frames: Array<ISpriteJSONSprite>;
  155538. /**
  155539. * object basic object containing the sprite meta data.
  155540. */
  155541. meta?: object;
  155542. }
  155543. }
  155544. declare module BABYLON {
  155545. /** @hidden */
  155546. export var spriteMapPixelShader: {
  155547. name: string;
  155548. shader: string;
  155549. };
  155550. }
  155551. declare module BABYLON {
  155552. /** @hidden */
  155553. export var spriteMapVertexShader: {
  155554. name: string;
  155555. shader: string;
  155556. };
  155557. }
  155558. declare module BABYLON {
  155559. /**
  155560. * Defines the basic options interface of a SpriteMap
  155561. */
  155562. export interface ISpriteMapOptions {
  155563. /**
  155564. * Vector2 of the number of cells in the grid.
  155565. */
  155566. stageSize?: Vector2;
  155567. /**
  155568. * Vector2 of the size of the output plane in World Units.
  155569. */
  155570. outputSize?: Vector2;
  155571. /**
  155572. * Vector3 of the position of the output plane in World Units.
  155573. */
  155574. outputPosition?: Vector3;
  155575. /**
  155576. * Vector3 of the rotation of the output plane.
  155577. */
  155578. outputRotation?: Vector3;
  155579. /**
  155580. * number of layers that the system will reserve in resources.
  155581. */
  155582. layerCount?: number;
  155583. /**
  155584. * number of max animation frames a single cell will reserve in resources.
  155585. */
  155586. maxAnimationFrames?: number;
  155587. /**
  155588. * number cell index of the base tile when the system compiles.
  155589. */
  155590. baseTile?: number;
  155591. /**
  155592. * boolean flip the sprite after its been repositioned by the framing data.
  155593. */
  155594. flipU?: boolean;
  155595. /**
  155596. * Vector3 scalar of the global RGB values of the SpriteMap.
  155597. */
  155598. colorMultiply?: Vector3;
  155599. }
  155600. /**
  155601. * Defines the IDisposable interface in order to be cleanable from resources.
  155602. */
  155603. export interface ISpriteMap extends IDisposable {
  155604. /**
  155605. * String name of the SpriteMap.
  155606. */
  155607. name: string;
  155608. /**
  155609. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  155610. */
  155611. atlasJSON: ISpriteJSONAtlas;
  155612. /**
  155613. * Texture of the SpriteMap.
  155614. */
  155615. spriteSheet: Texture;
  155616. /**
  155617. * The parameters to initialize the SpriteMap with.
  155618. */
  155619. options: ISpriteMapOptions;
  155620. }
  155621. /**
  155622. * Class used to manage a grid restricted sprite deployment on an Output plane.
  155623. */
  155624. export class SpriteMap implements ISpriteMap {
  155625. /** The Name of the spriteMap */
  155626. name: string;
  155627. /** The JSON file with the frame and meta data */
  155628. atlasJSON: ISpriteJSONAtlas;
  155629. /** The systems Sprite Sheet Texture */
  155630. spriteSheet: Texture;
  155631. /** Arguments passed with the Constructor */
  155632. options: ISpriteMapOptions;
  155633. /** Public Sprite Storage array, parsed from atlasJSON */
  155634. sprites: Array<ISpriteJSONSprite>;
  155635. /** Returns the Number of Sprites in the System */
  155636. get spriteCount(): number;
  155637. /** Returns the Position of Output Plane*/
  155638. get position(): Vector3;
  155639. /** Returns the Position of Output Plane*/
  155640. set position(v: Vector3);
  155641. /** Returns the Rotation of Output Plane*/
  155642. get rotation(): Vector3;
  155643. /** Returns the Rotation of Output Plane*/
  155644. set rotation(v: Vector3);
  155645. /** Sets the AnimationMap*/
  155646. get animationMap(): RawTexture;
  155647. /** Sets the AnimationMap*/
  155648. set animationMap(v: RawTexture);
  155649. /** Scene that the SpriteMap was created in */
  155650. private _scene;
  155651. /** Texture Buffer of Float32 that holds tile frame data*/
  155652. private _frameMap;
  155653. /** Texture Buffers of Float32 that holds tileMap data*/
  155654. private _tileMaps;
  155655. /** Texture Buffer of Float32 that holds Animation Data*/
  155656. private _animationMap;
  155657. /** Custom ShaderMaterial Central to the System*/
  155658. private _material;
  155659. /** Custom ShaderMaterial Central to the System*/
  155660. private _output;
  155661. /** Systems Time Ticker*/
  155662. private _time;
  155663. /**
  155664. * Creates a new SpriteMap
  155665. * @param name defines the SpriteMaps Name
  155666. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  155667. * @param spriteSheet is the Texture that the Sprites are on.
  155668. * @param options a basic deployment configuration
  155669. * @param scene The Scene that the map is deployed on
  155670. */
  155671. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  155672. /**
  155673. * Returns tileID location
  155674. * @returns Vector2 the cell position ID
  155675. */
  155676. getTileID(): Vector2;
  155677. /**
  155678. * Gets the UV location of the mouse over the SpriteMap.
  155679. * @returns Vector2 the UV position of the mouse interaction
  155680. */
  155681. getMousePosition(): Vector2;
  155682. /**
  155683. * Creates the "frame" texture Buffer
  155684. * -------------------------------------
  155685. * Structure of frames
  155686. * "filename": "Falling-Water-2.png",
  155687. * "frame": {"x":69,"y":103,"w":24,"h":32},
  155688. * "rotated": true,
  155689. * "trimmed": true,
  155690. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  155691. * "sourceSize": {"w":32,"h":32}
  155692. * @returns RawTexture of the frameMap
  155693. */
  155694. private _createFrameBuffer;
  155695. /**
  155696. * Creates the tileMap texture Buffer
  155697. * @param buffer normally and array of numbers, or a false to generate from scratch
  155698. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  155699. * @returns RawTexture of the tileMap
  155700. */
  155701. private _createTileBuffer;
  155702. /**
  155703. * Modifies the data of the tileMaps
  155704. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  155705. * @param pos is the iVector2 Coordinates of the Tile
  155706. * @param tile The SpriteIndex of the new Tile
  155707. */
  155708. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  155709. /**
  155710. * Creates the animationMap texture Buffer
  155711. * @param buffer normally and array of numbers, or a false to generate from scratch
  155712. * @returns RawTexture of the animationMap
  155713. */
  155714. private _createTileAnimationBuffer;
  155715. /**
  155716. * Modifies the data of the animationMap
  155717. * @param cellID is the Index of the Sprite
  155718. * @param _frame is the target Animation frame
  155719. * @param toCell is the Target Index of the next frame of the animation
  155720. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  155721. * @param speed is a global scalar of the time variable on the map.
  155722. */
  155723. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  155724. /**
  155725. * Exports the .tilemaps file
  155726. */
  155727. saveTileMaps(): void;
  155728. /**
  155729. * Imports the .tilemaps file
  155730. * @param url of the .tilemaps file
  155731. */
  155732. loadTileMaps(url: string): void;
  155733. /**
  155734. * Release associated resources
  155735. */
  155736. dispose(): void;
  155737. }
  155738. }
  155739. declare module BABYLON {
  155740. /**
  155741. * Class used to manage multiple sprites of different sizes on the same spritesheet
  155742. * @see https://doc.babylonjs.com/babylon101/sprites
  155743. */
  155744. export class SpritePackedManager extends SpriteManager {
  155745. /** defines the packed manager's name */
  155746. name: string;
  155747. /**
  155748. * Creates a new sprite manager from a packed sprite sheet
  155749. * @param name defines the manager's name
  155750. * @param imgUrl defines the sprite sheet url
  155751. * @param capacity defines the maximum allowed number of sprites
  155752. * @param scene defines the hosting scene
  155753. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  155754. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  155755. * @param samplingMode defines the smapling mode to use with spritesheet
  155756. * @param fromPacked set to true; do not alter
  155757. */
  155758. constructor(
  155759. /** defines the packed manager's name */
  155760. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  155761. }
  155762. }
  155763. declare module BABYLON {
  155764. /**
  155765. * Defines the list of states available for a task inside a AssetsManager
  155766. */
  155767. export enum AssetTaskState {
  155768. /**
  155769. * Initialization
  155770. */
  155771. INIT = 0,
  155772. /**
  155773. * Running
  155774. */
  155775. RUNNING = 1,
  155776. /**
  155777. * Done
  155778. */
  155779. DONE = 2,
  155780. /**
  155781. * Error
  155782. */
  155783. ERROR = 3
  155784. }
  155785. /**
  155786. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  155787. */
  155788. export abstract class AbstractAssetTask {
  155789. /**
  155790. * Task name
  155791. */ name: string;
  155792. /**
  155793. * Callback called when the task is successful
  155794. */
  155795. onSuccess: (task: any) => void;
  155796. /**
  155797. * Callback called when the task is not successful
  155798. */
  155799. onError: (task: any, message?: string, exception?: any) => void;
  155800. /**
  155801. * Creates a new AssetsManager
  155802. * @param name defines the name of the task
  155803. */
  155804. constructor(
  155805. /**
  155806. * Task name
  155807. */ name: string);
  155808. private _isCompleted;
  155809. private _taskState;
  155810. private _errorObject;
  155811. /**
  155812. * Get if the task is completed
  155813. */
  155814. get isCompleted(): boolean;
  155815. /**
  155816. * Gets the current state of the task
  155817. */
  155818. get taskState(): AssetTaskState;
  155819. /**
  155820. * Gets the current error object (if task is in error)
  155821. */
  155822. get errorObject(): {
  155823. message?: string;
  155824. exception?: any;
  155825. };
  155826. /**
  155827. * Internal only
  155828. * @hidden
  155829. */
  155830. _setErrorObject(message?: string, exception?: any): void;
  155831. /**
  155832. * Execute the current task
  155833. * @param scene defines the scene where you want your assets to be loaded
  155834. * @param onSuccess is a callback called when the task is successfully executed
  155835. * @param onError is a callback called if an error occurs
  155836. */
  155837. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155838. /**
  155839. * Execute the current task
  155840. * @param scene defines the scene where you want your assets to be loaded
  155841. * @param onSuccess is a callback called when the task is successfully executed
  155842. * @param onError is a callback called if an error occurs
  155843. */
  155844. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155845. /**
  155846. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  155847. * This can be used with failed tasks that have the reason for failure fixed.
  155848. */
  155849. reset(): void;
  155850. private onErrorCallback;
  155851. private onDoneCallback;
  155852. }
  155853. /**
  155854. * Define the interface used by progress events raised during assets loading
  155855. */
  155856. export interface IAssetsProgressEvent {
  155857. /**
  155858. * Defines the number of remaining tasks to process
  155859. */
  155860. remainingCount: number;
  155861. /**
  155862. * Defines the total number of tasks
  155863. */
  155864. totalCount: number;
  155865. /**
  155866. * Defines the task that was just processed
  155867. */
  155868. task: AbstractAssetTask;
  155869. }
  155870. /**
  155871. * Class used to share progress information about assets loading
  155872. */
  155873. export class AssetsProgressEvent implements IAssetsProgressEvent {
  155874. /**
  155875. * Defines the number of remaining tasks to process
  155876. */
  155877. remainingCount: number;
  155878. /**
  155879. * Defines the total number of tasks
  155880. */
  155881. totalCount: number;
  155882. /**
  155883. * Defines the task that was just processed
  155884. */
  155885. task: AbstractAssetTask;
  155886. /**
  155887. * Creates a AssetsProgressEvent
  155888. * @param remainingCount defines the number of remaining tasks to process
  155889. * @param totalCount defines the total number of tasks
  155890. * @param task defines the task that was just processed
  155891. */
  155892. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  155893. }
  155894. /**
  155895. * Define a task used by AssetsManager to load assets into a container
  155896. */
  155897. export class ContainerAssetTask extends AbstractAssetTask {
  155898. /**
  155899. * Defines the name of the task
  155900. */
  155901. name: string;
  155902. /**
  155903. * Defines the list of mesh's names you want to load
  155904. */
  155905. meshesNames: any;
  155906. /**
  155907. * Defines the root url to use as a base to load your meshes and associated resources
  155908. */
  155909. rootUrl: string;
  155910. /**
  155911. * Defines the filename or File of the scene to load from
  155912. */
  155913. sceneFilename: string | File;
  155914. /**
  155915. * Get the loaded asset container
  155916. */
  155917. loadedContainer: AssetContainer;
  155918. /**
  155919. * Gets the list of loaded meshes
  155920. */
  155921. loadedMeshes: Array<AbstractMesh>;
  155922. /**
  155923. * Gets the list of loaded particle systems
  155924. */
  155925. loadedParticleSystems: Array<IParticleSystem>;
  155926. /**
  155927. * Gets the list of loaded skeletons
  155928. */
  155929. loadedSkeletons: Array<Skeleton>;
  155930. /**
  155931. * Gets the list of loaded animation groups
  155932. */
  155933. loadedAnimationGroups: Array<AnimationGroup>;
  155934. /**
  155935. * Callback called when the task is successful
  155936. */
  155937. onSuccess: (task: ContainerAssetTask) => void;
  155938. /**
  155939. * Callback called when the task is successful
  155940. */
  155941. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  155942. /**
  155943. * Creates a new ContainerAssetTask
  155944. * @param name defines the name of the task
  155945. * @param meshesNames defines the list of mesh's names you want to load
  155946. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155947. * @param sceneFilename defines the filename or File of the scene to load from
  155948. */
  155949. constructor(
  155950. /**
  155951. * Defines the name of the task
  155952. */
  155953. name: string,
  155954. /**
  155955. * Defines the list of mesh's names you want to load
  155956. */
  155957. meshesNames: any,
  155958. /**
  155959. * Defines the root url to use as a base to load your meshes and associated resources
  155960. */
  155961. rootUrl: string,
  155962. /**
  155963. * Defines the filename or File of the scene to load from
  155964. */
  155965. sceneFilename: string | File);
  155966. /**
  155967. * Execute the current task
  155968. * @param scene defines the scene where you want your assets to be loaded
  155969. * @param onSuccess is a callback called when the task is successfully executed
  155970. * @param onError is a callback called if an error occurs
  155971. */
  155972. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155973. }
  155974. /**
  155975. * Define a task used by AssetsManager to load meshes
  155976. */
  155977. export class MeshAssetTask extends AbstractAssetTask {
  155978. /**
  155979. * Defines the name of the task
  155980. */
  155981. name: string;
  155982. /**
  155983. * Defines the list of mesh's names you want to load
  155984. */
  155985. meshesNames: any;
  155986. /**
  155987. * Defines the root url to use as a base to load your meshes and associated resources
  155988. */
  155989. rootUrl: string;
  155990. /**
  155991. * Defines the filename or File of the scene to load from
  155992. */
  155993. sceneFilename: string | File;
  155994. /**
  155995. * Gets the list of loaded meshes
  155996. */
  155997. loadedMeshes: Array<AbstractMesh>;
  155998. /**
  155999. * Gets the list of loaded particle systems
  156000. */
  156001. loadedParticleSystems: Array<IParticleSystem>;
  156002. /**
  156003. * Gets the list of loaded skeletons
  156004. */
  156005. loadedSkeletons: Array<Skeleton>;
  156006. /**
  156007. * Gets the list of loaded animation groups
  156008. */
  156009. loadedAnimationGroups: Array<AnimationGroup>;
  156010. /**
  156011. * Callback called when the task is successful
  156012. */
  156013. onSuccess: (task: MeshAssetTask) => void;
  156014. /**
  156015. * Callback called when the task is successful
  156016. */
  156017. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  156018. /**
  156019. * Creates a new MeshAssetTask
  156020. * @param name defines the name of the task
  156021. * @param meshesNames defines the list of mesh's names you want to load
  156022. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  156023. * @param sceneFilename defines the filename or File of the scene to load from
  156024. */
  156025. constructor(
  156026. /**
  156027. * Defines the name of the task
  156028. */
  156029. name: string,
  156030. /**
  156031. * Defines the list of mesh's names you want to load
  156032. */
  156033. meshesNames: any,
  156034. /**
  156035. * Defines the root url to use as a base to load your meshes and associated resources
  156036. */
  156037. rootUrl: string,
  156038. /**
  156039. * Defines the filename or File of the scene to load from
  156040. */
  156041. sceneFilename: string | File);
  156042. /**
  156043. * Execute the current task
  156044. * @param scene defines the scene where you want your assets to be loaded
  156045. * @param onSuccess is a callback called when the task is successfully executed
  156046. * @param onError is a callback called if an error occurs
  156047. */
  156048. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156049. }
  156050. /**
  156051. * Define a task used by AssetsManager to load text content
  156052. */
  156053. export class TextFileAssetTask extends AbstractAssetTask {
  156054. /**
  156055. * Defines the name of the task
  156056. */
  156057. name: string;
  156058. /**
  156059. * Defines the location of the file to load
  156060. */
  156061. url: string;
  156062. /**
  156063. * Gets the loaded text string
  156064. */
  156065. text: string;
  156066. /**
  156067. * Callback called when the task is successful
  156068. */
  156069. onSuccess: (task: TextFileAssetTask) => void;
  156070. /**
  156071. * Callback called when the task is successful
  156072. */
  156073. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  156074. /**
  156075. * Creates a new TextFileAssetTask object
  156076. * @param name defines the name of the task
  156077. * @param url defines the location of the file to load
  156078. */
  156079. constructor(
  156080. /**
  156081. * Defines the name of the task
  156082. */
  156083. name: string,
  156084. /**
  156085. * Defines the location of the file to load
  156086. */
  156087. url: string);
  156088. /**
  156089. * Execute the current task
  156090. * @param scene defines the scene where you want your assets to be loaded
  156091. * @param onSuccess is a callback called when the task is successfully executed
  156092. * @param onError is a callback called if an error occurs
  156093. */
  156094. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156095. }
  156096. /**
  156097. * Define a task used by AssetsManager to load binary data
  156098. */
  156099. export class BinaryFileAssetTask extends AbstractAssetTask {
  156100. /**
  156101. * Defines the name of the task
  156102. */
  156103. name: string;
  156104. /**
  156105. * Defines the location of the file to load
  156106. */
  156107. url: string;
  156108. /**
  156109. * Gets the lodaded data (as an array buffer)
  156110. */
  156111. data: ArrayBuffer;
  156112. /**
  156113. * Callback called when the task is successful
  156114. */
  156115. onSuccess: (task: BinaryFileAssetTask) => void;
  156116. /**
  156117. * Callback called when the task is successful
  156118. */
  156119. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  156120. /**
  156121. * Creates a new BinaryFileAssetTask object
  156122. * @param name defines the name of the new task
  156123. * @param url defines the location of the file to load
  156124. */
  156125. constructor(
  156126. /**
  156127. * Defines the name of the task
  156128. */
  156129. name: string,
  156130. /**
  156131. * Defines the location of the file to load
  156132. */
  156133. url: string);
  156134. /**
  156135. * Execute the current task
  156136. * @param scene defines the scene where you want your assets to be loaded
  156137. * @param onSuccess is a callback called when the task is successfully executed
  156138. * @param onError is a callback called if an error occurs
  156139. */
  156140. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156141. }
  156142. /**
  156143. * Define a task used by AssetsManager to load images
  156144. */
  156145. export class ImageAssetTask extends AbstractAssetTask {
  156146. /**
  156147. * Defines the name of the task
  156148. */
  156149. name: string;
  156150. /**
  156151. * Defines the location of the image to load
  156152. */
  156153. url: string;
  156154. /**
  156155. * Gets the loaded images
  156156. */
  156157. image: HTMLImageElement;
  156158. /**
  156159. * Callback called when the task is successful
  156160. */
  156161. onSuccess: (task: ImageAssetTask) => void;
  156162. /**
  156163. * Callback called when the task is successful
  156164. */
  156165. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  156166. /**
  156167. * Creates a new ImageAssetTask
  156168. * @param name defines the name of the task
  156169. * @param url defines the location of the image to load
  156170. */
  156171. constructor(
  156172. /**
  156173. * Defines the name of the task
  156174. */
  156175. name: string,
  156176. /**
  156177. * Defines the location of the image to load
  156178. */
  156179. url: string);
  156180. /**
  156181. * Execute the current task
  156182. * @param scene defines the scene where you want your assets to be loaded
  156183. * @param onSuccess is a callback called when the task is successfully executed
  156184. * @param onError is a callback called if an error occurs
  156185. */
  156186. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156187. }
  156188. /**
  156189. * Defines the interface used by texture loading tasks
  156190. */
  156191. export interface ITextureAssetTask<TEX extends BaseTexture> {
  156192. /**
  156193. * Gets the loaded texture
  156194. */
  156195. texture: TEX;
  156196. }
  156197. /**
  156198. * Define a task used by AssetsManager to load 2D textures
  156199. */
  156200. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  156201. /**
  156202. * Defines the name of the task
  156203. */
  156204. name: string;
  156205. /**
  156206. * Defines the location of the file to load
  156207. */
  156208. url: string;
  156209. /**
  156210. * Defines if mipmap should not be generated (default is false)
  156211. */
  156212. noMipmap?: boolean | undefined;
  156213. /**
  156214. * Defines if texture must be inverted on Y axis (default is true)
  156215. */
  156216. invertY: boolean;
  156217. /**
  156218. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  156219. */
  156220. samplingMode: number;
  156221. /**
  156222. * Gets the loaded texture
  156223. */
  156224. texture: Texture;
  156225. /**
  156226. * Callback called when the task is successful
  156227. */
  156228. onSuccess: (task: TextureAssetTask) => void;
  156229. /**
  156230. * Callback called when the task is successful
  156231. */
  156232. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  156233. /**
  156234. * Creates a new TextureAssetTask object
  156235. * @param name defines the name of the task
  156236. * @param url defines the location of the file to load
  156237. * @param noMipmap defines if mipmap should not be generated (default is false)
  156238. * @param invertY defines if texture must be inverted on Y axis (default is true)
  156239. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  156240. */
  156241. constructor(
  156242. /**
  156243. * Defines the name of the task
  156244. */
  156245. name: string,
  156246. /**
  156247. * Defines the location of the file to load
  156248. */
  156249. url: string,
  156250. /**
  156251. * Defines if mipmap should not be generated (default is false)
  156252. */
  156253. noMipmap?: boolean | undefined,
  156254. /**
  156255. * Defines if texture must be inverted on Y axis (default is true)
  156256. */
  156257. invertY?: boolean,
  156258. /**
  156259. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  156260. */
  156261. samplingMode?: number);
  156262. /**
  156263. * Execute the current task
  156264. * @param scene defines the scene where you want your assets to be loaded
  156265. * @param onSuccess is a callback called when the task is successfully executed
  156266. * @param onError is a callback called if an error occurs
  156267. */
  156268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156269. }
  156270. /**
  156271. * Define a task used by AssetsManager to load cube textures
  156272. */
  156273. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  156274. /**
  156275. * Defines the name of the task
  156276. */
  156277. name: string;
  156278. /**
  156279. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156280. */
  156281. url: string;
  156282. /**
  156283. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156284. */
  156285. extensions?: string[] | undefined;
  156286. /**
  156287. * Defines if mipmaps should not be generated (default is false)
  156288. */
  156289. noMipmap?: boolean | undefined;
  156290. /**
  156291. * Defines the explicit list of files (undefined by default)
  156292. */
  156293. files?: string[] | undefined;
  156294. /**
  156295. * Gets the loaded texture
  156296. */
  156297. texture: CubeTexture;
  156298. /**
  156299. * Callback called when the task is successful
  156300. */
  156301. onSuccess: (task: CubeTextureAssetTask) => void;
  156302. /**
  156303. * Callback called when the task is successful
  156304. */
  156305. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  156306. /**
  156307. * Creates a new CubeTextureAssetTask
  156308. * @param name defines the name of the task
  156309. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156310. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156311. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156312. * @param files defines the explicit list of files (undefined by default)
  156313. */
  156314. constructor(
  156315. /**
  156316. * Defines the name of the task
  156317. */
  156318. name: string,
  156319. /**
  156320. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156321. */
  156322. url: string,
  156323. /**
  156324. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156325. */
  156326. extensions?: string[] | undefined,
  156327. /**
  156328. * Defines if mipmaps should not be generated (default is false)
  156329. */
  156330. noMipmap?: boolean | undefined,
  156331. /**
  156332. * Defines the explicit list of files (undefined by default)
  156333. */
  156334. files?: string[] | undefined);
  156335. /**
  156336. * Execute the current task
  156337. * @param scene defines the scene where you want your assets to be loaded
  156338. * @param onSuccess is a callback called when the task is successfully executed
  156339. * @param onError is a callback called if an error occurs
  156340. */
  156341. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156342. }
  156343. /**
  156344. * Define a task used by AssetsManager to load HDR cube textures
  156345. */
  156346. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  156347. /**
  156348. * Defines the name of the task
  156349. */
  156350. name: string;
  156351. /**
  156352. * Defines the location of the file to load
  156353. */
  156354. url: string;
  156355. /**
  156356. * Defines the desired size (the more it increases the longer the generation will be)
  156357. */
  156358. size: number;
  156359. /**
  156360. * Defines if mipmaps should not be generated (default is false)
  156361. */
  156362. noMipmap: boolean;
  156363. /**
  156364. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156365. */
  156366. generateHarmonics: boolean;
  156367. /**
  156368. * 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)
  156369. */
  156370. gammaSpace: boolean;
  156371. /**
  156372. * Internal Use Only
  156373. */
  156374. reserved: boolean;
  156375. /**
  156376. * Gets the loaded texture
  156377. */
  156378. texture: HDRCubeTexture;
  156379. /**
  156380. * Callback called when the task is successful
  156381. */
  156382. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  156383. /**
  156384. * Callback called when the task is successful
  156385. */
  156386. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  156387. /**
  156388. * Creates a new HDRCubeTextureAssetTask object
  156389. * @param name defines the name of the task
  156390. * @param url defines the location of the file to load
  156391. * @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.
  156392. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156393. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156394. * @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)
  156395. * @param reserved Internal use only
  156396. */
  156397. constructor(
  156398. /**
  156399. * Defines the name of the task
  156400. */
  156401. name: string,
  156402. /**
  156403. * Defines the location of the file to load
  156404. */
  156405. url: string,
  156406. /**
  156407. * Defines the desired size (the more it increases the longer the generation will be)
  156408. */
  156409. size: number,
  156410. /**
  156411. * Defines if mipmaps should not be generated (default is false)
  156412. */
  156413. noMipmap?: boolean,
  156414. /**
  156415. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156416. */
  156417. generateHarmonics?: boolean,
  156418. /**
  156419. * 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)
  156420. */
  156421. gammaSpace?: boolean,
  156422. /**
  156423. * Internal Use Only
  156424. */
  156425. reserved?: boolean);
  156426. /**
  156427. * Execute the current task
  156428. * @param scene defines the scene where you want your assets to be loaded
  156429. * @param onSuccess is a callback called when the task is successfully executed
  156430. * @param onError is a callback called if an error occurs
  156431. */
  156432. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156433. }
  156434. /**
  156435. * Define a task used by AssetsManager to load Equirectangular cube textures
  156436. */
  156437. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  156438. /**
  156439. * Defines the name of the task
  156440. */
  156441. name: string;
  156442. /**
  156443. * Defines the location of the file to load
  156444. */
  156445. url: string;
  156446. /**
  156447. * Defines the desired size (the more it increases the longer the generation will be)
  156448. */
  156449. size: number;
  156450. /**
  156451. * Defines if mipmaps should not be generated (default is false)
  156452. */
  156453. noMipmap: boolean;
  156454. /**
  156455. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156456. * but the standard material would require them in Gamma space) (default is true)
  156457. */
  156458. gammaSpace: boolean;
  156459. /**
  156460. * Gets the loaded texture
  156461. */
  156462. texture: EquiRectangularCubeTexture;
  156463. /**
  156464. * Callback called when the task is successful
  156465. */
  156466. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  156467. /**
  156468. * Callback called when the task is successful
  156469. */
  156470. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  156471. /**
  156472. * Creates a new EquiRectangularCubeTextureAssetTask object
  156473. * @param name defines the name of the task
  156474. * @param url defines the location of the file to load
  156475. * @param size defines the desired size (the more it increases the longer the generation will be)
  156476. * If the size is omitted this implies you are using a preprocessed cubemap.
  156477. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156478. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  156479. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  156480. * (default is true)
  156481. */
  156482. constructor(
  156483. /**
  156484. * Defines the name of the task
  156485. */
  156486. name: string,
  156487. /**
  156488. * Defines the location of the file to load
  156489. */
  156490. url: string,
  156491. /**
  156492. * Defines the desired size (the more it increases the longer the generation will be)
  156493. */
  156494. size: number,
  156495. /**
  156496. * Defines if mipmaps should not be generated (default is false)
  156497. */
  156498. noMipmap?: boolean,
  156499. /**
  156500. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156501. * but the standard material would require them in Gamma space) (default is true)
  156502. */
  156503. gammaSpace?: boolean);
  156504. /**
  156505. * Execute the current task
  156506. * @param scene defines the scene where you want your assets to be loaded
  156507. * @param onSuccess is a callback called when the task is successfully executed
  156508. * @param onError is a callback called if an error occurs
  156509. */
  156510. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156511. }
  156512. /**
  156513. * This class can be used to easily import assets into a scene
  156514. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  156515. */
  156516. export class AssetsManager {
  156517. private _scene;
  156518. private _isLoading;
  156519. protected _tasks: AbstractAssetTask[];
  156520. protected _waitingTasksCount: number;
  156521. protected _totalTasksCount: number;
  156522. /**
  156523. * Callback called when all tasks are processed
  156524. */
  156525. onFinish: (tasks: AbstractAssetTask[]) => void;
  156526. /**
  156527. * Callback called when a task is successful
  156528. */
  156529. onTaskSuccess: (task: AbstractAssetTask) => void;
  156530. /**
  156531. * Callback called when a task had an error
  156532. */
  156533. onTaskError: (task: AbstractAssetTask) => void;
  156534. /**
  156535. * Callback called when a task is done (whatever the result is)
  156536. */
  156537. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  156538. /**
  156539. * Observable called when all tasks are processed
  156540. */
  156541. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  156542. /**
  156543. * Observable called when a task had an error
  156544. */
  156545. onTaskErrorObservable: Observable<AbstractAssetTask>;
  156546. /**
  156547. * Observable called when all tasks were executed
  156548. */
  156549. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  156550. /**
  156551. * Observable called when a task is done (whatever the result is)
  156552. */
  156553. onProgressObservable: Observable<IAssetsProgressEvent>;
  156554. /**
  156555. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  156556. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  156557. */
  156558. useDefaultLoadingScreen: boolean;
  156559. /**
  156560. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  156561. * when all assets have been downloaded.
  156562. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  156563. */
  156564. autoHideLoadingUI: boolean;
  156565. /**
  156566. * Creates a new AssetsManager
  156567. * @param scene defines the scene to work on
  156568. */
  156569. constructor(scene: Scene);
  156570. /**
  156571. * Add a ContainerAssetTask to the list of active tasks
  156572. * @param taskName defines the name of the new task
  156573. * @param meshesNames defines the name of meshes to load
  156574. * @param rootUrl defines the root url to use to locate files
  156575. * @param sceneFilename defines the filename of the scene file
  156576. * @returns a new ContainerAssetTask object
  156577. */
  156578. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  156579. /**
  156580. * Add a MeshAssetTask to the list of active tasks
  156581. * @param taskName defines the name of the new task
  156582. * @param meshesNames defines the name of meshes to load
  156583. * @param rootUrl defines the root url to use to locate files
  156584. * @param sceneFilename defines the filename of the scene file
  156585. * @returns a new MeshAssetTask object
  156586. */
  156587. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  156588. /**
  156589. * Add a TextFileAssetTask to the list of active tasks
  156590. * @param taskName defines the name of the new task
  156591. * @param url defines the url of the file to load
  156592. * @returns a new TextFileAssetTask object
  156593. */
  156594. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  156595. /**
  156596. * Add a BinaryFileAssetTask to the list of active tasks
  156597. * @param taskName defines the name of the new task
  156598. * @param url defines the url of the file to load
  156599. * @returns a new BinaryFileAssetTask object
  156600. */
  156601. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  156602. /**
  156603. * Add a ImageAssetTask to the list of active tasks
  156604. * @param taskName defines the name of the new task
  156605. * @param url defines the url of the file to load
  156606. * @returns a new ImageAssetTask object
  156607. */
  156608. addImageTask(taskName: string, url: string): ImageAssetTask;
  156609. /**
  156610. * Add a TextureAssetTask to the list of active tasks
  156611. * @param taskName defines the name of the new task
  156612. * @param url defines the url of the file to load
  156613. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156614. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  156615. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  156616. * @returns a new TextureAssetTask object
  156617. */
  156618. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  156619. /**
  156620. * Add a CubeTextureAssetTask to the list of active tasks
  156621. * @param taskName defines the name of the new task
  156622. * @param url defines the url of the file to load
  156623. * @param extensions defines the extension to use to load the cube map (can be null)
  156624. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156625. * @param files defines the list of files to load (can be null)
  156626. * @returns a new CubeTextureAssetTask object
  156627. */
  156628. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  156629. /**
  156630. *
  156631. * Add a HDRCubeTextureAssetTask to the list of active tasks
  156632. * @param taskName defines the name of the new task
  156633. * @param url defines the url of the file to load
  156634. * @param size defines the size you want for the cubemap (can be null)
  156635. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156636. * @param generateHarmonics defines if you want to automatically generate (true by default)
  156637. * @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)
  156638. * @param reserved Internal use only
  156639. * @returns a new HDRCubeTextureAssetTask object
  156640. */
  156641. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  156642. /**
  156643. *
  156644. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  156645. * @param taskName defines the name of the new task
  156646. * @param url defines the url of the file to load
  156647. * @param size defines the size you want for the cubemap (can be null)
  156648. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156649. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  156650. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  156651. * @returns a new EquiRectangularCubeTextureAssetTask object
  156652. */
  156653. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  156654. /**
  156655. * Remove a task from the assets manager.
  156656. * @param task the task to remove
  156657. */
  156658. removeTask(task: AbstractAssetTask): void;
  156659. private _decreaseWaitingTasksCount;
  156660. private _runTask;
  156661. /**
  156662. * Reset the AssetsManager and remove all tasks
  156663. * @return the current instance of the AssetsManager
  156664. */
  156665. reset(): AssetsManager;
  156666. /**
  156667. * Start the loading process
  156668. * @return the current instance of the AssetsManager
  156669. */
  156670. load(): AssetsManager;
  156671. /**
  156672. * Start the loading process as an async operation
  156673. * @return a promise returning the list of failed tasks
  156674. */
  156675. loadAsync(): Promise<void>;
  156676. }
  156677. }
  156678. declare module BABYLON {
  156679. /**
  156680. * Wrapper class for promise with external resolve and reject.
  156681. */
  156682. export class Deferred<T> {
  156683. /**
  156684. * The promise associated with this deferred object.
  156685. */
  156686. readonly promise: Promise<T>;
  156687. private _resolve;
  156688. private _reject;
  156689. /**
  156690. * The resolve method of the promise associated with this deferred object.
  156691. */
  156692. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  156693. /**
  156694. * The reject method of the promise associated with this deferred object.
  156695. */
  156696. get reject(): (reason?: any) => void;
  156697. /**
  156698. * Constructor for this deferred object.
  156699. */
  156700. constructor();
  156701. }
  156702. }
  156703. declare module BABYLON {
  156704. /**
  156705. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  156706. */
  156707. export class MeshExploder {
  156708. private _centerMesh;
  156709. private _meshes;
  156710. private _meshesOrigins;
  156711. private _toCenterVectors;
  156712. private _scaledDirection;
  156713. private _newPosition;
  156714. private _centerPosition;
  156715. /**
  156716. * Explodes meshes from a center mesh.
  156717. * @param meshes The meshes to explode.
  156718. * @param centerMesh The mesh to be center of explosion.
  156719. */
  156720. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  156721. private _setCenterMesh;
  156722. /**
  156723. * Get class name
  156724. * @returns "MeshExploder"
  156725. */
  156726. getClassName(): string;
  156727. /**
  156728. * "Exploded meshes"
  156729. * @returns Array of meshes with the centerMesh at index 0.
  156730. */
  156731. getMeshes(): Array<Mesh>;
  156732. /**
  156733. * Explodes meshes giving a specific direction
  156734. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  156735. */
  156736. explode(direction?: number): void;
  156737. }
  156738. }
  156739. declare module BABYLON {
  156740. /**
  156741. * Class used to help managing file picking and drag'n'drop
  156742. */
  156743. export class FilesInput {
  156744. /**
  156745. * List of files ready to be loaded
  156746. */
  156747. static get FilesToLoad(): {
  156748. [key: string]: File;
  156749. };
  156750. /**
  156751. * Callback called when a file is processed
  156752. */
  156753. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  156754. private _engine;
  156755. private _currentScene;
  156756. private _sceneLoadedCallback;
  156757. private _progressCallback;
  156758. private _additionalRenderLoopLogicCallback;
  156759. private _textureLoadingCallback;
  156760. private _startingProcessingFilesCallback;
  156761. private _onReloadCallback;
  156762. private _errorCallback;
  156763. private _elementToMonitor;
  156764. private _sceneFileToLoad;
  156765. private _filesToLoad;
  156766. /**
  156767. * Creates a new FilesInput
  156768. * @param engine defines the rendering engine
  156769. * @param scene defines the hosting scene
  156770. * @param sceneLoadedCallback callback called when scene is loaded
  156771. * @param progressCallback callback called to track progress
  156772. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  156773. * @param textureLoadingCallback callback called when a texture is loading
  156774. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  156775. * @param onReloadCallback callback called when a reload is requested
  156776. * @param errorCallback callback call if an error occurs
  156777. */
  156778. 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>);
  156779. private _dragEnterHandler;
  156780. private _dragOverHandler;
  156781. private _dropHandler;
  156782. /**
  156783. * Calls this function to listen to drag'n'drop events on a specific DOM element
  156784. * @param elementToMonitor defines the DOM element to track
  156785. */
  156786. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  156787. /** Gets the current list of files to load */
  156788. get filesToLoad(): File[];
  156789. /**
  156790. * Release all associated resources
  156791. */
  156792. dispose(): void;
  156793. private renderFunction;
  156794. private drag;
  156795. private drop;
  156796. private _traverseFolder;
  156797. private _processFiles;
  156798. /**
  156799. * Load files from a drop event
  156800. * @param event defines the drop event to use as source
  156801. */
  156802. loadFiles(event: any): void;
  156803. private _processReload;
  156804. /**
  156805. * Reload the current scene from the loaded files
  156806. */
  156807. reload(): void;
  156808. }
  156809. }
  156810. declare module BABYLON {
  156811. /**
  156812. * Defines the root class used to create scene optimization to use with SceneOptimizer
  156813. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156814. */
  156815. export class SceneOptimization {
  156816. /**
  156817. * Defines the priority of this optimization (0 by default which means first in the list)
  156818. */
  156819. priority: number;
  156820. /**
  156821. * Gets a string describing the action executed by the current optimization
  156822. * @returns description string
  156823. */
  156824. getDescription(): string;
  156825. /**
  156826. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156827. * @param scene defines the current scene where to apply this optimization
  156828. * @param optimizer defines the current optimizer
  156829. * @returns true if everything that can be done was applied
  156830. */
  156831. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156832. /**
  156833. * Creates the SceneOptimization object
  156834. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156835. * @param desc defines the description associated with the optimization
  156836. */
  156837. constructor(
  156838. /**
  156839. * Defines the priority of this optimization (0 by default which means first in the list)
  156840. */
  156841. priority?: number);
  156842. }
  156843. /**
  156844. * Defines an optimization used to reduce the size of render target textures
  156845. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156846. */
  156847. export class TextureOptimization extends SceneOptimization {
  156848. /**
  156849. * Defines the priority of this optimization (0 by default which means first in the list)
  156850. */
  156851. priority: number;
  156852. /**
  156853. * 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
  156854. */
  156855. maximumSize: number;
  156856. /**
  156857. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156858. */
  156859. step: number;
  156860. /**
  156861. * Gets a string describing the action executed by the current optimization
  156862. * @returns description string
  156863. */
  156864. getDescription(): string;
  156865. /**
  156866. * Creates the TextureOptimization object
  156867. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156868. * @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
  156869. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156870. */
  156871. constructor(
  156872. /**
  156873. * Defines the priority of this optimization (0 by default which means first in the list)
  156874. */
  156875. priority?: number,
  156876. /**
  156877. * 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
  156878. */
  156879. maximumSize?: number,
  156880. /**
  156881. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156882. */
  156883. step?: number);
  156884. /**
  156885. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156886. * @param scene defines the current scene where to apply this optimization
  156887. * @param optimizer defines the current optimizer
  156888. * @returns true if everything that can be done was applied
  156889. */
  156890. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156891. }
  156892. /**
  156893. * Defines an optimization used to increase or decrease the rendering resolution
  156894. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156895. */
  156896. export class HardwareScalingOptimization extends SceneOptimization {
  156897. /**
  156898. * Defines the priority of this optimization (0 by default which means first in the list)
  156899. */
  156900. priority: number;
  156901. /**
  156902. * Defines the maximum scale to use (2 by default)
  156903. */
  156904. maximumScale: number;
  156905. /**
  156906. * Defines the step to use between two passes (0.5 by default)
  156907. */
  156908. step: number;
  156909. private _currentScale;
  156910. private _directionOffset;
  156911. /**
  156912. * Gets a string describing the action executed by the current optimization
  156913. * @return description string
  156914. */
  156915. getDescription(): string;
  156916. /**
  156917. * Creates the HardwareScalingOptimization object
  156918. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156919. * @param maximumScale defines the maximum scale to use (2 by default)
  156920. * @param step defines the step to use between two passes (0.5 by default)
  156921. */
  156922. constructor(
  156923. /**
  156924. * Defines the priority of this optimization (0 by default which means first in the list)
  156925. */
  156926. priority?: number,
  156927. /**
  156928. * Defines the maximum scale to use (2 by default)
  156929. */
  156930. maximumScale?: number,
  156931. /**
  156932. * Defines the step to use between two passes (0.5 by default)
  156933. */
  156934. step?: number);
  156935. /**
  156936. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156937. * @param scene defines the current scene where to apply this optimization
  156938. * @param optimizer defines the current optimizer
  156939. * @returns true if everything that can be done was applied
  156940. */
  156941. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156942. }
  156943. /**
  156944. * Defines an optimization used to remove shadows
  156945. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156946. */
  156947. export class ShadowsOptimization extends SceneOptimization {
  156948. /**
  156949. * Gets a string describing the action executed by the current optimization
  156950. * @return description string
  156951. */
  156952. getDescription(): string;
  156953. /**
  156954. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156955. * @param scene defines the current scene where to apply this optimization
  156956. * @param optimizer defines the current optimizer
  156957. * @returns true if everything that can be done was applied
  156958. */
  156959. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156960. }
  156961. /**
  156962. * Defines an optimization used to turn post-processes off
  156963. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156964. */
  156965. export class PostProcessesOptimization extends SceneOptimization {
  156966. /**
  156967. * Gets a string describing the action executed by the current optimization
  156968. * @return description string
  156969. */
  156970. getDescription(): string;
  156971. /**
  156972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156973. * @param scene defines the current scene where to apply this optimization
  156974. * @param optimizer defines the current optimizer
  156975. * @returns true if everything that can be done was applied
  156976. */
  156977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156978. }
  156979. /**
  156980. * Defines an optimization used to turn lens flares off
  156981. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156982. */
  156983. export class LensFlaresOptimization extends SceneOptimization {
  156984. /**
  156985. * Gets a string describing the action executed by the current optimization
  156986. * @return description string
  156987. */
  156988. getDescription(): string;
  156989. /**
  156990. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156991. * @param scene defines the current scene where to apply this optimization
  156992. * @param optimizer defines the current optimizer
  156993. * @returns true if everything that can be done was applied
  156994. */
  156995. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156996. }
  156997. /**
  156998. * Defines an optimization based on user defined callback.
  156999. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  157000. */
  157001. export class CustomOptimization extends SceneOptimization {
  157002. /**
  157003. * Callback called to apply the custom optimization.
  157004. */
  157005. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  157006. /**
  157007. * Callback called to get custom description
  157008. */
  157009. onGetDescription: () => string;
  157010. /**
  157011. * Gets a string describing the action executed by the current optimization
  157012. * @returns description string
  157013. */
  157014. getDescription(): string;
  157015. /**
  157016. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  157017. * @param scene defines the current scene where to apply this optimization
  157018. * @param optimizer defines the current optimizer
  157019. * @returns true if everything that can be done was applied
  157020. */
  157021. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  157022. }
  157023. /**
  157024. * Defines an optimization used to turn particles off
  157025. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  157026. */
  157027. export class ParticlesOptimization extends SceneOptimization {
  157028. /**
  157029. * Gets a string describing the action executed by the current optimization
  157030. * @return description string
  157031. */
  157032. getDescription(): string;
  157033. /**
  157034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  157035. * @param scene defines the current scene where to apply this optimization
  157036. * @param optimizer defines the current optimizer
  157037. * @returns true if everything that can be done was applied
  157038. */
  157039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  157040. }
  157041. /**
  157042. * Defines an optimization used to turn render targets off
  157043. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  157044. */
  157045. export class RenderTargetsOptimization extends SceneOptimization {
  157046. /**
  157047. * Gets a string describing the action executed by the current optimization
  157048. * @return description string
  157049. */
  157050. getDescription(): string;
  157051. /**
  157052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  157053. * @param scene defines the current scene where to apply this optimization
  157054. * @param optimizer defines the current optimizer
  157055. * @returns true if everything that can be done was applied
  157056. */
  157057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  157058. }
  157059. /**
  157060. * Defines an optimization used to merge meshes with compatible materials
  157061. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  157062. */
  157063. export class MergeMeshesOptimization extends SceneOptimization {
  157064. private static _UpdateSelectionTree;
  157065. /**
  157066. * Gets or sets a boolean which defines if optimization octree has to be updated
  157067. */
  157068. static get UpdateSelectionTree(): boolean;
  157069. /**
  157070. * Gets or sets a boolean which defines if optimization octree has to be updated
  157071. */
  157072. static set UpdateSelectionTree(value: boolean);
  157073. /**
  157074. * Gets a string describing the action executed by the current optimization
  157075. * @return description string
  157076. */
  157077. getDescription(): string;
  157078. private _canBeMerged;
  157079. /**
  157080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  157081. * @param scene defines the current scene where to apply this optimization
  157082. * @param optimizer defines the current optimizer
  157083. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  157084. * @returns true if everything that can be done was applied
  157085. */
  157086. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  157087. }
  157088. /**
  157089. * Defines a list of options used by SceneOptimizer
  157090. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  157091. */
  157092. export class SceneOptimizerOptions {
  157093. /**
  157094. * Defines the target frame rate to reach (60 by default)
  157095. */
  157096. targetFrameRate: number;
  157097. /**
  157098. * Defines the interval between two checkes (2000ms by default)
  157099. */
  157100. trackerDuration: number;
  157101. /**
  157102. * Gets the list of optimizations to apply
  157103. */
  157104. optimizations: SceneOptimization[];
  157105. /**
  157106. * Creates a new list of options used by SceneOptimizer
  157107. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  157108. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  157109. */
  157110. constructor(
  157111. /**
  157112. * Defines the target frame rate to reach (60 by default)
  157113. */
  157114. targetFrameRate?: number,
  157115. /**
  157116. * Defines the interval between two checkes (2000ms by default)
  157117. */
  157118. trackerDuration?: number);
  157119. /**
  157120. * Add a new optimization
  157121. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  157122. * @returns the current SceneOptimizerOptions
  157123. */
  157124. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  157125. /**
  157126. * Add a new custom optimization
  157127. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  157128. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  157129. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  157130. * @returns the current SceneOptimizerOptions
  157131. */
  157132. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  157133. /**
  157134. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  157135. * @param targetFrameRate defines the target frame rate (60 by default)
  157136. * @returns a SceneOptimizerOptions object
  157137. */
  157138. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  157139. /**
  157140. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  157141. * @param targetFrameRate defines the target frame rate (60 by default)
  157142. * @returns a SceneOptimizerOptions object
  157143. */
  157144. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  157145. /**
  157146. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  157147. * @param targetFrameRate defines the target frame rate (60 by default)
  157148. * @returns a SceneOptimizerOptions object
  157149. */
  157150. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  157151. }
  157152. /**
  157153. * Class used to run optimizations in order to reach a target frame rate
  157154. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  157155. */
  157156. export class SceneOptimizer implements IDisposable {
  157157. private _isRunning;
  157158. private _options;
  157159. private _scene;
  157160. private _currentPriorityLevel;
  157161. private _targetFrameRate;
  157162. private _trackerDuration;
  157163. private _currentFrameRate;
  157164. private _sceneDisposeObserver;
  157165. private _improvementMode;
  157166. /**
  157167. * Defines an observable called when the optimizer reaches the target frame rate
  157168. */
  157169. onSuccessObservable: Observable<SceneOptimizer>;
  157170. /**
  157171. * Defines an observable called when the optimizer enables an optimization
  157172. */
  157173. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  157174. /**
  157175. * Defines an observable called when the optimizer is not able to reach the target frame rate
  157176. */
  157177. onFailureObservable: Observable<SceneOptimizer>;
  157178. /**
  157179. * Gets a boolean indicating if the optimizer is in improvement mode
  157180. */
  157181. get isInImprovementMode(): boolean;
  157182. /**
  157183. * Gets the current priority level (0 at start)
  157184. */
  157185. get currentPriorityLevel(): number;
  157186. /**
  157187. * Gets the current frame rate checked by the SceneOptimizer
  157188. */
  157189. get currentFrameRate(): number;
  157190. /**
  157191. * Gets or sets the current target frame rate (60 by default)
  157192. */
  157193. get targetFrameRate(): number;
  157194. /**
  157195. * Gets or sets the current target frame rate (60 by default)
  157196. */
  157197. set targetFrameRate(value: number);
  157198. /**
  157199. * Gets or sets the current interval between two checks (every 2000ms by default)
  157200. */
  157201. get trackerDuration(): number;
  157202. /**
  157203. * Gets or sets the current interval between two checks (every 2000ms by default)
  157204. */
  157205. set trackerDuration(value: number);
  157206. /**
  157207. * Gets the list of active optimizations
  157208. */
  157209. get optimizations(): SceneOptimization[];
  157210. /**
  157211. * Creates a new SceneOptimizer
  157212. * @param scene defines the scene to work on
  157213. * @param options defines the options to use with the SceneOptimizer
  157214. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  157215. * @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)
  157216. */
  157217. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  157218. /**
  157219. * Stops the current optimizer
  157220. */
  157221. stop(): void;
  157222. /**
  157223. * Reset the optimizer to initial step (current priority level = 0)
  157224. */
  157225. reset(): void;
  157226. /**
  157227. * Start the optimizer. By default it will try to reach a specific framerate
  157228. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  157229. */
  157230. start(): void;
  157231. private _checkCurrentState;
  157232. /**
  157233. * Release all resources
  157234. */
  157235. dispose(): void;
  157236. /**
  157237. * Helper function to create a SceneOptimizer with one single line of code
  157238. * @param scene defines the scene to work on
  157239. * @param options defines the options to use with the SceneOptimizer
  157240. * @param onSuccess defines a callback to call on success
  157241. * @param onFailure defines a callback to call on failure
  157242. * @returns the new SceneOptimizer object
  157243. */
  157244. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  157245. }
  157246. }
  157247. declare module BABYLON {
  157248. /**
  157249. * Class used to serialize a scene into a string
  157250. */
  157251. export class SceneSerializer {
  157252. /**
  157253. * Clear cache used by a previous serialization
  157254. */
  157255. static ClearCache(): void;
  157256. /**
  157257. * Serialize a scene into a JSON compatible object
  157258. * @param scene defines the scene to serialize
  157259. * @returns a JSON compatible object
  157260. */
  157261. static Serialize(scene: Scene): any;
  157262. /**
  157263. * Serialize a mesh into a JSON compatible object
  157264. * @param toSerialize defines the mesh to serialize
  157265. * @param withParents defines if parents must be serialized as well
  157266. * @param withChildren defines if children must be serialized as well
  157267. * @returns a JSON compatible object
  157268. */
  157269. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  157270. }
  157271. }
  157272. declare module BABYLON {
  157273. /**
  157274. * Class used to host texture specific utilities
  157275. */
  157276. export class TextureTools {
  157277. /**
  157278. * Uses the GPU to create a copy texture rescaled at a given size
  157279. * @param texture Texture to copy from
  157280. * @param width defines the desired width
  157281. * @param height defines the desired height
  157282. * @param useBilinearMode defines if bilinear mode has to be used
  157283. * @return the generated texture
  157284. */
  157285. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  157286. }
  157287. }
  157288. declare module BABYLON {
  157289. /**
  157290. * This represents the different options available for the video capture.
  157291. */
  157292. export interface VideoRecorderOptions {
  157293. /** Defines the mime type of the video. */
  157294. mimeType: string;
  157295. /** Defines the FPS the video should be recorded at. */
  157296. fps: number;
  157297. /** Defines the chunk size for the recording data. */
  157298. recordChunckSize: number;
  157299. /** The audio tracks to attach to the recording. */
  157300. audioTracks?: MediaStreamTrack[];
  157301. }
  157302. /**
  157303. * This can help with recording videos from BabylonJS.
  157304. * This is based on the available WebRTC functionalities of the browser.
  157305. *
  157306. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  157307. */
  157308. export class VideoRecorder {
  157309. private static readonly _defaultOptions;
  157310. /**
  157311. * Returns whether or not the VideoRecorder is available in your browser.
  157312. * @param engine Defines the Babylon Engine.
  157313. * @returns true if supported otherwise false.
  157314. */
  157315. static IsSupported(engine: Engine): boolean;
  157316. private readonly _options;
  157317. private _canvas;
  157318. private _mediaRecorder;
  157319. private _recordedChunks;
  157320. private _fileName;
  157321. private _resolve;
  157322. private _reject;
  157323. /**
  157324. * True when a recording is already in progress.
  157325. */
  157326. get isRecording(): boolean;
  157327. /**
  157328. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  157329. * @param engine Defines the BabylonJS Engine you wish to record.
  157330. * @param options Defines options that can be used to customize the capture.
  157331. */
  157332. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  157333. /**
  157334. * Stops the current recording before the default capture timeout passed in the startRecording function.
  157335. */
  157336. stopRecording(): void;
  157337. /**
  157338. * Starts recording the canvas for a max duration specified in parameters.
  157339. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  157340. * If null no automatic download will start and you can rely on the promise to get the data back.
  157341. * @param maxDuration Defines the maximum recording time in seconds.
  157342. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  157343. * @return A promise callback at the end of the recording with the video data in Blob.
  157344. */
  157345. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  157346. /**
  157347. * Releases internal resources used during the recording.
  157348. */
  157349. dispose(): void;
  157350. private _handleDataAvailable;
  157351. private _handleError;
  157352. private _handleStop;
  157353. }
  157354. }
  157355. declare module BABYLON {
  157356. /**
  157357. * Class containing a set of static utilities functions for screenshots
  157358. */
  157359. export class ScreenshotTools {
  157360. /**
  157361. * Captures a screenshot of the current rendering
  157362. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157363. * @param engine defines the rendering engine
  157364. * @param camera defines the source camera
  157365. * @param size This parameter can be set to a single number or to an object with the
  157366. * following (optional) properties: precision, width, height. If a single number is passed,
  157367. * it will be used for both width and height. If an object is passed, the screenshot size
  157368. * will be derived from the parameters. The precision property is a multiplier allowing
  157369. * rendering at a higher or lower resolution
  157370. * @param successCallback defines the callback receives a single parameter which contains the
  157371. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  157372. * src parameter of an <img> to display it
  157373. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  157374. * Check your browser for supported MIME types
  157375. */
  157376. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  157377. /**
  157378. * Captures a screenshot of the current rendering
  157379. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157380. * @param engine defines the rendering engine
  157381. * @param camera defines the source camera
  157382. * @param size This parameter can be set to a single number or to an object with the
  157383. * following (optional) properties: precision, width, height. If a single number is passed,
  157384. * it will be used for both width and height. If an object is passed, the screenshot size
  157385. * will be derived from the parameters. The precision property is a multiplier allowing
  157386. * rendering at a higher or lower resolution
  157387. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  157388. * Check your browser for supported MIME types
  157389. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  157390. * to the src parameter of an <img> to display it
  157391. */
  157392. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  157393. /**
  157394. * Generates an image screenshot from the specified camera.
  157395. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157396. * @param engine The engine to use for rendering
  157397. * @param camera The camera to use for rendering
  157398. * @param size This parameter can be set to a single number or to an object with the
  157399. * following (optional) properties: precision, width, height. If a single number is passed,
  157400. * it will be used for both width and height. If an object is passed, the screenshot size
  157401. * will be derived from the parameters. The precision property is a multiplier allowing
  157402. * rendering at a higher or lower resolution
  157403. * @param successCallback The callback receives a single parameter which contains the
  157404. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  157405. * src parameter of an <img> to display it
  157406. * @param mimeType The MIME type of the screenshot image (default: image/png).
  157407. * Check your browser for supported MIME types
  157408. * @param samples Texture samples (default: 1)
  157409. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  157410. * @param fileName A name for for the downloaded file.
  157411. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  157412. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  157413. */
  157414. 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;
  157415. /**
  157416. * Generates an image screenshot from the specified camera.
  157417. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157418. * @param engine The engine to use for rendering
  157419. * @param camera The camera to use for rendering
  157420. * @param size This parameter can be set to a single number or to an object with the
  157421. * following (optional) properties: precision, width, height. If a single number is passed,
  157422. * it will be used for both width and height. If an object is passed, the screenshot size
  157423. * will be derived from the parameters. The precision property is a multiplier allowing
  157424. * rendering at a higher or lower resolution
  157425. * @param mimeType The MIME type of the screenshot image (default: image/png).
  157426. * Check your browser for supported MIME types
  157427. * @param samples Texture samples (default: 1)
  157428. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  157429. * @param fileName A name for for the downloaded file.
  157430. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  157431. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  157432. * to the src parameter of an <img> to display it
  157433. */
  157434. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  157435. /**
  157436. * Gets height and width for screenshot size
  157437. * @private
  157438. */
  157439. private static _getScreenshotSize;
  157440. }
  157441. }
  157442. declare module BABYLON {
  157443. /**
  157444. * Interface for a data buffer
  157445. */
  157446. export interface IDataBuffer {
  157447. /**
  157448. * Reads bytes from the data buffer.
  157449. * @param byteOffset The byte offset to read
  157450. * @param byteLength The byte length to read
  157451. * @returns A promise that resolves when the bytes are read
  157452. */
  157453. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  157454. /**
  157455. * The byte length of the buffer.
  157456. */
  157457. readonly byteLength: number;
  157458. }
  157459. /**
  157460. * Utility class for reading from a data buffer
  157461. */
  157462. export class DataReader {
  157463. /**
  157464. * The data buffer associated with this data reader.
  157465. */
  157466. readonly buffer: IDataBuffer;
  157467. /**
  157468. * The current byte offset from the beginning of the data buffer.
  157469. */
  157470. byteOffset: number;
  157471. private _dataView;
  157472. private _dataByteOffset;
  157473. /**
  157474. * Constructor
  157475. * @param buffer The buffer to read
  157476. */
  157477. constructor(buffer: IDataBuffer);
  157478. /**
  157479. * Loads the given byte length.
  157480. * @param byteLength The byte length to load
  157481. * @returns A promise that resolves when the load is complete
  157482. */
  157483. loadAsync(byteLength: number): Promise<void>;
  157484. /**
  157485. * Read a unsigned 32-bit integer from the currently loaded data range.
  157486. * @returns The 32-bit integer read
  157487. */
  157488. readUint32(): number;
  157489. /**
  157490. * Read a byte array from the currently loaded data range.
  157491. * @param byteLength The byte length to read
  157492. * @returns The byte array read
  157493. */
  157494. readUint8Array(byteLength: number): Uint8Array;
  157495. /**
  157496. * Read a string from the currently loaded data range.
  157497. * @param byteLength The byte length to read
  157498. * @returns The string read
  157499. */
  157500. readString(byteLength: number): string;
  157501. /**
  157502. * Skips the given byte length the currently loaded data range.
  157503. * @param byteLength The byte length to skip
  157504. */
  157505. skipBytes(byteLength: number): void;
  157506. }
  157507. }
  157508. declare module BABYLON {
  157509. /**
  157510. * Class for storing data to local storage if available or in-memory storage otherwise
  157511. */
  157512. export class DataStorage {
  157513. private static _Storage;
  157514. private static _GetStorage;
  157515. /**
  157516. * Reads a string from the data storage
  157517. * @param key The key to read
  157518. * @param defaultValue The value if the key doesn't exist
  157519. * @returns The string value
  157520. */
  157521. static ReadString(key: string, defaultValue: string): string;
  157522. /**
  157523. * Writes a string to the data storage
  157524. * @param key The key to write
  157525. * @param value The value to write
  157526. */
  157527. static WriteString(key: string, value: string): void;
  157528. /**
  157529. * Reads a boolean from the data storage
  157530. * @param key The key to read
  157531. * @param defaultValue The value if the key doesn't exist
  157532. * @returns The boolean value
  157533. */
  157534. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  157535. /**
  157536. * Writes a boolean to the data storage
  157537. * @param key The key to write
  157538. * @param value The value to write
  157539. */
  157540. static WriteBoolean(key: string, value: boolean): void;
  157541. /**
  157542. * Reads a number from the data storage
  157543. * @param key The key to read
  157544. * @param defaultValue The value if the key doesn't exist
  157545. * @returns The number value
  157546. */
  157547. static ReadNumber(key: string, defaultValue: number): number;
  157548. /**
  157549. * Writes a number to the data storage
  157550. * @param key The key to write
  157551. * @param value The value to write
  157552. */
  157553. static WriteNumber(key: string, value: number): void;
  157554. }
  157555. }
  157556. declare module BABYLON {
  157557. /**
  157558. * Class used to record delta files between 2 scene states
  157559. */
  157560. export class SceneRecorder {
  157561. private _trackedScene;
  157562. private _savedJSON;
  157563. /**
  157564. * Track a given scene. This means the current scene state will be considered the original state
  157565. * @param scene defines the scene to track
  157566. */
  157567. track(scene: Scene): void;
  157568. /**
  157569. * Get the delta between current state and original state
  157570. * @returns a string containing the delta
  157571. */
  157572. getDelta(): any;
  157573. private _compareArray;
  157574. private _compareObjects;
  157575. private _compareCollections;
  157576. private static GetShadowGeneratorById;
  157577. /**
  157578. * Apply a given delta to a given scene
  157579. * @param deltaJSON defines the JSON containing the delta
  157580. * @param scene defines the scene to apply the delta to
  157581. */
  157582. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  157583. private static _ApplyPropertiesToEntity;
  157584. private static _ApplyDeltaForEntity;
  157585. }
  157586. }
  157587. declare module BABYLON {
  157588. /**
  157589. * A 3D trajectory consisting of an order list of vectors describing a
  157590. * path of motion through 3D space.
  157591. */
  157592. export class Trajectory {
  157593. private _points;
  157594. private readonly _segmentLength;
  157595. /**
  157596. * Serialize to JSON.
  157597. * @returns serialized JSON string
  157598. */
  157599. serialize(): string;
  157600. /**
  157601. * Deserialize from JSON.
  157602. * @param json serialized JSON string
  157603. * @returns deserialized Trajectory
  157604. */
  157605. static Deserialize(json: string): Trajectory;
  157606. /**
  157607. * Create a new empty Trajectory.
  157608. * @param segmentLength radius of discretization for Trajectory points
  157609. */
  157610. constructor(segmentLength?: number);
  157611. /**
  157612. * Get the length of the Trajectory.
  157613. * @returns length of the Trajectory
  157614. */
  157615. getLength(): number;
  157616. /**
  157617. * Append a new point to the Trajectory.
  157618. * NOTE: This implementation has many allocations.
  157619. * @param point point to append to the Trajectory
  157620. */
  157621. add(point: DeepImmutable<Vector3>): void;
  157622. /**
  157623. * Create a new Trajectory with a segment length chosen to make it
  157624. * probable that the new Trajectory will have a specified number of
  157625. * segments. This operation is imprecise.
  157626. * @param targetResolution number of segments desired
  157627. * @returns new Trajectory with approximately the requested number of segments
  157628. */
  157629. resampleAtTargetResolution(targetResolution: number): Trajectory;
  157630. /**
  157631. * Convert Trajectory segments into tokenized representation. This
  157632. * representation is an array of numbers where each nth number is the
  157633. * index of the token which is most similar to the nth segment of the
  157634. * Trajectory.
  157635. * @param tokens list of vectors which serve as discrete tokens
  157636. * @returns list of indices of most similar token per segment
  157637. */
  157638. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  157639. private static _forwardDir;
  157640. private static _inverseFromVec;
  157641. private static _upDir;
  157642. private static _fromToVec;
  157643. private static _lookMatrix;
  157644. /**
  157645. * Transform the rotation (i.e., direction) of a segment to isolate
  157646. * the relative transformation represented by the segment. This operation
  157647. * may or may not succeed due to singularities in the equations that define
  157648. * motion relativity in this context.
  157649. * @param priorVec the origin of the prior segment
  157650. * @param fromVec the origin of the current segment
  157651. * @param toVec the destination of the current segment
  157652. * @param result reference to output variable
  157653. * @returns whether or not transformation was successful
  157654. */
  157655. private static _transformSegmentDirToRef;
  157656. private static _bestMatch;
  157657. private static _score;
  157658. private static _bestScore;
  157659. /**
  157660. * Determine which token vector is most similar to the
  157661. * segment vector.
  157662. * @param segment segment vector
  157663. * @param tokens token vector list
  157664. * @returns index of the most similar token to the segment
  157665. */
  157666. private static _tokenizeSegment;
  157667. }
  157668. /**
  157669. * Class representing a set of known, named trajectories to which Trajectories can be
  157670. * added and using which Trajectories can be recognized.
  157671. */
  157672. export class TrajectoryClassifier {
  157673. private _maximumAllowableMatchCost;
  157674. private _vector3Alphabet;
  157675. private _levenshteinAlphabet;
  157676. private _nameToDescribedTrajectory;
  157677. /**
  157678. * Serialize to JSON.
  157679. * @returns JSON serialization
  157680. */
  157681. serialize(): string;
  157682. /**
  157683. * Deserialize from JSON.
  157684. * @param json JSON serialization
  157685. * @returns deserialized TrajectorySet
  157686. */
  157687. static Deserialize(json: string): TrajectoryClassifier;
  157688. /**
  157689. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  157690. * VERY naive, need to be generating these things from known
  157691. * sets. Better version later, probably eliminating this one.
  157692. * @returns auto-generated TrajectorySet
  157693. */
  157694. static Generate(): TrajectoryClassifier;
  157695. private constructor();
  157696. /**
  157697. * Add a new Trajectory to the set with a given name.
  157698. * @param trajectory new Trajectory to be added
  157699. * @param classification name to which to add the Trajectory
  157700. */
  157701. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  157702. /**
  157703. * Remove a known named trajectory and all Trajectories associated with it.
  157704. * @param classification name to remove
  157705. * @returns whether anything was removed
  157706. */
  157707. deleteClassification(classification: string): boolean;
  157708. /**
  157709. * Attempt to recognize a Trajectory from among all the classifications
  157710. * already known to the classifier.
  157711. * @param trajectory Trajectory to be recognized
  157712. * @returns classification of Trajectory if recognized, null otherwise
  157713. */
  157714. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  157715. }
  157716. }
  157717. declare module BABYLON {
  157718. /**
  157719. * An interface for all Hit test features
  157720. */
  157721. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  157722. /**
  157723. * Triggered when new babylon (transformed) hit test results are available
  157724. */
  157725. onHitTestResultObservable: Observable<T[]>;
  157726. }
  157727. /**
  157728. * Options used for hit testing
  157729. */
  157730. export interface IWebXRLegacyHitTestOptions {
  157731. /**
  157732. * Only test when user interacted with the scene. Default - hit test every frame
  157733. */
  157734. testOnPointerDownOnly?: boolean;
  157735. /**
  157736. * The node to use to transform the local results to world coordinates
  157737. */
  157738. worldParentNode?: TransformNode;
  157739. }
  157740. /**
  157741. * Interface defining the babylon result of raycasting/hit-test
  157742. */
  157743. export interface IWebXRLegacyHitResult {
  157744. /**
  157745. * Transformation matrix that can be applied to a node that will put it in the hit point location
  157746. */
  157747. transformationMatrix: Matrix;
  157748. /**
  157749. * The native hit test result
  157750. */
  157751. xrHitResult: XRHitResult | XRHitTestResult;
  157752. }
  157753. /**
  157754. * The currently-working hit-test module.
  157755. * Hit test (or Ray-casting) is used to interact with the real world.
  157756. * For further information read here - https://github.com/immersive-web/hit-test
  157757. */
  157758. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  157759. /**
  157760. * options to use when constructing this feature
  157761. */
  157762. readonly options: IWebXRLegacyHitTestOptions;
  157763. private _direction;
  157764. private _mat;
  157765. private _onSelectEnabled;
  157766. private _origin;
  157767. /**
  157768. * The module's name
  157769. */
  157770. static readonly Name: string;
  157771. /**
  157772. * The (Babylon) version of this module.
  157773. * This is an integer representing the implementation version.
  157774. * This number does not correspond to the WebXR specs version
  157775. */
  157776. static readonly Version: number;
  157777. /**
  157778. * Populated with the last native XR Hit Results
  157779. */
  157780. lastNativeXRHitResults: XRHitResult[];
  157781. /**
  157782. * Triggered when new babylon (transformed) hit test results are available
  157783. */
  157784. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  157785. /**
  157786. * Creates a new instance of the (legacy version) hit test feature
  157787. * @param _xrSessionManager an instance of WebXRSessionManager
  157788. * @param options options to use when constructing this feature
  157789. */
  157790. constructor(_xrSessionManager: WebXRSessionManager,
  157791. /**
  157792. * options to use when constructing this feature
  157793. */
  157794. options?: IWebXRLegacyHitTestOptions);
  157795. /**
  157796. * execute a hit test with an XR Ray
  157797. *
  157798. * @param xrSession a native xrSession that will execute this hit test
  157799. * @param xrRay the ray (position and direction) to use for ray-casting
  157800. * @param referenceSpace native XR reference space to use for the hit-test
  157801. * @param filter filter function that will filter the results
  157802. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157803. */
  157804. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  157805. /**
  157806. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  157807. * @param event the (select) event to use to select with
  157808. * @param referenceSpace the reference space to use for this hit test
  157809. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157810. */
  157811. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157812. /**
  157813. * attach this feature
  157814. * Will usually be called by the features manager
  157815. *
  157816. * @returns true if successful.
  157817. */
  157818. attach(): boolean;
  157819. /**
  157820. * detach this feature.
  157821. * Will usually be called by the features manager
  157822. *
  157823. * @returns true if successful.
  157824. */
  157825. detach(): boolean;
  157826. /**
  157827. * Dispose this feature and all of the resources attached
  157828. */
  157829. dispose(): void;
  157830. protected _onXRFrame(frame: XRFrame): void;
  157831. private _onHitTestResults;
  157832. private _onSelect;
  157833. }
  157834. }
  157835. declare module BABYLON {
  157836. /**
  157837. * Options used for hit testing (version 2)
  157838. */
  157839. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  157840. /**
  157841. * Do not create a permanent hit test. Will usually be used when only
  157842. * transient inputs are needed.
  157843. */
  157844. disablePermanentHitTest?: boolean;
  157845. /**
  157846. * Enable transient (for example touch-based) hit test inspections
  157847. */
  157848. enableTransientHitTest?: boolean;
  157849. /**
  157850. * Offset ray for the permanent hit test
  157851. */
  157852. offsetRay?: Vector3;
  157853. /**
  157854. * Offset ray for the transient hit test
  157855. */
  157856. transientOffsetRay?: Vector3;
  157857. /**
  157858. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  157859. */
  157860. useReferenceSpace?: boolean;
  157861. /**
  157862. * Override the default entity type(s) of the hit-test result
  157863. */
  157864. entityTypes?: XRHitTestTrackableType[];
  157865. }
  157866. /**
  157867. * Interface defining the babylon result of hit-test
  157868. */
  157869. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  157870. /**
  157871. * The input source that generated this hit test (if transient)
  157872. */
  157873. inputSource?: XRInputSource;
  157874. /**
  157875. * Is this a transient hit test
  157876. */
  157877. isTransient?: boolean;
  157878. /**
  157879. * Position of the hit test result
  157880. */
  157881. position: Vector3;
  157882. /**
  157883. * Rotation of the hit test result
  157884. */
  157885. rotationQuaternion: Quaternion;
  157886. /**
  157887. * The native hit test result
  157888. */
  157889. xrHitResult: XRHitTestResult;
  157890. }
  157891. /**
  157892. * The currently-working hit-test module.
  157893. * Hit test (or Ray-casting) is used to interact with the real world.
  157894. * For further information read here - https://github.com/immersive-web/hit-test
  157895. *
  157896. * Tested on chrome (mobile) 80.
  157897. */
  157898. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  157899. /**
  157900. * options to use when constructing this feature
  157901. */
  157902. readonly options: IWebXRHitTestOptions;
  157903. private _tmpMat;
  157904. private _tmpPos;
  157905. private _tmpQuat;
  157906. private _transientXrHitTestSource;
  157907. private _xrHitTestSource;
  157908. private initHitTestSource;
  157909. /**
  157910. * The module's name
  157911. */
  157912. static readonly Name: string;
  157913. /**
  157914. * The (Babylon) version of this module.
  157915. * This is an integer representing the implementation version.
  157916. * This number does not correspond to the WebXR specs version
  157917. */
  157918. static readonly Version: number;
  157919. /**
  157920. * When set to true, each hit test will have its own position/rotation objects
  157921. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  157922. * the developers will clone them or copy them as they see fit.
  157923. */
  157924. autoCloneTransformation: boolean;
  157925. /**
  157926. * Triggered when new babylon (transformed) hit test results are available
  157927. * Note - this will be called when results come back from the device. It can be an empty array!!
  157928. */
  157929. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  157930. /**
  157931. * Use this to temporarily pause hit test checks.
  157932. */
  157933. paused: boolean;
  157934. /**
  157935. * Creates a new instance of the hit test feature
  157936. * @param _xrSessionManager an instance of WebXRSessionManager
  157937. * @param options options to use when constructing this feature
  157938. */
  157939. constructor(_xrSessionManager: WebXRSessionManager,
  157940. /**
  157941. * options to use when constructing this feature
  157942. */
  157943. options?: IWebXRHitTestOptions);
  157944. /**
  157945. * attach this feature
  157946. * Will usually be called by the features manager
  157947. *
  157948. * @returns true if successful.
  157949. */
  157950. attach(): boolean;
  157951. /**
  157952. * detach this feature.
  157953. * Will usually be called by the features manager
  157954. *
  157955. * @returns true if successful.
  157956. */
  157957. detach(): boolean;
  157958. /**
  157959. * Dispose this feature and all of the resources attached
  157960. */
  157961. dispose(): void;
  157962. protected _onXRFrame(frame: XRFrame): void;
  157963. private _processWebXRHitTestResult;
  157964. }
  157965. }
  157966. declare module BABYLON {
  157967. /**
  157968. * Configuration options of the anchor system
  157969. */
  157970. export interface IWebXRAnchorSystemOptions {
  157971. /**
  157972. * a node that will be used to convert local to world coordinates
  157973. */
  157974. worldParentNode?: TransformNode;
  157975. /**
  157976. * If set to true a reference of the created anchors will be kept until the next session starts
  157977. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  157978. */
  157979. doNotRemoveAnchorsOnSessionEnded?: boolean;
  157980. }
  157981. /**
  157982. * A babylon container for an XR Anchor
  157983. */
  157984. export interface IWebXRAnchor {
  157985. /**
  157986. * A babylon-assigned ID for this anchor
  157987. */
  157988. id: number;
  157989. /**
  157990. * Transformation matrix to apply to an object attached to this anchor
  157991. */
  157992. transformationMatrix: Matrix;
  157993. /**
  157994. * The native anchor object
  157995. */
  157996. xrAnchor: XRAnchor;
  157997. /**
  157998. * if defined, this object will be constantly updated by the anchor's position and rotation
  157999. */
  158000. attachedNode?: TransformNode;
  158001. /**
  158002. * Remove this anchor from the scene
  158003. */
  158004. remove(): void;
  158005. }
  158006. /**
  158007. * An implementation of the anchor system for WebXR.
  158008. * For further information see https://github.com/immersive-web/anchors/
  158009. */
  158010. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  158011. private _options;
  158012. private _lastFrameDetected;
  158013. private _trackedAnchors;
  158014. private _referenceSpaceForFrameAnchors;
  158015. private _futureAnchors;
  158016. /**
  158017. * The module's name
  158018. */
  158019. static readonly Name: string;
  158020. /**
  158021. * The (Babylon) version of this module.
  158022. * This is an integer representing the implementation version.
  158023. * This number does not correspond to the WebXR specs version
  158024. */
  158025. static readonly Version: number;
  158026. /**
  158027. * Observers registered here will be executed when a new anchor was added to the session
  158028. */
  158029. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  158030. /**
  158031. * Observers registered here will be executed when an anchor was removed from the session
  158032. */
  158033. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  158034. /**
  158035. * Observers registered here will be executed when an existing anchor updates
  158036. * This can execute N times every frame
  158037. */
  158038. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  158039. /**
  158040. * Set the reference space to use for anchor creation, when not using a hit test.
  158041. * Will default to the session's reference space if not defined
  158042. */
  158043. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  158044. /**
  158045. * constructs a new anchor system
  158046. * @param _xrSessionManager an instance of WebXRSessionManager
  158047. * @param _options configuration object for this feature
  158048. */
  158049. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  158050. private _tmpVector;
  158051. private _tmpQuaternion;
  158052. private _populateTmpTransformation;
  158053. /**
  158054. * Create a new anchor point using a hit test result at a specific point in the scene
  158055. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  158056. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  158057. *
  158058. * @param hitTestResult The hit test result to use for this anchor creation
  158059. * @param position an optional position offset for this anchor
  158060. * @param rotationQuaternion an optional rotation offset for this anchor
  158061. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  158062. */
  158063. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  158064. /**
  158065. * Add a new anchor at a specific position and rotation
  158066. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  158067. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  158068. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  158069. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  158070. *
  158071. * @param position the position in which to add an anchor
  158072. * @param rotationQuaternion an optional rotation for the anchor transformation
  158073. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  158074. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  158075. */
  158076. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  158077. /**
  158078. * Get the list of anchors currently being tracked by the system
  158079. */
  158080. get anchors(): IWebXRAnchor[];
  158081. /**
  158082. * detach this feature.
  158083. * Will usually be called by the features manager
  158084. *
  158085. * @returns true if successful.
  158086. */
  158087. detach(): boolean;
  158088. /**
  158089. * Dispose this feature and all of the resources attached
  158090. */
  158091. dispose(): void;
  158092. protected _onXRFrame(frame: XRFrame): void;
  158093. /**
  158094. * avoiding using Array.find for global support.
  158095. * @param xrAnchor the plane to find in the array
  158096. */
  158097. private _findIndexInAnchorArray;
  158098. private _updateAnchorWithXRFrame;
  158099. private _createAnchorAtTransformation;
  158100. }
  158101. }
  158102. declare module BABYLON {
  158103. /**
  158104. * Options used in the plane detector module
  158105. */
  158106. export interface IWebXRPlaneDetectorOptions {
  158107. /**
  158108. * The node to use to transform the local results to world coordinates
  158109. */
  158110. worldParentNode?: TransformNode;
  158111. /**
  158112. * If set to true a reference of the created planes will be kept until the next session starts
  158113. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  158114. */
  158115. doNotRemovePlanesOnSessionEnded?: boolean;
  158116. }
  158117. /**
  158118. * A babylon interface for a WebXR plane.
  158119. * A Plane is actually a polygon, built from N points in space
  158120. *
  158121. * Supported in chrome 79, not supported in canary 81 ATM
  158122. */
  158123. export interface IWebXRPlane {
  158124. /**
  158125. * a babylon-assigned ID for this polygon
  158126. */
  158127. id: number;
  158128. /**
  158129. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  158130. */
  158131. polygonDefinition: Array<Vector3>;
  158132. /**
  158133. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  158134. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  158135. */
  158136. transformationMatrix: Matrix;
  158137. /**
  158138. * the native xr-plane object
  158139. */
  158140. xrPlane: XRPlane;
  158141. }
  158142. /**
  158143. * The plane detector is used to detect planes in the real world when in AR
  158144. * For more information see https://github.com/immersive-web/real-world-geometry/
  158145. */
  158146. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  158147. private _options;
  158148. private _detectedPlanes;
  158149. private _enabled;
  158150. private _lastFrameDetected;
  158151. /**
  158152. * The module's name
  158153. */
  158154. static readonly Name: string;
  158155. /**
  158156. * The (Babylon) version of this module.
  158157. * This is an integer representing the implementation version.
  158158. * This number does not correspond to the WebXR specs version
  158159. */
  158160. static readonly Version: number;
  158161. /**
  158162. * Observers registered here will be executed when a new plane was added to the session
  158163. */
  158164. onPlaneAddedObservable: Observable<IWebXRPlane>;
  158165. /**
  158166. * Observers registered here will be executed when a plane is no longer detected in the session
  158167. */
  158168. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  158169. /**
  158170. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  158171. * This can execute N times every frame
  158172. */
  158173. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  158174. /**
  158175. * construct a new Plane Detector
  158176. * @param _xrSessionManager an instance of xr Session manager
  158177. * @param _options configuration to use when constructing this feature
  158178. */
  158179. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  158180. /**
  158181. * detach this feature.
  158182. * Will usually be called by the features manager
  158183. *
  158184. * @returns true if successful.
  158185. */
  158186. detach(): boolean;
  158187. /**
  158188. * Dispose this feature and all of the resources attached
  158189. */
  158190. dispose(): void;
  158191. /**
  158192. * Check if the needed objects are defined.
  158193. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  158194. */
  158195. isCompatible(): boolean;
  158196. protected _onXRFrame(frame: XRFrame): void;
  158197. private _init;
  158198. private _updatePlaneWithXRPlane;
  158199. /**
  158200. * avoiding using Array.find for global support.
  158201. * @param xrPlane the plane to find in the array
  158202. */
  158203. private findIndexInPlaneArray;
  158204. }
  158205. }
  158206. declare module BABYLON {
  158207. /**
  158208. * Options interface for the background remover plugin
  158209. */
  158210. export interface IWebXRBackgroundRemoverOptions {
  158211. /**
  158212. * Further background meshes to disable when entering AR
  158213. */
  158214. backgroundMeshes?: AbstractMesh[];
  158215. /**
  158216. * flags to configure the removal of the environment helper.
  158217. * If not set, the entire background will be removed. If set, flags should be set as well.
  158218. */
  158219. environmentHelperRemovalFlags?: {
  158220. /**
  158221. * Should the skybox be removed (default false)
  158222. */
  158223. skyBox?: boolean;
  158224. /**
  158225. * Should the ground be removed (default false)
  158226. */
  158227. ground?: boolean;
  158228. };
  158229. /**
  158230. * don't disable the environment helper
  158231. */
  158232. ignoreEnvironmentHelper?: boolean;
  158233. }
  158234. /**
  158235. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  158236. */
  158237. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  158238. /**
  158239. * read-only options to be used in this module
  158240. */
  158241. readonly options: IWebXRBackgroundRemoverOptions;
  158242. /**
  158243. * The module's name
  158244. */
  158245. static readonly Name: string;
  158246. /**
  158247. * The (Babylon) version of this module.
  158248. * This is an integer representing the implementation version.
  158249. * This number does not correspond to the WebXR specs version
  158250. */
  158251. static readonly Version: number;
  158252. /**
  158253. * registered observers will be triggered when the background state changes
  158254. */
  158255. onBackgroundStateChangedObservable: Observable<boolean>;
  158256. /**
  158257. * constructs a new background remover module
  158258. * @param _xrSessionManager the session manager for this module
  158259. * @param options read-only options to be used in this module
  158260. */
  158261. constructor(_xrSessionManager: WebXRSessionManager,
  158262. /**
  158263. * read-only options to be used in this module
  158264. */
  158265. options?: IWebXRBackgroundRemoverOptions);
  158266. /**
  158267. * attach this feature
  158268. * Will usually be called by the features manager
  158269. *
  158270. * @returns true if successful.
  158271. */
  158272. attach(): boolean;
  158273. /**
  158274. * detach this feature.
  158275. * Will usually be called by the features manager
  158276. *
  158277. * @returns true if successful.
  158278. */
  158279. detach(): boolean;
  158280. /**
  158281. * Dispose this feature and all of the resources attached
  158282. */
  158283. dispose(): void;
  158284. protected _onXRFrame(_xrFrame: XRFrame): void;
  158285. private _setBackgroundState;
  158286. }
  158287. }
  158288. declare module BABYLON {
  158289. /**
  158290. * Options for the controller physics feature
  158291. */
  158292. export class IWebXRControllerPhysicsOptions {
  158293. /**
  158294. * Should the headset get its own impostor
  158295. */
  158296. enableHeadsetImpostor?: boolean;
  158297. /**
  158298. * Optional parameters for the headset impostor
  158299. */
  158300. headsetImpostorParams?: {
  158301. /**
  158302. * The type of impostor to create. Default is sphere
  158303. */
  158304. impostorType: number;
  158305. /**
  158306. * the size of the impostor. Defaults to 10cm
  158307. */
  158308. impostorSize?: number | {
  158309. width: number;
  158310. height: number;
  158311. depth: number;
  158312. };
  158313. /**
  158314. * Friction definitions
  158315. */
  158316. friction?: number;
  158317. /**
  158318. * Restitution
  158319. */
  158320. restitution?: number;
  158321. };
  158322. /**
  158323. * The physics properties of the future impostors
  158324. */
  158325. physicsProperties?: {
  158326. /**
  158327. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  158328. * Note that this requires a physics engine that supports mesh impostors!
  158329. */
  158330. useControllerMesh?: boolean;
  158331. /**
  158332. * The type of impostor to create. Default is sphere
  158333. */
  158334. impostorType?: number;
  158335. /**
  158336. * the size of the impostor. Defaults to 10cm
  158337. */
  158338. impostorSize?: number | {
  158339. width: number;
  158340. height: number;
  158341. depth: number;
  158342. };
  158343. /**
  158344. * Friction definitions
  158345. */
  158346. friction?: number;
  158347. /**
  158348. * Restitution
  158349. */
  158350. restitution?: number;
  158351. };
  158352. /**
  158353. * the xr input to use with this pointer selection
  158354. */
  158355. xrInput: WebXRInput;
  158356. }
  158357. /**
  158358. * Add physics impostor to your webxr controllers,
  158359. * including naive calculation of their linear and angular velocity
  158360. */
  158361. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  158362. private readonly _options;
  158363. private _attachController;
  158364. private _controllers;
  158365. private _debugMode;
  158366. private _delta;
  158367. private _headsetImpostor?;
  158368. private _headsetMesh?;
  158369. private _lastTimestamp;
  158370. private _tmpQuaternion;
  158371. private _tmpVector;
  158372. /**
  158373. * The module's name
  158374. */
  158375. static readonly Name: string;
  158376. /**
  158377. * The (Babylon) version of this module.
  158378. * This is an integer representing the implementation version.
  158379. * This number does not correspond to the webxr specs version
  158380. */
  158381. static readonly Version: number;
  158382. /**
  158383. * Construct a new Controller Physics Feature
  158384. * @param _xrSessionManager the corresponding xr session manager
  158385. * @param _options options to create this feature with
  158386. */
  158387. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  158388. /**
  158389. * @hidden
  158390. * enable debugging - will show console outputs and the impostor mesh
  158391. */
  158392. _enablePhysicsDebug(): void;
  158393. /**
  158394. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  158395. * @param xrController the controller to add
  158396. */
  158397. addController(xrController: WebXRInputSource): void;
  158398. /**
  158399. * attach this feature
  158400. * Will usually be called by the features manager
  158401. *
  158402. * @returns true if successful.
  158403. */
  158404. attach(): boolean;
  158405. /**
  158406. * detach this feature.
  158407. * Will usually be called by the features manager
  158408. *
  158409. * @returns true if successful.
  158410. */
  158411. detach(): boolean;
  158412. /**
  158413. * Get the headset impostor, if enabled
  158414. * @returns the impostor
  158415. */
  158416. getHeadsetImpostor(): PhysicsImpostor | undefined;
  158417. /**
  158418. * Get the physics impostor of a specific controller.
  158419. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  158420. * @param controller the controller or the controller id of which to get the impostor
  158421. * @returns the impostor or null
  158422. */
  158423. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  158424. /**
  158425. * Update the physics properties provided in the constructor
  158426. * @param newProperties the new properties object
  158427. */
  158428. setPhysicsProperties(newProperties: {
  158429. impostorType?: number;
  158430. impostorSize?: number | {
  158431. width: number;
  158432. height: number;
  158433. depth: number;
  158434. };
  158435. friction?: number;
  158436. restitution?: number;
  158437. }): void;
  158438. protected _onXRFrame(_xrFrame: any): void;
  158439. private _detachController;
  158440. }
  158441. }
  158442. declare module BABYLON {
  158443. /**
  158444. * A babylon interface for a "WebXR" feature point.
  158445. * Represents the position and confidence value of a given feature point.
  158446. */
  158447. export interface IWebXRFeaturePoint {
  158448. /**
  158449. * Represents the position of the feature point in world space.
  158450. */
  158451. position: Vector3;
  158452. /**
  158453. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  158454. */
  158455. confidenceValue: number;
  158456. }
  158457. /**
  158458. * The feature point system is used to detect feature points from real world geometry.
  158459. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  158460. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  158461. */
  158462. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  158463. private _enabled;
  158464. private _featurePointCloud;
  158465. /**
  158466. * The module's name
  158467. */
  158468. static readonly Name: string;
  158469. /**
  158470. * The (Babylon) version of this module.
  158471. * This is an integer representing the implementation version.
  158472. * This number does not correspond to the WebXR specs version
  158473. */
  158474. static readonly Version: number;
  158475. /**
  158476. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  158477. * Will notify the observers about which feature points have been added.
  158478. */
  158479. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  158480. /**
  158481. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  158482. * Will notify the observers about which feature points have been updated.
  158483. */
  158484. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  158485. /**
  158486. * The current feature point cloud maintained across frames.
  158487. */
  158488. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  158489. /**
  158490. * construct the feature point system
  158491. * @param _xrSessionManager an instance of xr Session manager
  158492. */
  158493. constructor(_xrSessionManager: WebXRSessionManager);
  158494. /**
  158495. * Detach this feature.
  158496. * Will usually be called by the features manager
  158497. *
  158498. * @returns true if successful.
  158499. */
  158500. detach(): boolean;
  158501. /**
  158502. * Dispose this feature and all of the resources attached
  158503. */
  158504. dispose(): void;
  158505. /**
  158506. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  158507. */
  158508. protected _onXRFrame(frame: XRFrame): void;
  158509. /**
  158510. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  158511. */
  158512. private _init;
  158513. }
  158514. }
  158515. declare module BABYLON {
  158516. /**
  158517. * Configuration interface for the hand tracking feature
  158518. */
  158519. export interface IWebXRHandTrackingOptions {
  158520. /**
  158521. * The xrInput that will be used as source for new hands
  158522. */
  158523. xrInput: WebXRInput;
  158524. /**
  158525. * Configuration object for the joint meshes
  158526. */
  158527. jointMeshes?: {
  158528. /**
  158529. * Should the meshes created be invisible (defaults to false)
  158530. */
  158531. invisible?: boolean;
  158532. /**
  158533. * A source mesh to be used to create instances. Defaults to a sphere.
  158534. * This mesh will be the source for all other (25) meshes.
  158535. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  158536. */
  158537. sourceMesh?: Mesh;
  158538. /**
  158539. * This function will be called after a mesh was created for a specific joint.
  158540. * Using this function you can either manipulate the instance or return a new mesh.
  158541. * When returning a new mesh the instance created before will be disposed
  158542. */
  158543. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  158544. /**
  158545. * Should the source mesh stay visible. Defaults to false
  158546. */
  158547. keepOriginalVisible?: boolean;
  158548. /**
  158549. * Scale factor for all instances (defaults to 2)
  158550. */
  158551. scaleFactor?: number;
  158552. /**
  158553. * Should each instance have its own physics impostor
  158554. */
  158555. enablePhysics?: boolean;
  158556. /**
  158557. * If enabled, override default physics properties
  158558. */
  158559. physicsProps?: {
  158560. friction?: number;
  158561. restitution?: number;
  158562. impostorType?: number;
  158563. };
  158564. /**
  158565. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  158566. */
  158567. disableDefaultHandMesh?: boolean;
  158568. /**
  158569. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  158570. */
  158571. handMeshes?: {
  158572. right: AbstractMesh;
  158573. left: AbstractMesh;
  158574. };
  158575. /**
  158576. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  158577. */
  158578. rigMapping?: {
  158579. right: string[];
  158580. left: string[];
  158581. };
  158582. };
  158583. }
  158584. /**
  158585. * Parts of the hands divided to writs and finger names
  158586. */
  158587. export const enum HandPart {
  158588. /**
  158589. * HandPart - Wrist
  158590. */
  158591. WRIST = "wrist",
  158592. /**
  158593. * HandPart - The THumb
  158594. */
  158595. THUMB = "thumb",
  158596. /**
  158597. * HandPart - Index finger
  158598. */
  158599. INDEX = "index",
  158600. /**
  158601. * HandPart - Middle finger
  158602. */
  158603. MIDDLE = "middle",
  158604. /**
  158605. * HandPart - Ring finger
  158606. */
  158607. RING = "ring",
  158608. /**
  158609. * HandPart - Little finger
  158610. */
  158611. LITTLE = "little"
  158612. }
  158613. /**
  158614. * Representing a single hand (with its corresponding native XRHand object)
  158615. */
  158616. export class WebXRHand implements IDisposable {
  158617. /** the controller to which the hand correlates */
  158618. readonly xrController: WebXRInputSource;
  158619. /** the meshes to be used to track the hand joints */
  158620. readonly trackedMeshes: AbstractMesh[];
  158621. private _handMesh?;
  158622. private _rigMapping?;
  158623. private _scene;
  158624. private _defaultHandMesh;
  158625. private _transformNodeMapping;
  158626. /**
  158627. * Hand-parts definition (key is HandPart)
  158628. */
  158629. handPartsDefinition: {
  158630. [key: string]: number[];
  158631. };
  158632. /**
  158633. * Populate the HandPartsDefinition object.
  158634. * This is called as a side effect since certain browsers don't have XRHand defined.
  158635. */
  158636. private generateHandPartsDefinition;
  158637. /**
  158638. * Construct a new hand object
  158639. * @param xrController the controller to which the hand correlates
  158640. * @param trackedMeshes the meshes to be used to track the hand joints
  158641. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  158642. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  158643. * @param disableDefaultHandMesh should the default mesh creation be disabled
  158644. */
  158645. constructor(
  158646. /** the controller to which the hand correlates */
  158647. xrController: WebXRInputSource,
  158648. /** the meshes to be used to track the hand joints */
  158649. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  158650. /**
  158651. * Update this hand from the latest xr frame
  158652. * @param xrFrame xrFrame to update from
  158653. * @param referenceSpace The current viewer reference space
  158654. * @param scaleFactor optional scale factor for the meshes
  158655. */
  158656. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  158657. /**
  158658. * Get meshes of part of the hand
  158659. * @param part the part of hand to get
  158660. * @returns An array of meshes that correlate to the hand part requested
  158661. */
  158662. getHandPartMeshes(part: HandPart): AbstractMesh[];
  158663. /**
  158664. * Dispose this Hand object
  158665. */
  158666. dispose(): void;
  158667. private _generateDefaultHandMesh;
  158668. }
  158669. /**
  158670. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  158671. */
  158672. export class WebXRHandTracking extends WebXRAbstractFeature {
  158673. /**
  158674. * options to use when constructing this feature
  158675. */
  158676. readonly options: IWebXRHandTrackingOptions;
  158677. private static _idCounter;
  158678. /**
  158679. * The module's name
  158680. */
  158681. static readonly Name: string;
  158682. /**
  158683. * The (Babylon) version of this module.
  158684. * This is an integer representing the implementation version.
  158685. * This number does not correspond to the WebXR specs version
  158686. */
  158687. static readonly Version: number;
  158688. /**
  158689. * This observable will notify registered observers when a new hand object was added and initialized
  158690. */
  158691. onHandAddedObservable: Observable<WebXRHand>;
  158692. /**
  158693. * This observable will notify its observers right before the hand object is disposed
  158694. */
  158695. onHandRemovedObservable: Observable<WebXRHand>;
  158696. private _hands;
  158697. /**
  158698. * Creates a new instance of the hit test feature
  158699. * @param _xrSessionManager an instance of WebXRSessionManager
  158700. * @param options options to use when constructing this feature
  158701. */
  158702. constructor(_xrSessionManager: WebXRSessionManager,
  158703. /**
  158704. * options to use when constructing this feature
  158705. */
  158706. options: IWebXRHandTrackingOptions);
  158707. /**
  158708. * Check if the needed objects are defined.
  158709. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  158710. */
  158711. isCompatible(): boolean;
  158712. /**
  158713. * attach this feature
  158714. * Will usually be called by the features manager
  158715. *
  158716. * @returns true if successful.
  158717. */
  158718. attach(): boolean;
  158719. /**
  158720. * detach this feature.
  158721. * Will usually be called by the features manager
  158722. *
  158723. * @returns true if successful.
  158724. */
  158725. detach(): boolean;
  158726. /**
  158727. * Dispose this feature and all of the resources attached
  158728. */
  158729. dispose(): void;
  158730. /**
  158731. * Get the hand object according to the controller id
  158732. * @param controllerId the controller id to which we want to get the hand
  158733. * @returns null if not found or the WebXRHand object if found
  158734. */
  158735. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  158736. /**
  158737. * Get a hand object according to the requested handedness
  158738. * @param handedness the handedness to request
  158739. * @returns null if not found or the WebXRHand object if found
  158740. */
  158741. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  158742. protected _onXRFrame(_xrFrame: XRFrame): void;
  158743. private _attachHand;
  158744. private _detachHand;
  158745. }
  158746. }
  158747. declare module BABYLON {
  158748. /**
  158749. * The motion controller class for all microsoft mixed reality controllers
  158750. */
  158751. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  158752. protected readonly _mapping: {
  158753. defaultButton: {
  158754. valueNodeName: string;
  158755. unpressedNodeName: string;
  158756. pressedNodeName: string;
  158757. };
  158758. defaultAxis: {
  158759. valueNodeName: string;
  158760. minNodeName: string;
  158761. maxNodeName: string;
  158762. };
  158763. buttons: {
  158764. "xr-standard-trigger": {
  158765. rootNodeName: string;
  158766. componentProperty: string;
  158767. states: string[];
  158768. };
  158769. "xr-standard-squeeze": {
  158770. rootNodeName: string;
  158771. componentProperty: string;
  158772. states: string[];
  158773. };
  158774. "xr-standard-touchpad": {
  158775. rootNodeName: string;
  158776. labelAnchorNodeName: string;
  158777. touchPointNodeName: string;
  158778. };
  158779. "xr-standard-thumbstick": {
  158780. rootNodeName: string;
  158781. componentProperty: string;
  158782. states: string[];
  158783. };
  158784. };
  158785. axes: {
  158786. "xr-standard-touchpad": {
  158787. "x-axis": {
  158788. rootNodeName: string;
  158789. };
  158790. "y-axis": {
  158791. rootNodeName: string;
  158792. };
  158793. };
  158794. "xr-standard-thumbstick": {
  158795. "x-axis": {
  158796. rootNodeName: string;
  158797. };
  158798. "y-axis": {
  158799. rootNodeName: string;
  158800. };
  158801. };
  158802. };
  158803. };
  158804. /**
  158805. * The base url used to load the left and right controller models
  158806. */
  158807. static MODEL_BASE_URL: string;
  158808. /**
  158809. * The name of the left controller model file
  158810. */
  158811. static MODEL_LEFT_FILENAME: string;
  158812. /**
  158813. * The name of the right controller model file
  158814. */
  158815. static MODEL_RIGHT_FILENAME: string;
  158816. profileId: string;
  158817. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158818. protected _getFilenameAndPath(): {
  158819. filename: string;
  158820. path: string;
  158821. };
  158822. protected _getModelLoadingConstraints(): boolean;
  158823. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158824. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158825. protected _updateModel(): void;
  158826. }
  158827. }
  158828. declare module BABYLON {
  158829. /**
  158830. * The motion controller class for oculus touch (quest, rift).
  158831. * This class supports legacy mapping as well the standard xr mapping
  158832. */
  158833. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  158834. private _forceLegacyControllers;
  158835. private _modelRootNode;
  158836. /**
  158837. * The base url used to load the left and right controller models
  158838. */
  158839. static MODEL_BASE_URL: string;
  158840. /**
  158841. * The name of the left controller model file
  158842. */
  158843. static MODEL_LEFT_FILENAME: string;
  158844. /**
  158845. * The name of the right controller model file
  158846. */
  158847. static MODEL_RIGHT_FILENAME: string;
  158848. /**
  158849. * Base Url for the Quest controller model.
  158850. */
  158851. static QUEST_MODEL_BASE_URL: string;
  158852. profileId: string;
  158853. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  158854. protected _getFilenameAndPath(): {
  158855. filename: string;
  158856. path: string;
  158857. };
  158858. protected _getModelLoadingConstraints(): boolean;
  158859. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158860. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158861. protected _updateModel(): void;
  158862. /**
  158863. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  158864. * between the touch and touch 2.
  158865. */
  158866. private _isQuest;
  158867. }
  158868. }
  158869. declare module BABYLON {
  158870. /**
  158871. * The motion controller class for the standard HTC-Vive controllers
  158872. */
  158873. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  158874. private _modelRootNode;
  158875. /**
  158876. * The base url used to load the left and right controller models
  158877. */
  158878. static MODEL_BASE_URL: string;
  158879. /**
  158880. * File name for the controller model.
  158881. */
  158882. static MODEL_FILENAME: string;
  158883. profileId: string;
  158884. /**
  158885. * Create a new Vive motion controller object
  158886. * @param scene the scene to use to create this controller
  158887. * @param gamepadObject the corresponding gamepad object
  158888. * @param handedness the handedness of the controller
  158889. */
  158890. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158891. protected _getFilenameAndPath(): {
  158892. filename: string;
  158893. path: string;
  158894. };
  158895. protected _getModelLoadingConstraints(): boolean;
  158896. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158897. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158898. protected _updateModel(): void;
  158899. }
  158900. }
  158901. declare module BABYLON {
  158902. /**
  158903. * A cursor which tracks a point on a path
  158904. */
  158905. export class PathCursor {
  158906. private path;
  158907. /**
  158908. * Stores path cursor callbacks for when an onchange event is triggered
  158909. */
  158910. private _onchange;
  158911. /**
  158912. * The value of the path cursor
  158913. */
  158914. value: number;
  158915. /**
  158916. * The animation array of the path cursor
  158917. */
  158918. animations: Animation[];
  158919. /**
  158920. * Initializes the path cursor
  158921. * @param path The path to track
  158922. */
  158923. constructor(path: Path2);
  158924. /**
  158925. * Gets the cursor point on the path
  158926. * @returns A point on the path cursor at the cursor location
  158927. */
  158928. getPoint(): Vector3;
  158929. /**
  158930. * Moves the cursor ahead by the step amount
  158931. * @param step The amount to move the cursor forward
  158932. * @returns This path cursor
  158933. */
  158934. moveAhead(step?: number): PathCursor;
  158935. /**
  158936. * Moves the cursor behind by the step amount
  158937. * @param step The amount to move the cursor back
  158938. * @returns This path cursor
  158939. */
  158940. moveBack(step?: number): PathCursor;
  158941. /**
  158942. * Moves the cursor by the step amount
  158943. * If the step amount is greater than one, an exception is thrown
  158944. * @param step The amount to move the cursor
  158945. * @returns This path cursor
  158946. */
  158947. move(step: number): PathCursor;
  158948. /**
  158949. * Ensures that the value is limited between zero and one
  158950. * @returns This path cursor
  158951. */
  158952. private ensureLimits;
  158953. /**
  158954. * Runs onchange callbacks on change (used by the animation engine)
  158955. * @returns This path cursor
  158956. */
  158957. private raiseOnChange;
  158958. /**
  158959. * Executes a function on change
  158960. * @param f A path cursor onchange callback
  158961. * @returns This path cursor
  158962. */
  158963. onchange(f: (cursor: PathCursor) => void): PathCursor;
  158964. }
  158965. }
  158966. declare module BABYLON {
  158967. /** @hidden */
  158968. export var blurPixelShader: {
  158969. name: string;
  158970. shader: string;
  158971. };
  158972. }
  158973. declare module BABYLON {
  158974. /** @hidden */
  158975. export var pointCloudVertexDeclaration: {
  158976. name: string;
  158977. shader: string;
  158978. };
  158979. }
  158980. // Mixins
  158981. interface Window {
  158982. mozIndexedDB: IDBFactory;
  158983. webkitIndexedDB: IDBFactory;
  158984. msIndexedDB: IDBFactory;
  158985. webkitURL: typeof URL;
  158986. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  158987. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  158988. WebGLRenderingContext: WebGLRenderingContext;
  158989. MSGesture: MSGesture;
  158990. CANNON: any;
  158991. AudioContext: AudioContext;
  158992. webkitAudioContext: AudioContext;
  158993. PointerEvent: any;
  158994. Math: Math;
  158995. Uint8Array: Uint8ArrayConstructor;
  158996. Float32Array: Float32ArrayConstructor;
  158997. mozURL: typeof URL;
  158998. msURL: typeof URL;
  158999. VRFrameData: any; // WebVR, from specs 1.1
  159000. DracoDecoderModule: any;
  159001. setImmediate(handler: (...args: any[]) => void): number;
  159002. }
  159003. interface HTMLCanvasElement {
  159004. requestPointerLock(): void;
  159005. msRequestPointerLock?(): void;
  159006. mozRequestPointerLock?(): void;
  159007. webkitRequestPointerLock?(): void;
  159008. /** Track wether a record is in progress */
  159009. isRecording: boolean;
  159010. /** Capture Stream method defined by some browsers */
  159011. captureStream(fps?: number): MediaStream;
  159012. }
  159013. interface CanvasRenderingContext2D {
  159014. msImageSmoothingEnabled: boolean;
  159015. }
  159016. interface MouseEvent {
  159017. mozMovementX: number;
  159018. mozMovementY: number;
  159019. webkitMovementX: number;
  159020. webkitMovementY: number;
  159021. msMovementX: number;
  159022. msMovementY: number;
  159023. }
  159024. interface Navigator {
  159025. mozGetVRDevices: (any: any) => any;
  159026. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  159027. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  159028. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  159029. webkitGetGamepads(): Gamepad[];
  159030. msGetGamepads(): Gamepad[];
  159031. webkitGamepads(): Gamepad[];
  159032. }
  159033. interface HTMLVideoElement {
  159034. mozSrcObject: any;
  159035. }
  159036. interface Math {
  159037. fround(x: number): number;
  159038. imul(a: number, b: number): number;
  159039. }
  159040. interface WebGLRenderingContext {
  159041. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  159042. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  159043. vertexAttribDivisor(index: number, divisor: number): void;
  159044. createVertexArray(): any;
  159045. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  159046. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  159047. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  159048. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  159049. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  159050. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  159051. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  159052. // Queries
  159053. createQuery(): WebGLQuery;
  159054. deleteQuery(query: WebGLQuery): void;
  159055. beginQuery(target: number, query: WebGLQuery): void;
  159056. endQuery(target: number): void;
  159057. getQueryParameter(query: WebGLQuery, pname: number): any;
  159058. getQuery(target: number, pname: number): any;
  159059. MAX_SAMPLES: number;
  159060. RGBA8: number;
  159061. READ_FRAMEBUFFER: number;
  159062. DRAW_FRAMEBUFFER: number;
  159063. UNIFORM_BUFFER: number;
  159064. HALF_FLOAT_OES: number;
  159065. RGBA16F: number;
  159066. RGBA32F: number;
  159067. R32F: number;
  159068. RG32F: number;
  159069. RGB32F: number;
  159070. R16F: number;
  159071. RG16F: number;
  159072. RGB16F: number;
  159073. RED: number;
  159074. RG: number;
  159075. R8: number;
  159076. RG8: number;
  159077. UNSIGNED_INT_24_8: number;
  159078. DEPTH24_STENCIL8: number;
  159079. MIN: number;
  159080. MAX: number;
  159081. /* Multiple Render Targets */
  159082. drawBuffers(buffers: number[]): void;
  159083. readBuffer(src: number): void;
  159084. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  159085. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  159086. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  159087. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  159088. // Occlusion Query
  159089. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  159090. ANY_SAMPLES_PASSED: number;
  159091. QUERY_RESULT_AVAILABLE: number;
  159092. QUERY_RESULT: number;
  159093. }
  159094. interface WebGLProgram {
  159095. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  159096. }
  159097. interface EXT_disjoint_timer_query {
  159098. QUERY_COUNTER_BITS_EXT: number;
  159099. TIME_ELAPSED_EXT: number;
  159100. TIMESTAMP_EXT: number;
  159101. GPU_DISJOINT_EXT: number;
  159102. QUERY_RESULT_EXT: number;
  159103. QUERY_RESULT_AVAILABLE_EXT: number;
  159104. queryCounterEXT(query: WebGLQuery, target: number): void;
  159105. createQueryEXT(): WebGLQuery;
  159106. beginQueryEXT(target: number, query: WebGLQuery): void;
  159107. endQueryEXT(target: number): void;
  159108. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  159109. deleteQueryEXT(query: WebGLQuery): void;
  159110. }
  159111. interface WebGLUniformLocation {
  159112. _currentState: any;
  159113. }
  159114. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  159115. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  159116. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  159117. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  159118. interface WebGLRenderingContext {
  159119. readonly RASTERIZER_DISCARD: number;
  159120. readonly DEPTH_COMPONENT24: number;
  159121. readonly TEXTURE_3D: number;
  159122. readonly TEXTURE_2D_ARRAY: number;
  159123. readonly TEXTURE_COMPARE_FUNC: number;
  159124. readonly TEXTURE_COMPARE_MODE: number;
  159125. readonly COMPARE_REF_TO_TEXTURE: number;
  159126. readonly TEXTURE_WRAP_R: number;
  159127. readonly HALF_FLOAT: number;
  159128. readonly RGB8: number;
  159129. readonly RED_INTEGER: number;
  159130. readonly RG_INTEGER: number;
  159131. readonly RGB_INTEGER: number;
  159132. readonly RGBA_INTEGER: number;
  159133. readonly R8_SNORM: number;
  159134. readonly RG8_SNORM: number;
  159135. readonly RGB8_SNORM: number;
  159136. readonly RGBA8_SNORM: number;
  159137. readonly R8I: number;
  159138. readonly RG8I: number;
  159139. readonly RGB8I: number;
  159140. readonly RGBA8I: number;
  159141. readonly R8UI: number;
  159142. readonly RG8UI: number;
  159143. readonly RGB8UI: number;
  159144. readonly RGBA8UI: number;
  159145. readonly R16I: number;
  159146. readonly RG16I: number;
  159147. readonly RGB16I: number;
  159148. readonly RGBA16I: number;
  159149. readonly R16UI: number;
  159150. readonly RG16UI: number;
  159151. readonly RGB16UI: number;
  159152. readonly RGBA16UI: number;
  159153. readonly R32I: number;
  159154. readonly RG32I: number;
  159155. readonly RGB32I: number;
  159156. readonly RGBA32I: number;
  159157. readonly R32UI: number;
  159158. readonly RG32UI: number;
  159159. readonly RGB32UI: number;
  159160. readonly RGBA32UI: number;
  159161. readonly RGB10_A2UI: number;
  159162. readonly R11F_G11F_B10F: number;
  159163. readonly RGB9_E5: number;
  159164. readonly RGB10_A2: number;
  159165. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  159166. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  159167. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  159168. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  159169. readonly DEPTH_COMPONENT32F: number;
  159170. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  159171. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  159172. 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;
  159173. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  159174. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  159175. readonly TRANSFORM_FEEDBACK: number;
  159176. readonly INTERLEAVED_ATTRIBS: number;
  159177. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  159178. createTransformFeedback(): WebGLTransformFeedback;
  159179. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  159180. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  159181. beginTransformFeedback(primitiveMode: number): void;
  159182. endTransformFeedback(): void;
  159183. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  159184. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  159185. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  159186. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  159187. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  159188. }
  159189. interface ImageBitmap {
  159190. readonly width: number;
  159191. readonly height: number;
  159192. close(): void;
  159193. }
  159194. interface WebGLQuery extends WebGLObject {
  159195. }
  159196. declare var WebGLQuery: {
  159197. prototype: WebGLQuery;
  159198. new(): WebGLQuery;
  159199. };
  159200. interface WebGLSampler extends WebGLObject {
  159201. }
  159202. declare var WebGLSampler: {
  159203. prototype: WebGLSampler;
  159204. new(): WebGLSampler;
  159205. };
  159206. interface WebGLSync extends WebGLObject {
  159207. }
  159208. declare var WebGLSync: {
  159209. prototype: WebGLSync;
  159210. new(): WebGLSync;
  159211. };
  159212. interface WebGLTransformFeedback extends WebGLObject {
  159213. }
  159214. declare var WebGLTransformFeedback: {
  159215. prototype: WebGLTransformFeedback;
  159216. new(): WebGLTransformFeedback;
  159217. };
  159218. interface WebGLVertexArrayObject extends WebGLObject {
  159219. }
  159220. declare var WebGLVertexArrayObject: {
  159221. prototype: WebGLVertexArrayObject;
  159222. new(): WebGLVertexArrayObject;
  159223. };
  159224. // Type definitions for WebVR API
  159225. // Project: https://w3c.github.io/webvr/
  159226. // Definitions by: six a <https://github.com/lostfictions>
  159227. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  159228. interface VRDisplay extends EventTarget {
  159229. /**
  159230. * Dictionary of capabilities describing the VRDisplay.
  159231. */
  159232. readonly capabilities: VRDisplayCapabilities;
  159233. /**
  159234. * z-depth defining the far plane of the eye view frustum
  159235. * enables mapping of values in the render target depth
  159236. * attachment to scene coordinates. Initially set to 10000.0.
  159237. */
  159238. depthFar: number;
  159239. /**
  159240. * z-depth defining the near plane of the eye view frustum
  159241. * enables mapping of values in the render target depth
  159242. * attachment to scene coordinates. Initially set to 0.01.
  159243. */
  159244. depthNear: number;
  159245. /**
  159246. * An identifier for this distinct VRDisplay. Used as an
  159247. * association point in the Gamepad API.
  159248. */
  159249. readonly displayId: number;
  159250. /**
  159251. * A display name, a user-readable name identifying it.
  159252. */
  159253. readonly displayName: string;
  159254. readonly isConnected: boolean;
  159255. readonly isPresenting: boolean;
  159256. /**
  159257. * If this VRDisplay supports room-scale experiences, the optional
  159258. * stage attribute contains details on the room-scale parameters.
  159259. */
  159260. readonly stageParameters: VRStageParameters | null;
  159261. /**
  159262. * Passing the value returned by `requestAnimationFrame` to
  159263. * `cancelAnimationFrame` will unregister the callback.
  159264. * @param handle Define the hanle of the request to cancel
  159265. */
  159266. cancelAnimationFrame(handle: number): void;
  159267. /**
  159268. * Stops presenting to the VRDisplay.
  159269. * @returns a promise to know when it stopped
  159270. */
  159271. exitPresent(): Promise<void>;
  159272. /**
  159273. * Return the current VREyeParameters for the given eye.
  159274. * @param whichEye Define the eye we want the parameter for
  159275. * @returns the eye parameters
  159276. */
  159277. getEyeParameters(whichEye: string): VREyeParameters;
  159278. /**
  159279. * Populates the passed VRFrameData with the information required to render
  159280. * the current frame.
  159281. * @param frameData Define the data structure to populate
  159282. * @returns true if ok otherwise false
  159283. */
  159284. getFrameData(frameData: VRFrameData): boolean;
  159285. /**
  159286. * Get the layers currently being presented.
  159287. * @returns the list of VR layers
  159288. */
  159289. getLayers(): VRLayer[];
  159290. /**
  159291. * Return a VRPose containing the future predicted pose of the VRDisplay
  159292. * when the current frame will be presented. The value returned will not
  159293. * change until JavaScript has returned control to the browser.
  159294. *
  159295. * The VRPose will contain the position, orientation, velocity,
  159296. * and acceleration of each of these properties.
  159297. * @returns the pose object
  159298. */
  159299. getPose(): VRPose;
  159300. /**
  159301. * Return the current instantaneous pose of the VRDisplay, with no
  159302. * prediction applied.
  159303. * @returns the current instantaneous pose
  159304. */
  159305. getImmediatePose(): VRPose;
  159306. /**
  159307. * The callback passed to `requestAnimationFrame` will be called
  159308. * any time a new frame should be rendered. When the VRDisplay is
  159309. * presenting the callback will be called at the native refresh
  159310. * rate of the HMD. When not presenting this function acts
  159311. * identically to how window.requestAnimationFrame acts. Content should
  159312. * make no assumptions of frame rate or vsync behavior as the HMD runs
  159313. * asynchronously from other displays and at differing refresh rates.
  159314. * @param callback Define the eaction to run next frame
  159315. * @returns the request handle it
  159316. */
  159317. requestAnimationFrame(callback: FrameRequestCallback): number;
  159318. /**
  159319. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  159320. * Repeat calls while already presenting will update the VRLayers being displayed.
  159321. * @param layers Define the list of layer to present
  159322. * @returns a promise to know when the request has been fulfilled
  159323. */
  159324. requestPresent(layers: VRLayer[]): Promise<void>;
  159325. /**
  159326. * Reset the pose for this display, treating its current position and
  159327. * orientation as the "origin/zero" values. VRPose.position,
  159328. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  159329. * updated when calling resetPose(). This should be called in only
  159330. * sitting-space experiences.
  159331. */
  159332. resetPose(): void;
  159333. /**
  159334. * The VRLayer provided to the VRDisplay will be captured and presented
  159335. * in the HMD. Calling this function has the same effect on the source
  159336. * canvas as any other operation that uses its source image, and canvases
  159337. * created without preserveDrawingBuffer set to true will be cleared.
  159338. * @param pose Define the pose to submit
  159339. */
  159340. submitFrame(pose?: VRPose): void;
  159341. }
  159342. declare var VRDisplay: {
  159343. prototype: VRDisplay;
  159344. new(): VRDisplay;
  159345. };
  159346. interface VRLayer {
  159347. leftBounds?: number[] | Float32Array | null;
  159348. rightBounds?: number[] | Float32Array | null;
  159349. source?: HTMLCanvasElement | null;
  159350. }
  159351. interface VRDisplayCapabilities {
  159352. readonly canPresent: boolean;
  159353. readonly hasExternalDisplay: boolean;
  159354. readonly hasOrientation: boolean;
  159355. readonly hasPosition: boolean;
  159356. readonly maxLayers: number;
  159357. }
  159358. interface VREyeParameters {
  159359. /** @deprecated */
  159360. readonly fieldOfView: VRFieldOfView;
  159361. readonly offset: Float32Array;
  159362. readonly renderHeight: number;
  159363. readonly renderWidth: number;
  159364. }
  159365. interface VRFieldOfView {
  159366. readonly downDegrees: number;
  159367. readonly leftDegrees: number;
  159368. readonly rightDegrees: number;
  159369. readonly upDegrees: number;
  159370. }
  159371. interface VRFrameData {
  159372. readonly leftProjectionMatrix: Float32Array;
  159373. readonly leftViewMatrix: Float32Array;
  159374. readonly pose: VRPose;
  159375. readonly rightProjectionMatrix: Float32Array;
  159376. readonly rightViewMatrix: Float32Array;
  159377. readonly timestamp: number;
  159378. }
  159379. interface VRPose {
  159380. readonly angularAcceleration: Float32Array | null;
  159381. readonly angularVelocity: Float32Array | null;
  159382. readonly linearAcceleration: Float32Array | null;
  159383. readonly linearVelocity: Float32Array | null;
  159384. readonly orientation: Float32Array | null;
  159385. readonly position: Float32Array | null;
  159386. readonly timestamp: number;
  159387. }
  159388. interface VRStageParameters {
  159389. sittingToStandingTransform?: Float32Array;
  159390. sizeX?: number;
  159391. sizeY?: number;
  159392. }
  159393. interface Navigator {
  159394. getVRDisplays(): Promise<VRDisplay[]>;
  159395. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  159396. }
  159397. interface Window {
  159398. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  159399. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  159400. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  159401. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  159402. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  159403. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  159404. }
  159405. interface Gamepad {
  159406. readonly displayId: number;
  159407. }
  159408. /**
  159409. * Available session modes
  159410. */
  159411. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  159412. /**
  159413. * Reference space types
  159414. */
  159415. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  159416. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  159417. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  159418. /**
  159419. * Handedness types
  159420. */
  159421. type XRHandedness = "none" | "left" | "right";
  159422. /**
  159423. * InputSource target ray modes
  159424. */
  159425. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  159426. /**
  159427. * Eye types
  159428. */
  159429. type XREye = "none" | "left" | "right";
  159430. /**
  159431. * Type of XR events available
  159432. */
  159433. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  159434. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  159435. type XRPlaneSet = Set<XRPlane>;
  159436. type XRAnchorSet = Set<XRAnchor>;
  159437. type XREventHandler = (callback: any) => void;
  159438. interface XRLayer extends EventTarget {}
  159439. interface XRSessionInit {
  159440. optionalFeatures?: string[];
  159441. requiredFeatures?: string[];
  159442. }
  159443. interface XRSessionEvent extends Event {
  159444. readonly session: XRSession;
  159445. }
  159446. interface XRSystem {
  159447. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  159448. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  159449. }
  159450. interface XRViewport {
  159451. readonly x: number;
  159452. readonly y: number;
  159453. readonly width: number;
  159454. readonly height: number;
  159455. }
  159456. interface XRWebGLLayerInit {
  159457. antialias?: boolean;
  159458. depth?: boolean;
  159459. stencil?: boolean;
  159460. alpha?: boolean;
  159461. multiview?: boolean;
  159462. framebufferScaleFactor?: number;
  159463. }
  159464. declare class XRWebGLLayer {
  159465. static getNativeFramebufferScaleFactor(session: XRSession): number;
  159466. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  159467. readonly antialias: boolean;
  159468. readonly framebuffer: WebGLFramebuffer;
  159469. readonly framebufferWidth: number;
  159470. readonly framebufferHeight: number;
  159471. readonly ignoreDepthValues: boolean;
  159472. getViewport: (view: XRView) => XRViewport;
  159473. }
  159474. // tslint:disable-next-line no-empty-interface
  159475. interface XRSpace extends EventTarget {}
  159476. interface XRRenderState {
  159477. readonly baseLayer?: XRWebGLLayer;
  159478. readonly depthFar: number;
  159479. readonly depthNear: number;
  159480. readonly inlineVerticalFieldOfView?: number;
  159481. }
  159482. interface XRRenderStateInit extends XRRenderState {
  159483. baseLayer: XRWebGLLayer;
  159484. depthFar: number;
  159485. depthNear: number;
  159486. inlineVerticalFieldOfView?: number;
  159487. layers?: XRLayer[];
  159488. }
  159489. interface XRReferenceSpace extends XRSpace {
  159490. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  159491. onreset: XREventHandler;
  159492. }
  159493. interface XRBoundedReferenceSpace extends XRSpace {
  159494. readonly boundsGeometry: DOMPointReadOnly[];
  159495. }
  159496. interface XRInputSource {
  159497. readonly handedness: XRHandedness;
  159498. readonly targetRayMode: XRTargetRayMode;
  159499. readonly targetRaySpace: XRSpace;
  159500. readonly gripSpace?: XRSpace;
  159501. readonly gamepad?: Gamepad;
  159502. readonly profiles: Array<string>;
  159503. readonly hand?: XRHand;
  159504. }
  159505. interface XRPose {
  159506. readonly transform: XRRigidTransform;
  159507. readonly emulatedPosition: boolean;
  159508. }
  159509. interface XRFrame {
  159510. readonly session: XRSession;
  159511. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  159512. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  159513. // AR
  159514. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  159515. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  159516. // Anchors
  159517. trackedAnchors?: XRAnchorSet;
  159518. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  159519. // Planes
  159520. worldInformation?: {
  159521. detectedPlanes?: XRPlaneSet;
  159522. };
  159523. // Hand tracking
  159524. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  159525. }
  159526. interface XRInputSourceEvent extends Event {
  159527. readonly frame: XRFrame;
  159528. readonly inputSource: XRInputSource;
  159529. }
  159530. type XRInputSourceArray = XRInputSource[];
  159531. interface XRSession {
  159532. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  159533. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  159534. /**
  159535. * Returns a list of this session's XRInputSources, each representing an input device
  159536. * used to control the camera and/or scene.
  159537. */
  159538. readonly inputSources: Array<XRInputSource>;
  159539. /**
  159540. * object which contains options affecting how the imagery is rendered.
  159541. * This includes things such as the near and far clipping planes
  159542. */
  159543. readonly renderState: XRRenderState;
  159544. readonly visibilityState: XRVisibilityState;
  159545. /**
  159546. * Removes a callback from the animation frame painting callback from
  159547. * XRSession's set of animation frame rendering callbacks, given the
  159548. * identifying handle returned by a previous call to requestAnimationFrame().
  159549. */
  159550. cancelAnimationFrame: (handle: number) => void;
  159551. /**
  159552. * Ends the WebXR session. Returns a promise which resolves when the
  159553. * session has been shut down.
  159554. */
  159555. end(): Promise<void>;
  159556. /**
  159557. * Schedules the specified method to be called the next time the user agent
  159558. * is working on rendering an animation frame for the WebXR device. Returns an
  159559. * integer value which can be used to identify the request for the purposes of
  159560. * canceling the callback using cancelAnimationFrame(). This method is comparable
  159561. * to the Window.requestAnimationFrame() method.
  159562. */
  159563. requestAnimationFrame: XRFrameRequestCallback;
  159564. /**
  159565. * Requests that a new XRReferenceSpace of the specified type be created.
  159566. * Returns a promise which resolves with the XRReferenceSpace or
  159567. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  159568. * the requested space type isn't supported by the device.
  159569. */
  159570. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  159571. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  159572. onend: XREventHandler;
  159573. oninputsourceschange: XREventHandler;
  159574. onselect: XREventHandler;
  159575. onselectstart: XREventHandler;
  159576. onselectend: XREventHandler;
  159577. onsqueeze: XREventHandler;
  159578. onsqueezestart: XREventHandler;
  159579. onsqueezeend: XREventHandler;
  159580. onvisibilitychange: XREventHandler;
  159581. // hit test
  159582. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  159583. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  159584. // legacy AR hit test
  159585. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  159586. // legacy plane detection
  159587. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  159588. }
  159589. interface XRViewerPose extends XRPose {
  159590. readonly views: Array<XRView>;
  159591. }
  159592. declare class XRRigidTransform {
  159593. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  159594. position: DOMPointReadOnly;
  159595. orientation: DOMPointReadOnly;
  159596. matrix: Float32Array;
  159597. inverse: XRRigidTransform;
  159598. }
  159599. interface XRView {
  159600. readonly eye: XREye;
  159601. readonly projectionMatrix: Float32Array;
  159602. readonly transform: XRRigidTransform;
  159603. readonly recommendedViewportScale?: number;
  159604. requestViewportScale(scale: number): void;
  159605. }
  159606. interface XRInputSourceChangeEvent extends Event {
  159607. session: XRSession;
  159608. removed: Array<XRInputSource>;
  159609. added: Array<XRInputSource>;
  159610. }
  159611. // Experimental/Draft features
  159612. declare class XRRay {
  159613. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  159614. origin: DOMPointReadOnly;
  159615. direction: DOMPointReadOnly;
  159616. matrix: Float32Array;
  159617. }
  159618. declare enum XRHitTestTrackableType {
  159619. "point",
  159620. "plane",
  159621. "mesh",
  159622. }
  159623. interface XRHitResult {
  159624. hitMatrix: Float32Array;
  159625. }
  159626. interface XRTransientInputHitTestResult {
  159627. readonly inputSource: XRInputSource;
  159628. readonly results: Array<XRHitTestResult>;
  159629. }
  159630. interface XRHitTestResult {
  159631. getPose(baseSpace: XRSpace): XRPose | undefined;
  159632. // When anchor system is enabled
  159633. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  159634. }
  159635. interface XRHitTestSource {
  159636. cancel(): void;
  159637. }
  159638. interface XRTransientInputHitTestSource {
  159639. cancel(): void;
  159640. }
  159641. interface XRHitTestOptionsInit {
  159642. space: XRSpace;
  159643. entityTypes?: Array<XRHitTestTrackableType>;
  159644. offsetRay?: XRRay;
  159645. }
  159646. interface XRTransientInputHitTestOptionsInit {
  159647. profile: string;
  159648. entityTypes?: Array<XRHitTestTrackableType>;
  159649. offsetRay?: XRRay;
  159650. }
  159651. interface XRAnchor {
  159652. anchorSpace: XRSpace;
  159653. delete(): void;
  159654. }
  159655. interface XRPlane {
  159656. orientation: "Horizontal" | "Vertical";
  159657. planeSpace: XRSpace;
  159658. polygon: Array<DOMPointReadOnly>;
  159659. lastChangedTime: number;
  159660. }
  159661. interface XRJointSpace extends XRSpace {}
  159662. interface XRJointPose extends XRPose {
  159663. radius: number | undefined;
  159664. }
  159665. interface XRHand extends Iterable<XRJointSpace> {
  159666. readonly length: number;
  159667. [index: number]: XRJointSpace;
  159668. readonly WRIST: number;
  159669. readonly THUMB_METACARPAL: number;
  159670. readonly THUMB_PHALANX_PROXIMAL: number;
  159671. readonly THUMB_PHALANX_DISTAL: number;
  159672. readonly THUMB_PHALANX_TIP: number;
  159673. readonly INDEX_METACARPAL: number;
  159674. readonly INDEX_PHALANX_PROXIMAL: number;
  159675. readonly INDEX_PHALANX_INTERMEDIATE: number;
  159676. readonly INDEX_PHALANX_DISTAL: number;
  159677. readonly INDEX_PHALANX_TIP: number;
  159678. readonly MIDDLE_METACARPAL: number;
  159679. readonly MIDDLE_PHALANX_PROXIMAL: number;
  159680. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  159681. readonly MIDDLE_PHALANX_DISTAL: number;
  159682. readonly MIDDLE_PHALANX_TIP: number;
  159683. readonly RING_METACARPAL: number;
  159684. readonly RING_PHALANX_PROXIMAL: number;
  159685. readonly RING_PHALANX_INTERMEDIATE: number;
  159686. readonly RING_PHALANX_DISTAL: number;
  159687. readonly RING_PHALANX_TIP: number;
  159688. readonly LITTLE_METACARPAL: number;
  159689. readonly LITTLE_PHALANX_PROXIMAL: number;
  159690. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  159691. readonly LITTLE_PHALANX_DISTAL: number;
  159692. readonly LITTLE_PHALANX_TIP: number;
  159693. }
  159694. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  159695. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  159696. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  159697. interface XRSession {
  159698. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  159699. }
  159700. interface XRFrame {
  159701. featurePointCloud? : Array<number>;
  159702. }